<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being "Free Software" and "Free Software Needs Free Documentation", with the Front-Cover Texts being "A GNU Manual," and with the Back-Cover Texts as in (a) below. (a) The FSF's Back-Cover Text is: "You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom." --> <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>GDB/MI Program Execution (Debugging with GDB)</title> <meta name="description" content="GDB/MI Program Execution (Debugging with GDB)"> <meta name="keywords" content="GDB/MI Program Execution (Debugging with GDB)"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <link href="index.html#Top" rel="start" title="Top"> <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="GDB_002fMI.html#GDB_002fMI" rel="up" title="GDB/MI"> <link href="GDB_002fMI-Stack-Manipulation.html#GDB_002fMI-Stack-Manipulation" rel="next" title="GDB/MI Stack Manipulation"> <link href="GDB_002fMI-Ada-Tasking-Commands.html#GDB_002fMI-Ada-Tasking-Commands" rel="prev" title="GDB/MI Ada Tasking Commands"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en"> <a name="GDB_002fMI-Program-Execution"></a> <div class="header"> <p> Next: <a href="GDB_002fMI-Stack-Manipulation.html#GDB_002fMI-Stack-Manipulation" accesskey="n" rel="next">GDB/MI Stack Manipulation</a>, Previous: <a href="GDB_002fMI-Ada-Tasking-Commands.html#GDB_002fMI-Ada-Tasking-Commands" accesskey="p" rel="prev">GDB/MI Ada Tasking Commands</a>, Up: <a href="GDB_002fMI.html#GDB_002fMI" accesskey="u" rel="up">GDB/MI</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> <hr> <a name="GDB_002fMI-Program-Execution-1"></a> <h3 class="section">27.13 <small>GDB/MI</small> Program Execution</h3> <p>These are the asynchronous commands which generate the out-of-band record ‘<samp>*stopped</samp>’. Currently <small>GDB</small> only really executes asynchronously with remote targets and this interaction is mimicked in other cases. </p> <a name="The-_002dexec_002dcontinue-Command"></a> <h4 class="subheading">The <code>-exec-continue</code> Command</h4> <a name="index-_002dexec_002dcontinue"></a> <a name="Synopsis-30"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-continue [--reverse] [--all|--thread-group N] </pre></div> <p>Resumes the execution of the inferior program, which will continue to execute until it reaches a debugger stop event. If the ‘<samp>--reverse</samp>’ option is specified, execution resumes in reverse until it reaches a stop event. Stop events may include </p><ul> <li> breakpoints or watchpoints </li><li> signals or exceptions </li><li> the end of the process (or its beginning under ‘<samp>--reverse</samp>’) </li><li> the end or beginning of a replay log if one is being used. </li></ul> <p>In all-stop mode (see <a href="All_002dStop-Mode.html#All_002dStop-Mode">All-Stop Mode</a>), may resume only one thread, or all threads, depending on the value of the ‘<samp>scheduler-locking</samp>’ variable. If ‘<samp>--all</samp>’ is specified, all threads (in all inferiors) will be resumed. The ‘<samp>--all</samp>’ option is ignored in all-stop mode. If the ‘<samp>--thread-group</samp>’ options is specified, then all threads in that thread group are resumed. </p> <a name="GDB-Command-29"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> corresponding is ‘<samp>continue</samp>’. </p> <a name="Example-29"></a> <h4 class="subsubheading">Example</h4> <div class="smallexample"> <pre class="smallexample">-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",arch="i386:x86_64"} (gdb) </pre></div> <a name="The-_002dexec_002dfinish-Command"></a> <h4 class="subheading">The <code>-exec-finish</code> Command</h4> <a name="index-_002dexec_002dfinish"></a> <a name="Synopsis-31"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-finish [--reverse] </pre></div> <p>Resumes the execution of the inferior program until the current function is exited. Displays the results returned by the function. If the ‘<samp>--reverse</samp>’ option is specified, resumes the reverse execution of the inferior program until the point where current function was called. </p> <a name="GDB-Command-30"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>finish</samp>’. </p> <a name="Example-30"></a> <h4 class="subsubheading">Example</h4> <p>Function returning <code>void</code>. </p> <div class="smallexample"> <pre class="smallexample">-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",arch="i386:x86_64"} (gdb) </pre></div> <p>Function returning other than <code>void</code>. The name of the internal <small>GDB</small> variable storing the result is printed, together with the value itself. </p> <div class="smallexample"> <pre class="smallexample">-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", arch="i386:x86_64"}, gdb-result-var="$1",return-value="0" (gdb) </pre></div> <a name="The-_002dexec_002dinterrupt-Command"></a> <h4 class="subheading">The <code>-exec-interrupt</code> Command</h4> <a name="index-_002dexec_002dinterrupt"></a> <a name="Synopsis-32"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-interrupt [--all|--thread-group N] </pre></div> <p>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 ‘<samp>^done</samp>’ output. If the user is trying to interrupt a non-running program, an error message will be printed. </p> <p>Note that when asynchronous execution is enabled, this command is asynchronous just like other execution commands. That is, first the ‘<samp>^done</samp>’ response will be printed, and the target stop will be reported after that using the ‘<samp>*stopped</samp>’ notification. </p> <p>In non-stop mode, only the context thread is interrupted by default. All threads (in all inferiors) will be interrupted if the ‘<samp>--all</samp>’ option is specified. If the ‘<samp>--thread-group</samp>’ option is specified, all threads in that group will be interrupted. </p> <a name="GDB-Command-31"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>interrupt</samp>’. </p> <a name="Example-31"></a> <h4 class="subsubheading">Example</h4> <div class="smallexample"> <pre class="smallexample">(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",arch="i386:x86_64"} (gdb) (gdb) -exec-interrupt ^error,msg="mi_cmd_exec_interrupt: Inferior not executing." (gdb) </pre></div> <a name="The-_002dexec_002djump-Command"></a> <h4 class="subheading">The <code>-exec-jump</code> Command</h4> <a name="index-_002dexec_002djump"></a> <a name="Synopsis-33"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-jump <var>location</var> </pre></div> <p>Resumes execution of the inferior program at the location specified by parameter. See <a href="Specify-Location.html#Specify-Location">Specify Location</a>, for a description of the different forms of <var>location</var>. </p> <a name="GDB-Command-32"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>jump</samp>’. </p> <a name="Example-32"></a> <h4 class="subsubheading">Example</h4> <div class="smallexample"> <pre class="smallexample">-exec-jump foo.c:10 *running,thread-id="all" ^running </pre></div> <a name="The-_002dexec_002dnext-Command"></a> <h4 class="subheading">The <code>-exec-next</code> Command</h4> <a name="index-_002dexec_002dnext"></a> <a name="Synopsis-34"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-next [--reverse] </pre></div> <p>Resumes execution of the inferior program, stopping when the beginning of the next source line is reached. </p> <p>If the ‘<samp>--reverse</samp>’ 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. </p> <a name="GDB-Command-33"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>next</samp>’. </p> <a name="Example-33"></a> <h4 class="subsubheading">Example</h4> <div class="smallexample"> <pre class="smallexample">-exec-next ^running (gdb) *stopped,reason="end-stepping-range",line="8",file="hello.c" (gdb) </pre></div> <a name="The-_002dexec_002dnext_002dinstruction-Command"></a> <h4 class="subheading">The <code>-exec-next-instruction</code> Command</h4> <a name="index-_002dexec_002dnext_002dinstruction"></a> <a name="Synopsis-35"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-next-instruction [--reverse] </pre></div> <p>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. </p> <p>If the ‘<samp>--reverse</samp>’ 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. </p> <a name="GDB-Command-34"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>nexti</samp>’. </p> <a name="Example-34"></a> <h4 class="subsubheading">Example</h4> <div class="smallexample"> <pre class="smallexample">(gdb) -exec-next-instruction ^running (gdb) *stopped,reason="end-stepping-range", addr="0x000100d4",line="5",file="hello.c" (gdb) </pre></div> <a name="The-_002dexec_002dreturn-Command"></a> <h4 class="subheading">The <code>-exec-return</code> Command</h4> <a name="index-_002dexec_002dreturn"></a> <a name="Synopsis-36"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-return </pre></div> <p>Makes current function return immediately. Doesn’t execute the inferior. Displays the new current frame. </p> <a name="GDB-Command-35"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>return</samp>’. </p> <a name="Example-35"></a> <h4 class="subsubheading">Example</h4> <div class="smallexample"> <pre class="smallexample">(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", arch="i386:x86_64"} (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", arch="i386:x86_64"} (gdb) </pre></div> <a name="The-_002dexec_002drun-Command"></a> <h4 class="subheading">The <code>-exec-run</code> Command</h4> <a name="index-_002dexec_002drun"></a> <a name="Synopsis-37"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-run [ --all | --thread-group N ] [ --start ] </pre></div> <p>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. </p> <p>When neither the ‘<samp>--all</samp>’ nor the ‘<samp>--thread-group</samp>’ option is specified, the current inferior is started. If the ‘<samp>--thread-group</samp>’ option is specified, it should refer to a thread group of type ‘<samp>process</samp>’, and that thread group will be started. If the ‘<samp>--all</samp>’ option is specified, then all inferiors will be started. </p> <p>Using the ‘<samp>--start</samp>’ option instructs the debugger to stop the execution at the start of the inferior’s main subprogram, following the same behavior as the <code>start</code> command (see <a href="Starting.html#Starting">Starting</a>). </p> <a name="GDB-Command-36"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>run</samp>’. </p> <a name="Examples-2"></a> <h4 class="subsubheading">Examples</h4> <div class="smallexample"> <pre class="smallexample">(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",arch="i386:x86_64"} (gdb) </pre></div> <p>Program exited normally: </p> <div class="smallexample"> <pre class="smallexample">(gdb) -exec-run ^running (gdb) x = 55 *stopped,reason="exited-normally" (gdb) </pre></div> <p>Program exited exceptionally: </p> <div class="smallexample"> <pre class="smallexample">(gdb) -exec-run ^running (gdb) x = 55 *stopped,reason="exited",exit-code="01" (gdb) </pre></div> <p>Another way the program can terminate is if it receives a signal such as <code>SIGINT</code>. In this case, <small>GDB/MI</small> displays this: </p> <div class="smallexample"> <pre class="smallexample">(gdb) *stopped,reason="exited-signalled",signal-name="SIGINT", signal-meaning="Interrupt" </pre></div> <a name="The-_002dexec_002dstep-Command"></a> <h4 class="subheading">The <code>-exec-step</code> Command</h4> <a name="index-_002dexec_002dstep"></a> <a name="Synopsis-38"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-step [--reverse] </pre></div> <p>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 ‘<samp>--reverse</samp>’ option is specified, resumes reverse execution of the inferior program, stopping at the beginning of the previously executed source line. </p> <a name="GDB-Command-37"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>step</samp>’. </p> <a name="Example-36"></a> <h4 class="subsubheading">Example</h4> <p>Stepping into a function: </p> <div class="smallexample"> <pre class="smallexample">-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",arch="i386:x86_64"} (gdb) </pre></div> <p>Regular stepping: </p> <div class="smallexample"> <pre class="smallexample">-exec-step ^running (gdb) *stopped,reason="end-stepping-range",line="14",file="recursive2.c" (gdb) </pre></div> <a name="The-_002dexec_002dstep_002dinstruction-Command"></a> <h4 class="subheading">The <code>-exec-step-instruction</code> Command</h4> <a name="index-_002dexec_002dstep_002dinstruction"></a> <a name="Synopsis-39"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-step-instruction [--reverse] </pre></div> <p>Resumes the inferior which executes one machine instruction. If the ‘<samp>--reverse</samp>’ option is specified, resumes reverse execution of the inferior program, stopping at the previously executed instruction. The output, once <small>GDB</small> 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. </p> <a name="GDB-Command-38"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>stepi</samp>’. </p> <a name="Example-37"></a> <h4 class="subsubheading">Example</h4> <div class="smallexample"> <pre class="smallexample">(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",arch="i386:x86_64"} (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",arch="i386:x86_64"} (gdb) </pre></div> <a name="The-_002dexec_002duntil-Command"></a> <h4 class="subheading">The <code>-exec-until</code> Command</h4> <a name="index-_002dexec_002duntil"></a> <a name="Synopsis-40"></a> <h4 class="subsubheading">Synopsis</h4> <div class="smallexample"> <pre class="smallexample"> -exec-until [ <var>location</var> ] </pre></div> <p>Executes the inferior until the <var>location</var> 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 ‘<samp>location-reached</samp>’. </p> <a name="GDB-Command-39"></a> <h4 class="subsubheading"><small>GDB</small> Command</h4> <p>The corresponding <small>GDB</small> command is ‘<samp>until</samp>’. </p> <a name="Example-38"></a> <h4 class="subsubheading">Example</h4> <div class="smallexample"> <pre class="smallexample">(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", arch="i386:x86_64"} (gdb) </pre></div> <hr> <div class="header"> <p> Next: <a href="GDB_002fMI-Stack-Manipulation.html#GDB_002fMI-Stack-Manipulation" accesskey="n" rel="next">GDB/MI Stack Manipulation</a>, Previous: <a href="GDB_002fMI-Ada-Tasking-Commands.html#GDB_002fMI-Ada-Tasking-Commands" accesskey="p" rel="prev">GDB/MI Ada Tasking Commands</a>, Up: <a href="GDB_002fMI.html#GDB_002fMI" accesskey="u" rel="up">GDB/MI</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> </body> </html>