Debugging with GDB: GDB/MI Program Execution |
---|
Next: GDB/MI Stack Manipulation, Previous: GDB/MI Ada Tasking Commands, Up: GDB/MI [Contents][Index]
These are the asynchronous commands which generate the out-of-band record ‘*stopped’. Currently GDB only really executes asynchronously with remote targets and this interaction is mimicked in other cases.
-exec-continue
Command-exec-continue [--reverse] [--all|--thread-group N]
Resumes the execution of the inferior program, which will continue to execute until it reaches a debugger stop event. If the ‘--reverse’ option is specified, execution resumes in reverse until it reaches a stop event. Stop events may include
In all-stop mode (see All-Stop Mode), may resume only one thread, or all threads, depending on the value of the ‘scheduler-locking’ variable. If ‘--all’ is specified, all threads (in all inferiors) will be resumed. The ‘--all’ option is ignored in all-stop mode. If the ‘--thread-group’ options is specified, then all threads in that thread group are resumed.
The corresponding GDB corresponding is ‘continue’.
-exec-continue ^running (gdb) @Hello world *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={ func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c", line="13"} (gdb)
-exec-finish
Command-exec-finish [--reverse]
Resumes the execution of the inferior program until the current function is exited. Displays the results returned by the function. If the ‘--reverse’ option is specified, resumes the reverse execution of the inferior program until the point where current function was called.
The corresponding GDB command is ‘finish’.
Function returning void
.
-exec-finish ^running (gdb) @hello from foo *stopped,reason="function-finished",frame={func="main",args=[], file="hello.c",fullname="/home/foo/bar/hello.c",line="7"} (gdb)
Function returning other than void
. The name of the internal
GDB variable storing the result is printed, together with the
value itself.
-exec-finish ^running (gdb) *stopped,reason="function-finished",frame={addr="0x000107b0",func="foo", args=[{name="a",value="1"],{name="b",value="9"}}, file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, gdb-result-var="$1",return-value="0" (gdb)
-exec-interrupt
Command-exec-interrupt [--all|--thread-group N]
Interrupts the background execution of the target. Note how the token associated with the stop message is the one for the execution command that has been interrupted. The token for the interrupt itself only appears in the ‘^done’ output. If the user is trying to interrupt a non-running program, an error message will be printed.
Note that when asynchronous execution is enabled, this command is asynchronous just like other execution commands. That is, first the ‘^done’ response will be printed, and the target stop will be reported after that using the ‘*stopped’ notification.
In non-stop mode, only the context thread is interrupted by default. All threads (in all inferiors) will be interrupted if the ‘--all’ option is specified. If the ‘--thread-group’ option is specified, all threads in that group will be interrupted.
The corresponding GDB command is ‘interrupt’.
(gdb) 111-exec-continue 111^running (gdb) 222-exec-interrupt 222^done (gdb) 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt", frame={addr="0x00010140",func="foo",args=[],file="try.c", fullname="/home/foo/bar/try.c",line="13"} (gdb) (gdb) -exec-interrupt ^error,msg="mi_cmd_exec_interrupt: Inferior not executing." (gdb)
-exec-jump
Command-exec-jump location
Resumes execution of the inferior program at the location specified by parameter. See Specify Location, for a description of the different forms of location.
The corresponding GDB command is ‘jump’.
-exec-jump foo.c:10 *running,thread-id="all" ^running
-exec-next
Command-exec-next [--reverse]
Resumes execution of the inferior program, stopping when the beginning of the next source line is reached.
If the ‘--reverse’ option is specified, resumes reverse execution of the inferior program, stopping at the beginning of the previous source line. If you issue this command on the first line of a function, it will take you back to the caller of that function, to the source line where the function was called.
The corresponding GDB command is ‘next’.
-exec-next ^running (gdb) *stopped,reason="end-stepping-range",line="8",file="hello.c" (gdb)
-exec-next-instruction
Command-exec-next-instruction [--reverse]
Executes one machine instruction. If the instruction is a function call, continues until the function returns. If the program stops at an instruction in the middle of a source line, the address will be printed as well.
If the ‘--reverse’ option is specified, resumes reverse execution of the inferior program, stopping at the previous instruction. If the previously executed instruction was a return from another function, it will continue to execute in reverse until the call to that function (from the current stack frame) is reached.
The corresponding GDB command is ‘nexti’.
(gdb) -exec-next-instruction ^running (gdb) *stopped,reason="end-stepping-range", addr="0x000100d4",line="5",file="hello.c" (gdb)
-exec-return
Command-exec-return
Makes current function return immediately. Doesn’t execute the inferior. Displays the new current frame.
The corresponding GDB command is ‘return’.
(gdb) 200-break-insert callee4 200^done,bkpt={number="1",addr="0x00010734", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"} (gdb) 000-exec-run 000^running (gdb) 000*stopped,reason="breakpoint-hit",disp="keep",bkptno="1", frame={func="callee4",args=[], file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"} (gdb) 205-break-delete 205^done (gdb) 111-exec-return 111^done,frame={level="0",func="callee3", args=[{name="strarg", value="0x11940 \"A string argument.\""}], file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"} (gdb)
-exec-run
Command-exec-run [ --all | --thread-group N ] [ --start ]
Starts execution of the inferior from the beginning. The inferior executes until either a breakpoint is encountered or the program exits. In the latter case the output will include an exit code, if the program has exited exceptionally.
When neither the ‘--all’ nor the ‘--thread-group’ option is specified, the current inferior is started. If the ‘--thread-group’ option is specified, it should refer to a thread group of type ‘process’, and that thread group will be started. If the ‘--all’ option is specified, then all inferiors will be started.
Using the ‘--start’ option instructs the debugger to stop
the execution at the start of the inferior’s main subprogram,
following the same behavior as the start
command
(see Starting).
The corresponding GDB command is ‘run’.
(gdb) -break-insert main ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"} (gdb) -exec-run ^running (gdb) *stopped,reason="breakpoint-hit",disp="keep",bkptno="1", frame={func="main",args=[],file="recursive2.c", fullname="/home/foo/bar/recursive2.c",line="4"} (gdb)
Program exited normally:
(gdb) -exec-run ^running (gdb) x = 55 *stopped,reason="exited-normally" (gdb)
Program exited exceptionally:
(gdb) -exec-run ^running (gdb) x = 55 *stopped,reason="exited",exit-code="01" (gdb)
Another way the program can terminate is if it receives a signal such as
SIGINT
. In this case, GDB/MI displays this:
(gdb) *stopped,reason="exited-signalled",signal-name="SIGINT", signal-meaning="Interrupt"
-exec-step
Command-exec-step [--reverse]
Resumes execution of the inferior program, stopping when the beginning of the next source line is reached, if the next source line is not a function call. If it is, stop at the first instruction of the called function. If the ‘--reverse’ option is specified, resumes reverse execution of the inferior program, stopping at the beginning of the previously executed source line.
The corresponding GDB command is ‘step’.
Stepping into a function:
-exec-step ^running (gdb) *stopped,reason="end-stepping-range", frame={func="foo",args=[{name="a",value="10"}, {name="b",value="0"}],file="recursive2.c", fullname="/home/foo/bar/recursive2.c",line="11"} (gdb)
Regular stepping:
-exec-step ^running (gdb) *stopped,reason="end-stepping-range",line="14",file="recursive2.c" (gdb)
-exec-step-instruction
Command-exec-step-instruction [--reverse]
Resumes the inferior which executes one machine instruction. If the ‘--reverse’ option is specified, resumes reverse execution of the inferior program, stopping at the previously executed instruction. The output, once GDB has stopped, will vary depending on whether we have stopped in the middle of a source line or not. In the former case, the address at which the program stopped will be printed as well.
The corresponding GDB command is ‘stepi’.
(gdb) -exec-step-instruction ^running (gdb) *stopped,reason="end-stepping-range", frame={func="foo",args=[],file="try.c", fullname="/home/foo/bar/try.c",line="10"} (gdb) -exec-step-instruction ^running (gdb) *stopped,reason="end-stepping-range", frame={addr="0x000100f4",func="foo",args=[],file="try.c", fullname="/home/foo/bar/try.c",line="10"} (gdb)
-exec-until
Command-exec-until [ location ]
Executes the inferior until the location specified in the argument is reached. If there is no argument, the inferior executes until a source line greater than the current one is reached. The reason for stopping in this case will be ‘location-reached’.
The corresponding GDB command is ‘until’.
(gdb) -exec-until recursive2.c:6 ^running (gdb) x = 55 *stopped,reason="location-reached",frame={func="main",args=[], file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6"} (gdb)
Next: GDB/MI Stack Manipulation, Previous: GDB/MI Ada Tasking Commands, Up: GDB/MI [Contents][Index]