Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / gdb / GDB-MI-Program-Control.html
blob3a06cdf548c887cc4aa3e9b820d4f3560ce004b6
1 <html lang="en">
2 <head>
3 <title>Debugging with GDB</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="Debugging with GDB">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="GDB%2fMI%20Program%20Control">GDB/MI Program Control</a>,
13 Next:<a rel="next" accesskey="n" href="GDB-MI-Miscellaneous-Commands.html#GDB%2fMI%20Miscellaneous%20Commands">GDB/MI Miscellaneous Commands</a>,
14 Previous:<a rel="previous" accesskey="p" href="GDB-MI-Data-Manipulation.html#GDB%2fMI%20Data%20Manipulation">GDB/MI Data Manipulation</a>,
15 Up:<a rel="up" accesskey="u" href="GDB-MI.html#GDB%2fMI">GDB/MI</a>
16 <hr><br>
17 </div>
19 <h3 class="section"><small>GDB/MI</small> Program control</h3>
21 <h5 class="subsubheading">Program termination</h5>
23 <p>As a result of execution, the inferior program can run to completion, if
24 it doesn't encounter any breakpoints. In this case the output will
25 include an exit code, if the program has exited exceptionally.
27 <h5 class="subsubheading">Examples</h5>
29 <p>Program exited normally:
31 <pre class="smallexample"> (gdb)
32 -exec-run
33 ^running
34 (gdb)
35 x = 55
36 *stopped,reason="exited-normally"
37 (gdb)
38 </pre>
40 <p>Program exited exceptionally:
42 <pre class="smallexample"> (gdb)
43 -exec-run
44 ^running
45 (gdb)
46 x = 55
47 *stopped,reason="exited",exit-code="01"
48 (gdb)
49 </pre>
51 <p>Another way the program can terminate is if it receives a signal such as
52 <code>SIGINT</code>. In this case, <small>GDB/MI</small> displays this:
54 <pre class="smallexample"> (gdb)
55 *stopped,reason="exited-signalled",signal-name="SIGINT",
56 signal-meaning="Interrupt"
57 </pre>
59 <h4 class="subheading">The <code>-exec-abort</code> Command</h4>
61 <h5 class="subsubheading">Synopsis</h5>
63 <pre class="example"> -exec-abort
64 </pre>
66 <p>Kill the inferior running program.
68 <h5 class="subsubheading">GDB Command</h5>
70 <p>The corresponding GDB command is <code>kill</code>.
72 <h5 class="subsubheading">Example</h5>
74 <p>N.A.
76 <h4 class="subheading">The <code>-exec-arguments</code> Command</h4>
78 <h5 class="subsubheading">Synopsis</h5>
80 <pre class="example"> -exec-arguments <var>args</var>
81 </pre>
83 <p>Set the inferior program arguments, to be used in the next
84 <code>-exec-run</code>.
86 <h5 class="subsubheading">GDB Command</h5>
88 <p>The corresponding GDB command is <code>set args</code>.
90 <h5 class="subsubheading">Example</h5>
92 <p>Don't have one around.
94 <h4 class="subheading">The <code>-exec-continue</code> Command</h4>
96 <h5 class="subsubheading">Synopsis</h5>
98 <pre class="example"> -exec-continue
99 </pre>
101 <p>Asynchronous command. Resumes the execution of the inferior program
102 until a breakpoint is encountered, or until the inferior exits.
104 <h5 class="subsubheading">GDB Command</h5>
106 <p>The corresponding GDB corresponding is <code>continue</code>.
108 <h5 class="subsubheading">Example</h5>
110 <pre class="smallexample"> -exec-continue
111 ^running
112 (gdb)
113 @Hello world
114 *stopped,reason="breakpoint-hit",bkptno="2",frame={func="foo",args=[],
115 file="hello.c",line="13"}
116 (gdb)
117 </pre>
119 <h4 class="subheading">The <code>-exec-finish</code> Command</h4>
121 <h5 class="subsubheading">Synopsis</h5>
123 <pre class="example"> -exec-finish
124 </pre>
126 <p>Asynchronous command. Resumes the execution of the inferior program
127 until the current function is exited. Displays the results returned by
128 the function.
130 <h5 class="subsubheading">GDB Command</h5>
132 <p>The corresponding GDB command is <code>finish</code>.
134 <h5 class="subsubheading">Example</h5>
136 <p>Function returning <code>void</code>.
138 <pre class="smallexample"> -exec-finish
139 ^running
140 (gdb)
141 @hello from foo
142 *stopped,reason="function-finished",frame={func="main",args=[],
143 file="hello.c",line="7"}
144 (gdb)
145 </pre>
147 <p>Function returning other than <code>void</code>. The name of the internal
148 GDB variable storing the result is printed, together with the
149 value itself.
151 <pre class="smallexample"> -exec-finish
152 ^running
153 (gdb)
154 *stopped,reason="function-finished",frame={addr="0x000107b0",func="foo",
155 args=[{name="a",value="1"],{name="b",value="9"}},
156 file="recursive2.c",line="14"},
157 gdb-result-var="$1",return-value="0"
158 (gdb)
159 </pre>
161 <h4 class="subheading">The <code>-exec-interrupt</code> Command</h4>
163 <h5 class="subsubheading">Synopsis</h5>
165 <pre class="example"> -exec-interrupt
166 </pre>
168 <p>Asynchronous command. Interrupts the background execution of the target.
169 Note how the token associated with the stop message is the one for the
170 execution command that has been interrupted. The token for the interrupt
171 itself only appears in the <code>^done</code> output. If the user is trying to
172 interrupt a non-running program, an error message will be printed.
174 <h5 class="subsubheading">GDB Command</h5>
176 <p>The corresponding GDB command is <code>interrupt</code>.
178 <h5 class="subsubheading">Example</h5>
180 <pre class="smallexample"> (gdb)
181 111-exec-continue
182 111^running
184 (gdb)
185 222-exec-interrupt
186 222^done
187 (gdb)
188 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
189 frame={addr="0x00010140",func="foo",args=[],file="try.c",line="13"}
190 (gdb)
192 (gdb)
193 -exec-interrupt
194 ^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
195 (gdb)
196 </pre>
198 <h4 class="subheading">The <code>-exec-next</code> Command</h4>
200 <h5 class="subsubheading">Synopsis</h5>
202 <pre class="example"> -exec-next
203 </pre>
205 <p>Asynchronous command. Resumes execution of the inferior program, stopping
206 when the beginning of the next source line is reached.
208 <h5 class="subsubheading">GDB Command</h5>
210 <p>The corresponding GDB command is <code>next</code>.
212 <h5 class="subsubheading">Example</h5>
214 <pre class="smallexample"> -exec-next
215 ^running
216 (gdb)
217 *stopped,reason="end-stepping-range",line="8",file="hello.c"
218 (gdb)
219 </pre>
221 <h4 class="subheading">The <code>-exec-next-instruction</code> Command</h4>
223 <h5 class="subsubheading">Synopsis</h5>
225 <pre class="example"> -exec-next-instruction
226 </pre>
228 <p>Asynchronous command. Executes one machine instruction. If the
229 instruction is a function call continues until the function returns. If
230 the program stops at an instruction in the middle of a source line, the
231 address will be printed as well.
233 <h5 class="subsubheading">GDB Command</h5>
235 <p>The corresponding GDB command is <code>nexti</code>.
237 <h5 class="subsubheading">Example</h5>
239 <pre class="smallexample"> (gdb)
240 -exec-next-instruction
241 ^running
243 (gdb)
244 *stopped,reason="end-stepping-range",
245 addr="0x000100d4",line="5",file="hello.c"
246 (gdb)
247 </pre>
249 <h4 class="subheading">The <code>-exec-return</code> Command</h4>
251 <h5 class="subsubheading">Synopsis</h5>
253 <pre class="example"> -exec-return
254 </pre>
256 <p>Makes current function return immediately. Doesn't execute the inferior.
257 Displays the new current frame.
259 <h5 class="subsubheading">GDB Command</h5>
261 <p>The corresponding GDB command is <code>return</code>.
263 <h5 class="subsubheading">Example</h5>
265 <pre class="smallexample"> (gdb)
266 200-break-insert callee4
267 200^done,bkpt={number="1",addr="0x00010734",
268 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
269 (gdb)
270 000-exec-run
271 000^running
272 (gdb)
273 000*stopped,reason="breakpoint-hit",bkptno="1",
274 frame={func="callee4",args=[],
275 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
276 (gdb)
277 205-break-delete
278 205^done
279 (gdb)
280 111-exec-return
281 111^done,frame={level="0 ",func="callee3",
282 args=[{name="strarg",
283 value="0x11940 \"A string argument.\""}],
284 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
285 (gdb)
286 </pre>
288 <h4 class="subheading">The <code>-exec-run</code> Command</h4>
290 <h5 class="subsubheading">Synopsis</h5>
292 <pre class="example"> -exec-run
293 </pre>
295 <p>Asynchronous command. Starts execution of the inferior from the
296 beginning. The inferior executes until either a breakpoint is
297 encountered or the program exits.
299 <h5 class="subsubheading">GDB Command</h5>
301 <p>The corresponding GDB command is <code>run</code>.
303 <h5 class="subsubheading">Example</h5>
305 <pre class="smallexample"> (gdb)
306 -break-insert main
307 ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"}
308 (gdb)
309 -exec-run
310 ^running
311 (gdb)
312 *stopped,reason="breakpoint-hit",bkptno="1",
313 frame={func="main",args=[],file="recursive2.c",line="4"}
314 (gdb)
315 </pre>
317 <h4 class="subheading">The <code>-exec-show-arguments</code> Command</h4>
319 <h5 class="subsubheading">Synopsis</h5>
321 <pre class="example"> -exec-show-arguments
322 </pre>
324 <p>Print the arguments of the program.
326 <h5 class="subsubheading">GDB Command</h5>
328 <p>The corresponding GDB command is <code>show args</code>.
330 <h5 class="subsubheading">Example</h5>
332 <p>N.A.
334 <h4 class="subheading">The <code>-exec-step</code> Command</h4>
336 <h5 class="subsubheading">Synopsis</h5>
338 <pre class="example"> -exec-step
339 </pre>
341 <p>Asynchronous command. Resumes execution of the inferior program, stopping
342 when the beginning of the next source line is reached, if the next
343 source line is not a function call. If it is, stop at the first
344 instruction of the called function.
346 <h5 class="subsubheading">GDB Command</h5>
348 <p>The corresponding GDB command is <code>step</code>.
350 <h5 class="subsubheading">Example</h5>
352 <p>Stepping into a function:
354 <pre class="smallexample"> -exec-step
355 ^running
356 (gdb)
357 *stopped,reason="end-stepping-range",
358 frame={func="foo",args=[{name="a",value="10"},
359 {name="b",value="0"}],file="recursive2.c",line="11"}
360 (gdb)
361 </pre>
363 <p>Regular stepping:
365 <pre class="smallexample"> -exec-step
366 ^running
367 (gdb)
368 *stopped,reason="end-stepping-range",line="14",file="recursive2.c"
369 (gdb)
370 </pre>
372 <h4 class="subheading">The <code>-exec-step-instruction</code> Command</h4>
374 <h5 class="subsubheading">Synopsis</h5>
376 <pre class="example"> -exec-step-instruction
377 </pre>
379 <p>Asynchronous command. Resumes the inferior which executes one machine
380 instruction. The output, once GDB has stopped, will vary depending on
381 whether we have stopped in the middle of a source line or not. In the
382 former case, the address at which the program stopped will be printed as
383 well.
385 <h5 class="subsubheading">GDB Command</h5>
387 <p>The corresponding GDB command is <code>stepi</code>.
389 <h5 class="subsubheading">Example</h5>
391 <pre class="smallexample"> (gdb)
392 -exec-step-instruction
393 ^running
395 (gdb)
396 *stopped,reason="end-stepping-range",
397 frame={func="foo",args=[],file="try.c",line="10"}
398 (gdb)
399 -exec-step-instruction
400 ^running
402 (gdb)
403 *stopped,reason="end-stepping-range",
404 frame={addr="0x000100f4",func="foo",args=[],file="try.c",line="10"}
405 (gdb)
406 </pre>
408 <h4 class="subheading">The <code>-exec-until</code> Command</h4>
410 <h5 class="subsubheading">Synopsis</h5>
412 <pre class="example"> -exec-until [ <var>location</var> ]
413 </pre>
415 <p>Asynchronous command. Executes the inferior until the <var>location</var>
416 specified in the argument is reached. If there is no argument, the inferior
417 executes until a source line greater than the current one is reached.
418 The reason for stopping in this case will be <code>location-reached</code>.
420 <h5 class="subsubheading">GDB Command</h5>
422 <p>The corresponding GDB command is <code>until</code>.
424 <h5 class="subsubheading">Example</h5>
426 <pre class="smallexample"> (gdb)
427 -exec-until recursive2.c:6
428 ^running
429 (gdb)
430 x = 55
431 *stopped,reason="location-reached",frame={func="main",args=[],
432 file="recursive2.c",line="6"}
433 (gdb)
434 </pre>
436 <h4 class="subheading">The <code>-file-exec-and-symbols</code> Command</h4>
438 <h5 class="subsubheading">Synopsis</h5>
440 <pre class="example"> -file-exec-and-symbols <var>file</var>
441 </pre>
443 <p>Specify the executable file to be debugged. This file is the one from
444 which the symbol table is also read. If no file is specified, the
445 command clears the executable and symbol information. If breakpoints
446 are set when using this command with no arguments, GDB will produce
447 error messages. Otherwise, no output is produced, except a completion
448 notification.
450 <h5 class="subsubheading">GDB Command</h5>
452 <p>The corresponding GDB command is <code>file</code>.
454 <h5 class="subsubheading">Example</h5>
456 <pre class="smallexample"> (gdb)
457 -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
458 ^done
459 (gdb)
460 </pre>
462 <h4 class="subheading">The <code>-file-exec-file</code> Command</h4>
464 <h5 class="subsubheading">Synopsis</h5>
466 <pre class="example"> -file-exec-file <var>file</var>
467 </pre>
469 <p>Specify the executable file to be debugged. Unlike
470 <code>-file-exec-and-symbols</code>, the symbol table is <em>not</em> read
471 from this file. If used without argument, GDB clears the information
472 about the executable file. No output is produced, except a completion
473 notification.
475 <h5 class="subsubheading">GDB Command</h5>
477 <p>The corresponding GDB command is <code>exec-file</code>.
479 <h5 class="subsubheading">Example</h5>
481 <pre class="smallexample"> (gdb)
482 -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
483 ^done
484 (gdb)
485 </pre>
487 <h4 class="subheading">The <code>-file-list-exec-sections</code> Command</h4>
489 <h5 class="subsubheading">Synopsis</h5>
491 <pre class="example"> -file-list-exec-sections
492 </pre>
494 <p>List the sections of the current executable file.
496 <h5 class="subsubheading">GDB Command</h5>
498 <p>The GDB command <code>info file</code> shows, among the rest, the same
499 information as this command. <code>gdbtk</code> has a corresponding command
500 <code>gdb_load_info</code>.
502 <h5 class="subsubheading">Example</h5>
504 <p>N.A.
506 <h4 class="subheading">The <code>-file-list-exec-source-files</code> Command</h4>
508 <h5 class="subsubheading">Synopsis</h5>
510 <pre class="example"> -file-list-exec-source-files
511 </pre>
513 <p>List the source files for the current executable.
515 <h5 class="subsubheading">GDB Command</h5>
517 <p>There's no GDB command which directly corresponds to this one.
518 <code>gdbtk</code> has an analogous command <code>gdb_listfiles</code>.
520 <h5 class="subsubheading">Example</h5>
522 <p>N.A.
524 <h4 class="subheading">The <code>-file-list-shared-libraries</code> Command</h4>
526 <h5 class="subsubheading">Synopsis</h5>
528 <pre class="example"> -file-list-shared-libraries
529 </pre>
531 <p>List the shared libraries in the program.
533 <h5 class="subsubheading">GDB Command</h5>
535 <p>The corresponding GDB command is <code>info shared</code>.
537 <h5 class="subsubheading">Example</h5>
539 <p>N.A.
541 <h4 class="subheading">The <code>-file-list-symbol-files</code> Command</h4>
543 <h5 class="subsubheading">Synopsis</h5>
545 <pre class="example"> -file-list-symbol-files
546 </pre>
548 <p>List symbol files.
550 <h5 class="subsubheading">GDB Command</h5>
552 <p>The corresponding GDB command is <code>info file</code> (part of it).
554 <h5 class="subsubheading">Example</h5>
556 <p>N.A.
558 <h4 class="subheading">The <code>-file-symbol-file</code> Command</h4>
560 <h5 class="subsubheading">Synopsis</h5>
562 <pre class="example"> -file-symbol-file <var>file</var>
563 </pre>
565 <p>Read symbol table info from the specified <var>file</var> argument. When
566 used without arguments, clears GDB's symbol table info. No output is
567 produced, except for a completion notification.
569 <h5 class="subsubheading">GDB Command</h5>
571 <p>The corresponding GDB command is <code>symbol-file</code>.
573 <h5 class="subsubheading">Example</h5>
575 <pre class="smallexample"> (gdb)
576 -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
577 ^done
578 (gdb)
579 </pre>
581 </body></html>