Supported on windows
Supported on linux
Not supported on android
run command
Starts executing a new instance of a program under GDB.
Syntax
run
run [Arguments]
r
r [Arguments]
run [Arguments]
r
r [Arguments]
Parameters
- Arguments
- Specifies the command-line arguments passed to the program via argv and argc parameters.
Restrictions
The run command should only be used if you want to debug a new instance of the program. Use the continue command instead in the following cases:
- To resume a process after attaching to it with attach
- To start debugging with gdbserver
- To continue from a breakpoint
If you issue the run command after a breakpoint is hit, your program will be restarted from the beginning.
Examples
The following commands start executing a program passing "Hello World" as arguments:
(gdb) b main
Breakpoint 1 at 0x8048444: file 0.cpp, line 3.
(gdb) run "Hello World"
Starting program: /home/testuser/0.elf "Hello World"
Breakpoint 1, main (argc=2, argv=0xbffff774) at 0.cpp:3
3 {
(gdb) print *argv@argc
$1 = {0xbffff894 "/home/testuser/0.elf", 0xbffff8a9 "Hello World"}
Breakpoint 1 at 0x8048444: file 0.cpp, line 3.
(gdb) run "Hello World"
Starting program: /home/testuser/0.elf "Hello World"
Breakpoint 1, main (argc=2, argv=0xbffff774) at 0.cpp:3
3 {
(gdb) print *argv@argc
$1 = {0xbffff894 "/home/testuser/0.elf", 0xbffff8a9 "Hello World"}
Common errors
Using the run command to start debugging with gdbserver will result in an error. Use the continue command instead:
(gdb) target remote :2001
Remote debugging using :2001
Reading symbols from /lib/ld-linux.so.2...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/ld-2.15.so...done.
done.
Loaded symbols for /lib/ld-linux.so.2
0xb7fdf1d0 in _start () from /lib/ld-linux.so.2
(gdb) run
The "remote" target does not support "run". Try "help target" or "continue".
(gdb) b main
Breakpoint 1 at 0x8048444: file 0.cpp, line 3.
(gdb) continue
Continuing.
Breakpoint 1, main (argc=1, argv=0xbffff7a4) at 0.cpp:3
3 {
Remote debugging using :2001
Reading symbols from /lib/ld-linux.so.2...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/ld-2.15.so...done.
done.
Loaded symbols for /lib/ld-linux.so.2
0xb7fdf1d0 in _start () from /lib/ld-linux.so.2
(gdb) run
The "remote" target does not support "run". Try "help target" or "continue".
(gdb) b main
Breakpoint 1 at 0x8048444: file 0.cpp, line 3.
(gdb) continue
Continuing.
Breakpoint 1, main (argc=1, argv=0xbffff7a4) at 0.cpp:3
3 {
Compatibility with VisualGDB
Do not execute the run command manually under Visual Studio. VisualGDB automatically issues an equivalent of it when you press F5 to start your debugging session: