Supported on windows
Supported on linux
Not supported on embedded
Not supported on android

start command

Sets a temporary breakpoint on main() and starts executing a program under GDB.

Syntax

start
start [Arguments]

Parameters

Arguments
Specifies the command-line arguments passed to the program via argv and argc parameters.

Restrictions

The start 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 start command after a breakpoint is hit, your program will be restarted from the beginning.

Remarks

For C/C++ programs the start command is equivalent to the following command sequence:

tbreak main
run

Examples

The following commands start executing a program passing "Hello World" as arguments:

(gdb) start "Hello World"
Temporary breakpoint 1 at 0x80483b7: file 0.cpp, line 3.
Starting program: /home/testuser/0.elf "Hello World"

Temporary breakpoint 1, main (argc=2, argv=0xbffff774) at 0.cpp:33 return 0;
(gdb) print *argv@argc
$1 = {0xbffff895 "/home/testuser/0.elf", 0xbffff8aa "Hello World"}

This example shows that the start command issued after attaching to a process will restart it:

(gdb) attach 28325
Attaching to program: /home/testuser/0.elf, process 28325
Reading symbols from /lib/i386-linux-gnu/libc.so.6...
done.
Loaded symbols for /lib/i386-linux-gnu/libc.so.6
0xb7768424 in __kernel_vsyscall ()
(gdb) start
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Temporary breakpoint 1 at 0x8048444: file 0.cpp, line 3.
Starting program: /home/testuser/0.elf
Temporary breakpoint 1, main (argc=1, argv=0xbffff844) at 0.cpp:3
3 {

Common errors

Using the start 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) start
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 start command manually under Visual Studio. VisualGDB automatically issues an equivalent of the run command when you press F5 to start your debugging session:

See also