GNU Binutils with patches for OS216
修订版 | fe3f5fc8280c8697ec793b7090ae2845abf570f5 (tree) |
---|---|
时间 | 1991-03-30 11:13:24 |
作者 | Roland Pesch <pesch@cygn...> |
Commiter | Roland Pesch |
Restructured manual; introduced introductory sample session.
@@ -8,17 +8,18 @@ | ||
8 | 8 | @c _HOST__ architectures (and you can of course get the full source, |
9 | 9 | @c with all configurations, from wherever you got this). |
10 | 10 | _if__(0) |
11 | +_0__ | |
11 | 12 | |
12 | 13 | THIS IS THE FULL SOURCE. The full source needs to be run through m4 |
13 | 14 | before either tex- or info- formatting: for example, |
14 | - m4 pretex.m4 none.m4 m680x0.m4 as.texinfo >as-680x0.texinfo | |
15 | + m4 pretex.m4 none.m4 m680x0.m4 gdb.texinfo >gdb-680x0.texinfo | |
15 | 16 | will produce (assuming your path finds either GNU or SysV m4; Berkeley |
16 | 17 | won't do) a file suitable for formatting. See the text in "pretex.m4" |
17 | 18 | for a fuller explanation (and the macro definitions). |
18 | - | |
19 | +_1__ | |
19 | 20 | _fi__(0) |
20 | 21 | @c |
21 | -@synindex ky cp | |
22 | +@syncodeindex ky cp | |
22 | 23 | @c FOR UPDATES LEADING TO THIS DRAFT, GDB CHANGELOG CONSULTED BETWEEN: |
23 | 24 | @c Tue Feb 26 01:47:07 1991 Cygnus John Gilmore (cygnus at yuba) |
24 | 25 | @c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint) |
@@ -220,14 +221,176 @@ HPPA architecture support. | ||
220 | 221 | |
221 | 222 | @end itemize |
222 | 223 | |
223 | -@node Invocation, User Interface, New Features, Top | |
224 | -@chapter Starting _GDBN__ | |
224 | +@node Sample Session,,, | |
225 | +@chapter A Sample _GDB__ Session | |
226 | + | |
227 | +You can use this manual at your leisure to read all about _GDBN__. | |
228 | +However, a handful of commands are enough to get started using the | |
229 | +debugger. This chapter illustrates these commands. | |
230 | + | |
231 | +In this sample session, we emphasize user input like this: @var{input}, | |
232 | +to make it easier to pick out from the surrounding output. | |
233 | + | |
234 | +We'll be using _GDBN__ to inspect GNU @code{m4} (a generic macro | |
235 | +processor). | |
236 | + | |
237 | +_0__@smallexample | |
238 | +$ @var{cd gm4/common} | |
239 | + | |
240 | +$ @var{_GDBP__ m4} | |
241 | +Reading symbol data from m4...done. | |
242 | +@end smallexample | |
243 | + | |
244 | +@noindent | |
245 | +_GDBN__ only reads enough symbol data to know where to find the rest | |
246 | +when needed; as a result, the first prompt comes up very quickly. | |
247 | + | |
248 | +@smallexample | |
249 | +(_GDBP__) @var{break m4_changequote} | |
250 | +Breakpoint 1 at 0x59d4: file builtin.c, line 812. | |
251 | +@end smallexample | |
252 | + | |
253 | +@noindent | |
254 | +We've chosen to see how the @code{m4} builtin @samp{changequote} | |
255 | +works. We know the relevant subroutine is @samp{m4_changequote} (from | |
256 | +inspecting the source), so we set a breakpoint there. | |
257 | + | |
258 | +@smallexample | |
259 | +(_GDBP__) @var{run} | |
260 | +Starting program: /s1/gnu/src/gm4/common/m4 | |
261 | +@var{`usual' quotes <not these>} | |
262 | +usual quotes <not these> | |
263 | +@end smallexample | |
264 | + | |
265 | +@noindent | |
266 | +Now we've started @code{m4} running under _GDBN__ control; while we don't touch | |
267 | +the @samp{m4_changequote} subroutine, the program runs as usual. | |
268 | + | |
269 | +@smallexample | |
270 | +@var{changequote(<,>)} | |
271 | + | |
272 | +Breakpoint 1, m4_changequote (argc=3, argv=0x2b958) at builtin.c:812 | |
273 | +812 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3)) | |
274 | +@end smallexample | |
275 | +@noindent | |
276 | +Once we've encountered the breakpoint, _GDBN__ suspends execution | |
277 | +of our program, displaying information about where it stopped. | |
278 | + | |
279 | +@smallexample | |
280 | +(_GDBP__) @var{s} | |
281 | +bad_argc (name=0xf833cfb4<Address 0xf833cfb4 out of | |
282 | + bounds>, argc=3, min=1, max=3) at builtin.c:230 | |
283 | +230 if (min > 0 && argc < min) @{ | |
284 | +@end smallexample | |
285 | +@noindent | |
286 | +We single-stepped with the command @samp{s}; since there was a subroutine | |
287 | +call, we've stopped in the first line of that subroutine, not in the next line | |
288 | +of @code{m4_changequote}. | |
289 | + | |
290 | +The command @samp{next} would have taken us to the next line of the same | |
291 | +subroutine. Now that we've stopped deeper in the stack, we can use the | |
292 | +@samp{backtrace} command (which can also be spelled @samp{bt}) to get | |
293 | +information about where we are. | |
294 | + | |
295 | +@smallexample | |
296 | +(_GDBP__) @var{bt} | |
297 | +#0 bad_argc (name=0xf833cfb4<Address 0xf833cfb4 out of bounds>, argc=3, | |
298 | + min=1, max=3) at builtin.c:230 | |
299 | +#1 0x59ec in m4_changequote (argc=3, argv=0x2b958) at builtin.c:812 | |
300 | +#2 0x6e38 in expand_macro (sym=0x2b060) at macro.c:242 | |
301 | +#3 0x6840 in expand_token (obs=0x0, t=176224, td=0xf7fffb08) at macro.c:71 | |
302 | +#4 0x6794 in expand_input () at macro.c:40 | |
303 | +#5 0x28dc in main (argc=0, argv=0xf7fffbf8) at m4.c:174 | |
304 | +@end smallexample | |
305 | + | |
306 | +@noindent | |
307 | +We'll tell _GDBN__ to finish execution of this subroutine, to get back | |
308 | +to @code{m4_changequote}. | |
309 | + | |
310 | +@smallexample | |
311 | +(_GDBP__) @var{finish} | |
312 | +Run till exit from #0 bad_argc (name=0xf833cfb4<Address 0xf833cfb4 out of | |
313 | + bounds>, argc=3, min=1, max=3) at builtin.c:230 | |
314 | +0x59ec in m4_changequote (argc=3, argv=0x2b958) at builtin.c:812 | |
315 | +812 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3)) | |
316 | +Value returned is $1 = false | |
317 | +(_GDBP__) @var{s} | |
318 | +815 lquote = (argc >= 2) ? TOKEN_DATA_TEXT(argv[1])[0] : DEF_LQUOTE; | |
319 | +(_GDBP__) @var{whatis lquote} | |
320 | +type = char | |
321 | +(_GDBP__) @var{p lquote} | |
322 | +$2 = 96 '`' | |
323 | +@end smallexample | |
324 | + | |
325 | +@noindent | |
326 | +When we stepped to another line, @code{m4} was about to set a variable | |
327 | +@samp{lquote}; we inspected its type with @samp{whatis} and its value | |
328 | +with @samp{p} (the @samp{print} command). We can see some context by | |
329 | +displaying the surrounding source code, with the @samp{l} (@code{list}) | |
330 | +command. | |
331 | + | |
332 | +@smallexample | |
333 | +(_GDBP__) @var{l} | |
334 | +810 token_data **argv; | |
335 | +811 @{ | |
336 | +812 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3)) | |
337 | +813 return; | |
338 | +814 | |
339 | +815 lquote = (argc >= 2) ? TOKEN_DATA_TEXT(argv[1])[0] : DEF_LQUOTE; | |
340 | +816 rquote = (argc >= 3) ? TOKEN_DATA_TEXT(argv[2])[0] : DEF_RQUOTE; | |
341 | +817 @} | |
342 | +818 | |
343 | +819 /* | |
344 | +(_GDBP__) @var{s} | |
345 | +816 rquote = (argc >= 3) ? TOKEN_DATA_TEXT(argv[2])[0] : DEF_RQUOTE; | |
346 | +(_GDBP__) @var{s} | |
347 | +817 @} | |
348 | +(_GDBP__) @var{p lquote} | |
349 | +$3 = 60 '<' | |
350 | +(_GDBP__) @var{p rquote} | |
351 | +$4 = 62 '>' | |
352 | +@end smallexample | |
353 | + | |
354 | +@noindent | |
355 | +We proceeded past another line with @samp{s}, and inspected the new | |
356 | +values of @code{m4}'s internal variables @code{rquote} and | |
357 | +@code{lquote}. | |
358 | + | |
359 | +Since we're done with our inspection of this subroutine, we'll tell | |
360 | +_GDBN__ to allow @code{m4} to continue running, with the @samp{c} | |
361 | +(@code{continue}) command: | |
362 | + | |
363 | +@smallexample | |
364 | +(_GDBP__) @var{c} | |
365 | +Continuing. | |
366 | + | |
367 | +@var{`usual' quotes <not these>} | |
368 | +`usual' quotes not these | |
369 | + | |
370 | +Program exited normally. | |
371 | +(_GDBP__) @var{quit} | |
372 | + | |
373 | +$ | |
374 | +_1__@end smallexample | |
375 | + | |
376 | +@noindent | |
377 | +Finally, when we ended the @code{m4} run, _GDBN__ told us | |
378 | +``@code{Program exited normally.}'' We ended our _GDBN__ session with | |
379 | +the _GDBN__ @samp{quit} command. | |
380 | + | |
381 | + | |
382 | +@node Starting and Stopping,,, | |
383 | +@chapter Starting and Stopping | |
384 | + | |
385 | +@node Starting _GDBN__,,, | |
386 | +@section Starting _GDBN__ | |
225 | 387 | |
226 | 388 | _GDBN__ is invoked with the shell command @samp{_GDBP__}. Once started, it reads |
227 | 389 | commands from the terminal until you tell it to exit. |
228 | 390 | |
229 | -The most usual way to start _GDBN__ is with one argument or two, specifying | |
230 | -an executable program as the argument: | |
391 | +You can start by just calling @samp{_GDBP__} with no arguments or | |
392 | +options; but the most usual way to start _GDBN__ is with one argument or | |
393 | +two, specifying an executable program as the argument: | |
231 | 394 | @example |
232 | 395 | _GDBP__ program |
233 | 396 | @end example |
@@ -245,7 +408,7 @@ in sequential order. The order makes a difference when the | ||
245 | 408 | @samp{-x} option is used. |
246 | 409 | |
247 | 410 | @node File Options, Mode Options, Invocation, Invocation |
248 | -@section Options and Arguments to Choose Files | |
411 | +@subsection Options and Arguments to Choose Files | |
249 | 412 | |
250 | 413 | As shown above, any arguments other than options specify an executable |
251 | 414 | file and core file; that is, the first argument encountered with no |
@@ -275,8 +438,8 @@ Execute _GDBN__ commands from file @var{file}. @xref{Command Files}. | ||
275 | 438 | Add @var{directory} to the path to search for source files. |
276 | 439 | @end table |
277 | 440 | |
278 | -@node Mode Options, Remote i960-Nindy, File Options, Invocation | |
279 | -@section Options to Choose Modes | |
441 | +@node Mode Options, , , | |
442 | +@subsection Options to Choose Modes | |
280 | 443 | |
281 | 444 | @table @code |
282 | 445 | @item -nx |
@@ -323,7 +486,7 @@ _GDBN__ for remote debugging. | ||
323 | 486 | |
324 | 487 | _if__(_I960__) |
325 | 488 | @node i960-Nindy Remote,,, |
326 | -@section _GDBN__ with a Remote Intel 960 (Nindy) | |
489 | +@subsection _GDBN__ with a Remote Intel 960 (Nindy) | |
327 | 490 | |
328 | 491 | ``Nindy'' is the name of a Rom Monitor program for Intel 960 target |
329 | 492 | systems. When _GDBN__ is configured to control a remote Intel 960 using |
@@ -341,7 +504,7 @@ By using the @samp{target} command at any point during your _GDBN__ session. | ||
341 | 504 | @end itemize |
342 | 505 | |
343 | 506 | @node Nindy Startup,,, |
344 | -@subsection Startup with Nindy | |
507 | +@subsubsection Startup with Nindy | |
345 | 508 | |
346 | 509 | The command-line options for Nindy are detailed below. If you simply |
347 | 510 | start @code{_GDBP__} without using options to specify a serial port, you are |
@@ -355,7 +518,7 @@ responding to the prompt with an empty line. If you do this, and later | ||
355 | 518 | wish to attach to Nindy, use @samp{target} (@pxref{Target Commands}). |
356 | 519 | |
357 | 520 | @node Nindy Options,,, |
358 | -@subsection Options for Nindy | |
521 | +@subsubsection Options for Nindy | |
359 | 522 | |
360 | 523 | These are the startup options for beginning your _GDBN__ session with a |
361 | 524 | Nindy-960 board attached: |
@@ -402,7 +565,7 @@ _fi__(_I960__) | ||
402 | 565 | |
403 | 566 | _if__(_AMD29K__) |
404 | 567 | @node EB29K Remote,,, |
405 | -@section Starting _GDBN__ with a Remote EB29K | |
568 | +@subsection _GDBN__ with a Remote EB29K | |
406 | 569 | |
407 | 570 | @cindex EB29K board |
408 | 571 | @cindex running 29K programs |
@@ -415,12 +578,12 @@ you've hooked the cable between the PC's @samp{COM1} port and | ||
415 | 578 | @samp{/dev/ttya} on the Unix system. |
416 | 579 | |
417 | 580 | @node Comms (EB29K),,, |
418 | -@subsection Communications Setup | |
581 | +@subsubsection Communications Setup | |
419 | 582 | The next step is to set up the PC's port, by doing something like the |
420 | 583 | following in DOS on the PC: |
421 | -@example | |
584 | +_0__@example | |
422 | 585 | C:\> MODE com1:9600,n,8,1,none |
423 | -@end example | |
586 | +_1__@end example | |
424 | 587 | @noindent |
425 | 588 | This example---run on an MS DOS 4.0 system---sets the PC port to 9600 |
426 | 589 | bps, no parity, eight data bits, one stop bit, and no ``retry'' action; |
@@ -431,9 +594,9 @@ end of the connection as well. | ||
431 | 594 | |
432 | 595 | To give control of the PC to the Unix side of the serial line, type |
433 | 596 | the following at the DOS console: |
434 | -@example | |
597 | +_0__@example | |
435 | 598 | C:\> CTTY com1 |
436 | -@end example | |
599 | +_1__@end example | |
437 | 600 | @noindent |
438 | 601 | (Later, if you wish to return control to the DOS console, you can use |
439 | 602 | the command @samp{CTTY con}---but you must send it over the device that |
@@ -472,7 +635,7 @@ start the PC program @samp{EBMON} (an EB29K control program supplied | ||
472 | 635 | with your board by AMD). You should see an initial display from |
473 | 636 | @code{EBMON} similar to the one in our example, ending with the |
474 | 637 | @code{EBMON} prompt @samp{#}--- |
475 | -@example | |
638 | +_0__@example | |
476 | 639 | C:\> g: |
477 | 640 | |
478 | 641 | G:\> CD \usr\joe\work29k |
@@ -501,7 +664,7 @@ Am29027 Available = No | ||
501 | 664 | Byte Write Available = Yes |
502 | 665 | |
503 | 666 | # ~. |
504 | -@end example | |
667 | +_1__@end example | |
505 | 668 | |
506 | 669 | Then exit the @code{cu} or @code{tip} program (done in the example by |
507 | 670 | typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} will keep |
@@ -516,8 +679,8 @@ other way---perhaps floppy-disk transfer---of getting the 29K program | ||
516 | 679 | from the Unix system to the PC; _GDBN__ will @emph{not} download it over the |
517 | 680 | serial line. |
518 | 681 | |
519 | -@node _GDBP__-EB29K | |
520 | -@subsection EB29K cross-debugging | |
682 | +@node _GDBP__-EB29K,,, | |
683 | +@subsubsection EB29K cross-debugging | |
521 | 684 | Finally, @code{cd} to the directory containing an image of your 29K |
522 | 685 | program on the Unix system, and start _GDBN__---specifying as argument the |
523 | 686 | name of your 29K program: |
@@ -558,7 +721,7 @@ Type @samp{CTTY con} to return command input to the main DOS console, | ||
558 | 721 | and type @samp{~.} to leave @code{tip} or @code{cu}. |
559 | 722 | |
560 | 723 | @node Remote Log, , Remote Commands, Remote |
561 | -@subsection Remote Log | |
724 | +@subsubsection Remote Log | |
562 | 725 | @kindex eb.log |
563 | 726 | @cindex log file for EB29K |
564 | 727 | The @samp{target amd-eb} command creates a file @file{eb.log} in the |
@@ -569,9 +732,54 @@ another window often helps to debug trouble with @code{EBMON}, or | ||
569 | 732 | unexpected events on the PC side of the connection. |
570 | 733 | _fi__(_AMD29K__) |
571 | 734 | |
572 | -@node User Interface, Files, Invocation, Top | |
573 | -@chapter _GDBN__ Commands and Displays | |
735 | +@node Stopping _GDBN__,,, | |
736 | +@section Stopping _GDBN__ | |
737 | +@cindex exiting _GDBN__ | |
738 | +@kindex quit | |
739 | +To exit _GDBN__, use the @samp{quit} command (abbreviated @samp{q}), or type | |
740 | +an end-of-file character (usually @kbd{C-d}). | |
741 | + | |
742 | +@cindex interrupt | |
743 | +An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather | |
744 | +will terminate the action of any _GDBN__ command that is in progress and | |
745 | +return to _GDBN__ command level. It is safe to type the interrupt | |
746 | +character at any time because _GDBN__ does not allow it to take effect | |
747 | +until a time when it is safe. | |
574 | 748 | |
749 | +If you've been using _GDBN__ to control an attached process or device, | |
750 | +you can release it with the @samp{detach} command; @pxref{Attach}. | |
751 | + | |
752 | +@node Shell Commands,,, | |
753 | +@section Shell Commands | |
754 | +If you just need to execute occasional shell commands during your | |
755 | +debugging session, there's no need to stop or suspend _GDBN__; you can | |
756 | +just use the @samp{shell} command. | |
757 | + | |
758 | +@table @code | |
759 | +@item shell @var{command string} | |
760 | +@kindex shell | |
761 | +@cindex shell escape | |
762 | +Directs _GDBN__ to invoke an inferior shell to execute @var{command string}. | |
763 | +The environment variable @code{SHELL} is used if it exists, otherwise _GDBN__ | |
764 | +uses @samp{/bin/sh}. | |
765 | +@end table | |
766 | + | |
767 | +The utility @samp{make} is often needed in development environments. | |
768 | +You don't have to use the @samp{shell} command for this purpose in _GDBN__: | |
769 | + | |
770 | +@table @code | |
771 | +@item make @dots{} | |
772 | +@kindex make | |
773 | +@cindex calling make | |
774 | +Causes _GDBN__ to execute an inferior @code{make} program with the specified | |
775 | +arguments. This is equivalent to @samp{shell make @dots{}}. | |
776 | +@end table | |
777 | + | |
778 | +@node Commands,,, | |
779 | +@chapter _GDBN__ Commands | |
780 | + | |
781 | +@node Command Syntax,,, | |
782 | +@section Command Syntax | |
575 | 783 | A _GDBN__ command is a single line of input. There is no limit on how long |
576 | 784 | it can be. It starts with a command name, which is followed by arguments |
577 | 785 | whose meaning depends on the command name. For example, the command |
@@ -599,3419 +807,3539 @@ differently when repeated because that is more useful. | ||
599 | 807 | A line of input starting with @samp{#} is a comment; it does nothing. |
600 | 808 | This is useful mainly in command files (@xref{Command Files}). |
601 | 809 | |
810 | +@node Help,,, | |
811 | +@section Getting Help | |
602 | 812 | @cindex online documentation |
603 | 813 | @kindex help |
604 | -@table @code | |
605 | -@item help | |
606 | -@itemx help @var{category} | |
607 | -@itemx help @var{command} | |
608 | 814 | You can always ask _GDBN__ itself for information on its commands, using the |
609 | -command @samp{help}. With a command name as argument, it will display a | |
610 | -paragraph on how to use the command. Used with no arguments, | |
611 | -@samp{help} displays a short list of named categories of commands; you | |
612 | -can then use @samp{help @var{category}} to list the individual commands | |
613 | -in a category. | |
614 | - | |
615 | -@kindex info version | |
616 | -@item info version | |
617 | -As _GDBN__ evolves, new commands are introduced, and old ones may wither | |
618 | -away. If multiple versions of _GDBN__ are in use at your site, it may | |
619 | -occasionally be useful to make sure what version of _GDBN__ you're running. | |
620 | -_GDBN__ announces its version whenever it starts up; but you can make it | |
621 | -repeat this information with the @samp{info version} command. | |
622 | -@end table | |
623 | - | |
624 | -@cindex prompt | |
625 | -_GDBN__ indicates its readiness to read a command by printing a string | |
626 | -called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You can | |
627 | -change the prompt string with the @samp{set prompt} command. For | |
628 | -instance, when debugging _GDBN__ with _GDBN__, it is useful to change the prompt | |
629 | -in one of the _GDBN__s so that you tell which one you are talking to. | |
630 | - | |
631 | -@table @code | |
632 | -@item set prompt @var{newprompt} | |
633 | -@kindex set prompt | |
634 | -Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth. | |
635 | -@kindex show prompt | |
636 | -@item show prompt | |
637 | -Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} | |
638 | -@end table | |
639 | - | |
640 | -@cindex exiting _GDBN__ | |
641 | -@kindex quit | |
642 | -To exit _GDBN__, use the @samp{quit} command (abbreviated @samp{q}), or type | |
643 | -an end-of-file character (usually @ctrl{d}). An interrupt (often | |
644 | -@ctrl{c}) will not exit from _GDBN__, but rather will terminate the action | |
645 | -of any _GDBN__ command that is in progress and return to _GDBN__ command level. | |
646 | -It is safe to type the interrupt character at any time because _GDBN__ does | |
647 | -not allow it to take effect until a time when it is safe. | |
648 | - | |
649 | -@cindex readline | |
650 | -@cindex command line editing | |
651 | -@cindex history substitution | |
652 | -_GDBN__ reads its input commands via the @code{readline} interface. This | |
653 | -GNU library provides consistent behavior for programs which provide a | |
654 | -command line interface to the user. Advantages are @samp{emacs}-style | |
655 | -or @samp{vi}-style inline editing of commands, @samp{csh}-like history | |
656 | -substitution, and a storage and recall of command history across | |
657 | -debugging sessions. | |
658 | - | |
659 | -You may control the behavior of command line editing in _GDBN__ with the | |
660 | -command @samp{set}. You may check the status of any of these settings | |
661 | -with the command @samp{show}. | |
815 | +command @samp{help}. | |
662 | 816 | |
663 | 817 | @table @code |
664 | -@kindex set editing | |
665 | -@cindex editing | |
666 | -@item set editing | |
667 | -@itemx set editing on | |
668 | -Enable command line editing (enabled by default). | |
669 | - | |
670 | -@item set editing off | |
671 | -Disable command line editing. | |
818 | +@item help | |
819 | +Used with no arguments, @samp{help} displays a short list of named | |
820 | +categories of commands: | |
821 | +@example | |
822 | +(_GDBP__) help | |
823 | +List of classes of commands: | |
824 | + | |
825 | +running -- Running the program | |
826 | +stack -- Examining the stack | |
827 | +data -- Examining data | |
828 | +breakpoints -- Making program stop at certain points | |
829 | +files -- Specifying and examining files | |
830 | +status -- Status inquiries | |
831 | +support -- Support facilities | |
832 | +user-defined -- User-defined commands | |
833 | +aliases -- Aliases of other commands | |
834 | +obscure -- Obscure features | |
835 | + | |
836 | +Type "help" followed by a class name for a list of commands in that class. | |
837 | +Type "help" followed by command name for full documentation. | |
838 | +Command name abbreviations are allowed if unambiguous. | |
839 | +(_GDBP__) | |
840 | +@end example | |
672 | 841 | |
673 | -@kindex show editing | |
674 | -@item show editing | |
675 | -Show whether command line editing is enabled. | |
842 | +@item help @var{category} | |
843 | +Using one of the general help categories as an argument, you can get a | |
844 | +list of the individual commands in a category. For example, here is the | |
845 | +help display for category @samp{status}: | |
846 | +@example | |
847 | +(_GDBP__) help status | |
848 | +Status inquiries. | |
676 | 849 | |
677 | -@cindex history file | |
678 | -@kindex set history file | |
679 | -@item set history file @var{filename} | |
680 | -Set the name of the _GDBN__ command history file to @samp{filename}. This is | |
681 | -the file from which _GDBN__ will read an initial command history | |
682 | -list or to which it will write this list when it exits. This list is | |
683 | -accessed through history expansion or through the history | |
684 | -command editing characters listed below. This file defaults to the | |
685 | -value of the environmental variable @code{GDBHISTFILE}, or to | |
686 | -@code{./.gdb_history} if this variable is not set. | |
850 | +List of commands: | |
687 | 851 | |
688 | -@cindex history write | |
689 | -@kindex set history write | |
690 | -@item set history write | |
691 | -@itemx set history write on | |
692 | -Make _GDBN__ record command history in a file, whose name may be specified with the | |
693 | -@samp{set history file} command. By default, this option is disabled. | |
852 | +show -- Generic command for showing things set with "set" | |
853 | +info -- Generic command for printing status | |
694 | 854 | |
695 | -@item set history write off | |
696 | -Make _GDBN__ stop recording command history in a file. | |
855 | +Type "help" followed by command name for full documentation. | |
856 | +Command name abbreviations are allowed if unambiguous. | |
857 | +(_GDBP__) | |
858 | +@end example | |
697 | 859 | |
698 | -@cindex history size | |
699 | -@kindex set history size | |
700 | -@item set history size @var{size} | |
701 | -Set the number of commands which _GDBN__ will keep in its history list. | |
702 | -This defaults to the value of the environmental variable | |
703 | -@code{HISTSIZE}, or to 256 if this variable is not set. | |
860 | +@item help @var{command} | |
861 | +With a command name as @samp{help} argument, _GDBN__ will display a | |
862 | +short paragraph on how to use that command. | |
704 | 863 | @end table |
705 | 864 | |
706 | -@cindex history expansion | |
707 | -History expansion assigns special meaning to the character @samp{!} | |
708 | -(@pxref{Event Designators}). Since @samp{!} is also the logical not | |
709 | -operator in C, history expansion is off by default. If you decide to | |
710 | -enable history expansion with the @samp{set history expansion on} | |
711 | -command, you may sometimes need to follow @samp{!} (when it is used as | |
712 | -logical not, in an expression) with a space or a tab to prevent it from | |
713 | -being expanded. The @code{readline} history facilities will not attempt | |
714 | -substitution on the strings @samp{!=} and @samp{!(}, even when history | |
715 | -expansion is enabled. | |
716 | - | |
717 | -The commands to control history expansion are: | |
865 | +In addition to @samp{help}, you can use the _GDBN__ commands @samp{info} | |
866 | +and @samp{show} to inquire about the state of your program, or the state | |
867 | +of _GDBN__ itself. Both commands support many ``sub-commands'', or | |
868 | +topics of inquiry; this manual introduces each of them in the | |
869 | +appropriate context. The listings under ``@code{info}'' and under | |
870 | +``@code{show}'' in the Index point to all the sub-commands | |
871 | +(@pxref{Index}). | |
718 | 872 | |
719 | 873 | @table @code |
720 | - | |
721 | -@kindex set history expansion | |
722 | -@item set history expansion on | |
723 | -@itemx set history expansion | |
724 | -Enable history expansion. History expansion is off by default. | |
725 | - | |
726 | -@item set history expansion off | |
727 | -Disable history expansion. | |
728 | - | |
729 | -The @code{readline} code comes with more complete documentation of | |
730 | -editing and history expansion features. Users unfamiliar with @samp{emacs} | |
731 | -or @samp{vi} may wish to read it. @xref{Command Line Editing}. | |
732 | - | |
733 | -@kindex show history | |
734 | -@item show history | |
735 | -@itemx show history file | |
736 | -@itemx show history write | |
737 | -@itemx show history size | |
738 | -@itemx show history expansion | |
739 | -These commands display the state of the _GDBN__ history parameters. | |
740 | -@samp{show history} by itself displays all four states. | |
874 | +@kindex info | |
875 | +@item info | |
876 | +This command is for describing the state of your program; for example, | |
877 | +it can list the arguments given to your program (@samp{info args}), the | |
878 | +registers currently in use (@samp{info registers}), or the breakpoints | |
879 | +you've set (@samp{info breakpoints}). You can get a complete list of | |
880 | +the @code{info} sub-commands with @samp{help info}. | |
741 | 881 | |
742 | 882 | @kindex show |
743 | -@kindex info set | |
744 | 883 | @item show |
745 | -@itemx info set | |
746 | -This chapter introduces a number of internal _GDBN__ variables that you | |
747 | -can control with the @samp{set} command, and display with the | |
748 | -@samp{show} command. A number of others are introduced throughout the | |
749 | -manual. To display all the settable parameters and their current | |
884 | +In contrast, @samp{show} is for describing the state of _GDBN__ itself. | |
885 | +You can change most of the things you can @code{show}, by using the | |
886 | +related command @samp{set}; for example, you can control what number | |
887 | +system is used for displays with @samp{set radix}, or simply inquire | |
888 | +which possibility is currently in use with @samp{show radix}. | |
889 | + | |
890 | +@kindex info set | |
891 | +To display all the settable parameters and their current | |
750 | 892 | values, you can use @samp{show} with no arguments; you may also use |
751 | 893 | @samp{info set}. Both commands produce the same display. |
894 | +@c FIXME: "info set" violates the rule that "info" is for state of | |
895 | +@c FIXME...program. Ck w/ GNU: "info set" to be called something else, | |
896 | +@c FIXME...or change desc of rule---eg "state of prog and debugging session"? | |
897 | + | |
898 | + | |
899 | +@kindex show version | |
900 | +@item show version | |
901 | +@c FIXME: chgd to "show version" from "info". Verify John doing same to GDBv4. | |
902 | +This @samp{show} subcommand is one of those with no corresponding | |
903 | +@samp{set} subcommand. As _GDBN__ evolves, new commands are introduced, | |
904 | +and old ones may wither away. If multiple versions of _GDBN__ are in | |
905 | +use at your site, it may occasionally be useful to make sure what | |
906 | +version of _GDBN__ you're running. It is also useful to include this | |
907 | +information in _GDBN__ bug-reports. _GDBN__ announces its version | |
908 | +number if you start it with no arguments; but you can make it give this | |
909 | +information on request, with the @samp{show version} command. | |
752 | 910 | |
753 | 911 | @end table |
754 | 912 | |
755 | -@table @code | |
756 | -@kindex info editing | |
757 | -@item info editing | |
758 | -Display the last ten commands in the command history. | |
913 | +@node Running,,, | |
914 | +@chapter Running Programs Under _GDBN__ | |
759 | 915 | |
760 | -@item info editing @var{n} | |
761 | -Print ten commands centered on command number @var{n}. | |
916 | +@node Compilation,,, | |
917 | +@section Compiling for Debugging | |
762 | 918 | |
763 | -@item info editing + | |
764 | -Print ten commands just after the commands last printed. | |
919 | +In order to debug a program effectively, you need to ask for debugging | |
920 | +information when you compile it. This debugging information is stored | |
921 | +in the object file; it describes the data type of each variable or | |
922 | +function and the correspondence between source line numbers and | |
923 | +addresses in the executable code. | |
765 | 924 | |
766 | -@end table | |
925 | +To request debugging information, specify the @samp{-g} option when you run | |
926 | +the compiler. | |
767 | 927 | |
768 | -Occasionally it is useful to execute a shell command from within _GDBN__. | |
769 | -This can be done with the @samp{shell} command. | |
928 | +The Unix C compiler is unable to handle the @samp{-g} and @samp{-O} options | |
929 | +together. This means that you cannot ask for optimization if you ask for | |
930 | +debugger information. | |
770 | 931 | |
771 | -@table @code | |
772 | -@item shell @var{command string} | |
773 | -@kindex shell | |
774 | -@cindex shell escape | |
775 | -Directs _GDBN__ to invoke an inferior shell to execute @var{command string}. | |
776 | -The environment variable @code{SHELL} is used if it exists, otherwise _GDBN__ | |
777 | -uses @samp{/bin/sh}. | |
778 | -@end table | |
932 | +The GNU C compiler supports @samp{-g} with or without @samp{-O}, making it | |
933 | +possible to debug optimized code. We recommend that you @emph{always} use | |
934 | +@samp{-g} whenever you compile a program. You may think the program is | |
935 | +correct, but there's no sense in pushing your luck. | |
779 | 936 | |
780 | -The utility @samp{make} is often needed in development environments. | |
781 | -You don't have to use the @samp{shell} command for this purpose in _GDBN__: | |
937 | +Some things do not work as well with @samp{-g -O} as with just | |
938 | +@samp{-g}, particularly on machines with instruction scheduling. If in | |
939 | +doubt, recompile with @samp{-g} alone, and if this fixes the problem, | |
940 | +please report it as a bug (including a test case---@pxref{_GDBN__ Bugs}). | |
782 | 941 | |
783 | -@table @code | |
784 | -@item make @dots{} | |
785 | -@kindex make | |
786 | -@cindex calling make | |
787 | -Causes _GDBN__ to execute an inferior @code{make} program with the specified | |
788 | -arguments. This is equivalent to @samp{shell make @dots{}}. | |
789 | -@end table | |
942 | +Older versions of the GNU C compiler, _GCC__, permitted a variant option | |
943 | +@samp{-gg} for debugging information. _GDBN__ no longer supports this format; | |
944 | +if your GNU C compiler has this option, do not use it. | |
790 | 945 | |
791 | -@cindex screen size | |
792 | -@cindex pauses in output | |
793 | -Certain commands to _GDBN__ may produce large amounts of information output | |
794 | -to the screen. To help you read all of it, _GDBN__ pauses and asks you for | |
795 | -input at the end of each page of output. Type @key{RET} when you want | |
796 | -to continue the output. Normally _GDBN__ knows the size of the screen from | |
797 | -the termcap data base together with the value of the @code{TERM} | |
798 | -environment variable and the @code{stty rows} and @code{stty cols} | |
799 | -settings. If this is not correct, you can override it with | |
800 | -the @samp{set screen-height} and @samp{set screen-width} commands: | |
801 | - | |
802 | -_GDBN__ also uses the screen width setting to determine when to wrap lines | |
803 | -of output. Depending what is being printed, it tries to break the | |
804 | -line at a readable place, rather than simply letting it overflow onto | |
805 | -the following line. | |
946 | +@ignore | |
947 | +@comment As far as I know, there are no cases in which _GDBN__ will | |
948 | +@comment produce strange output in this case. (but no promises). | |
949 | +If your program includes archives made with the @code{ar} program, and | |
950 | +if the object files used as input to @code{ar} were compiled without the | |
951 | +@samp{-g} option and have names longer than 15 characters, _GDBN__ will get | |
952 | +confused reading the program's symbol table. No error message will be | |
953 | +given, but _GDBN__ may behave strangely. The reason for this problem is a | |
954 | +deficiency in the Unix archive file format, which cannot represent file | |
955 | +names longer than 15 characters. | |
806 | 956 | |
807 | -@table @code | |
808 | -@item set screen-height @var{lpp} | |
809 | -@itemx show screen-height | |
810 | -@itemx set screen-width @var{cpl} | |
811 | -@itemx show screen-width | |
812 | -@kindex set screen-height | |
813 | -@kindex set screen-width | |
814 | -@kindex show screen-width | |
815 | -@kindex show screen-height | |
816 | -These @samp{set} commands specify a screen height of @var{lpp} lines and | |
817 | -a screen width of @var{cpl} characters. The associated @samp{show} | |
818 | -commands display the current settings. | |
957 | +To avoid this problem, compile the archive members with the @samp{-g} | |
958 | +option or use shorter file names. Alternatively, use a version of GNU | |
959 | +@code{ar} dated more recently than August 1989. | |
960 | +@end ignore | |
819 | 961 | |
820 | -If you specify a height of zero lines, _GDBN__ will not pause during output | |
821 | -no matter how long the output is. This is useful if output is to a file | |
822 | -or to an editor buffer. | |
823 | -@end table | |
824 | 962 | |
825 | -@cindex number representation | |
826 | -@cindex entering numbers | |
827 | -You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by | |
828 | -the usual conventions: octal numbers begin with @samp{0}, decimal | |
829 | -numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}. | |
830 | -Numbers that begin with none of these are, by default, entered in base | |
831 | -10; likewise, the default display for numbers---when no particular | |
832 | -format is specified---is base 10. You can change the default base for | |
833 | -both input and output with the @samp{set radix} command. | |
963 | +@node Starting,,, | |
964 | +@section Starting your Program | |
965 | +@cindex starting | |
966 | +@cindex running | |
967 | +@kindex run | |
968 | +To start your program under _GDBN__, use the @samp{run} command. Except on | |
969 | +VxWorks, the program must already have been specified using the | |
970 | +@samp{file} or @samp{exec-file} command, or with an argument to _GDBN__ | |
971 | +(@pxref{Files}). | |
834 | 972 | |
835 | -@table @code | |
836 | -@kindex set radix | |
837 | -@item set radix @var{base} | |
838 | -Set the default base for numeric input and display. Supported choices | |
839 | -for @var{base} are decimal 8, 10, 16. @var{base} must itself be | |
840 | -specified either unambiguously or using the current default radix; for | |
841 | -example, any of | |
973 | +On targets that support processes, @samp{run} creates an inferior | |
974 | +process and makes that process run your program. On other targets, | |
975 | +@samp{run} jumps to the location it has recorded for the start of the | |
976 | +program. | |
842 | 977 | |
843 | -@example | |
844 | -set radix 012 | |
845 | -set radix 10. | |
846 | -set radix 0xa | |
847 | -@end example | |
978 | +The execution of a program is affected by certain information it | |
979 | +receives from its superior. _GDBN__ provides ways to specify this | |
980 | +information, which you must do @i{before} starting the program. (You | |
981 | +can change it after starting the program, but such changes do not affect | |
982 | +the program unless you start it over again.) This information may be | |
983 | +divided into three categories: | |
848 | 984 | |
849 | -@noindent | |
850 | -will set the base to decimal. On the other hand, @samp{set radix 10} | |
851 | -will leave the radix unchanged no matter what it was. | |
985 | +@table @asis | |
986 | +@item The @i{arguments.} | |
987 | +You specify the arguments to give the program as the arguments of the | |
988 | +@samp{run} command. If a shell is available on your target, the shell | |
989 | +is used to pass the arguments, so that you may use normal conventions | |
990 | +(for example regular expression expansion or variable substitution) in | |
991 | +describing the arguments. In Unix systems, you can control which shell | |
992 | +is used with the @code{SHELL} environment variable. | |
852 | 993 | |
853 | -@kindex show radix | |
854 | -@item show radix | |
855 | -Display the current default base for numeric input and display. | |
994 | +@item The @i{environment.} | |
995 | +The program normally inherits its environment from _GDBN__, but you can | |
996 | +use the _GDBN__ commands @samp{set environment} and | |
997 | +@samp{unset environment} to change parts of the environment that will | |
998 | +be given to the program.@refill | |
856 | 999 | |
1000 | +@item The @i{working directory.} | |
1001 | +The program inherits its working directory from _GDBN__. You can set _GDBN__'s | |
1002 | +working directory with the @samp{cd} command in _GDBN__. | |
857 | 1003 | @end table |
858 | 1004 | |
859 | -By default, _GDBN__ is silent about its inner workings. If you are running | |
860 | -on a slow machine, you may want to use the @samp{set verbose} command. | |
861 | -It will make _GDBN__ tell you when it does a lengthy internal operation, so | |
862 | -you won't think it has crashed. | |
1005 | +When you issue the @samp{run} command, your program begins to execute | |
1006 | +immediately. @xref{Stopping}, for discussion of how to arrange for your | |
1007 | +program to stop. | |
863 | 1008 | |
864 | -Currently, the messages controlled by @samp{set verbose} are those which | |
865 | -announce that the symbol table for a source file is being read | |
866 | -(@pxref{Files}, in the description of the command | |
867 | -@samp{symbol-file}). | |
868 | -@c The following is the right way to do it, but emacs 18.55 doesn't support | |
869 | -@c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo | |
870 | -@c is released. | |
871 | -@ignore | |
872 | -see @samp{symbol-file} in @ref{Files}). | |
873 | -@end ignore | |
1009 | +Note that once your program has been started by the @samp{run} command, | |
1010 | +you may evaluate expressions that involve calls to functions in the | |
1011 | +inferior, using the @samp{print} or @samp{call} commands. @xref{Data}. | |
874 | 1012 | |
875 | -@table @code | |
876 | -@kindex set verbose | |
877 | -@item set verbose on | |
878 | -Enables _GDBN__'s output of certain informational messages. | |
1013 | +If the modification time of your symbol file has changed since the last | |
1014 | +time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and re-read | |
1015 | +it. In this process, it tries to retain your current breakpoints. | |
879 | 1016 | |
880 | -@item set verbose off | |
881 | -Disables _GDBN__'s output of certain informational messages. | |
1017 | +@menu | |
1018 | +* Arguments:: Specifying the arguments for your program. | |
1019 | +* Environment:: Specifying the environment for your program. | |
1020 | +* Working Directory:: Specifying the working directory for giving | |
1021 | + to your program when it is run. | |
1022 | +* Input/Output:: Specifying the program's standard input and output. | |
1023 | +* Attach:: Debugging a process started outside _GDBN__. | |
1024 | +* Kill Process:: Getting rid of the child process running your program. | |
1025 | +@end menu | |
882 | 1026 | |
883 | -@kindex show verbose | |
884 | -@item show verbose | |
885 | -Displays whether @samp{set verbose} is on or off. | |
886 | -@end table | |
1027 | +@node Arguments, Environment, Running, Running | |
1028 | +@section Your Program's Arguments | |
887 | 1029 | |
888 | -By default, if _GDBN__ encounters bugs in the symbol table of an object file, | |
889 | -it prints a single message about each type of problem it finds, then | |
890 | -shuts up. You can suppress these messages, or allow more than one such | |
891 | -message to be printed if you want to see how frequent the problems are. | |
892 | -@xref{Files}. | |
1030 | +@cindex arguments (to your program) | |
1031 | +The arguments to your program are specified by the arguments of the | |
1032 | +@samp{run} command. They are passed to a shell, which expands wildcard | |
1033 | +characters and performs redirection of I/O, and thence to the program. | |
893 | 1034 | |
1035 | +@samp{run} with no arguments uses the same arguments used by the previous | |
1036 | +@samp{run}. | |
1037 | + | |
1038 | +@kindex set args | |
894 | 1039 | @table @code |
895 | -@kindex set complaints | |
896 | -@item set complaints @var{limit} | |
897 | -Permits _GDBN__ to output @var{limit} complaints about each type of unusual | |
898 | -symbols before becoming silent about the problem. Set @var{limit} to | |
899 | -zero to suppress all complaints; set it to a large number to prevent | |
900 | -complaints from being suppressed. | |
1040 | +@item set args | |
1041 | +The command @samp{set args} can be used to specify the arguments to be used | |
1042 | +the next time the program is run. If @samp{set args} has no arguments, it | |
1043 | +means to use no arguments the next time the program is run. If you have | |
1044 | +run your program with arguments and want to run it again with no arguments, | |
1045 | +this is the only way to do so. | |
901 | 1046 | |
902 | -@kindex show complaints | |
903 | -@item show complaints | |
904 | -Displays how many symbol complaints _GDBN__ is permitted to produce. | |
1047 | +@item show args | |
1048 | +@kindex show args | |
1049 | +Show the arguments to give your program when it is started. | |
905 | 1050 | @end table |
906 | 1051 | |
907 | -By default, _GDBN__ is cautious, and asks what sometimes seem to be a lot of | |
908 | -stupid questions. For example, if you try to run a program which is | |
909 | -already running: | |
910 | -@example | |
911 | - | |
912 | -(_GDBP__) run | |
913 | -The program being debugged has been started already. | |
914 | -Start it from the beginning? (y or n) | |
915 | -@end example | |
1052 | +@node Environment, Working Directory, Arguments, Running | |
1053 | +@section Your Program's Environment | |
916 | 1054 | |
917 | -If you're willing to unflinchingly face the consequences of your own | |
918 | -commands, you can disable this ``feature'': | |
1055 | +@cindex environment (of your program) | |
1056 | +The @dfn{environment} consists of a set of @dfn{environment variables} and | |
1057 | +their values. Environment variables conventionally record such things as | |
1058 | +your user name, your home directory, your terminal type, and your search | |
1059 | +path for programs to run. Usually you set up environment variables with | |
1060 | +the shell and they are inherited by all the other programs you run. When | |
1061 | +debugging, it can be useful to try running the program with different | |
1062 | +environments without having to start the debugger over again. | |
919 | 1063 | |
920 | 1064 | @table @code |
921 | -@kindex set caution | |
922 | -@cindex flinching | |
923 | -@cindex stupid questions | |
924 | -@item set caution off | |
925 | -Disables cautious questions. | |
1065 | +@item show environment @var{varname} | |
1066 | +@kindex show environment | |
1067 | +Print the value of environment variable @var{varname} to be given to | |
1068 | +your program when it is started. | |
926 | 1069 | |
927 | -@item set caution on | |
928 | -Enables cautious questions (the default). | |
1070 | +@item show environment | |
1071 | +Print the names and values of all environment variables to be given to | |
1072 | +your program when it is started. | |
929 | 1073 | |
930 | -@item show caution | |
931 | -@kindex show caution | |
932 | -Displays state of cautious questions. | |
933 | -@end table | |
1074 | +@item set environment @var{varname} @var{value} | |
1075 | +@itemx set environment @var{varname} = @var{value} | |
1076 | +@kindex set environment | |
1077 | +Sets environment variable @var{varname} to @var{value}, for your program | |
1078 | +only, not for _GDBN__ itself. @var{value} may be any string; the values of | |
1079 | +environment variables are just strings, and any interpretation is | |
1080 | +supplied by your program itself. The @var{value} parameter is optional; | |
1081 | +if it is eliminated, the variable is set to a null value. | |
934 | 1082 | |
935 | -@node Files, Compilation, User Interface, Top | |
936 | -@chapter Specifying _GDBN__'s Files | |
1083 | +For example, this command: | |
937 | 1084 | |
938 | -@cindex core dump file | |
939 | -@cindex executable file | |
940 | -@cindex symbol table | |
941 | -_GDBN__ needs to know the file name of the program to be debugged, both in | |
942 | -order to read its symbol table and in order to start the program. To | |
943 | -debug a core dump of a previous run, _GDBN__ must be told the file name of | |
944 | -the core dump. | |
1085 | +@example | |
1086 | +set env USER = foo | |
1087 | +@end example | |
945 | 1088 | |
946 | -The usual way to specify the executable and core dump file names is with | |
947 | -the command arguments given when you start _GDBN__, as discussed in | |
948 | -@pxref{Invocation}. | |
1089 | +@noindent | |
1090 | +tells the program, when subsequently run, to assume it is being run | |
1091 | +on behalf of the user named @samp{foo}. | |
949 | 1092 | |
950 | -But occasionally it is necessary to change to a different file during a | |
951 | -_GDBN__ session. Or you may run _GDBN__ and forget to specify the files you | |
952 | -want to use. In these situations the _GDBN__ commands to specify new files | |
953 | -are useful. | |
1093 | +@item delete environment @var{varname} | |
1094 | +@itemx unset environment @var{varname} | |
1095 | +@kindex delete environment | |
1096 | +@kindex unset environment | |
1097 | +Remove variable @var{varname} from the environment to be passed to your | |
1098 | +program. This is different from @samp{set env @var{varname}@ =}; | |
1099 | +@samp{delete environment} removes the variable from the environment, | |
1100 | +rather than assigning it an empty value. This command can be | |
1101 | +abbreviated @samp{d e}. | |
1102 | +@end table | |
954 | 1103 | |
955 | -@table @code | |
956 | -@item file @var{filename} | |
957 | -@kindex file | |
958 | -Use @var{filename} as the program to be debugged. It is read for its | |
959 | -symbols, for getting the contents of pure memory, and it is the program | |
960 | -executed when you use the @samp{run} command. If you do not specify a | |
961 | -directory and the file is not found in _GDBN__'s working directory, _GDBN__ will | |
962 | -use the environment variable @code{PATH} as a list of directories to | |
963 | -search, just as the shell does when looking for a program to run. | |
1104 | +@node Working Directory, Input/Output, Environment, Running | |
1105 | +@section Your Program's Working Directory | |
964 | 1106 | |
965 | -@samp{file} with no argument makes both executable file and symbol | |
966 | -table become unspecified. | |
1107 | +@cindex working directory (of your program) | |
1108 | +Each time you start your program with @samp{run}, it inherits its | |
1109 | +working directory from the current working directory of _GDBN__. _GDBN__'s | |
1110 | +working directory is initially whatever it inherited from its parent | |
1111 | +process (typically the shell), but you can specify a new working | |
1112 | +directory in _GDBN__ with the @samp{cd} command. | |
967 | 1113 | |
968 | -@item exec-file @var{filename} | |
969 | -@kindex exec-file | |
970 | -Specify that the program to be run (but not the symbol table) is found | |
971 | -in @var{filename}. _GDBN__ will search the environment variable @code{PATH} | |
972 | -if necessary to locate the program. | |
1114 | +The _GDBN__ working directory also serves as a default for the commands | |
1115 | +that specify files for _GDBN__ to operate on. @xref{Files}. | |
973 | 1116 | |
974 | -@item symbol-file @var{filename} | |
975 | -@kindex symbol-file | |
976 | -Read symbol table information from file @var{filename}. @code{PATH} is | |
977 | -searched when necessary. Use the @samp{file} command to get both symbol | |
978 | -table and program to run from the same file. | |
1117 | +@table @code | |
1118 | +@item cd @var{directory} | |
1119 | +@kindex cd | |
1120 | +Set _GDBN__'s working directory to @var{directory}. | |
979 | 1121 | |
980 | -@samp{symbol-file} with no argument clears out _GDBN__'s information on your | |
981 | -program's symbol table. | |
1122 | +@item pwd | |
1123 | +@kindex pwd | |
1124 | +Print _GDBN__'s working directory. | |
1125 | +@end table | |
982 | 1126 | |
983 | -The @samp{symbol-file} command causes _GDBN__ to forget the contents of its | |
984 | -convenience variables, the value history, and all breakpoints and | |
985 | -auto-display expressions. This is because they may contain pointers to | |
986 | -the internal data recording symbols and data types, which are part of | |
987 | -the old symbol table data being discarded inside _GDBN__. | |
1127 | +@node Input/Output, Attach, Working Directory, Running | |
1128 | +@section Your Program's Input and Output | |
988 | 1129 | |
989 | -On some kinds of object files, the @samp{symbol-file} command does not | |
990 | -actually read the symbol table in full right away. Instead, it scans | |
991 | -the symbol table quickly to find which source files and which symbols | |
992 | -are present. The details are read later, one source file at a time, | |
993 | -when they are needed. | |
1130 | +@cindex redirection | |
1131 | +@cindex i/o | |
1132 | +@cindex terminal | |
1133 | +@cindex controlling terminal | |
1134 | +By default, the program you run under _GDBN__ does input and output to the same | |
1135 | +terminal that _GDBN__ uses. | |
994 | 1136 | |
995 | -The purpose of this two-stage reading strategy is to make _GDBN__ start up | |
996 | -faster. For the most part, it is invisible except for occasional pauses | |
997 | -while the symbol table details for a particular source file are being | |
998 | -read. (The @samp{set verbose} command can turn these pauses into | |
999 | -messages if desired. @xref{User Interface}). | |
1137 | +You can redirect the program's input and/or output using @samp{sh}-style | |
1138 | +redirection commands in the @samp{run} command. For example, | |
1000 | 1139 | |
1001 | -When the symbol table is stored in COFF format, @samp{symbol-file} does | |
1002 | -read the symbol table data in full right away. We haven't implemented | |
1003 | -the two-stage strategy for COFF yet. | |
1140 | +_0__@example | |
1141 | +run > outfile | |
1142 | +_1__@end example | |
1004 | 1143 | |
1005 | -When _GDBN__ is configured for a particular environment, it will understand | |
1006 | -debugging information in whatever format is the standard generated for | |
1007 | -that environment; you may use either the GNU compiler _GCC__, or other | |
1008 | -compilers that adhere to the local conventions. Best results are | |
1009 | -usually obtained from _GCC__; for example, using _GCC__ you can generate | |
1010 | -debugging information for optimized code. | |
1144 | +@noindent | |
1145 | +starts the program, diverting its output to the file @file{outfile}. | |
1011 | 1146 | |
1012 | -While the symbol file is being read, _GDBN__ will occasionally encounter | |
1013 | -problems, such as symbol types it does not recognize, or known bugs in | |
1014 | -compiler output. By default, it prints one message about each such | |
1015 | -type of problem, no matter how many times the problem occurs. You can | |
1016 | -ask it to print more messages, to see how many times the problems occur, | |
1017 | -or can shut the messages off entirely, with the @samp{set | |
1018 | -complaints} command (@xref{User Interface}). | |
1147 | +@kindex tty | |
1148 | +Another way to specify where the program should do input and output is | |
1149 | +with the @samp{tty} command. This command accepts a file name as | |
1150 | +argument, and causes this file to be the default for future @samp{run} | |
1151 | +commands. It also resets the controlling terminal for the child | |
1152 | +process, for future @samp{run} commands. For example, | |
1019 | 1153 | |
1020 | -The messages currently printed, and their meanings, are: | |
1154 | +@example | |
1155 | +tty /dev/ttyb | |
1156 | +@end example | |
1021 | 1157 | |
1022 | -@table @code | |
1023 | -@item inner block not inside outer block in @var{symbol} | |
1158 | +@noindent | |
1159 | +directs that processes started with subsequent @samp{run} commands | |
1160 | +default to do input and output on the terminal @file{/dev/ttyb} and have | |
1161 | +that as their controlling terminal. | |
1024 | 1162 | |
1025 | -The symbol information shows where symbol scopes begin and end | |
1026 | -(such as at the start of a function or a block of statements). This | |
1027 | -error indicates that an inner scope block is not fully contained | |
1028 | -in its outer scope blocks. _GDBN__ circumvents the problem by treating | |
1029 | -the inner block as if it had the same scope as the outer block. | |
1030 | -@var{symbol} may be ``(don't know)'' if the outer block is not | |
1031 | -a function. | |
1163 | +An explicit redirection in @samp{run} overrides the @samp{tty} command's | |
1164 | +effect on input/output redirection, but not its effect on the | |
1165 | +controlling terminal. | |
1032 | 1166 | |
1033 | -@item block at @var{address} out of order | |
1167 | +When you use the @samp{tty} command or redirect input in the @samp{run} | |
1168 | +command, only the @emph{input for your program} is affected. The input | |
1169 | +for _GDBN__ still comes from your terminal. | |
1034 | 1170 | |
1035 | -The symbol information for symbol scope blocks should occur in | |
1036 | -order of increasing addresses. This error indicates that it does not | |
1037 | -do so. _GDBN__ does not circumvent this problem, and will have trouble | |
1038 | -locating symbols in the source file whose symbols being read. (You | |
1039 | -can often determine what source file is affected by turning on | |
1040 | -@samp{info verbose}. @xref{User Interface}.) | |
1171 | +@node Attach, Kill Process, Input/Output, Running | |
1172 | +@section Debugging an Already-Running Process | |
1173 | +@kindex attach | |
1174 | +@cindex attach | |
1041 | 1175 | |
1042 | -@item bad block start address patched | |
1176 | +@table @code | |
1177 | +@item attach @var{process--id} | |
1178 | +This command attaches to a running process, if your currently selected | |
1179 | +target supports processes. (@samp{info files} will show your active | |
1180 | +targets). The command takes as argument a process ID. | |
1043 | 1181 | |
1044 | -The symbol information for a symbol scope block has a start address | |
1045 | -smaller than the address of the preceding source line. This is known | |
1046 | -to occur in the SunOS 4.1.1 (and earlier) C compiler. _GDBN__ circumvents | |
1047 | -the problem by treating the symbol scope block as starting on the | |
1048 | -previous source line. | |
1182 | +You specify a process ID to debug an already-running process that was | |
1183 | +started outside of _GDBN__. (The usual way to find out the process-id of | |
1184 | +a Unix process is with the @code{ps} utility, or with the @code{jobs -l} | |
1185 | +shell command.) In this case, you must have permission to send the | |
1186 | +process a signal, and it must have the same effective user ID as the | |
1187 | +debugger. | |
1188 | +@end table | |
1049 | 1189 | |
1050 | -@comment @item{encountered DBX-style class variable debugging information. | |
1051 | -@comment You seem to have compiled your program with "g++ -g0" instead of "g++ -g". | |
1052 | -@comment Therefore _GDBN__ will not know about your class variables} | |
1053 | -@comment | |
1054 | -@comment This error indicates that the symbol information produced for a C++ | |
1055 | -@comment program includes zero-size fields, which indicated static fields in | |
1056 | -@comment a previous release of the G++ compiler. This message is probably | |
1057 | -@comment obsolete. | |
1058 | -@comment | |
1059 | -@item bad string table offset in symbol @var{n} | |
1190 | +When using @samp{attach}, you should first use the @samp{file} command | |
1191 | +to specify the program running in the process and load its symbol table. | |
1060 | 1192 | |
1061 | -Symbol number @var{n} contains a pointer into the string table which is | |
1062 | -larger than the size of the string table. _GDBN__ circumvents the problem | |
1063 | -by considering the symbol to have the name @code{foo}, which may cause | |
1064 | -other problems if many symbols end up with this name. @cindex{foo} | |
1193 | +The first thing _GDBN__ does after arranging to debug the process is to stop | |
1194 | +it. You can examine and modify an attached process with all the _GDBN__ | |
1195 | +commands that ordinarily available when you start processes with | |
1196 | +@samp{run}. You can insert breakpoints; you can step and continue; you | |
1197 | +can modify storage. If you would rather the process continue running, | |
1198 | +you may use the @samp{continue} command after attaching _GDBN__ to the | |
1199 | +process. | |
1065 | 1200 | |
1066 | -@item unknown symbol type @code{0xNN} | |
1201 | +@kindex detach | |
1202 | +When you have finished debugging the attached process, you can use the | |
1203 | +@samp{detach} command to release it from _GDBN__'s control. Detaching | |
1204 | +the process continues its execution. After the @samp{detach} command, | |
1205 | +that process and _GDBN__ become completely independent once more, and you | |
1206 | +are ready to @samp{attach} another process or start one with @samp{run}. | |
1067 | 1207 | |
1068 | -The symbol information contains new data types that _GDBN__ does not yet | |
1069 | -know how to read. @code{0xNN} is the symbol type of the misunderstood | |
1070 | -information, in hexadecimal. _GDBN__ circumvents the error by ignoring | |
1071 | -this symbol information. This will usually allow the program to be | |
1072 | -debugged, though certain symbols will not be accessible. If you | |
1073 | -encounter such a problem and feel like debugging it, you can debug _GDBP__ | |
1074 | -with itself, breakpoint on "complain", then go "up" to | |
1075 | -read_dbx_symtab() and examine *bufp to see the symbol. | |
1208 | +If you exit _GDBN__ or use the @samp{run} command while you have an attached | |
1209 | +process, you kill that process. By default, you will be asked for | |
1210 | +confirmation if you try to do either of these things; you can control | |
1211 | +whether or not this happens by using the @samp{set caution} command | |
1212 | +(@pxref{User Interface}). | |
1076 | 1213 | |
1077 | -@c @item stub type has NULL name | |
1078 | -@c | |
1079 | -@c FIXME, Mike Tiemann needs to write about what this means. | |
1214 | +@node Kill Process, , Attach, Running | |
1215 | +@section Killing the Child Process | |
1080 | 1216 | |
1081 | -@item const/volatile indicator missing, got 'X' | |
1217 | +@table @code | |
1218 | +@item kill | |
1219 | +@kindex kill | |
1220 | +Kill the child process in which your program is running under _GDBN__. | |
1221 | +@end table | |
1082 | 1222 | |
1083 | -The symbol information for a C++ type is missing some information that | |
1084 | -the compiler should have output for it. | |
1223 | +This command is useful if you wish to debug a core dump instead. _GDBN__ | |
1224 | +ignores any core dump file if it is actually running the program. | |
1085 | 1225 | |
1086 | -@item C++ type mismatch between compiler and debugger | |
1226 | +On some operating systems, you can't execute your program in another | |
1227 | +process while breakpoints are active inside _GDBN__. The @samp{kill} | |
1228 | +command is also useful in this situation, if you wish to run the program | |
1229 | +outside the debugger. | |
1087 | 1230 | |
1088 | -The debugger could not parse a type specification output by the compiler | |
1089 | -for some C++ object. | |
1231 | +The @samp{kill} command is also useful if you wish to recompile and | |
1232 | +relink the program, since on many systems it is impossible to modify an | |
1233 | +executable file which is running in a process. In this case, when you | |
1234 | +next type @samp{run}, _GDBN__ will notice that the file has changed, and | |
1235 | +will re-read the symbol table (while trying to preserve your current | |
1236 | +breakpoint settings). | |
1090 | 1237 | |
1091 | -@end table | |
1238 | +@node Stopping, Stack, Running, Top | |
1239 | +@chapter Stopping and Continuing | |
1092 | 1240 | |
1093 | -@item core-file @var{filename} | |
1094 | -@itemx core @var{filename} | |
1095 | -@kindex core | |
1096 | -@kindex core-file | |
1097 | -Specify the whereabouts of a core dump file to be used as the ``contents | |
1098 | -of memory''. Traditionally, core files contain only some parts of the | |
1099 | -address space of the process that generated them; _GDBN__ can access the | |
1100 | -executable file itself for other parts. | |
1241 | +When you run a program normally, it runs until it terminates. The | |
1242 | +principal purpose of using a debugger is so that you can stop it before | |
1243 | +that point; or so that if the program runs into trouble you can | |
1244 | +investigate and find out why. | |
1101 | 1245 | |
1102 | -@samp{core-file} with no argument specifies that no core file is | |
1103 | -to be used. | |
1246 | +@menu | |
1247 | +* Signals:: Fatal signals in your program just stop it; | |
1248 | + then you can use _GDBN__ to see what is going on. | |
1249 | +* Breakpoints:: Breakpoints let you stop your program when it | |
1250 | + reaches a specified point in the code. | |
1251 | + an expression changes. | |
1252 | +* Continuing:: Resuming execution until the next signal or breakpoint. | |
1253 | +* Stepping:: Stepping runs the program a short distance and | |
1254 | + then stops it wherever it has come to. | |
1255 | +@end menu | |
1104 | 1256 | |
1105 | -Note that the core file is ignored when your program is actually running | |
1106 | -under _GDBN__. So, if you have been running the program and you wish to | |
1107 | -debug a core file instead, you must kill the subprocess in which the | |
1108 | -program is running. To do this, use the @samp{kill} command | |
1109 | -(@pxref{Kill Process}). | |
1257 | +@node Signals, Breakpoints, Stopping, Stopping | |
1258 | +@section Signals | |
1259 | +@cindex signals | |
1110 | 1260 | |
1111 | -@item load @var{filename} | |
1112 | -@kindex load | |
1113 | -This command will dynamically link @var{filename} on the current target, | |
1114 | -performing any necessary downloads, then add @var{filename}'s symbol | |
1115 | -table in the same way as the @samp{add-syms} command. | |
1261 | +A signal is an asynchronous event that can happen in a program. The | |
1262 | +operating system defines the possible kinds of signals, and gives each kind | |
1263 | +a name and a number. For example, @code{SIGINT} is the signal a program | |
1264 | +gets when you type @kbd{Ctrl-c}; @code{SIGSEGV} is the signal a program | |
1265 | +gets from referencing a place in memory far away from all the areas in use; | |
1266 | +@code{SIGALRM} occurs when the alarm clock timer goes off (which happens | |
1267 | +only if the program has requested an alarm). | |
1116 | 1268 | |
1117 | -@item add-syms @var{filename} @var{address} | |
1118 | -@kindex add-syms | |
1119 | -@cindex dynamic linking | |
1120 | -The @samp{add-syms} command reads additional symbol table information | |
1121 | -from the file @var{filename}. You would use this command when that file | |
1122 | -has been dynamically loaded (by some other means) into the program that | |
1123 | -is running. @var{address} should be the memory address at which the | |
1124 | -file has been loaded; _GDBN__ cannot figure this out for itself. | |
1269 | +@cindex fatal signals | |
1270 | +Some signals, including @code{SIGALRM}, are a normal part of the | |
1271 | +functioning of the program. Others, such as @code{SIGSEGV}, indicate | |
1272 | +errors; these signals are @dfn{fatal} (kill the program immediately) if the | |
1273 | +program has not specified in advance some other way to handle the signal. | |
1274 | +@code{SIGINT} does not indicate an error in the program, but it is normally | |
1275 | +fatal so it can carry out the purpose of @kbd{Ctrl-c}: to kill the program. | |
1125 | 1276 | |
1126 | -The symbol table of the file @var{filename} is added to the symbol table | |
1127 | -originally read with the @samp{symbol-file} command. You can use the | |
1128 | -@samp{add-syms} command any number of times; the new symbol data thus | |
1129 | -read keeps adding to the old. The @samp{symbol-file} command forgets | |
1130 | -all the symbol data _GDBN__ has read. | |
1277 | +_GDBN__ has the ability to detect any occurrence of a signal in the program | |
1278 | +running under _GDBN__'s control. You can tell _GDBN__ in advance what to do for | |
1279 | +each kind of signal. | |
1131 | 1280 | |
1132 | -@item info files | |
1133 | -@itemx info target | |
1134 | -@kindex info files | |
1135 | -@kindex info target | |
1136 | -@samp{info files} and @samp{info target} are synonymous; both print the | |
1137 | -current targets (@pxref{Targets}), including the names of the | |
1138 | -executable and core dump files currently in use by _GDBN__, and the files | |
1139 | -from which symbols were loaded. | |
1281 | +@cindex handling signals | |
1282 | +Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM} | |
1283 | +(so as not to interfere with their role in the functioning of the program) | |
1284 | +but to stop the program immediately whenever an error signal happens. | |
1285 | +You can change these settings with the @samp{handle} command. | |
1140 | 1286 | |
1141 | -Beware: the similar command @samp{info targets} lists all possible | |
1142 | -targets rather than current ones. | |
1287 | +@table @code | |
1288 | +@item info signal | |
1289 | +@kindex info signal | |
1290 | +Print a table of all the kinds of signals and how _GDBN__ has been told to | |
1291 | +handle each one. You can use this to see the signal numbers of all | |
1292 | +the defined types of signals. | |
1143 | 1293 | |
1294 | +@item handle @var{signal} @var{keywords}@dots{} | |
1295 | +@kindex handle | |
1296 | +Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the | |
1297 | +number of a signal or its name (with or without the @samp{SIG} at the | |
1298 | +beginning). The @var{keywords} say what change to make. | |
1144 | 1299 | @end table |
1145 | 1300 | |
1146 | -While all three file-specifying commands allow both absolute and relative | |
1147 | -file names as arguments, _GDBN__ always converts the file name to an absolute | |
1148 | -one and remembers it that way. | |
1149 | - | |
1150 | -@kindex sharedlibrary | |
1151 | -@kindex share | |
1152 | -@cindex shared libraries | |
1153 | - | |
1154 | -_GDBN__ supports the SunOS shared library format. Symbols from a shared | |
1155 | -library cannot be referenced before the shared library has been linked | |
1156 | -with the program. (That is to say, after one types @samp{run} and | |
1157 | -the function @code{main()} has been entered; or when examining core | |
1158 | -files.) Once the shared library has been linked in, you can use the | |
1159 | -following commands: | |
1301 | +The keywords allowed by the @samp{handle} command can be abbreviated. | |
1302 | +Their full names are | |
1160 | 1303 | |
1161 | 1304 | @table @code |
1162 | -@item sharedlibrary @var{regex} | |
1163 | -@itemx share @var{regex} | |
1164 | -Load shared object library symbols for files matching a UNIX regular | |
1165 | -expression. | |
1305 | +@item nostop | |
1306 | +_GDBN__ should not stop the program when this signal happens. It may | |
1307 | +still print a message telling you that the signal has come in. | |
1166 | 1308 | |
1167 | -@item share | |
1168 | -@itemx sharedlibrary | |
1169 | -Load symbols for all shared libraries. | |
1309 | +@item stop | |
1310 | +_GDBN__ should stop the program when this signal happens. This implies | |
1311 | +the @samp{print} keyword as well. | |
1170 | 1312 | |
1171 | -@item info share | |
1172 | -@itemx info sharedlibrary | |
1173 | -@kindex info sharedlibrary | |
1174 | -@kindex info share | |
1175 | -Print the names of the shared libraries which are currently loaded. | |
1176 | -@end table | |
1313 | +@item print | |
1314 | +_GDBN__ should print a message when this signal happens. | |
1177 | 1315 | |
1316 | +@item noprint | |
1317 | +_GDBN__ should not mention the occurrence of the signal at all. This | |
1318 | +implies the @samp{nostop} keyword as well. | |
1178 | 1319 | |
1179 | -@node Compilation, Targets, Files, Top | |
1180 | -@chapter Compiling for Debugging | |
1320 | +@item pass | |
1321 | +_GDBN__ should allow the program to see this signal; the program will be | |
1322 | +able to handle the signal, or may be terminated if the signal is fatal | |
1323 | +and not handled. | |
1181 | 1324 | |
1182 | -In order to debug a program effectively, you need to ask for debugging | |
1183 | -information when you compile it. This debugging information is stored | |
1184 | -in the object file; it describes the data type of each variable or | |
1185 | -function and the correspondence between source line numbers and | |
1186 | -addresses in the executable code. | |
1325 | +@item nopass | |
1326 | +_GDBN__ should not allow the program to see this signal. | |
1327 | +@end table | |
1187 | 1328 | |
1188 | -To request debugging information, specify the @samp{-g} option when you run | |
1189 | -the compiler. | |
1329 | +When a signal has been set to stop the program, the program cannot see the | |
1330 | +signal until you continue. It will see the signal then, if @samp{pass} is | |
1331 | +in effect for the signal in question @i{at that time}. In other words, | |
1332 | +after _GDBN__ reports a signal, you can use the @samp{handle} command with | |
1333 | +@samp{pass} or @samp{nopass} to control whether that signal will be seen by | |
1334 | +the program when you later continue it. | |
1190 | 1335 | |
1191 | -The Unix C compiler is unable to handle the @samp{-g} and @samp{-O} options | |
1192 | -together. This means that you cannot ask for optimization if you ask for | |
1193 | -debugger information. | |
1336 | +You can also use the @samp{signal} command to prevent the program from | |
1337 | +seeing a signal, or cause it to see a signal it normally would not see, | |
1338 | +or to give it any signal at any time. @xref{Signaling}. | |
1194 | 1339 | |
1195 | -The GNU C compiler supports @samp{-g} with or without @samp{-O}, making it | |
1196 | -possible to debug optimized code. We recommend that you @emph{always} use | |
1197 | -@samp{-g} whenever you compile a program. You may think the program is | |
1198 | -correct, but there's no sense in pushing your luck. | |
1340 | +@node Breakpoints, Continuing, Signals, Stopping | |
1341 | +@section Breakpoints | |
1199 | 1342 | |
1200 | -Some things do not work as well with @samp{-g -O} as with just | |
1201 | -@samp{-g}, particularly on machines with instruction scheduling. If in | |
1202 | -doubt, recompile with @samp{-g} alone, and if this fixes the problem, | |
1203 | -please report it as a bug (including a test case---@pxref{_GDBN__ Bugs}). | |
1343 | +@cindex breakpoints | |
1344 | +A @dfn{breakpoint} makes your program stop whenever a certain point in the | |
1345 | +program is reached. You set breakpoints explicitly with _GDBN__ commands, | |
1346 | +specifying the place where the program should stop by line number, function | |
1347 | +name or exact address in the program. You can add various other conditions | |
1348 | +to control whether the program will stop. | |
1204 | 1349 | |
1205 | -Older versions of the GNU C compiler, _GCC__, permitted a variant option | |
1206 | -@samp{-gg} for debugging information. _GDBN__ no longer supports this format; | |
1207 | -if your GNU C compiler has this option, do not use it. | |
1350 | +Each breakpoint is assigned a number when it is created; these numbers are | |
1351 | +successive integers starting with 1. In many of the commands for controlling | |
1352 | +various features of breakpoints you use the breakpoint number to say which | |
1353 | +breakpoint you want to change. Each breakpoint may be @dfn{enabled} or | |
1354 | +@dfn{disabled}; if disabled, it has no effect on the program until you | |
1355 | +enable it again. | |
1208 | 1356 | |
1209 | -@ignore | |
1210 | -@comment As far as I know, there are no cases in which _GDBN__ will | |
1211 | -@comment produce strange output in this case. (but no promises). | |
1212 | -If your program includes archives made with the @code{ar} program, and | |
1213 | -if the object files used as input to @code{ar} were compiled without the | |
1214 | -@samp{-g} option and have names longer than 15 characters, _GDBN__ will get | |
1215 | -confused reading the program's symbol table. No error message will be | |
1216 | -given, but _GDBN__ may behave strangely. The reason for this problem is a | |
1217 | -deficiency in the Unix archive file format, which cannot represent file | |
1218 | -names longer than 15 characters. | |
1357 | +@table @code | |
1358 | +@kindex info break | |
1359 | +@kindex $_ | |
1360 | +@item info break | |
1361 | +The command @samp{info break} prints a list of all breakpoints set and not | |
1362 | +deleted, showing their numbers, where in the program they are, and any | |
1363 | +special features in use for them. Disabled breakpoints are included in the | |
1364 | +list, but marked as disabled. @samp{info break} with a breakpoint number | |
1365 | +as argument lists only that breakpoint. The convenience variable @code{$_} | |
1366 | +and the default examining-address for the @samp{x} command are set to the | |
1367 | +address of the last breakpoint listed (@pxref{Memory}). | |
1219 | 1368 | |
1220 | -To avoid this problem, compile the archive members with the @samp{-g} | |
1221 | -option or use shorter file names. Alternatively, use a version of GNU | |
1222 | -@code{ar} dated more recently than August 1989. | |
1223 | -@end ignore | |
1369 | +@kindex info watch | |
1370 | +@item info watch | |
1371 | +This command prints a list of watchpoints. | |
1224 | 1372 | |
1225 | -@node Targets, Running, Compilation, Top | |
1226 | -@chapter Specifying a Debugging Target | |
1227 | -@cindex debugging target | |
1228 | -@kindex target | |
1229 | -A @dfn{target} is an interface between the debugger and a particular | |
1230 | -kind of file or process. | |
1373 | +@cindex watchpoints | |
1374 | +A @dfn{watchpoint} is a special breakpoint that stops your program when | |
1375 | +the value of an expression changes. You can use a watchpoint to stop | |
1376 | +execution whenever the value of an expression changes, without having to | |
1377 | +predict a particular place in the inferior process where this may | |
1378 | +happen. Aside from the different syntax in setting a watchpoint, it is | |
1379 | +managed exactly like any other breakpoint and is enabled, disabled, and | |
1380 | +deleted using exactly the same commands. | |
1231 | 1381 | |
1232 | -Often, you will be able to run _GDBN__ in the same host environment as the | |
1233 | -program you are debugging; in that case, the debugging target can just be | |
1234 | -specified as a side effect of the @samp{file} or @samp{core} commands. | |
1235 | -When you need more flexibility---for example, running _GDBN__ on a | |
1236 | -physically separate host, controlling standalone systems over a | |
1237 | -serial port, or realtime systems over a TCP/IP connection---you can use | |
1238 | -the @samp{target} command. | |
1382 | +Watchpoints currently execute two orders of magnitude more slowly than | |
1383 | +other breakpoints, but this can well be worth it to catch errors where | |
1384 | +you have no clue what part of your program is the culprit. Some | |
1385 | +processors provide special hardware to implement this feature; future | |
1386 | +releases of _GDBN__ will use such hardware if it is available. | |
1387 | + | |
1388 | +@end table | |
1239 | 1389 | |
1240 | 1390 | @menu |
1241 | -* Active Targets:: Active Targets | |
1242 | -* Target Commands:: Commands for Managing Targets | |
1391 | +* Set Breaks:: How to establish breakpoints. | |
1392 | +* Exception Handling:: How _GDBN__ supports exception handling for C++. | |
1393 | +* Delete Breaks:: How to remove breakpoints no longer needed. | |
1394 | +* Disabling:: How to disable breakpoints (turn them off temporarily). | |
1395 | +* Conditions:: Making extra conditions on whether to stop. | |
1396 | +* Break Commands:: Commands to be executed at a breakpoint. | |
1397 | +* Error in Breakpoints:: | |
1243 | 1398 | @end menu |
1244 | 1399 | |
1245 | -@node Active Targets, Target Commands, Targets, Targets | |
1246 | -@section Active Targets | |
1247 | -@cindex stacking targets | |
1248 | -@cindex active targets | |
1249 | -@cindex multiple targets | |
1400 | +@node Set Breaks, Exception Handling, Breakpoints, Breakpoints | |
1401 | +@subsection Setting Breakpoints | |
1250 | 1402 | |
1251 | -Targets are managed in three @dfn{strata} that correspond to different | |
1252 | -classes of target: processes, core files, and executable files. This | |
1253 | -allows you to (for example) start a process and inspect its activity | |
1254 | -without abandoning your work on a core file. | |
1403 | +@kindex break | |
1404 | +@kindex watch | |
1405 | +Breakpoints are set with the @samp{break} command (abbreviated @samp{b}). | |
1406 | +Watchpoints are set with the @samp{watch} command. | |
1255 | 1407 | |
1256 | -More than one target can potentially respond to a request. In | |
1257 | -particular, when you access memory _GDBN__ will walk down the three strata of | |
1258 | -targets until it finds a target that can handle that particular address. | |
1408 | +You have several ways to say where the breakpoint should go. | |
1259 | 1409 | |
1260 | -Strata are always examined in a fixed order: first a process if there is | |
1261 | -one, then a core file if there is one, and finally an executable file if | |
1262 | -there is one of those. | |
1410 | +@table @code | |
1411 | +@item break @var{function} | |
1412 | +Set a breakpoint at entry to function @var{function}. | |
1263 | 1413 | |
1264 | -When you specify a new target in a given stratum, it replaces any target | |
1265 | -previously in that stratum. | |
1414 | +@item break @var{+offset} | |
1415 | +@itemx break @var{-offset} | |
1416 | +Set a breakpoint some number of lines forward or back from the position | |
1417 | +at which execution stopped in the currently selected frame. | |
1266 | 1418 | |
1267 | -To get rid of a target without replacing it, use the @samp{detach} | |
1268 | -command. The related command @samp{attach} provides you with a way of | |
1269 | -choosing a particular running process as a new target. @xref{Attach}. | |
1419 | +@item break @var{linenum} | |
1420 | +Set a breakpoint at line @var{linenum} in the current source file. | |
1421 | +That file is the last file whose source text was printed. This | |
1422 | +breakpoint will stop the program just before it executes any of the | |
1423 | +code on that line. | |
1270 | 1424 | |
1271 | -@node Target Commands, , Active Targets, Targets | |
1272 | -@section Commands for Managing Targets | |
1425 | +@item break @var{filename}:@var{linenum} | |
1426 | +Set a breakpoint at line @var{linenum} in source file @var{filename}. | |
1273 | 1427 | |
1274 | -@table @code | |
1275 | -@item target @var{type} @var{parameters} | |
1276 | -Connects the _GDBN__ host environment to a target machine or process. A | |
1277 | -target is typically a protocol for talking to debugging facilities. You | |
1278 | -use the argument @var{type} to specify the type or protocol of the | |
1279 | -target machine; for example, @samp{target vxworks} for a TCP/IP link to | |
1280 | -a VxWorks system. | |
1428 | +@item break @var{filename}:@var{function} | |
1429 | +Set a breakpoint at entry to function @var{function} found in file | |
1430 | +@var{filename}. Specifying a file name as well as a function name is | |
1431 | +superfluous except when multiple files contain similarly named | |
1432 | +functions. | |
1433 | + | |
1434 | +@item break *@var{address} | |
1435 | +Set a breakpoint at address @var{address}. You can use this to set | |
1436 | +breakpoints in parts of the program which do not have debugging | |
1437 | +information or source files. | |
1438 | + | |
1439 | +@item break | |
1440 | +Set a breakpoint at the next instruction to be executed in the selected | |
1441 | +stack frame (@pxref{Stack}). In any selected frame but the innermost, | |
1442 | +this will cause the program to stop as soon as control returns to that | |
1443 | +frame. This is equivalent to a @samp{finish} command in the frame | |
1444 | +inside the selected frame. If this is done in the innermost frame, _GDBN__ | |
1445 | +will stop the next time it reaches the current location; this may be | |
1446 | +useful inside of loops. | |
1447 | + | |
1448 | +_GDBN__ normally ignores breakpoints when it resumes execution, until at | |
1449 | +least one instruction has been executed. If it did not do this, you | |
1450 | +would be unable to proceed past a breakpoint without first disabling the | |
1451 | +breakpoint. This rule applies whether or not the breakpoint already | |
1452 | +existed when the program stopped. | |
1453 | + | |
1454 | +@item break @dots{} if @var{cond} | |
1455 | +Set a breakpoint with condition @var{cond}; evaluate the expression | |
1456 | +@var{cond} each time the breakpoint is reached, and stop only if the | |
1457 | +value is nonzero. @samp{@dots{}} stands for one of the possible | |
1458 | +arguments described above (or no argument) specifying where to break. | |
1459 | +@xref{Conditions}, for more information on breakpoint conditions. | |
1460 | + | |
1461 | +@item tbreak @var{args} | |
1462 | +@kindex tbreak | |
1463 | +Set a breakpoint enabled only for one stop. @var{args} are the | |
1464 | +same as in the @samp{break} command, and the breakpoint is set in the same | |
1465 | +way, but the breakpoint is automatically disabled the first time it | |
1466 | +is hit. @xref{Disabling}. | |
1467 | + | |
1468 | +@item rbreak @var{regex} | |
1469 | +@kindex rbreak | |
1470 | +Set a breakpoint on all functions matching @var{regex}. This is | |
1471 | +useful for setting breakpoints on overloaded functions that are not | |
1472 | +members of any special classes. This command sets an unconditional | |
1473 | +breakpoint on all matches, printing a list of all breakpoints it set. | |
1474 | +Once these breakpoints are set, they are treated just like the | |
1475 | +breakpoints set with the @samp{break} command. They can be deleted, | |
1476 | +disabled, made conditional, etc., in the standard ways. | |
1477 | + | |
1478 | +@kindex watch | |
1479 | +@item watch @var{expr} | |
1480 | +Set a watchpoint for an expression. | |
1481 | +@end table | |
1482 | + | |
1483 | +_GDBN__ allows you to set any number of breakpoints at the same place in the | |
1484 | +program. There is nothing silly or meaningless about this. When the | |
1485 | +breakpoints are conditional, this is even useful (@pxref{Conditions}). | |
1486 | + | |
1487 | +@node Exception Handling, Delete Breaks, Set Breaks, Breakpoints | |
1488 | +@subsection Breakpoints and Exceptions | |
1489 | +@cindex exception handlers | |
1490 | + | |
1491 | +Some languages, such as GNU C++, implement exception handling. _GDBN__ | |
1492 | +can be used to examine what caused the program to raise an exception | |
1493 | +and to list the exceptions the program is prepared to handle at a | |
1494 | +given point in time. | |
1495 | + | |
1496 | +@cindex raise exceptions | |
1497 | +GNU C++ raises an exception by calling a library function named | |
1498 | +@code{__raise_exception} which has the following ANSI C interface: | |
1281 | 1499 | |
1282 | -Further @var{parameters} are interpreted by the target protocol, but | |
1283 | -typically include things like device names or host names to connect | |
1284 | -with, process numbers, and baud rates. Executing | |
1285 | 1500 | @example |
1286 | - target @var{type} | |
1501 | + /* ADDR is where the exception identifier is stored. | |
1502 | + ID is the exception identifier. */ | |
1503 | + void __raise_exception (void **addr, void *id); | |
1287 | 1504 | @end example |
1288 | 1505 | |
1289 | 1506 | @noindent |
1290 | -(without any parameters) will issue a message about what | |
1291 | -parameters are required for that target type. | |
1507 | +You can make the debugger catch all exceptions @emph{before} any stack | |
1508 | +unwinding takes place: set a breakpoint on @code{__raise_exception} | |
1509 | +(@pxref{Breakpoints}). If you set a breakpoint in an exception handler | |
1510 | +instead, it may not be easy to find out where the exception was raised. | |
1292 | 1511 | |
1293 | -@item info targets | |
1294 | -@kindex info targets | |
1295 | -Displays the names of all targets available. Beware: the similar | |
1296 | -command @samp{info target} displays targets currently in use rather than | |
1297 | -all available ones. @samp{info files} gives the same information as | |
1298 | -@samp{info target} (@pxref{Files}). | |
1512 | +By using a conditional breakpoint (@xref{Conditions}), you can cause | |
1513 | +the debugger to stop only when a specific exception is raised. | |
1514 | +Multiple conditional breakpoints can be used to stop the program when | |
1515 | +any of a number of exceptions are raised. | |
1516 | + | |
1517 | +@table @code | |
1518 | +@item catch @var{exceptions} | |
1519 | +@kindex catch | |
1520 | + | |
1521 | +Breakpoints can be set at active exception handlers by using the | |
1522 | +@samp{catch} command. @var{exceptions} is a list of names of exceptions | |
1523 | +to catch. | |
1299 | 1524 | @end table |
1300 | 1525 | |
1301 | -Here are some common targets (available, or not, depending on _GDBN__ | |
1302 | -configuration): | |
1526 | +You can use @samp{info catch} to list active exception handlers; | |
1527 | +@pxref{Frame Info}. | |
1303 | 1528 | |
1304 | -@table @code | |
1305 | -@item target exec @var{prog} | |
1306 | -@kindex target exec | |
1307 | -An executable file. @samp{target exec @var{prog}} is the same as | |
1308 | -@samp{exec-file @var{prog}}. | |
1529 | +There are currently some limitations to exception handling in _GDBN__. | |
1530 | +These will be corrected in a future release. | |
1309 | 1531 | |
1310 | -@item target core @var{filename} | |
1311 | -@kindex target core | |
1312 | -A core dump file. @samp{target core @var{filename}} is the same as | |
1313 | -@samp{core-file @var{filename}}. | |
1532 | +@itemize @bullet | |
1533 | +@item | |
1534 | +If you call a function interactively, _GDBN__ will normally return | |
1535 | +control to you when the function has finished executing. If the call | |
1536 | +raises an exception, however, the call may bypass the mechanism that | |
1537 | +returns control to the user and cause the program to simply continue | |
1538 | +running until it hits a breakpoint, catches a signal that _GDBN__ is | |
1539 | +listening for, or exits. | |
1540 | +@item | |
1541 | +You cannot raise an exception interactively. | |
1542 | +@item | |
1543 | +You cannot interactively install an exception handler. | |
1544 | +@end itemize | |
1314 | 1545 | |
1315 | -@item target remote @var{dev} | |
1316 | -@kindex target remote | |
1317 | -Remote serial target in _GDBP__-specific protocol. The argument @var{dev} | |
1318 | -specifies what serial device to use for the connection (e.g. | |
1319 | -@code{/dev/ttya}). | |
1546 | +@node Delete Breaks, Disabling, Exception Handling, Breakpoints | |
1547 | +@subsection Deleting Breakpoints | |
1320 | 1548 | |
1321 | -_if__(_AMD29K__) | |
1322 | -@item target amd-eb @var{dev} @var{speed} @var{PROG} | |
1323 | -@kindex target amd-eb | |
1324 | -@cindex AMD EB29K | |
1325 | -Remote PC-resident AMD EB29K board, attached over serial lines. | |
1326 | -@var{dev} is the serial device, as for @samp{target remote}; | |
1327 | -@samp{speed} allows you to specify the linespeed; and @var{PROG} is the | |
1328 | -name of the program to be debugged, as it appears to DOS on the PC. | |
1329 | -@xref{AMD29K Remote}. | |
1549 | +@cindex clearing breakpoints, watchpoints | |
1550 | +@cindex deleting breakpoints, watchpoints | |
1551 | +It is often necessary to eliminate a breakpoint once it has done its job | |
1552 | +and you no longer want the program to stop there. This is called | |
1553 | +@dfn{deleting} the breakpoint. A breakpoint that has been deleted no | |
1554 | +longer exists in any sense; it is forgotten. | |
1330 | 1555 | |
1331 | -_fi__(_AMD29K__) | |
1332 | -_if__(_I960__) | |
1333 | -@item target nindy @var{devicename} | |
1334 | -@kindex target nindy | |
1335 | -An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is | |
1336 | -the name of the serial device to use for the connection, e.g. | |
1337 | -@samp{/dev/ttya}. | |
1556 | +With the @samp{clear} command you can delete breakpoints according to where | |
1557 | +they are in the program. With the @samp{delete} command you can delete | |
1558 | +individual breakpoints by specifying their breakpoint numbers. | |
1338 | 1559 | |
1339 | -_fi__(_I960__) | |
1340 | -_if__(_VXWORKS__) | |
1341 | -@item target vxworks @var{machinename} | |
1342 | -@kindex target vxworks | |
1343 | -A VxWorks system, attached via TCP/IP. The argument @var{machinename} | |
1344 | -is the target system's machine name or IP address. | |
1560 | +It is not necessary to delete a breakpoint to proceed past it. _GDBN__ | |
1561 | +automatically ignores breakpoints on the first instruction to be executed | |
1562 | +when you continue execution without changing the execution address. | |
1345 | 1563 | |
1346 | -_fi__(_VXWORKS__) | |
1564 | +@table @code | |
1565 | +@item clear | |
1566 | +@kindex clear | |
1567 | +Delete any breakpoints at the next instruction to be executed in the | |
1568 | +selected stack frame (@pxref{Selection}). When the innermost frame | |
1569 | +is selected, this is a good way to delete a breakpoint that the program | |
1570 | +just stopped at. | |
1571 | + | |
1572 | +@item clear @var{function} | |
1573 | +@itemx clear @var{filename}:@var{function} | |
1574 | +Delete any breakpoints set at entry to the function @var{function}. | |
1575 | + | |
1576 | +@item clear @var{linenum} | |
1577 | +@itemx clear @var{filename}:@var{linenum} | |
1578 | +Delete any breakpoints set at or within the code of the specified line. | |
1579 | + | |
1580 | +@item delete breakpoints @var{bnums}@dots{} | |
1581 | +@itemx delete @var{bnums}@dots{} | |
1582 | +@itemx delete | |
1583 | +@kindex delete breakpoints | |
1584 | +@kindex delete | |
1585 | +Delete the breakpoints of the numbers specified as arguments. If no | |
1586 | +argument is specified, delete all breakpoints. | |
1347 | 1587 | @end table |
1348 | 1588 | |
1349 | -_if__(_GENERIC__) | |
1350 | -Different targets are available on different configurations of _GDBN__; your | |
1351 | -configuration may have more or fewer targets. | |
1352 | -_fi__(_GENERIC__) | |
1589 | +@node Disabling, Conditions, Delete Breaks, Breakpoints | |
1590 | +@subsection Disabling Breakpoints | |
1353 | 1591 | |
1354 | -@node Running, Stopping, Targets, Top | |
1355 | -@chapter Running Programs Under _GDBN__ | |
1592 | +@cindex disabled breakpoints | |
1593 | +@cindex enabled breakpoints | |
1594 | +Rather than deleting a breakpoint, you might prefer to @dfn{disable} it. | |
1595 | +This makes the breakpoint inoperative as if it had been deleted, but | |
1596 | +remembers the information on the breakpoint so that you can @dfn{enable} | |
1597 | +it again later. | |
1356 | 1598 | |
1357 | -@cindex running | |
1358 | -@kindex run | |
1359 | -To start your program under _GDBN__, use the @samp{run} command. Except on | |
1360 | -VxWorks, the program must already have been specified using the | |
1361 | -@samp{file} or @samp{exec-file} command, or with an argument to _GDBN__ | |
1362 | -(@pxref{Files}). | |
1599 | +You disable and enable breakpoints with the @samp{enable} and | |
1600 | +@samp{disable} commands, optionally specifying one or more breakpoint | |
1601 | +numbers as arguments. Use @samp{info break} to print a list of | |
1602 | +breakpoints if you don't know which breakpoint numbers to use. | |
1363 | 1603 | |
1364 | -On targets that support processes, @samp{run} creates an inferior | |
1365 | -process and makes that process run your program. On other targets, | |
1366 | -@samp{run} jumps to the location it has recorded for the start of the | |
1367 | -program. | |
1604 | +A breakpoint can have any of four different states of enablement: | |
1368 | 1605 | |
1369 | -The execution of a program is affected by certain information it | |
1370 | -receives from its superior. _GDBN__ provides ways to specify this | |
1371 | -information, which you must do @i{before} starting the program. (You | |
1372 | -can change it after starting the program, but such changes do not affect | |
1373 | -the program unless you start it over again.) This information may be | |
1374 | -divided into three categories: | |
1606 | +@itemize @bullet | |
1607 | +@item | |
1608 | +Enabled. The breakpoint will stop the program. A breakpoint made | |
1609 | +with the @samp{break} command starts out in this state. | |
1610 | +@item | |
1611 | +Disabled. The breakpoint has no effect on the program. | |
1612 | +@item | |
1613 | +Enabled once. The breakpoint will stop the program, but | |
1614 | +when it does so it will become disabled. A breakpoint made | |
1615 | +with the @samp{tbreak} command starts out in this state. | |
1616 | +@item | |
1617 | +Enabled for deletion. The breakpoint will stop the program, but | |
1618 | +immediately after it does so it will be deleted permanently. | |
1619 | +@end itemize | |
1375 | 1620 | |
1376 | -@table @asis | |
1377 | -@item The @i{arguments.} | |
1378 | -You specify the arguments to give the program as the arguments of the | |
1379 | -@samp{run} command. If a shell is available on your target, the shell | |
1380 | -is used to pass the arguments, so that you may use normal conventions | |
1381 | -(for example regular expression expansion or variable substitution) in | |
1382 | -describing the arguments. In Unix systems, you can control which shell | |
1383 | -is used with the @code{SHELL} environment variable. | |
1621 | +You can use the following commands to enable or disable a breakpoint: | |
1384 | 1622 | |
1385 | -@item The @i{environment.} | |
1386 | -The program normally inherits its environment from _GDBN__, but you can | |
1387 | -use the _GDBN__ commands @samp{set environment} and | |
1388 | -@samp{unset environment} to change parts of the environment that will | |
1389 | -be given to the program.@refill | |
1623 | +@table @code | |
1624 | +@item disable breakpoints @var{bnums}@dots{} | |
1625 | +@itemx disable @var{bnums}@dots{} | |
1626 | +@itemx disable | |
1627 | +@kindex disable breakpoints | |
1628 | +@kindex disable | |
1629 | +Disable the specified breakpoints---or all breakpoints, if none are | |
1630 | +listed. A disabled breakpoint has no effect but is not forgotten. All | |
1631 | +options such as ignore-counts, conditions and commands are remembered in | |
1632 | +case the breakpoint is enabled again later. | |
1390 | 1633 | |
1391 | -@item The @i{working directory.} | |
1392 | -The program inherits its working directory from _GDBN__. You can set _GDBN__'s | |
1393 | -working directory with the @samp{cd} command in _GDBN__. | |
1634 | +@item enable breakpoints @var{bnums}@dots{} | |
1635 | +@itemx enable @var{bnums}@dots{} | |
1636 | +@itemx enable | |
1637 | +@kindex enable breakpoints | |
1638 | +@kindex enable | |
1639 | +Enable the specified breakpoints (or all defined breakpoints). They | |
1640 | +become effective once again in stopping the program, until you specify | |
1641 | +otherwise. | |
1642 | + | |
1643 | +@item enable breakpoints once @var{bnums}@dots{} | |
1644 | +@itemx enable once @var{bnums}@dots{} | |
1645 | +Enable the specified breakpoints temporarily. Each will be disabled | |
1646 | +again the next time it stops the program (unless you have used one of | |
1647 | +these commands to specify a different state before that time comes). | |
1648 | + | |
1649 | +@item enable breakpoints delete @var{bnums}@dots{} | |
1650 | +@itemx enable delete @var{bnums}@dots{} | |
1651 | +Enable the specified breakpoints to work once and then die. Each of | |
1652 | +the breakpoints will be deleted the next time it stops the program | |
1653 | +(unless you have used one of these commands to specify a different | |
1654 | +state before that time comes). | |
1394 | 1655 | @end table |
1395 | 1656 | |
1396 | -When you issue the @samp{run} command, your program begins to execute | |
1397 | -immediately. @xref{Stopping}, for discussion of how to arrange for your | |
1398 | -program to stop. | |
1657 | +Save for a breakpoint set with @samp{tbreak} (@pxref{Set Breaks}), | |
1658 | +breakpoints that you set are enabled or disabled only when you use one | |
1659 | +of the commands above. (The command @samp{until} can set and delete a | |
1660 | +breakpoint on its own, but it will not change the state of your | |
1661 | +breakpoints). | |
1399 | 1662 | |
1400 | -Note that once your program has been started by the @samp{run} command, | |
1401 | -you may evaluate expressions that involve calls to functions in the | |
1402 | -inferior, using the @samp{print} or @samp{call} commands. @xref{Data}. | |
1663 | +@node Conditions, Break Commands, Disabling, Breakpoints | |
1664 | +@subsection Break Conditions | |
1665 | +@cindex conditional breakpoints | |
1666 | +@cindex breakpoint conditions | |
1403 | 1667 | |
1404 | -If the modification time of your symbol file has changed since the last | |
1405 | -time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and re-read | |
1406 | -it. In this process, it tries to retain your current breakpoints. | |
1668 | +The simplest sort of breakpoint breaks every time the program reaches a | |
1669 | +specified place. You can also specify a @dfn{condition} for a | |
1670 | +breakpoint. A condition is just a boolean expression in your | |
1671 | +programming language. (@xref{Expressions}). A breakpoint with a | |
1672 | +condition evaluates the expression each time the program reaches it, and | |
1673 | +the program stops only if the condition is true. | |
1407 | 1674 | |
1408 | -@menu | |
1409 | -* Arguments:: Specifying the arguments for your program. | |
1410 | -* Environment:: Specifying the environment for your program. | |
1411 | -* Working Directory:: Specifying the working directory for giving | |
1412 | - to your program when it is run. | |
1413 | -* Input/Output:: Specifying the program's standard input and output. | |
1414 | -* Attach:: Debugging a process started outside _GDBN__. | |
1415 | -* Kill Process:: Getting rid of the child process running your program. | |
1416 | -@end menu | |
1675 | +Break conditions may have side effects, and may even call functions in your | |
1676 | +program. These may sound like strange things to do, but their effects are | |
1677 | +completely predictable unless there is another enabled breakpoint at the | |
1678 | +same address. (In that case, _GDBN__ might see the other breakpoint first and | |
1679 | +stop the program without checking the condition of this one.) Note that | |
1680 | +breakpoint commands are usually more convenient and flexible for the | |
1681 | +purpose of performing side effects when a breakpoint is reached | |
1682 | +(@pxref{Break Commands}). | |
1417 | 1683 | |
1418 | -@node Arguments, Environment, Running, Running | |
1419 | -@section Your Program's Arguments | |
1684 | +Break conditions can be specified when a breakpoint is set, by using | |
1685 | +@samp{if} in the arguments to the @samp{break} command. @xref{Set Breaks}. | |
1686 | +They can also be changed at any time with the @samp{condition} command: | |
1420 | 1687 | |
1421 | -@cindex arguments (to your program) | |
1422 | -The arguments to your program are specified by the arguments of the | |
1423 | -@samp{run} command. They are passed to a shell, which expands wildcard | |
1424 | -characters and performs redirection of I/O, and thence to the program. | |
1688 | +@table @code | |
1689 | +@item condition @var{bnum} @var{expression} | |
1690 | +@kindex condition | |
1691 | +Specify @var{expression} as the break condition for breakpoint number | |
1692 | +@var{bnum}. From now on, this breakpoint will stop the program only if | |
1693 | +the value of @var{expression} is true (nonzero, in C). @var{expression} | |
1694 | +is not evaluated at the time the @samp{condition} command is given. | |
1695 | +When you call @samp{condition}, the expression you specify is checked | |
1696 | +immediately for syntactic correctness, and to determine whether symbols | |
1697 | +in it have referents in the context of your breakpoint. | |
1698 | +@xref{Expressions}. | |
1425 | 1699 | |
1426 | -@samp{run} with no arguments uses the same arguments used by the previous | |
1427 | -@samp{run}. | |
1700 | +@item condition @var{bnum} | |
1701 | +Remove the condition from breakpoint number @var{bnum}. It becomes | |
1702 | +an ordinary unconditional breakpoint. | |
1703 | +@end table | |
1704 | + | |
1705 | +@cindex ignore count (of breakpoint) | |
1706 | +A special case of a breakpoint condition is to stop only when the | |
1707 | +breakpoint has been reached a certain number of times. This is so | |
1708 | +useful that there is a special way to do it, using the @dfn{ignore | |
1709 | +count} of the breakpoint. Every breakpoint has an ignore count, which | |
1710 | +is an integer. Most of the time, the ignore count is zero, and | |
1711 | +therefore has no effect. But if the program reaches a breakpoint whose | |
1712 | +ignore count is positive, then instead of stopping, it just decrements | |
1713 | +the ignore count by one and continues. As a result, if the ignore count | |
1714 | +value is @var{n}, the breakpoint will not stop the next @var{n} times it | |
1715 | +is reached. | |
1428 | 1716 | |
1429 | -@kindex set args | |
1430 | 1717 | @table @code |
1431 | -@item set args | |
1432 | -The command @samp{set args} can be used to specify the arguments to be used | |
1433 | -the next time the program is run. If @samp{set args} has no arguments, it | |
1434 | -means to use no arguments the next time the program is run. If you have | |
1435 | -run your program with arguments and want to run it again with no arguments, | |
1436 | -this is the only way to do so. | |
1718 | +@item ignore @var{bnum} @var{count} | |
1719 | +@kindex ignore | |
1720 | +Set the ignore count of breakpoint number @var{bnum} to @var{count}. | |
1721 | +The next @var{count} times the breakpoint is reached, your program's | |
1722 | +execution will not stop; other than to decrement the ignore count, _GDBN__ | |
1723 | +takes no action. | |
1437 | 1724 | |
1438 | -@item show args | |
1439 | -@kindex show args | |
1440 | -Show the arguments to give your program when it is started. | |
1725 | +To make the breakpoint stop the next time it is reached, specify | |
1726 | +a count of zero. | |
1727 | + | |
1728 | +@item continue @var{count} | |
1729 | +@itemx cont @var{count} | |
1730 | +@itemx c @var{count} | |
1731 | +@itemx fg @var{count} | |
1732 | +@kindex cont @var{count} | |
1733 | +@kindex continue @var{count} | |
1734 | +Continue execution of the program, setting the ignore count of the | |
1735 | +breakpoint that the program stopped at to @var{count} minus one. | |
1736 | +Thus, the program will not stop at this breakpoint until the | |
1737 | +@var{count}'th time it is reached. | |
1738 | + | |
1739 | +This command is allowed only when the program stopped due to a | |
1740 | +breakpoint. At other times, the argument to @samp{cont} is ignored. | |
1741 | + | |
1742 | +The synonym @samp{fg} is provided purely for convenience, and has | |
1743 | +exactly the same behavior as other forms of the command. | |
1441 | 1744 | @end table |
1442 | 1745 | |
1443 | -@node Environment, Working Directory, Arguments, Running | |
1444 | -@section Your Program's Environment | |
1746 | +If a breakpoint has a positive ignore count and a condition, the condition | |
1747 | +is not checked. Once the ignore count reaches zero, the condition will | |
1748 | +be checked. | |
1445 | 1749 | |
1446 | -@cindex environment (of your program) | |
1447 | -The @dfn{environment} consists of a set of @dfn{environment variables} and | |
1448 | -their values. Environment variables conventionally record such things as | |
1449 | -your user name, your home directory, your terminal type, and your search | |
1450 | -path for programs to run. Usually you set up environment variables with | |
1451 | -the shell and they are inherited by all the other programs you run. When | |
1452 | -debugging, it can be useful to try running the program with different | |
1453 | -environments without having to start the debugger over again. | |
1750 | +Note that you could achieve the effect of the ignore count with a | |
1751 | +condition such as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience | |
1752 | +variable that is decremented each time. @xref{Convenience Vars}. | |
1753 | + | |
1754 | +@node Break Commands, Error in Breakpoints, Conditions, Breakpoints | |
1755 | +@subsection Commands Executed on Breaking | |
1756 | + | |
1757 | +@cindex breakpoint commands | |
1758 | +You can give any breakpoint a series of commands to execute when the | |
1759 | +program stops due to that breakpoint. For example, you might want to | |
1760 | +print the values of certain expressions, or enable other breakpoints. | |
1761 | + | |
1762 | +@table @code | |
1763 | +@item commands @var{bnum} | |
1764 | +@kindex commands | |
1765 | +Specify a list of commands for breakpoint number @var{bnum}. The commands | |
1766 | +themselves appear on the following lines. Type a line containing just | |
1767 | +@samp{end} to terminate the commands. | |
1768 | + | |
1769 | +To remove all commands from a breakpoint, use the command | |
1770 | +@samp{commands} and follow it immediately by @samp{end}; that is, give | |
1771 | +no commands. | |
1772 | + | |
1773 | +With no arguments, @samp{commands} refers to the last breakpoint set | |
1774 | +(not to the breakpoint most recently encountered). | |
1775 | +@end table | |
1776 | + | |
1777 | +You can use breakpoint commands to start the program up again. Simply | |
1778 | +use the @samp{cont} command, or @samp{step}, or any other command to | |
1779 | +resume execution. However, if you do this, any further commands in the | |
1780 | +same breakpoint's command list are ignored. When the program stops | |
1781 | +again, _GDBN__ will act according to the cause of that stop. | |
1782 | + | |
1783 | +@kindex silent | |
1784 | +If the first command specified is @samp{silent}, the usual message about | |
1785 | +stopping at a breakpoint is not printed. This may be desirable for | |
1786 | +breakpoints that are to print a specific message and then continue. | |
1787 | +If the remaining commands too print nothing, you will see no sign that | |
1788 | +the breakpoint was reached at all. @samp{silent} is not really a command; | |
1789 | +it is meaningful only at the beginning of the commands for a breakpoint. | |
1454 | 1790 | |
1455 | -@table @code | |
1456 | -@item show environment @var{varname} | |
1457 | -@kindex show environment | |
1458 | -Print the value of environment variable @var{varname} to be given to | |
1459 | -your program when it is started. | |
1791 | +The commands @samp{echo} and @samp{output} that allow you to print precisely | |
1792 | +controlled output are often useful in silent breakpoints. @xref{Output}. | |
1460 | 1793 | |
1461 | -@item show environment | |
1462 | -Print the names and values of all environment variables to be given to | |
1463 | -your program when it is started. | |
1794 | +For example, here is how you could use breakpoint commands to print the | |
1795 | +value of @code{x} at entry to @code{foo} whenever it is positive. | |
1464 | 1796 | |
1465 | -@item set environment @var{varname} @var{value} | |
1466 | -@itemx set environment @var{varname} = @var{value} | |
1467 | -@kindex set environment | |
1468 | -Sets environment variable @var{varname} to @var{value}, for your program | |
1469 | -only, not for _GDBN__ itself. @var{value} may be any string; the values of | |
1470 | -environment variables are just strings, and any interpretation is | |
1471 | -supplied by your program itself. The @var{value} parameter is optional; | |
1472 | -if it is eliminated, the variable is set to a null value. | |
1797 | +_0__@example | |
1798 | +break foo if x>0 | |
1799 | +commands | |
1800 | +silent | |
1801 | +echo x is\040 | |
1802 | +output x | |
1803 | +echo \n | |
1804 | +cont | |
1805 | +end | |
1806 | +_1__@end example | |
1473 | 1807 | |
1474 | -For example, this command: | |
1808 | +One application for breakpoint commands is to correct one bug so you can | |
1809 | +test another. Put a breakpoint just after the erroneous line of code, give | |
1810 | +it a condition to detect the case in which something erroneous has been | |
1811 | +done, and give it commands to assign correct values to any variables that | |
1812 | +need them. End with the @samp{cont} command so that the program does not | |
1813 | +stop, and start with the @samp{silent} command so that no output is | |
1814 | +produced. Here is an example: | |
1475 | 1815 | |
1476 | 1816 | @example |
1477 | -set env USER = foo | |
1817 | +break 403 | |
1818 | +commands | |
1819 | +silent | |
1820 | +set x = y + 4 | |
1821 | +cont | |
1822 | +end | |
1478 | 1823 | @end example |
1479 | 1824 | |
1480 | -@noindent | |
1481 | -tells the program, when subsequently run, to assume it is being run | |
1482 | -on behalf of the user named @samp{foo}. | |
1825 | +One deficiency in the operation of automatically continuing breakpoints | |
1826 | +under Unix appears when your program uses raw mode for the terminal. | |
1827 | +_GDBN__ switches back to its own terminal modes (not raw) before executing | |
1828 | +commands, and then must switch back to raw mode when your program is | |
1829 | +continued. This causes any pending terminal input to be lost. | |
1830 | +In the GNU system, this will be fixed by changing the behavior of | |
1831 | +terminal modes. | |
1483 | 1832 | |
1484 | -@item delete environment @var{varname} | |
1485 | -@itemx unset environment @var{varname} | |
1486 | -@kindex delete environment | |
1487 | -@kindex unset environment | |
1488 | -Remove variable @var{varname} from the environment to be passed to your | |
1489 | -program. This is different from @samp{set env @var{varname}@ =}; | |
1490 | -@samp{delete environment} removes the variable from the environment, | |
1491 | -rather than assigning it an empty value. This command can be | |
1492 | -abbreviated @samp{d e}. | |
1493 | -@end table | |
1833 | +Under Unix, when you have this problem, you might be able to get around | |
1834 | +it by putting your actions into the breakpoint condition instead of | |
1835 | +commands. For example | |
1494 | 1836 | |
1495 | -@node Working Directory, Input/Output, Environment, Running | |
1496 | -@section Your Program's Working Directory | |
1837 | +@example | |
1838 | +condition 5 (x = y + 4), 0 | |
1839 | +@end example | |
1497 | 1840 | |
1498 | -@cindex working directory (of your program) | |
1499 | -Each time you start your program with @samp{run}, it inherits its | |
1500 | -working directory from the current working directory of _GDBN__. _GDBN__'s | |
1501 | -working directory is initially whatever it inherited from its parent | |
1502 | -process (typically the shell), but you can specify a new working | |
1503 | -directory in _GDBN__ with the @samp{cd} command. | |
1841 | +@noindent | |
1842 | +specifies a condition expression (@xref{Expressions}) that will change | |
1843 | +@code{x} as needed, then always have the value 0 so the program will not | |
1844 | +stop. Loss of input is avoided here because break conditions are | |
1845 | +evaluated without changing the terminal modes. When you want to have | |
1846 | +nontrivial conditions for performing the side effects, the operators | |
1847 | +@samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful. | |
1504 | 1848 | |
1505 | -The _GDBN__ working directory also serves as a default for the commands | |
1506 | -that specify files for _GDBN__ to operate on. @xref{Files}. | |
1849 | +@node Error in Breakpoints, , Break Commands, Breakpoints | |
1850 | +@subsection ``Cannot Insert Breakpoints'' | |
1507 | 1851 | |
1508 | -@table @code | |
1509 | -@item cd @var{directory} | |
1510 | -@kindex cd | |
1511 | -Set _GDBN__'s working directory to @var{directory}. | |
1852 | +@c FIXME: "cannot insert breakpoints" error, v unclear. | |
1853 | +@c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91 | |
1854 | +Under some operating systems, breakpoints cannot be used in a program if | |
1855 | +any other process is running that program. In this situation, | |
1856 | +attempting to run or continue a program with a breakpoint will cause _GDBN__ | |
1857 | +to stop the other process. | |
1512 | 1858 | |
1513 | -@item pwd | |
1514 | -@kindex pwd | |
1515 | -Print _GDBN__'s working directory. | |
1516 | -@end table | |
1859 | +When this happens, you have three ways to proceed: | |
1517 | 1860 | |
1518 | -@node Input/Output, Attach, Working Directory, Running | |
1519 | -@section Your Program's Input and Output | |
1861 | +@enumerate | |
1862 | +@item | |
1863 | +Remove or disable the breakpoints, then continue. | |
1520 | 1864 | |
1521 | -@cindex redirection | |
1522 | -@cindex i/o | |
1523 | -@cindex terminal | |
1524 | -@cindex controlling terminal | |
1525 | -By default, the program you run under _GDBN__ does input and output to the same | |
1526 | -terminal that _GDBN__ uses. | |
1865 | +@item | |
1866 | +Suspend _GDBN__, and copy the file containing the program to a new name. | |
1867 | +Resume _GDBN__ and use the @samp{exec-file} command to specify that _GDBN__ | |
1868 | +should run the program under that name. Then start the program again. | |
1527 | 1869 | |
1528 | -You can redirect the program's input and/or output using @samp{sh}-style | |
1529 | -redirection commands in the @samp{run} command. For example, | |
1870 | +@item | |
1871 | +Relink the program so that the text segment is nonsharable, using the | |
1872 | +linker option @samp{-N}. The operating system limitation may not apply | |
1873 | +to nonsharable executables. | |
1874 | +@end enumerate | |
1530 | 1875 | |
1531 | -@example | |
1532 | -run > outfile | |
1533 | -@end example | |
1876 | +@node Continuing, Stepping, Breakpoints, Stopping | |
1877 | +@section Continuing | |
1534 | 1878 | |
1535 | -@noindent | |
1536 | -starts the program, diverting its output to the file @file{outfile}. | |
1879 | +After your program stops, most likely you will want it to run some more if | |
1880 | +the bug you are looking for has not happened yet. | |
1537 | 1881 | |
1538 | -@kindex tty | |
1539 | -Another way to specify where the program should do input and output is | |
1540 | -with the @samp{tty} command. This command accepts a file name as | |
1541 | -argument, and causes this file to be the default for future @samp{run} | |
1542 | -commands. It also resets the controlling terminal for the child | |
1543 | -process, for future @samp{run} commands. For example, | |
1882 | +@table @code | |
1883 | +@item continue | |
1884 | +@item cont | |
1885 | +@kindex cont | |
1886 | +@kindex continue | |
1887 | +Continue running the program at the place where it stopped. | |
1888 | +@end table | |
1544 | 1889 | |
1545 | -@example | |
1546 | -tty /dev/ttyb | |
1547 | -@end example | |
1890 | +If the program stopped at a breakpoint, the place to continue running | |
1891 | +is the address of the breakpoint. You might expect that continuing would | |
1892 | +just stop at the same breakpoint immediately. In fact, @samp{cont} | |
1893 | +takes special care to prevent that from happening. You do not need | |
1894 | +to delete the breakpoint to proceed through it after stopping at it. | |
1548 | 1895 | |
1549 | -@noindent | |
1550 | -directs that processes started with subsequent @samp{run} commands | |
1551 | -default to do input and output on the terminal @file{/dev/ttyb} and have | |
1552 | -that as their controlling terminal. | |
1896 | +You can, however, specify an ignore-count for the breakpoint that the | |
1897 | +program stopped at, by means of an argument to the @samp{cont} command. | |
1898 | +@xref{Conditions}. | |
1553 | 1899 | |
1554 | -An explicit redirection in @samp{run} overrides the @samp{tty} command's | |
1555 | -effect on input/output redirection, but not its effect on the | |
1556 | -controlling terminal. | |
1900 | +If the program stopped because of a signal other than @code{SIGINT} or | |
1901 | +@code{SIGTRAP}, continuing will cause the program to see that signal. | |
1902 | +You may not want this to happen. For example, if the program stopped | |
1903 | +due to some sort of memory reference error, you might store correct | |
1904 | +values into the erroneous variables and continue, hoping to see more | |
1905 | +execution; but the program would probably terminate immediately as | |
1906 | +a result of the fatal signal once it sees the signal. To prevent this, | |
1907 | +you can continue with @samp{signal 0}. @xref{Signaling}. You can | |
1908 | +also act in advance to control what signals your program will see, using | |
1909 | +the @samp{handle} command (@pxref{Signals}). | |
1557 | 1910 | |
1558 | -When you use the @samp{tty} command or redirect input in the @samp{run} | |
1559 | -command, only the @emph{input for your program} is affected. The input | |
1560 | -for _GDBN__ still comes from your terminal. | |
1911 | +@node Stepping, , Continuing, Stopping | |
1912 | +@section Stepping | |
1561 | 1913 | |
1562 | -@node Attach, Kill Process, Input/Output, Running | |
1563 | -@section Debugging an Already-Running Process | |
1564 | -@kindex attach | |
1565 | -@cindex attach | |
1914 | +@cindex stepping | |
1915 | +@dfn{Stepping} means setting your program in motion for a limited time, so | |
1916 | +that control will return automatically to the debugger after one line of | |
1917 | +code or one machine instruction. Breakpoints are active during stepping | |
1918 | +and the program will stop for them even if it has not gone as far as the | |
1919 | +stepping command specifies. | |
1566 | 1920 | |
1567 | 1921 | @table @code |
1568 | -@item attach @var{process--id} | |
1569 | -This command attaches to a running process, if your currently selected | |
1570 | -target supports processes. (@samp{info files} will show your active | |
1571 | -targets). The command takes as argument a process ID. | |
1922 | +@item step | |
1923 | +@kindex step | |
1924 | +Continue running the program until control reaches a different line, | |
1925 | +then stop it and return control to the debugger. This command is | |
1926 | +abbreviated @samp{s}. | |
1572 | 1927 | |
1573 | -You specify a process ID to debug an already-running process that was | |
1574 | -started outside of _GDBN__. (The usual way to find out the process-id of | |
1575 | -a Unix process is with the @code{ps} utility, or with the @code{jobs -l} | |
1576 | -shell command.) In this case, you must have permission to send the | |
1577 | -process a signal, and it must have the same effective user ID as the | |
1578 | -debugger. | |
1579 | -@end table | |
1928 | +This command may be given when control is within a function for which | |
1929 | +there is no debugging information. In that case, execution will proceed | |
1930 | +until control reaches a different function, or is about to return from | |
1931 | +this function. An argument repeats this action. | |
1580 | 1932 | |
1581 | -When using @samp{attach}, you should first use the @samp{file} command | |
1582 | -to specify the program running in the process and load its symbol table. | |
1933 | +@item step @var{count} | |
1934 | +Continue running as in @samp{step}, but do so @var{count} times. If a | |
1935 | +breakpoint is reached or a signal not related to stepping occurs before | |
1936 | +@var{count} steps, stepping stops right away. | |
1583 | 1937 | |
1584 | -The first thing _GDBN__ does after arranging to debug the process is to stop | |
1585 | -it. You can examine and modify an attached process with all the _GDBN__ | |
1586 | -commands that ordinarily available when you start processes with | |
1587 | -@samp{run}. You can insert breakpoints; you can step and continue; you | |
1588 | -can modify storage. If you would rather the process continue running, | |
1589 | -you may use the @samp{continue} command after attaching _GDBN__ to the | |
1590 | -process. | |
1938 | +@item next | |
1939 | +@kindex next | |
1940 | +Similar to @samp{step}, but any function calls appearing within the line of | |
1941 | +code are executed without stopping. Execution stops when control reaches a | |
1942 | +different line of code at the stack level which was executing when the | |
1943 | +@samp{next} command was given. This command is abbreviated @samp{n}. | |
1591 | 1944 | |
1592 | -@kindex detach | |
1593 | -When you have finished debugging the attached process, you can use the | |
1594 | -@samp{detach} command to release it from _GDBN__'s control. Detaching | |
1595 | -the process continues its execution. After the @samp{detach} command, | |
1596 | -that process and _GDBN__ become completely independent once more, and you | |
1597 | -are ready to @samp{attach} another process or start one with @samp{run}. | |
1945 | +An argument is a repeat count, as in @samp{step}. | |
1598 | 1946 | |
1599 | -If you exit _GDBN__ or use the @samp{run} command while you have an attached | |
1600 | -process, you kill that process. By default, you will be asked for | |
1601 | -confirmation if you try to do either of these things; you can control | |
1602 | -whether or not this happens by using the @samp{set caution} command | |
1603 | -(@pxref{User Interface}). | |
1947 | +@samp{next} within a function without debugging information acts as does | |
1948 | +@samp{step}, but any function calls appearing within the code of the | |
1949 | +function are executed without stopping. | |
1950 | + | |
1951 | +@item finish | |
1952 | +@kindex finish | |
1953 | +Continue running until just after the selected stack frame returns (or | |
1954 | +until there is some other reason to stop, such as a fatal signal or a | |
1955 | +breakpoint). Print value returned by the selected stack frame (if any). | |
1956 | + | |
1957 | +Contrast this with the @samp{return} command (@pxref{Returning}). | |
1604 | 1958 | |
1605 | -@node Kill Process, , Attach, Running | |
1606 | -@section Killing the Child Process | |
1959 | +@item until | |
1960 | +@kindex until | |
1961 | +This command is used to avoid single stepping through a loop more than | |
1962 | +once. It is like the @samp{next} command, except that when @samp{until} | |
1963 | +encounters a jump, it automatically continues execution until the | |
1964 | +program counter is greater than the address of the jump. | |
1607 | 1965 | |
1608 | -@table @code | |
1609 | -@item kill | |
1610 | -@kindex kill | |
1611 | -Kill the child process in which your program is running under _GDBN__. | |
1612 | -@end table | |
1966 | +This means that when you reach the end of a loop after single stepping | |
1967 | +though it, @samp{until} will cause the program to continue execution | |
1968 | +until the loop is exited. In contrast, a @samp{next} command at the end | |
1969 | +of a loop will simply step back to the beginning of the loop, which | |
1970 | +would force you to step through the next iteration. | |
1613 | 1971 | |
1614 | -This command is useful if you wish to debug a core dump instead. _GDBN__ | |
1615 | -ignores any core dump file if it is actually running the program. | |
1972 | +@samp{until} always stops the program if it attempts to exit the current | |
1973 | +stack frame. | |
1616 | 1974 | |
1617 | -On some operating systems, you can't execute your program in another | |
1618 | -process while breakpoints are active inside _GDBN__. The @samp{kill} | |
1619 | -command is also useful in this situation, if you wish to run the program | |
1620 | -outside the debugger. | |
1975 | +@samp{until} may produce somewhat counterintuitive results if the order | |
1976 | +of the source lines does not match the actual order of execution. For | |
1977 | +example, in a typical C @code{for}-loop, the third expression in the | |
1978 | +@code{for}-statement (the loop-step expression) is executed after the | |
1979 | +statements in the body of the loop, but is written before them. | |
1980 | +Therefore, the @samp{until} command would appear to step back to the | |
1981 | +beginning of the loop when it advances to this expression. However, it | |
1982 | +has not really done so, not in terms of the actual machine code. | |
1621 | 1983 | |
1622 | -The @samp{kill} command is also useful if you wish to recompile and | |
1623 | -relink the program, since on many systems it is impossible to modify an | |
1624 | -executable file which is running in a process. In this case, when you | |
1625 | -next type @samp{run}, _GDBN__ will notice that the file has changed, and | |
1626 | -will re-read the symbol table (while trying to preserve your current | |
1627 | -breakpoint settings). | |
1984 | +Note that @samp{until} with no argument works by means of single | |
1985 | +instruction stepping, and hence is slower than @samp{until} with an | |
1986 | +argument. | |
1628 | 1987 | |
1629 | -@node Stopping, Stack, Running, Top | |
1630 | -@chapter Stopping and Continuing | |
1988 | +@item until @var{location} | |
1989 | +Continue running the program until either the specified location is | |
1990 | +reached, or the current (innermost) stack frame returns. @var{location} | |
1991 | +is any of the forms of argument acceptable to @samp{break} (@pxref{Set | |
1992 | +Breaks}). This form of the command uses breakpoints, and hence is | |
1993 | +quicker than @samp{until} without an argument. | |
1631 | 1994 | |
1632 | -When you run a program normally, it runs until it terminates. The | |
1633 | -principal purpose of using a debugger is so that you can stop it before | |
1634 | -that point; or so that if the program runs into trouble you can | |
1635 | -investigate and find out why. | |
1995 | +@item stepi | |
1996 | +@itemx si | |
1997 | +@kindex stepi | |
1998 | +@kindex si | |
1999 | +Execute one machine instruction, then stop and return to the debugger. | |
1636 | 2000 | |
1637 | -@menu | |
1638 | -* Signals:: Fatal signals in your program just stop it; | |
1639 | - then you can use _GDBN__ to see what is going on. | |
1640 | -* Breakpoints:: Breakpoints let you stop your program when it | |
1641 | - reaches a specified point in the code. | |
1642 | - an expression changes. | |
1643 | -* Continuing:: Resuming execution until the next signal or breakpoint. | |
1644 | -* Stepping:: Stepping runs the program a short distance and | |
1645 | - then stops it wherever it has come to. | |
1646 | -@end menu | |
2001 | +It is often useful to do @samp{display/i $pc} when stepping by machine | |
2002 | +instructions. This will cause the next instruction to be executed to | |
2003 | +be displayed automatically at each stop. @xref{Auto Display}. | |
1647 | 2004 | |
1648 | -@node Signals, Breakpoints, Stopping, Stopping | |
1649 | -@section Signals | |
1650 | -@cindex signals | |
2005 | +An argument is a repeat count, as in @samp{step}. | |
1651 | 2006 | |
1652 | -A signal is an asynchronous event that can happen in a program. The | |
1653 | -operating system defines the possible kinds of signals, and gives each kind | |
1654 | -a name and a number. For example, @code{SIGINT} is the signal a program | |
1655 | -gets when you type @kbd{Ctrl-c}; @code{SIGSEGV} is the signal a program | |
1656 | -gets from referencing a place in memory far away from all the areas in use; | |
1657 | -@code{SIGALRM} occurs when the alarm clock timer goes off (which happens | |
1658 | -only if the program has requested an alarm). | |
2007 | +@item nexti | |
2008 | +@itemx ni | |
2009 | +@kindex nexti | |
2010 | +@kindex ni | |
2011 | +Execute one machine instruction, but if it is a subroutine call, | |
2012 | +proceed until the subroutine returns. | |
1659 | 2013 | |
1660 | -@cindex fatal signals | |
1661 | -Some signals, including @code{SIGALRM}, are a normal part of the | |
1662 | -functioning of the program. Others, such as @code{SIGSEGV}, indicate | |
1663 | -errors; these signals are @dfn{fatal} (kill the program immediately) if the | |
1664 | -program has not specified in advance some other way to handle the signal. | |
1665 | -@code{SIGINT} does not indicate an error in the program, but it is normally | |
1666 | -fatal so it can carry out the purpose of @kbd{Ctrl-c}: to kill the program. | |
2014 | +An argument is a repeat count, as in @samp{next}. | |
2015 | +@end table | |
1667 | 2016 | |
1668 | -_GDBN__ has the ability to detect any occurrence of a signal in the program | |
1669 | -running under _GDBN__'s control. You can tell _GDBN__ in advance what to do for | |
1670 | -each kind of signal. | |
2017 | +A typical technique for using stepping is to put a breakpoint | |
2018 | +(@pxref{Breakpoints}) at the beginning of the function or the section of | |
2019 | +the program in which a problem is believed to lie, and then step through | |
2020 | +the suspect area, examining the variables that are interesting, until the | |
2021 | +problem happens. | |
1671 | 2022 | |
1672 | -@cindex handling signals | |
1673 | -Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM} | |
1674 | -(so as not to interfere with their role in the functioning of the program) | |
1675 | -but to stop the program immediately whenever an error signal happens. | |
1676 | -You can change these settings with the @samp{handle} command. | |
2023 | +The @samp{cont} command can be used after stepping to resume execution | |
2024 | +until the next breakpoint or signal. | |
1677 | 2025 | |
1678 | -@table @code | |
1679 | -@item info signal | |
1680 | -@kindex info signal | |
1681 | -Print a table of all the kinds of signals and how _GDBN__ has been told to | |
1682 | -handle each one. You can use this to see the signal numbers of all | |
1683 | -the defined types of signals. | |
2026 | +@node Stack, Source, Stopping, Top | |
2027 | +@chapter Examining the Stack | |
1684 | 2028 | |
1685 | -@item handle @var{signal} @var{keywords}@dots{} | |
1686 | -@kindex handle | |
1687 | -Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the | |
1688 | -number of a signal or its name (with or without the @samp{SIG} at the | |
1689 | -beginning). The @var{keywords} say what change to make. | |
1690 | -@end table | |
2029 | +When your program has stopped, the first thing you need to know is where it | |
2030 | +stopped and how it got there. | |
1691 | 2031 | |
1692 | -The keywords allowed by the @samp{handle} command can be abbreviated. | |
1693 | -Their full names are | |
2032 | +@cindex call stack | |
2033 | +Each time your program performs a function call, the information about | |
2034 | +where in the program the call was made from is saved in a block of data | |
2035 | +called a @dfn{stack frame}. The frame also contains the arguments of the | |
2036 | +call and the local variables of the function that was called. All the | |
2037 | +stack frames are allocated in a region of memory called the @dfn{call | |
2038 | +stack}. | |
1694 | 2039 | |
1695 | -@table @code | |
1696 | -@item nostop | |
1697 | -_GDBN__ should not stop the program when this signal happens. It may | |
1698 | -still print a message telling you that the signal has come in. | |
2040 | +When your program stops, the _GDBN__ commands for examining the stack allow you | |
2041 | +to see all of this information. | |
1699 | 2042 | |
1700 | -@item stop | |
1701 | -_GDBN__ should stop the program when this signal happens. This implies | |
1702 | -the @samp{print} keyword as well. | |
2043 | +One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands | |
2044 | +refer implicitly to the selected frame. In particular, whenever you ask | |
2045 | +_GDBN__ for the value of a variable in the program, the value is found in the | |
2046 | +selected frame. There are special _GDBN__ commands to select whichever frame | |
2047 | +you are interested in. | |
1703 | 2048 | |
1704 | -@item print | |
1705 | -_GDBN__ should print a message when this signal happens. | |
2049 | +When the program stops, _GDBN__ automatically selects the currently executing | |
2050 | +frame and describes it briefly as the @samp{frame} command does | |
2051 | +(@pxref{Frame Info, Info}). | |
1706 | 2052 | |
1707 | -@item noprint | |
1708 | -_GDBN__ should not mention the occurrence of the signal at all. This | |
1709 | -implies the @samp{nostop} keyword as well. | |
2053 | +@menu | |
2054 | +* Frames:: Explanation of stack frames and terminology. | |
2055 | +* Backtrace:: Summarizing many frames at once. | |
2056 | +* Selection:: How to select a stack frame. | |
2057 | +* Frame Info:: Information on a Frame | |
2058 | +@end menu | |
1710 | 2059 | |
1711 | -@item pass | |
1712 | -_GDBN__ should allow the program to see this signal; the program will be | |
1713 | -able to handle the signal, or may be terminated if the signal is fatal | |
1714 | -and not handled. | |
2060 | +@node Frames, Backtrace, Stack, Stack | |
2061 | +@section Stack Frames | |
1715 | 2062 | |
1716 | -@item nopass | |
1717 | -_GDBN__ should not allow the program to see this signal. | |
1718 | -@end table | |
2063 | +@cindex frame | |
2064 | +@cindex stack frame | |
2065 | +The call stack is divided up into contiguous pieces called @dfn{stack | |
2066 | +frames}, or @dfn{frames} for short; each frame is the data associated | |
2067 | +with one call to one function. The frame contains the arguments given | |
2068 | +to the function, the function's local variables, and the address at | |
2069 | +which the function is executing. | |
1719 | 2070 | |
1720 | -When a signal has been set to stop the program, the program cannot see the | |
1721 | -signal until you continue. It will see the signal then, if @samp{pass} is | |
1722 | -in effect for the signal in question @i{at that time}. In other words, | |
1723 | -after _GDBN__ reports a signal, you can use the @samp{handle} command with | |
1724 | -@samp{pass} or @samp{nopass} to control whether that signal will be seen by | |
1725 | -the program when you later continue it. | |
2071 | +@cindex initial frame | |
2072 | +@cindex outermost frame | |
2073 | +@cindex innermost frame | |
2074 | +When your program is started, the stack has only one frame, that of the | |
2075 | +function @code{main}. This is called the @dfn{initial} frame or the | |
2076 | +@dfn{outermost} frame. Each time a function is called, a new frame is | |
2077 | +made. Each time a function returns, the frame for that function invocation | |
2078 | +is eliminated. If a function is recursive, there can be many frames for | |
2079 | +the same function. The frame for the function in which execution is | |
2080 | +actually occurring is called the @dfn{innermost} frame. This is the most | |
2081 | +recently created of all the stack frames that still exist. | |
1726 | 2082 | |
1727 | -You can also use the @samp{signal} command to prevent the program from | |
1728 | -seeing a signal, or cause it to see a signal it normally would not see, | |
1729 | -or to give it any signal at any time. @xref{Signaling}. | |
2083 | +@cindex frame pointer | |
2084 | +Inside your program, stack frames are identified by their addresses. A | |
2085 | +stack frame consists of many bytes, each of which has its own address; each | |
2086 | +kind of computer has a convention for choosing one of those bytes whose | |
2087 | +address serves as the address of the frame. Usually this address is kept | |
2088 | +in a register called the @dfn{frame pointer register} while execution is | |
2089 | +going on in that frame. | |
1730 | 2090 | |
1731 | -@node Breakpoints, Continuing, Signals, Stopping | |
1732 | -@section Breakpoints | |
2091 | +@cindex frame number | |
2092 | +_GDBN__ assigns numbers to all existing stack frames, starting with zero for | |
2093 | +the innermost frame, one for the frame that called it, and so on upward. | |
2094 | +These numbers do not really exist in your program; they are to give you a | |
2095 | +way of talking about stack frames in _GDBN__ commands. | |
1733 | 2096 | |
1734 | -@cindex breakpoints | |
1735 | -A @dfn{breakpoint} makes your program stop whenever a certain point in the | |
1736 | -program is reached. You set breakpoints explicitly with _GDBN__ commands, | |
1737 | -specifying the place where the program should stop by line number, function | |
1738 | -name or exact address in the program. You can add various other conditions | |
1739 | -to control whether the program will stop. | |
2097 | +@cindex selected frame | |
2098 | +Many _GDBN__ commands refer implicitly to one stack frame, called the | |
2099 | +@dfn{selected} stack frame. You can select any frame using one set of | |
2100 | +_GDBN__ commands, and then other commands will operate on that frame. When | |
2101 | +your program stops, _GDBN__ automatically selects the innermost frame. | |
1740 | 2102 | |
1741 | -Each breakpoint is assigned a number when it is created; these numbers are | |
1742 | -successive integers starting with 1. In many of the commands for controlling | |
1743 | -various features of breakpoints you use the breakpoint number to say which | |
1744 | -breakpoint you want to change. Each breakpoint may be @dfn{enabled} or | |
1745 | -@dfn{disabled}; if disabled, it has no effect on the program until you | |
1746 | -enable it again. | |
2103 | +@cindex frameless execution | |
2104 | +Some compilers allow functions to be compiled to run without a frame | |
2105 | +reserved for them on the stack. (For example, the _GCC__ option | |
2106 | +@samp{-fomit-frame-pointer} will generate functions without a frame.) | |
2107 | +This is occasionally done with heavily used library functions to save | |
2108 | +the frame setup time. _GDBN__ has limited facilities for dealing with these | |
2109 | +function invocations; if the innermost function invocation has no stack | |
2110 | +frame, _GDBN__ will give it a virtual stack frame of 0 and correctly allow | |
2111 | +tracing of the function call chain. Results are undefined if a function | |
2112 | +invocation besides the innermost one is frameless. | |
1747 | 2113 | |
1748 | -@table @code | |
1749 | -@kindex info break | |
1750 | -@kindex $_ | |
1751 | -@item info break | |
1752 | -The command @samp{info break} prints a list of all breakpoints set and not | |
1753 | -deleted, showing their numbers, where in the program they are, and any | |
1754 | -special features in use for them. Disabled breakpoints are included in the | |
1755 | -list, but marked as disabled. @samp{info break} with a breakpoint number | |
1756 | -as argument lists only that breakpoint. The convenience variable @code{$_} | |
1757 | -and the default examining-address for the @samp{x} command are set to the | |
1758 | -address of the last breakpoint listed (@pxref{Memory}). | |
2114 | +@node Backtrace, Selection, Frames, Stack | |
2115 | +@section Backtraces | |
1759 | 2116 | |
1760 | -@kindex info watch | |
1761 | -@item info watch | |
1762 | -This command prints a list of watchpoints. | |
2117 | +A backtrace is a summary of how the program got where it is. It shows one | |
2118 | +line per frame, for many frames, starting with the currently executing | |
2119 | +frame (frame zero), followed by its caller (frame one), and on up the | |
2120 | +stack. | |
1763 | 2121 | |
1764 | -@cindex watchpoints | |
1765 | -A @dfn{watchpoint} is a special breakpoint that stops your program when | |
1766 | -the value of an expression changes. You can use a watchpoint to stop | |
1767 | -execution whenever the value of an expression changes, without having to | |
1768 | -predict a particular place in the inferior process where this may | |
1769 | -happen. Aside from the different syntax in setting a watchpoint, it is | |
1770 | -managed exactly like any other breakpoint and is enabled, disabled, and | |
1771 | -deleted using exactly the same commands. | |
2122 | +@table @code | |
2123 | +@item backtrace | |
2124 | +@itemx bt | |
2125 | +@kindex backtrace | |
2126 | +@kindex bt | |
2127 | +Print a backtrace of the entire stack: one line per frame for all | |
2128 | +frames in the stack. | |
1772 | 2129 | |
1773 | -Watchpoints currently execute two orders of magnitude more slowly than | |
1774 | -other breakpoints, but this can well be worth it to catch errors where | |
1775 | -you have no clue what part of your program is the culprit. Some | |
1776 | -processors provide special hardware to implement this feature; future | |
1777 | -releases of _GDBN__ will use such hardware if it is available. | |
2130 | +You can stop the backtrace at any time by typing the system interrupt | |
2131 | +character, normally @kbd{Control-C}. | |
2132 | + | |
2133 | +@item backtrace @var{n} | |
2134 | +@itemx bt @var{n} | |
2135 | +Similar, but print only the innermost @var{n} frames. | |
1778 | 2136 | |
2137 | +@item backtrace @var{-n} | |
2138 | +@itemx bt @var{-n} | |
2139 | +Similar, but print only the outermost @var{n} frames. | |
1779 | 2140 | @end table |
1780 | 2141 | |
1781 | -@menu | |
1782 | -* Set Breaks:: How to establish breakpoints. | |
1783 | -* Exception Handling:: How _GDBN__ supports exception handling for C++. | |
1784 | -* Delete Breaks:: How to remove breakpoints no longer needed. | |
1785 | -* Disabling:: How to disable breakpoints (turn them off temporarily). | |
1786 | -* Conditions:: Making extra conditions on whether to stop. | |
1787 | -* Break Commands:: Commands to be executed at a breakpoint. | |
1788 | -* Error in Breakpoints:: | |
1789 | -@end menu | |
2142 | +@kindex where | |
2143 | +@kindex info stack | |
2144 | +The names @samp{where} and @samp{info stack} are additional aliases | |
2145 | +for @samp{backtrace}. | |
1790 | 2146 | |
1791 | -@node Set Breaks, Exception Handling, Breakpoints, Breakpoints | |
1792 | -@subsection Setting Breakpoints | |
2147 | +Every line in the backtrace shows the frame number and the function | |
2148 | +name. The program counter value is also shown---unless you use | |
2149 | +@samp{set addressprint off}. | |
1793 | 2150 | |
1794 | -@kindex break | |
1795 | -@kindex watch | |
1796 | -Breakpoints are set with the @samp{break} command (abbreviated @samp{b}). | |
1797 | -Watchpoints are set with the @samp{watch} command. | |
2151 | +If the function is in a source file whose symbol table data has been | |
2152 | +fully read, the backtrace shows the source file name and line number, as | |
2153 | +well as the arguments to the function. When the line number is shown, | |
2154 | +the program counter value is omitted if it is at the beginning of the | |
2155 | +code for that line number. | |
1798 | 2156 | |
1799 | -You have several ways to say where the breakpoint should go. | |
2157 | +Here is an example of a backtrace. It was made with the command | |
2158 | +@samp{bt 3}, so it shows the innermost three frames. | |
1800 | 2159 | |
1801 | -@table @code | |
1802 | -@item break @var{function} | |
1803 | -Set a breakpoint at entry to function @var{function}. | |
2160 | +@example | |
2161 | +#0 rtx_equal_p (x=(rtx) 0x8e58c, y=(rtx) 0x1086c4) \ | |
2162 | +(/gp/rms/cc/rtlanal.c line 337) | |
2163 | +#1 0x246b0 in expand_call (...) (...) | |
2164 | +#2 0x21cfc in expand_expr (...) (...) | |
2165 | +(More stack frames follow...) | |
2166 | +@end example | |
1804 | 2167 | |
1805 | -@item break @var{+offset} | |
1806 | -@itemx break @var{-offset} | |
1807 | -Set a breakpoint some number of lines forward or back from the position | |
1808 | -at which execution stopped in the currently selected frame. | |
2168 | +@noindent | |
2169 | +The functions @code{expand_call} and @code{expand_expr} are in a file | |
2170 | +whose symbol details have not been fully read. Full detail is available | |
2171 | +for the function @code{rtx_equal_p}, which is in the file | |
2172 | +@file{rtlanal.c}. Its arguments, named @code{x} and @code{y}, are shown | |
2173 | +with their typed values. | |
1809 | 2174 | |
1810 | -@item break @var{linenum} | |
1811 | -Set a breakpoint at line @var{linenum} in the current source file. | |
1812 | -That file is the last file whose source text was printed. This | |
1813 | -breakpoint will stop the program just before it executes any of the | |
1814 | -code on that line. | |
2175 | +@node Selection, Frame Info, Backtrace, Stack | |
2176 | +@section Selecting a Frame | |
1815 | 2177 | |
1816 | -@item break @var{filename}:@var{linenum} | |
1817 | -Set a breakpoint at line @var{linenum} in source file @var{filename}. | |
2178 | +Most commands for examining the stack and other data in the program work on | |
2179 | +whichever stack frame is selected at the moment. Here are the commands for | |
2180 | +selecting a stack frame; all of them finish by printing a brief description | |
2181 | +of the stack frame just selected. | |
1818 | 2182 | |
1819 | -@item break @var{filename}:@var{function} | |
1820 | -Set a breakpoint at entry to function @var{function} found in file | |
1821 | -@var{filename}. Specifying a file name as well as a function name is | |
1822 | -superfluous except when multiple files contain similarly named | |
1823 | -functions. | |
2183 | +@table @code | |
2184 | +@item frame @var{n} | |
2185 | +@kindex frame | |
2186 | +Select frame number @var{n}. Recall that frame zero is the innermost | |
2187 | +(currently executing) frame, frame one is the frame that called the | |
2188 | +innermost one, and so on. The highest-numbered frame is @code{main}'s | |
2189 | +frame. | |
1824 | 2190 | |
1825 | -@item break *@var{address} | |
1826 | -Set a breakpoint at address @var{address}. You can use this to set | |
1827 | -breakpoints in parts of the program which do not have debugging | |
1828 | -information or source files. | |
2191 | +@item frame @var{addr} | |
2192 | +Select the frame at address @var{addr}. This is useful mainly if the | |
2193 | +chaining of stack frames has been damaged by a bug, making it | |
2194 | +impossible for _GDBN__ to assign numbers properly to all frames. In | |
2195 | +addition, this can be useful when the program has multiple stacks and | |
2196 | +switches between them. | |
1829 | 2197 | |
1830 | -@item break | |
1831 | -Set a breakpoint at the next instruction to be executed in the selected | |
1832 | -stack frame (@pxref{Stack}). In any selected frame but the innermost, | |
1833 | -this will cause the program to stop as soon as control returns to that | |
1834 | -frame. This is equivalent to a @samp{finish} command in the frame | |
1835 | -inside the selected frame. If this is done in the innermost frame, _GDBN__ | |
1836 | -will stop the next time it reaches the current location; this may be | |
1837 | -useful inside of loops. | |
2198 | +@item up @var{n} | |
2199 | +@kindex up | |
2200 | +Select the frame @var{n} frames up from the frame previously selected. | |
2201 | +For positive numbers @var{n}, this advances toward the outermost | |
2202 | +frame, to higher frame numbers, to frames that have existed longer. | |
2203 | +@var{n} defaults to one. | |
1838 | 2204 | |
1839 | -_GDBN__ normally ignores breakpoints when it resumes execution, until at | |
1840 | -least one instruction has been executed. If it did not do this, you | |
1841 | -would be unable to proceed past a breakpoint without first disabling the | |
1842 | -breakpoint. This rule applies whether or not the breakpoint already | |
1843 | -existed when the program stopped. | |
2205 | +@item down @var{n} | |
2206 | +@kindex down | |
2207 | +Select the frame @var{n} frames down from the frame previously | |
2208 | +selected. For positive numbers @var{n}, this advances toward the | |
2209 | +innermost frame, to lower frame numbers, to frames that were created | |
2210 | +more recently. @var{n} defaults to one. | |
2211 | +@end table | |
1844 | 2212 | |
1845 | -@item break @dots{} if @var{cond} | |
1846 | -Set a breakpoint with condition @var{cond}; evaluate the expression | |
1847 | -@var{cond} each time the breakpoint is reached, and stop only if the | |
1848 | -value is nonzero. @samp{@dots{}} stands for one of the possible | |
1849 | -arguments described above (or no argument) specifying where to break. | |
1850 | -@xref{Conditions}, for more information on breakpoint conditions. | |
2213 | +All of these commands end by printing some information on the frame that | |
2214 | +has been selected: the frame number, the function name, the arguments, the | |
2215 | +source file and line number of execution in that frame, and the text of | |
2216 | +that source line. For example: | |
1851 | 2217 | |
1852 | -@item tbreak @var{args} | |
1853 | -@kindex tbreak | |
1854 | -Set a breakpoint enabled only for one stop. @var{args} are the | |
1855 | -same as in the @samp{break} command, and the breakpoint is set in the same | |
1856 | -way, but the breakpoint is automatically disabled the first time it | |
1857 | -is hit. @xref{Disabling}. | |
2218 | +@example | |
2219 | +#3 main (argc=3, argv=??, env=??) at main.c:67 | |
2220 | +67 read_input_file (argv[i]); | |
2221 | +@end example | |
1858 | 2222 | |
1859 | -@item rbreak @var{regex} | |
1860 | -@kindex rbreak | |
1861 | -Set a breakpoint on all functions matching @var{regex}. This is | |
1862 | -useful for setting breakpoints on overloaded functions that are not | |
1863 | -members of any special classes. This command sets an unconditional | |
1864 | -breakpoint on all matches, printing a list of all breakpoints it set. | |
1865 | -Once these breakpoints are set, they are treated just like the | |
1866 | -breakpoints set with the @samp{break} command. They can be deleted, | |
1867 | -disabled, made conditional, etc., in the standard ways. | |
2223 | +After such a printout, the @samp{list} command with no arguments will print | |
2224 | +ten lines centered on the point of execution in the frame. @xref{List}. | |
1868 | 2225 | |
1869 | -@kindex watch | |
1870 | -@item watch @var{expr} | |
1871 | -Set a watchpoint for an expression. | |
1872 | -@end table | |
2226 | +@table @code | |
2227 | +@item up-silently @var{n} | |
2228 | +@itemx down-silently @var{n} | |
2229 | +@kindex down-silently | |
2230 | +@kindex up-silently | |
2231 | +These two commands are variants of @samp{up} and @samp{down}, | |
2232 | +respectively; they differ in that they do their work silently, without | |
2233 | +causing display of the new frame. They are intended primarily for use | |
2234 | +in _GDBN__ command scripts, where the output might be unnecessary and | |
2235 | +distracting. | |
1873 | 2236 | |
1874 | -_GDBN__ allows you to set any number of breakpoints at the same place in the | |
1875 | -program. There is nothing silly or meaningless about this. When the | |
1876 | -breakpoints are conditional, this is even useful (@pxref{Conditions}). | |
2237 | +@end table | |
1877 | 2238 | |
1878 | -@node Exception Handling, Delete Breaks, Set Breaks, Breakpoints | |
1879 | -@subsection Breakpoints and Exceptions | |
1880 | -@cindex exception handlers | |
2239 | +@node Frame Info, , Selection, Stack | |
2240 | +@section Information on a Frame | |
1881 | 2241 | |
1882 | -Some languages, such as GNU C++, implement exception handling. _GDBN__ | |
1883 | -can be used to examine what caused the program to raise an exception | |
1884 | -and to list the exceptions the program is prepared to handle at a | |
1885 | -given point in time. | |
2242 | +There are several other commands to print information about the selected | |
2243 | +stack frame. | |
1886 | 2244 | |
1887 | -@cindex raise exceptions | |
1888 | -GNU C++ raises an exception by calling a library function named | |
1889 | -@code{__raise_exception} which has the following ANSI C interface: | |
2245 | +@table @code | |
2246 | +@item frame | |
2247 | +When used without any argument, this command does not change which frame | |
2248 | +is selected, but still prints a brief description of the currently | |
2249 | +selected stack frame. It can be abbreviated @samp{f}. With an | |
2250 | +argument, this command is used to select a stack frame; with no | |
2251 | +argument, it does not change which frame is selected, but still prints | |
2252 | +the same kind of information. | |
1890 | 2253 | |
1891 | -@example | |
1892 | - /* ADDR is where the exception identifier is stored. | |
1893 | - ID is the exception identifier. */ | |
1894 | - void __raise_exception (void **addr, void *id); | |
1895 | -@end example | |
2254 | +@item info frame | |
2255 | +@kindex info frame | |
2256 | +This command prints a verbose description of the selected stack frame, | |
2257 | +including the address of the frame, the addresses of the next frame in | |
2258 | +(called by this frame) and the next frame out (caller of this frame), | |
2259 | +the address of the frame's arguments, the program counter saved in it | |
2260 | +(the address of execution in the caller frame), and which registers | |
2261 | +were saved in the frame. The verbose description is useful when | |
2262 | +something has gone wrong that has made the stack format fail to fit | |
2263 | +the usual conventions. | |
1896 | 2264 | |
1897 | -@noindent | |
1898 | -You can make the debugger catch all exceptions @emph{before} any stack | |
1899 | -unwinding takes place: set a breakpoint on @code{__raise_exception} | |
1900 | -(@pxref{Breakpoints}). If you set a breakpoint in an exception handler | |
1901 | -instead, it may not be easy to find out where the exception was raised. | |
2265 | +@item info frame @var{addr} | |
2266 | +Print a verbose description of the frame at address @var{addr}, | |
2267 | +without selecting that frame. The selected frame remains unchanged by | |
2268 | +this command. | |
1902 | 2269 | |
1903 | -By using a conditional breakpoint (@xref{Conditions}), you can cause | |
1904 | -the debugger to stop only when a specific exception is raised. | |
1905 | -Multiple conditional breakpoints can be used to stop the program when | |
1906 | -any of a number of exceptions are raised. | |
2270 | +@item info args | |
2271 | +@kindex info args | |
2272 | +Print the arguments of the selected frame, each on a separate line. | |
1907 | 2273 | |
1908 | -@table @code | |
1909 | -@item catch @var{exceptions} | |
1910 | -@kindex catch | |
2274 | +@item info locals | |
2275 | +@kindex info locals | |
2276 | +Print the local variables of the selected frame, each on a separate | |
2277 | +line. These are all variables declared static or automatic within all | |
2278 | +program blocks that execution in this frame is currently inside of. | |
1911 | 2279 | |
1912 | -Breakpoints can be set at active exception handlers by using the | |
1913 | -@samp{catch} command. @var{exceptions} is a list of names of exceptions | |
1914 | -to catch. | |
2280 | +@item info catch | |
2281 | +@kindex info catch | |
2282 | +@cindex catch exceptions | |
2283 | +@cindex exception handlers | |
2284 | +Print a list of all the exception handlers that are active in the | |
2285 | +current stack frame given the current value of @code{pc}. To see other | |
2286 | +exception handlers, visit the associated frame (using the @samp{up}, | |
2287 | +@samp{down}, or @samp{frame} commands); then type @samp{info catch}. | |
2288 | +@xref{Exception Handling}. | |
1915 | 2289 | @end table |
1916 | 2290 | |
1917 | -You can use @samp{info catch} to list active exception handlers; | |
1918 | -@pxref{Frame Info}. | |
1919 | - | |
1920 | -There are currently some limitations to exception handling in _GDBN__. | |
1921 | -These will be corrected in a future release. | |
2291 | +@node Source, Data, Stack, Top | |
2292 | +@chapter Examining Source Files | |
1922 | 2293 | |
1923 | -@itemize @bullet | |
1924 | -@item | |
1925 | -If you call a function interactively, _GDBN__ will normally return | |
1926 | -control to you when the function has finished executing. If the call | |
1927 | -raises an exception, however, the call may bypass the mechanism that | |
1928 | -returns control to the user and cause the program to simply continue | |
1929 | -running until it hits a breakpoint, catches a signal that _GDBN__ is | |
1930 | -listening for, or exits. | |
1931 | -@item | |
1932 | -You cannot raise an exception interactively. | |
1933 | -@item | |
1934 | -You cannot interactively install an exception handler. | |
1935 | -@end itemize | |
2294 | +_GDBN__ knows which source files your program was compiled from, and | |
2295 | +can print parts of their text. When your program stops, _GDBN__ | |
2296 | +spontaneously prints the line it stopped in. Likewise, when you | |
2297 | +select a stack frame (@pxref{Selection}), _GDBN__ prints the line | |
2298 | +which execution in that frame has stopped in. You can also | |
2299 | +print parts of source files by explicit command. | |
1936 | 2300 | |
1937 | -@node Delete Breaks, Disabling, Exception Handling, Breakpoints | |
1938 | -@subsection Deleting Breakpoints | |
2301 | +@menu | |
2302 | +* List:: Using the @samp{list} command to print source files. | |
2303 | +* Search:: Commands for searching source files. | |
2304 | +* Source Path:: Specifying the directories to search for source files. | |
2305 | +@end menu | |
1939 | 2306 | |
1940 | -@cindex clearing breakpoints, watchpoints | |
1941 | -@cindex deleting breakpoints, watchpoints | |
1942 | -It is often necessary to eliminate a breakpoint once it has done its job | |
1943 | -and you no longer want the program to stop there. This is called | |
1944 | -@dfn{deleting} the breakpoint. A breakpoint that has been deleted no | |
1945 | -longer exists in any sense; it is forgotten. | |
2307 | +@node List, Search, Source, Source | |
2308 | +@section Printing Source Lines | |
1946 | 2309 | |
1947 | -With the @samp{clear} command you can delete breakpoints according to where | |
1948 | -they are in the program. With the @samp{delete} command you can delete | |
1949 | -individual breakpoints by specifying their breakpoint numbers. | |
2310 | +@kindex list | |
2311 | +@kindex l | |
2312 | +To print lines from a source file, use the @samp{list} command | |
2313 | +(abbreviated @samp{l}). There are several ways to specify what part | |
2314 | +of the file you want to print. | |
1950 | 2315 | |
1951 | -It is not necessary to delete a breakpoint to proceed past it. _GDBN__ | |
1952 | -automatically ignores breakpoints on the first instruction to be executed | |
1953 | -when you continue execution without changing the execution address. | |
2316 | +Here are the forms of the @samp{list} command most commonly used: | |
1954 | 2317 | |
1955 | 2318 | @table @code |
1956 | -@item clear | |
1957 | -@kindex clear | |
1958 | -Delete any breakpoints at the next instruction to be executed in the | |
1959 | -selected stack frame (@pxref{Selection}). When the innermost frame | |
1960 | -is selected, this is a good way to delete a breakpoint that the program | |
1961 | -just stopped at. | |
2319 | +@item list @var{linenum} | |
2320 | +Print ten lines centered around line number @var{linenum} in the | |
2321 | +current source file. | |
1962 | 2322 | |
1963 | -@item clear @var{function} | |
1964 | -@itemx clear @var{filename}:@var{function} | |
1965 | -Delete any breakpoints set at entry to the function @var{function}. | |
2323 | +@item list @var{function} | |
2324 | +Print ten lines centered around the beginning of function | |
2325 | +@var{function}. | |
1966 | 2326 | |
1967 | -@item clear @var{linenum} | |
1968 | -@itemx clear @var{filename}:@var{linenum} | |
1969 | -Delete any breakpoints set at or within the code of the specified line. | |
2327 | +@item list | |
2328 | +Print ten more lines. If the last lines printed were printed with a | |
2329 | +@samp{list} command, this prints ten lines following the last lines | |
2330 | +printed; however, if the last line printed was a solitary line printed | |
2331 | +as part of displaying a stack frame (@pxref{Stack}), this prints ten | |
2332 | +lines centered around that line. | |
1970 | 2333 | |
1971 | -@item delete breakpoints @var{bnums}@dots{} | |
1972 | -@itemx delete @var{bnums}@dots{} | |
1973 | -@itemx delete | |
1974 | -@kindex delete breakpoints | |
1975 | -@kindex delete | |
1976 | -Delete the breakpoints of the numbers specified as arguments. If no | |
1977 | -argument is specified, delete all breakpoints. | |
2334 | +@item list - | |
2335 | +Print ten lines just before the lines last printed. | |
1978 | 2336 | @end table |
1979 | 2337 | |
1980 | -@node Disabling, Conditions, Delete Breaks, Breakpoints | |
1981 | -@subsection Disabling Breakpoints | |
1982 | - | |
1983 | -@cindex disabled breakpoints | |
1984 | -@cindex enabled breakpoints | |
1985 | -Rather than deleting a breakpoint, you might prefer to @dfn{disable} it. | |
1986 | -This makes the breakpoint inoperative as if it had been deleted, but | |
1987 | -remembers the information on the breakpoint so that you can @dfn{enable} | |
1988 | -it again later. | |
2338 | +Repeating a @samp{list} command with @key{RET} discards the argument, | |
2339 | +so it is equivalent to typing just @samp{list}. This is more useful | |
2340 | +than listing the same lines again. An exception is made for an | |
2341 | +argument of @samp{-}; that argument is preserved in repetition so that | |
2342 | +each repetition moves up in the file. | |
1989 | 2343 | |
1990 | -You disable and enable breakpoints with the @samp{enable} and | |
1991 | -@samp{disable} commands, optionally specifying one or more breakpoint | |
1992 | -numbers as arguments. Use @samp{info break} to print a list of | |
1993 | -breakpoints if you don't know which breakpoint numbers to use. | |
2344 | +@cindex linespec | |
2345 | +In general, the @samp{list} command expects you to supply zero, one or two | |
2346 | +@dfn{linespecs}. Linespecs specify source lines; there are several ways | |
2347 | +of writing them but the effect is always to specify some source line. | |
2348 | +Here is a complete description of the possible arguments for @samp{list}: | |
1994 | 2349 | |
1995 | -A breakpoint can have any of four different states of enablement: | |
2350 | +@table @code | |
2351 | +@item list @var{linespec} | |
2352 | +Print ten lines centered around the line specified by @var{linespec}. | |
1996 | 2353 | |
1997 | -@itemize @bullet | |
1998 | -@item | |
1999 | -Enabled. The breakpoint will stop the program. A breakpoint made | |
2000 | -with the @samp{break} command starts out in this state. | |
2001 | -@item | |
2002 | -Disabled. The breakpoint has no effect on the program. | |
2003 | -@item | |
2004 | -Enabled once. The breakpoint will stop the program, but | |
2005 | -when it does so it will become disabled. A breakpoint made | |
2006 | -with the @samp{tbreak} command starts out in this state. | |
2007 | -@item | |
2008 | -Enabled for deletion. The breakpoint will stop the program, but | |
2009 | -immediately after it does so it will be deleted permanently. | |
2010 | -@end itemize | |
2354 | +@item list @var{first},@var{last} | |
2355 | +Print lines from @var{first} to @var{last}. Both arguments are | |
2356 | +linespecs. | |
2011 | 2357 | |
2012 | -You can use the following commands to enable or disable a breakpoint: | |
2358 | +@item list ,@var{last} | |
2359 | +Print ten lines ending with @var{last}. | |
2013 | 2360 | |
2014 | -@table @code | |
2015 | -@item disable breakpoints @var{bnums}@dots{} | |
2016 | -@itemx disable @var{bnums}@dots{} | |
2017 | -@itemx disable | |
2018 | -@kindex disable breakpoints | |
2019 | -@kindex disable | |
2020 | -Disable the specified breakpoints---or all breakpoints, if none are | |
2021 | -listed. A disabled breakpoint has no effect but is not forgotten. All | |
2022 | -options such as ignore-counts, conditions and commands are remembered in | |
2023 | -case the breakpoint is enabled again later. | |
2361 | +@item list @var{first}, | |
2362 | +Print ten lines starting with @var{first}. | |
2024 | 2363 | |
2025 | -@item enable breakpoints @var{bnums}@dots{} | |
2026 | -@itemx enable @var{bnums}@dots{} | |
2027 | -@itemx enable | |
2028 | -@kindex enable breakpoints | |
2029 | -@kindex enable | |
2030 | -Enable the specified breakpoints (or all defined breakpoints). They | |
2031 | -become effective once again in stopping the program, until you specify | |
2032 | -otherwise. | |
2364 | +@item list + | |
2365 | +Print ten lines just after the lines last printed. | |
2033 | 2366 | |
2034 | -@item enable breakpoints once @var{bnums}@dots{} | |
2035 | -@itemx enable once @var{bnums}@dots{} | |
2036 | -Enable the specified breakpoints temporarily. Each will be disabled | |
2037 | -again the next time it stops the program (unless you have used one of | |
2038 | -these commands to specify a different state before that time comes). | |
2367 | +@item list - | |
2368 | +Print ten lines just before the lines last printed. | |
2039 | 2369 | |
2040 | -@item enable breakpoints delete @var{bnums}@dots{} | |
2041 | -@itemx enable delete @var{bnums}@dots{} | |
2042 | -Enable the specified breakpoints to work once and then die. Each of | |
2043 | -the breakpoints will be deleted the next time it stops the program | |
2044 | -(unless you have used one of these commands to specify a different | |
2045 | -state before that time comes). | |
2370 | +@item list | |
2371 | +As described in the preceding table. | |
2046 | 2372 | @end table |
2047 | 2373 | |
2048 | -Save for a breakpoint set with @samp{tbreak} (@pxref{Set Breaks}), | |
2049 | -breakpoints that you set are enabled or disabled only when you use one | |
2050 | -of the commands above. (The command @samp{until} can set and delete a | |
2051 | -breakpoint on its own, but it will not change the state of your | |
2052 | -breakpoints). | |
2053 | - | |
2054 | -@node Conditions, Break Commands, Disabling, Breakpoints | |
2055 | -@subsection Break Conditions | |
2056 | -@cindex conditional breakpoints | |
2057 | -@cindex breakpoint conditions | |
2058 | - | |
2059 | -The simplest sort of breakpoint breaks every time the program reaches a | |
2060 | -specified place. You can also specify a @dfn{condition} for a | |
2061 | -breakpoint. A condition is just a boolean expression in your | |
2062 | -programming language. (@xref{Expressions}). A breakpoint with a | |
2063 | -condition evaluates the expression each time the program reaches it, and | |
2064 | -the program stops only if the condition is true. | |
2374 | +Here are the ways of specifying a single source line---all the | |
2375 | +kinds of linespec. | |
2065 | 2376 | |
2066 | -Break conditions may have side effects, and may even call functions in your | |
2067 | -program. These may sound like strange things to do, but their effects are | |
2068 | -completely predictable unless there is another enabled breakpoint at the | |
2069 | -same address. (In that case, _GDBN__ might see the other breakpoint first and | |
2070 | -stop the program without checking the condition of this one.) Note that | |
2071 | -breakpoint commands are usually more convenient and flexible for the | |
2072 | -purpose of performing side effects when a breakpoint is reached | |
2073 | -(@pxref{Break Commands}). | |
2377 | +@table @code | |
2378 | +@item @var{linenum} | |
2379 | +Specifies line @var{linenum} of the current source file. | |
2380 | +When a @samp{list} command has two linespecs, this refers to | |
2381 | +the same source file as the first linespec. | |
2074 | 2382 | |
2075 | -Break conditions can be specified when a breakpoint is set, by using | |
2076 | -@samp{if} in the arguments to the @samp{break} command. @xref{Set Breaks}. | |
2077 | -They can also be changed at any time with the @samp{condition} command: | |
2383 | +@item +@var{offset} | |
2384 | +Specifies the line @var{offset} lines after the last line printed. | |
2385 | +When used as the second linespec in a @samp{list} command that has | |
2386 | +two, this specifies the line @var{offset} lines down from the | |
2387 | +first linespec. | |
2078 | 2388 | |
2079 | -@table @code | |
2080 | -@item condition @var{bnum} @var{expression} | |
2081 | -@kindex condition | |
2082 | -Specify @var{expression} as the break condition for breakpoint number | |
2083 | -@var{bnum}. From now on, this breakpoint will stop the program only if | |
2084 | -the value of @var{expression} is true (nonzero, in C). @var{expression} | |
2085 | -is not evaluated at the time the @samp{condition} command is given. | |
2086 | -When you call @samp{condition}, the expression you specify is checked | |
2087 | -immediately for syntactic correctness, and to determine whether symbols | |
2088 | -in it have referents in the context of your breakpoint. | |
2089 | -@xref{Expressions}. | |
2389 | +@item -@var{offset} | |
2390 | +Specifies the line @var{offset} lines before the last line printed. | |
2090 | 2391 | |
2091 | -@item condition @var{bnum} | |
2092 | -Remove the condition from breakpoint number @var{bnum}. It becomes | |
2093 | -an ordinary unconditional breakpoint. | |
2094 | -@end table | |
2392 | +@item @var{filename}:@var{linenum} | |
2393 | +Specifies line @var{linenum} in the source file @var{filename}. | |
2095 | 2394 | |
2096 | -@cindex ignore count (of breakpoint) | |
2097 | -A special case of a breakpoint condition is to stop only when the | |
2098 | -breakpoint has been reached a certain number of times. This is so | |
2099 | -useful that there is a special way to do it, using the @dfn{ignore | |
2100 | -count} of the breakpoint. Every breakpoint has an ignore count, which | |
2101 | -is an integer. Most of the time, the ignore count is zero, and | |
2102 | -therefore has no effect. But if the program reaches a breakpoint whose | |
2103 | -ignore count is positive, then instead of stopping, it just decrements | |
2104 | -the ignore count by one and continues. As a result, if the ignore count | |
2105 | -value is @var{n}, the breakpoint will not stop the next @var{n} times it | |
2106 | -is reached. | |
2395 | +@item @var{function} | |
2396 | +Specifies the line of the open-brace that begins the body of the | |
2397 | +function @var{function}. | |
2107 | 2398 | |
2108 | -@table @code | |
2109 | -@item ignore @var{bnum} @var{count} | |
2110 | -@kindex ignore | |
2111 | -Set the ignore count of breakpoint number @var{bnum} to @var{count}. | |
2112 | -The next @var{count} times the breakpoint is reached, your program's | |
2113 | -execution will not stop; other than to decrement the ignore count, _GDBN__ | |
2114 | -takes no action. | |
2399 | +@item @var{filename}:@var{function} | |
2400 | +Specifies the line of the open-brace that begins the body of the | |
2401 | +function @var{function} in the file @var{filename}. The file name is | |
2402 | +needed with a function name only for disambiguation of identically | |
2403 | +named functions in different source files. | |
2115 | 2404 | |
2116 | -To make the breakpoint stop the next time it is reached, specify | |
2117 | -a count of zero. | |
2405 | +@item *@var{address} | |
2406 | +Specifies the line containing the program address @var{address}. | |
2407 | +@var{address} may be any expression. | |
2408 | +@end table | |
2118 | 2409 | |
2119 | -@item continue @var{count} | |
2120 | -@itemx cont @var{count} | |
2121 | -@itemx c @var{count} | |
2122 | -@itemx fg @var{count} | |
2123 | -@kindex cont @var{count} | |
2124 | -@kindex continue @var{count} | |
2125 | -Continue execution of the program, setting the ignore count of the | |
2126 | -breakpoint that the program stopped at to @var{count} minus one. | |
2127 | -Thus, the program will not stop at this breakpoint until the | |
2128 | -@var{count}'th time it is reached. | |
2410 | +One other command is used to map source lines to program addresses. | |
2129 | 2411 | |
2130 | -This command is allowed only when the program stopped due to a | |
2131 | -breakpoint. At other times, the argument to @samp{cont} is ignored. | |
2412 | +@table @code | |
2413 | +@item info line @var{linenum} | |
2414 | +@kindex info line | |
2415 | +Print the starting and ending addresses of the compiled code for | |
2416 | +source line @var{linenum}. | |
2132 | 2417 | |
2133 | -The synonym @samp{fg} is provided purely for convenience, and has | |
2134 | -exactly the same behavior as other forms of the command. | |
2418 | +@kindex $_ | |
2419 | +The default examine address for the @samp{x} command is changed to the | |
2420 | +starting address of the line, so that @samp{x/i} is sufficient to | |
2421 | +begin examining the machine code (@pxref{Memory}). Also, this address | |
2422 | +is saved as the value of the convenience variable @code{$_} | |
2423 | +(@pxref{Convenience Vars}). | |
2135 | 2424 | @end table |
2136 | 2425 | |
2137 | -If a breakpoint has a positive ignore count and a condition, the condition | |
2138 | -is not checked. Once the ignore count reaches zero, the condition will | |
2139 | -be checked. | |
2426 | +@node Search, Source Path, List, Source | |
2427 | +@section Searching Source Files | |
2428 | +@cindex searching | |
2429 | +@kindex search | |
2430 | +@kindex forward-search | |
2431 | +@kindex reverse-search | |
2140 | 2432 | |
2141 | -Note that you could achieve the effect of the ignore count with a | |
2142 | -condition such as @w{@samp{$foo-- <= 0}} using a debugger convenience | |
2143 | -variable that is decremented each time. @xref{Convenience Vars}. | |
2433 | +There are two commands for searching through the current source file for a | |
2434 | +regular expression. | |
2144 | 2435 | |
2145 | -@node Break Commands, Error in Breakpoints, Conditions, Breakpoints | |
2146 | -@subsection Commands Executed on Breaking | |
2436 | +The command @samp{forward-search @var{regexp}} checks each line, starting | |
2437 | +with the one following the last line listed, for a match for @var{regexp}. | |
2438 | +It lists the line that is found. You can abbreviate the command name | |
2439 | +as @samp{fo}. The synonym @samp{search @var{regexp}} is also supported. | |
2147 | 2440 | |
2148 | -@cindex breakpoint commands | |
2149 | -You can give any breakpoint a series of commands to execute when the | |
2150 | -program stops due to that breakpoint. For example, you might want to | |
2151 | -print the values of certain expressions, or enable other breakpoints. | |
2441 | +The command @samp{reverse-search @var{regexp}} checks each line, starting | |
2442 | +with the one before the last line listed and going backward, for a match | |
2443 | +for @var{regexp}. It lists the line that is found. You can abbreviate | |
2444 | +this command with as little as @samp{rev}. | |
2152 | 2445 | |
2153 | -@table @code | |
2154 | -@item commands @var{bnum} | |
2155 | -@kindex commands | |
2156 | -Specify a list of commands for breakpoint number @var{bnum}. The commands | |
2157 | -themselves appear on the following lines. Type a line containing just | |
2158 | -@samp{end} to terminate the commands. | |
2446 | +@node Source Path, , Search, Source | |
2447 | +@section Specifying Source Directories | |
2159 | 2448 | |
2160 | -To remove all commands from a breakpoint, use the command | |
2161 | -@samp{commands} and follow it immediately by @samp{end}; that is, give | |
2162 | -no commands. | |
2449 | +@cindex source path | |
2450 | +@cindex directories for source files | |
2451 | +Executable programs sometimes do not record the directories of the source | |
2452 | +files from which they were compiled, just the names. Even when they do, | |
2453 | +the directories could be moved between the compilation and your debugging | |
2454 | +session. _GDBN__ remembers a list of directories to search for source files; | |
2455 | +this is called the @dfn{source path}. Each time _GDBN__ wants a source file, | |
2456 | +it tries all the directories in the list, in the order they are present | |
2457 | +in the list, until it finds a file with the desired name. Note that | |
2458 | +the executable search path is @emph{not} used for this purpose. Neither is | |
2459 | +the current working directory, unless it happens to be in the source | |
2460 | +path. | |
2163 | 2461 | |
2164 | -With no arguments, @samp{commands} refers to the last breakpoint set | |
2165 | -(not to the breakpoint most recently encountered). | |
2166 | -@end table | |
2462 | +If it can't find a source file in the source path, and the object program | |
2463 | +records what directory it was compiled in, _GDBN__ tries that directory too. | |
2464 | +If the source path is empty, and there is no record of the compilation | |
2465 | +directory, _GDBN__ will, as a last resort, look in the current directory. | |
2167 | 2466 | |
2168 | -You can use breakpoint commands to start the program up again. Simply | |
2169 | -use the @samp{cont} command, or @samp{step}, or any other command to | |
2170 | -resume execution. However, if you do this, any further commands in the | |
2171 | -same breakpoint's command list are ignored. When the program stops | |
2172 | -again, _GDBN__ will act according to the cause of that stop. | |
2467 | +Whenever you reset or rearrange the source path, _GDBN__ will clear out | |
2468 | +any information it has cached about where source files are found, where | |
2469 | +each line is in the file, etc. | |
2173 | 2470 | |
2174 | -@kindex silent | |
2175 | -If the first command specified is @samp{silent}, the usual message about | |
2176 | -stopping at a breakpoint is not printed. This may be desirable for | |
2177 | -breakpoints that are to print a specific message and then continue. | |
2178 | -If the remaining commands too print nothing, you will see no sign that | |
2179 | -the breakpoint was reached at all. @samp{silent} is not really a command; | |
2180 | -it is meaningful only at the beginning of the commands for a breakpoint. | |
2471 | +@kindex directory | |
2472 | +When you start _GDBN__, its source path is empty. | |
2473 | +To add other directories, use the @samp{directory} command. | |
2181 | 2474 | |
2182 | -The commands @samp{echo} and @samp{output} that allow you to print precisely | |
2183 | -controlled output are often useful in silent breakpoints. @xref{Output}. | |
2475 | +@table @code | |
2476 | +@item directory @var{dirnames...} | |
2477 | +Add directory @var{dirname} to the front of the source path. Several | |
2478 | +directory names may be given to this command, separated by whitespace or | |
2479 | +@samp{:}. If a name is already in the source path, it is moved to the | |
2480 | +front of the path, so it will be searched sooner. | |
2184 | 2481 | |
2185 | -For example, here is how you could use breakpoint commands to print the | |
2186 | -value of @code{x} at entry to @code{foo} whenever it is positive. | |
2482 | +@item directory | |
2483 | +Reset the source path to empty again. This requires confirmation. | |
2187 | 2484 | |
2188 | -@example | |
2189 | -break foo if x>0 | |
2190 | -commands | |
2191 | -silent | |
2192 | -echo x is\040 | |
2193 | -output x | |
2194 | -echo \n | |
2195 | -cont | |
2196 | -end | |
2197 | -@end example | |
2485 | +@item info directories | |
2486 | +@kindex info directories | |
2487 | +Print the source path: show which directories it contains. | |
2488 | +@end table | |
2198 | 2489 | |
2199 | -One application for breakpoint commands is to correct one bug so you can | |
2200 | -test another. Put a breakpoint just after the erroneous line of code, give | |
2201 | -it a condition to detect the case in which something erroneous has been | |
2202 | -done, and give it commands to assign correct values to any variables that | |
2203 | -need them. End with the @samp{cont} command so that the program does not | |
2204 | -stop, and start with the @samp{silent} command so that no output is | |
2205 | -produced. Here is an example: | |
2490 | +Because the @samp{directory} command, when used with arguments, adds to | |
2491 | +the front of the source path, it can affect files that _GDBN__ has already | |
2492 | +found. If the source path contains directories that you do not want, | |
2493 | +and these directories contain misleading files with names matching your | |
2494 | +source files, the way to correct the situation is as follows: | |
2206 | 2495 | |
2207 | -@example | |
2208 | -break 403 | |
2209 | -commands | |
2210 | -silent | |
2211 | -set x = y + 4 | |
2212 | -cont | |
2213 | -end | |
2214 | -@end example | |
2496 | +@enumerate | |
2497 | +@item | |
2498 | +Use @samp{directory} with no argument to reset the source path to empty. | |
2215 | 2499 | |
2216 | -One deficiency in the operation of automatically continuing breakpoints | |
2217 | -under Unix appears when your program uses raw mode for the terminal. | |
2218 | -_GDBN__ switches back to its own terminal modes (not raw) before executing | |
2219 | -commands, and then must switch back to raw mode when your program is | |
2220 | -continued. This causes any pending terminal input to be lost. | |
2221 | -In the GNU system, this will be fixed by changing the behavior of | |
2222 | -terminal modes. | |
2500 | +@item | |
2501 | +Use @samp{directory} with suitable arguments to add any other | |
2502 | +directories you want in the source path. You can add all the directories | |
2503 | +in one command. | |
2504 | +@end enumerate | |
2223 | 2505 | |
2224 | -Under Unix, when you have this problem, you might be able to get around | |
2225 | -it by putting your actions into the breakpoint condition instead of | |
2226 | -commands. For example | |
2506 | +@node Data, Symbols, Source, Top | |
2507 | +@chapter Examining Data | |
2508 | + | |
2509 | +@cindex printing data | |
2510 | +@cindex examining data | |
2511 | +@kindex print | |
2512 | +@kindex inspect | |
2513 | +The usual way to examine data in your program is with the @samp{print} | |
2514 | +command (abbreviated @samp{p}), or its synonym @samp{inspect}. It | |
2515 | +evaluates and prints the value of any valid expression of the language | |
2516 | +the program is written in (for now, C or C++). You type | |
2227 | 2517 | |
2228 | 2518 | @example |
2229 | -condition 5 (x = y + 4), 0 | |
2519 | +print @var{exp} | |
2230 | 2520 | @end example |
2231 | 2521 | |
2232 | 2522 | @noindent |
2233 | -specifies a condition expression (@xref{Expressions}) that will change | |
2234 | -@code{x} as needed, then always have the value 0 so the program will not | |
2235 | -stop. Loss of input is avoided here because break conditions are | |
2236 | -evaluated without changing the terminal modes. When you want to have | |
2237 | -nontrivial conditions for performing the side effects, the operators | |
2238 | -@samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful. | |
2239 | - | |
2240 | -@node Error in Breakpoints, , Break Commands, Breakpoints | |
2241 | -@subsection ``Cannot Insert Breakpoints'' | |
2242 | - | |
2243 | -@c FIXME: "cannot insert breakpoints" error, v unclear. | |
2244 | -@c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91 | |
2245 | -Under some operating systems, breakpoints cannot be used in a program if | |
2246 | -any other process is running that program. In this situation, | |
2247 | -attempting to run or continue a program with a breakpoint will cause _GDBN__ | |
2248 | -to stop the other process. | |
2523 | +where @var{exp} is any valid expression (in the source language), and | |
2524 | +the value of @var{exp} is printed in a format appropriate to its data | |
2525 | +type. | |
2249 | 2526 | |
2250 | -When this happens, you have three ways to proceed: | |
2527 | +A more low-level way of examining data is with the @samp{x} command. | |
2528 | +It examines data in memory at a specified address and prints it in a | |
2529 | +specified format. | |
2251 | 2530 | |
2252 | -@enumerate | |
2253 | -@item | |
2254 | -Remove or disable the breakpoints, then continue. | |
2531 | +@menu | |
2532 | +* Expressions:: Expressions that can be computed and printed. | |
2533 | +* Variables:: Using your program's variables in expressions. | |
2534 | +* Arrays:: Examining part of memory as an array. | |
2535 | +* Format options:: Controlling how structures and arrays are printed. | |
2536 | +* Output formats:: Specifying formats for printing values. | |
2537 | +* Auto Display:: Printing certain expressions whenever program stops. | |
2538 | +* Value History:: Referring to values previously printed. | |
2539 | +* Convenience Vars:: Giving names to values for future reference. | |
2540 | +* Registers:: Referring to and storing in machine registers. | |
2541 | +@end menu | |
2255 | 2542 | |
2256 | -@item | |
2257 | -Suspend _GDBN__, and copy the file containing the program to a new name. | |
2258 | -Resume _GDBN__ and use the @samp{exec-file} command to specify that _GDBN__ | |
2259 | -should run the program under that name. Then start the program again. | |
2543 | +@node Expressions, Variables, Data, Data | |
2544 | +@section Expressions | |
2260 | 2545 | |
2261 | -@item | |
2262 | -Relink the program so that the text segment is nonsharable, using the | |
2263 | -linker option @samp{-N}. The operating system limitation may not apply | |
2264 | -to nonsharable executables. | |
2265 | -@end enumerate | |
2546 | +@cindex expressions | |
2547 | +Many different _GDBN__ commands accept an expression and compute its value. | |
2548 | +Any kind of constant, variable or operator defined by the programming | |
2549 | +language you are using is legal in an expression in _GDBN__. This includes | |
2550 | +conditional expressions, function calls, casts and string constants. It | |
2551 | +unfortunately does not include symbols defined by preprocessor | |
2552 | +@code{#define} commands, or C++ expressions involving @samp{::}, the | |
2553 | +name resolution operator. | |
2266 | 2554 | |
2267 | -@node Continuing, Stepping, Breakpoints, Stopping | |
2268 | -@section Continuing | |
2555 | +Casts are supported in all languages, not just in C, because it is so | |
2556 | +useful to cast a number into a pointer so as to examine a structure | |
2557 | +at that address in memory. | |
2269 | 2558 | |
2270 | -After your program stops, most likely you will want it to run some more if | |
2271 | -the bug you are looking for has not happened yet. | |
2559 | +_GDBN__ supports three kinds of operator in addition to those of programming | |
2560 | +languages: | |
2272 | 2561 | |
2273 | 2562 | @table @code |
2274 | -@item continue | |
2275 | -@item cont | |
2276 | -@kindex cont | |
2277 | -@kindex continue | |
2278 | -Continue running the program at the place where it stopped. | |
2279 | -@end table | |
2563 | +@item @@ | |
2564 | +@samp{@@} is a binary operator for treating parts of memory as arrays. | |
2565 | +@xref{Arrays}, for more information. | |
2280 | 2566 | |
2281 | -If the program stopped at a breakpoint, the place to continue running | |
2282 | -is the address of the breakpoint. You might expect that continuing would | |
2283 | -just stop at the same breakpoint immediately. In fact, @samp{cont} | |
2284 | -takes special care to prevent that from happening. You do not need | |
2285 | -to delete the breakpoint to proceed through it after stopping at it. | |
2567 | +@item :: | |
2568 | +@samp{::} allows you to specify a variable in terms of the file or | |
2569 | +function it is defined in. @xref{Variables}. | |
2286 | 2570 | |
2287 | -You can, however, specify an ignore-count for the breakpoint that the | |
2288 | -program stopped at, by means of an argument to the @samp{cont} command. | |
2289 | -@xref{Conditions}. | |
2571 | +@item @{@var{type}@} @var{addr} | |
2572 | +Refers to an object of type @var{type} stored at address @var{addr} in | |
2573 | +memory. @var{addr} may be any expression whose value is an integer or | |
2574 | +pointer (but parentheses are required around nonunary operators, just as in | |
2575 | +a cast). This construct is allowed regardless of what kind of data is | |
2576 | +officially supposed to reside at @var{addr}.@refill | |
2577 | +@end table | |
2290 | 2578 | |
2291 | -If the program stopped because of a signal other than @code{SIGINT} or | |
2292 | -@code{SIGTRAP}, continuing will cause the program to see that signal. | |
2293 | -You may not want this to happen. For example, if the program stopped | |
2294 | -due to some sort of memory reference error, you might store correct | |
2295 | -values into the erroneous variables and continue, hoping to see more | |
2296 | -execution; but the program would probably terminate immediately as | |
2297 | -a result of the fatal signal once it sees the signal. To prevent this, | |
2298 | -you can continue with @samp{signal 0}. @xref{Signaling}. You can | |
2299 | -also act in advance to control what signals your program will see, using | |
2300 | -the @samp{handle} command (@pxref{Signals}). | |
2579 | +@node Variables, Arrays, Expressions, Data | |
2580 | +@section Program Variables | |
2301 | 2581 | |
2302 | -@node Stepping, , Continuing, Stopping | |
2303 | -@section Stepping | |
2582 | +The most common kind of expression to use is the name of a variable | |
2583 | +in your program. | |
2304 | 2584 | |
2305 | -@cindex stepping | |
2306 | -@dfn{Stepping} means setting your program in motion for a limited time, so | |
2307 | -that control will return automatically to the debugger after one line of | |
2308 | -code or one machine instruction. Breakpoints are active during stepping | |
2309 | -and the program will stop for them even if it has not gone as far as the | |
2310 | -stepping command specifies. | |
2585 | +Variables in expressions are understood in the selected stack frame | |
2586 | +(@pxref{Selection}); they must either be global (or static) or be visible | |
2587 | +according to the scope rules of the programming language from the point of | |
2588 | +execution in that frame. This means that in the function | |
2311 | 2589 | |
2312 | -@table @code | |
2313 | -@item step | |
2314 | -@kindex step | |
2315 | -Continue running the program until control reaches a different line, | |
2316 | -then stop it and return control to the debugger. This command is | |
2317 | -abbreviated @samp{s}. | |
2590 | +@example | |
2591 | +foo (a) | |
2592 | + int a; | |
2593 | +@{ | |
2594 | + bar (a); | |
2595 | + @{ | |
2596 | + int b = test (); | |
2597 | + bar (b); | |
2598 | + @} | |
2599 | +@} | |
2600 | +@end example | |
2318 | 2601 | |
2319 | -This command may be given when control is within a function for which | |
2320 | -there is no debugging information. In that case, execution will proceed | |
2321 | -until control reaches a different function, or is about to return from | |
2322 | -this function. An argument repeats this action. | |
2602 | +@noindent | |
2603 | +the variable @code{a} is usable whenever the program is executing | |
2604 | +within the function @code{foo}, but the variable @code{b} is visible | |
2605 | +only while the program is executing inside the block in which @code{b} | |
2606 | +is declared. | |
2323 | 2607 | |
2324 | -@item step @var{count} | |
2325 | -Continue running as in @samp{step}, but do so @var{count} times. If a | |
2326 | -breakpoint is reached or a signal not related to stepping occurs before | |
2327 | -@var{count} steps, stepping stops right away. | |
2608 | +As a special exception, you can refer to a variable or function whose | |
2609 | +scope is a single source file even if the current execution point is not | |
2610 | +in this file. But it is possible to have more than one such variable | |
2611 | +or function with the same name (if they are in different source files). | |
2612 | +In such a case, it is not defined which one you will get. If you wish, | |
2613 | +you can specify any one of them using the colon-colon construct: | |
2328 | 2614 | |
2329 | -@item next | |
2330 | -@kindex next | |
2331 | -Similar to @samp{step}, but any function calls appearing within the line of | |
2332 | -code are executed without stopping. Execution stops when control reaches a | |
2333 | -different line of code at the stack level which was executing when the | |
2334 | -@samp{next} command was given. This command is abbreviated @samp{n}. | |
2615 | +@cindex colon-colon | |
2616 | +@cindex scope | |
2617 | +@kindex :: | |
2618 | +@example | |
2619 | +@var{block}::@var{variable} | |
2620 | +@end example | |
2335 | 2621 | |
2336 | -An argument is a repeat count, as in @samp{step}. | |
2622 | +@noindent | |
2623 | +Here @var{block} is the name of the source file whose variable you want. | |
2337 | 2624 | |
2338 | -@samp{next} within a function without debugging information acts as does | |
2339 | -@samp{step}, but any function calls appearing within the code of the | |
2340 | -function are executed without stopping. | |
2625 | +@cindex name resolution (C++) | |
2626 | +Unfortunately, this use of @samp{::} conflicts with the very similar use | |
2627 | +of the same notation in C++; accordingly, _GDBN__ does not support use of | |
2628 | +the C++ name resolution operator in _GDBN__ expressions. | |
2341 | 2629 | |
2342 | -@item finish | |
2343 | -@kindex finish | |
2344 | -Continue running until just after the selected stack frame returns (or | |
2345 | -until there is some other reason to stop, such as a fatal signal or a | |
2346 | -breakpoint). Print value returned by the selected stack frame (if any). | |
2630 | +@node Arrays, Format options, Variables, Data | |
2631 | +@section Artificial Arrays | |
2347 | 2632 | |
2348 | -Contrast this with the @samp{return} command (@pxref{Returning}). | |
2633 | +@cindex artificial array | |
2634 | +@kindex @@ | |
2635 | +It is often useful to print out several successive objects of the | |
2636 | +same type in memory; a section of an array, or an array of | |
2637 | +dynamically determined size for which only a pointer exists in the | |
2638 | +program. | |
2349 | 2639 | |
2350 | -@item until | |
2351 | -@kindex until | |
2352 | -This command is used to avoid single stepping through a loop more than | |
2353 | -once. It is like the @samp{next} command, except that when @samp{until} | |
2354 | -encounters a jump, it automatically continues execution until the | |
2355 | -program counter is greater than the address of the jump. | |
2640 | +This can be done by constructing an @dfn{artificial array} with the | |
2641 | +binary operator @samp{@@}. The left operand of @samp{@@} should be | |
2642 | +the first element of the desired array, as an individual object. | |
2643 | +The right operand should be the length of the array. The result is | |
2644 | +an array value whose elements are all of the type of the left argument. | |
2645 | +The first element is actually the left argument; the second element | |
2646 | +comes from bytes of memory immediately following those that hold the | |
2647 | +first element, and so on. Here is an example. If a program says | |
2356 | 2648 | |
2357 | -This means that when you reach the end of a loop after single stepping | |
2358 | -though it, @samp{until} will cause the program to continue execution | |
2359 | -until the loop is exited. In contrast, a @samp{next} command at the end | |
2360 | -of a loop will simply step back to the beginning of the loop, which | |
2361 | -would force you to step through the next iteration. | |
2649 | +@example | |
2650 | +int *array = (int *) malloc (len * sizeof (int)); | |
2651 | +@end example | |
2362 | 2652 | |
2363 | -@samp{until} always stops the program if it attempts to exit the current | |
2364 | -stack frame. | |
2653 | +@noindent | |
2654 | +you can print the contents of @code{array} with | |
2365 | 2655 | |
2366 | -@samp{until} may produce somewhat counterintuitive results if the order | |
2367 | -of the source lines does not match the actual order of execution. For | |
2368 | -example, in a typical C @code{for}-loop, the third expression in the | |
2369 | -@code{for}-statement (the loop-step expression) is executed after the | |
2370 | -statements in the body of the loop, but is written before them. | |
2371 | -Therefore, the @samp{until} command would appear to step back to the | |
2372 | -beginning of the loop when it advances to this expression. However, it | |
2373 | -has not really done so, not in terms of the actual machine code. | |
2656 | +@example | |
2657 | +p *array@@len | |
2658 | +@end example | |
2374 | 2659 | |
2375 | -Note that @samp{until} with no argument works by means of single | |
2376 | -instruction stepping, and hence is slower than @samp{until} with an | |
2377 | -argument. | |
2660 | +The left operand of @samp{@@} must reside in memory. Array values made | |
2661 | +with @samp{@@} in this way behave just like other arrays in terms of | |
2662 | +subscripting, and are coerced to pointers when used in expressions. | |
2663 | +(It would probably appear in an expression via the value history, | |
2664 | +after you had printed it out.) | |
2378 | 2665 | |
2379 | -@item until @var{location} | |
2380 | -Continue running the program until either the specified location is | |
2381 | -reached, or the current (innermost) stack frame returns. @var{location} | |
2382 | -is any of the forms of argument acceptable to @samp{break} (@pxref{Set | |
2383 | -Breaks}). This form of the command uses breakpoints, and hence is | |
2384 | -quicker than @samp{until} without an argument. | |
2666 | +@node Format options, Output formats, Arrays, Data | |
2667 | +@section Format options | |
2385 | 2668 | |
2386 | -@item stepi | |
2387 | -@itemx si | |
2388 | -@kindex stepi | |
2389 | -@kindex si | |
2390 | -Execute one machine instruction, then stop and return to the debugger. | |
2669 | +@cindex format options | |
2670 | +_GDBN__ provides a few ways to control how arrays, structures, and symbols are | |
2671 | +printed. | |
2391 | 2672 | |
2392 | -It is often useful to do @samp{display/i $pc} when stepping by machine | |
2393 | -instructions. This will cause the next instruction to be executed to | |
2394 | -be displayed automatically at each stop. @xref{Auto Display}. | |
2673 | +@table @code | |
2674 | +@item set array-max @var{number-of-elements} | |
2675 | +@kindex set array-max | |
2676 | +If _GDBN__ is printing a large array, it will stop printing after it has | |
2677 | +printed the number of elements set by the @samp{set array-max} command. | |
2678 | +This limit also applies to the display of strings. | |
2395 | 2679 | |
2396 | -An argument is a repeat count, as in @samp{step}. | |
2680 | +@item show array-max | |
2681 | +@kindex show array-max | |
2682 | +Display the number of elements of a large array that _GDBN__ will print | |
2683 | +before losing patience. | |
2397 | 2684 | |
2398 | -@item nexti | |
2399 | -@itemx ni | |
2400 | -@kindex nexti | |
2401 | -@kindex ni | |
2402 | -Execute one machine instruction, but if it is a subroutine call, | |
2403 | -proceed until the subroutine returns. | |
2685 | +@item set arrayprint | |
2686 | +@itemx set arrayprint on | |
2687 | +@kindex set arrayprint | |
2688 | +_GDBN__ will pretty print arrays. This format is more convenient to read, | |
2689 | +but uses more space. The default is off. | |
2404 | 2690 | |
2405 | -An argument is a repeat count, as in @samp{next}. | |
2406 | -@end table | |
2691 | +@item set arrayprint off. | |
2692 | +Return to compressed format for arrays. | |
2407 | 2693 | |
2408 | -A typical technique for using stepping is to put a breakpoint | |
2409 | -(@pxref{Breakpoints}) at the beginning of the function or the section of | |
2410 | -the program in which a problem is believed to lie, and then step through | |
2411 | -the suspect area, examining the variables that are interesting, until the | |
2412 | -problem happens. | |
2694 | +@item show arrayprint | |
2695 | +@kindex show arrayprint | |
2696 | +Show whether compressed or pretty format is selected for displaying | |
2697 | +arrays. | |
2413 | 2698 | |
2414 | -The @samp{cont} command can be used after stepping to resume execution | |
2415 | -until the next breakpoint or signal. | |
2699 | +@item set demangle | |
2700 | +@itemx set demangle on | |
2701 | +@kindex set demangle | |
2702 | +Print C++ names in their source form rather than in the mangled form | |
2703 | +in which they are passed to the assembler and linker for type-safe linkage. | |
2704 | +The default is on. | |
2416 | 2705 | |
2417 | -@node Stack, Source, Stopping, Top | |
2418 | -@chapter Examining the Stack | |
2706 | +@item show demangle | |
2707 | +@kindex show demangle | |
2708 | +Show whether C++ names will be printed in mangled or demangled form. | |
2419 | 2709 | |
2420 | -When your program has stopped, the first thing you need to know is where it | |
2421 | -stopped and how it got there. | |
2710 | +@item set asm-demangle | |
2711 | +@itemx set asm-demangle on | |
2712 | +@kindex set asm-demangle | |
2713 | +Print C++ names in their source form rather than their mangled form, even | |
2714 | +in assembler code printouts such as instruction disassemblies. | |
2715 | +The default is off. | |
2716 | + | |
2717 | +@item show asm-demangle | |
2718 | +@kindex show asm-demangle | |
2719 | +Show whether C++ names in assembly listings will be printed in mangled | |
2720 | +or demangled form. | |
2422 | 2721 | |
2423 | -@cindex call stack | |
2424 | -Each time your program performs a function call, the information about | |
2425 | -where in the program the call was made from is saved in a block of data | |
2426 | -called a @dfn{stack frame}. The frame also contains the arguments of the | |
2427 | -call and the local variables of the function that was called. All the | |
2428 | -stack frames are allocated in a region of memory called the @dfn{call | |
2429 | -stack}. | |
2722 | +@item set vtblprint | |
2723 | +@itemx set vtblprint on | |
2724 | +@kindex set vtblprint | |
2725 | +Pretty print C++ virtual function tables. The default is off. | |
2430 | 2726 | |
2431 | -When your program stops, the _GDBN__ commands for examining the stack allow you | |
2432 | -to see all of this information. | |
2727 | +@item set vtblprint off | |
2728 | +Do not pretty print C++ virtual function tables. | |
2433 | 2729 | |
2434 | -One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands | |
2435 | -refer implicitly to the selected frame. In particular, whenever you ask | |
2436 | -_GDBN__ for the value of a variable in the program, the value is found in the | |
2437 | -selected frame. There are special _GDBN__ commands to select whichever frame | |
2438 | -you are interested in. | |
2730 | +@item show vtblprint | |
2731 | +@kindex show vtblprint | |
2732 | +Show whether C++ virtual function tables are pretty printed, or not. | |
2439 | 2733 | |
2440 | -When the program stops, _GDBN__ automatically selects the currently executing | |
2441 | -frame and describes it briefly as the @samp{frame} command does | |
2442 | -(@pxref{Frame Info, Info}). | |
2734 | +@item set addressprint | |
2735 | +@item set addressprint on | |
2736 | +@kindex set addressprint | |
2737 | +_GDBN__ will print memory addresses in stack traces, structure values, pointer | |
2738 | +values, breakpoints, etc. The default is on. | |
2443 | 2739 | |
2444 | -@menu | |
2445 | -* Frames:: Explanation of stack frames and terminology. | |
2446 | -* Backtrace:: Summarizing many frames at once. | |
2447 | -* Selection:: How to select a stack frame. | |
2448 | -* Frame Info:: Information on a Frame | |
2449 | -@end menu | |
2740 | +@item set addressprint off | |
2741 | +Do not print addresses. | |
2450 | 2742 | |
2451 | -@node Frames, Backtrace, Stack, Stack | |
2452 | -@section Stack Frames | |
2743 | +@item show addressprint | |
2744 | +@kindex show addressprint | |
2745 | +Show whether or not addresses are to be printed. | |
2453 | 2746 | |
2454 | -@cindex frame | |
2455 | -@cindex stack frame | |
2456 | -The call stack is divided up into contiguous pieces called @dfn{stack | |
2457 | -frames}, or @dfn{frames} for short; each frame is the data associated | |
2458 | -with one call to one function. The frame contains the arguments given | |
2459 | -to the function, the function's local variables, and the address at | |
2460 | -which the function is executing. | |
2747 | +@item set prettyprint on | |
2748 | +@kindex set prettyprint | |
2749 | +Cause _GDBN__ to print structures in an indented format with one member per | |
2750 | +line, like this: | |
2461 | 2751 | |
2462 | -@cindex initial frame | |
2463 | -@cindex outermost frame | |
2464 | -@cindex innermost frame | |
2465 | -When your program is started, the stack has only one frame, that of the | |
2466 | -function @code{main}. This is called the @dfn{initial} frame or the | |
2467 | -@dfn{outermost} frame. Each time a function is called, a new frame is | |
2468 | -made. Each time a function returns, the frame for that function invocation | |
2469 | -is eliminated. If a function is recursive, there can be many frames for | |
2470 | -the same function. The frame for the function in which execution is | |
2471 | -actually occurring is called the @dfn{innermost} frame. This is the most | |
2472 | -recently created of all the stack frames that still exist. | |
2752 | +@example | |
2753 | +$1 = @{ | |
2754 | + next = 0x0, | |
2755 | + flags = @{ | |
2756 | + sweet = 1, | |
2757 | + sour = 1 | |
2758 | + @}, | |
2759 | + meat = 0x54 "Pork" | |
2760 | +@} | |
2761 | +@end example | |
2473 | 2762 | |
2474 | -@cindex frame pointer | |
2475 | -Inside your program, stack frames are identified by their addresses. A | |
2476 | -stack frame consists of many bytes, each of which has its own address; each | |
2477 | -kind of computer has a convention for choosing one of those bytes whose | |
2478 | -address serves as the address of the frame. Usually this address is kept | |
2479 | -in a register called the @dfn{frame pointer register} while execution is | |
2480 | -going on in that frame. | |
2763 | +@item set prettyprint off | |
2764 | +Cause _GDBN__ to print structures in a compact format, like this: | |
2481 | 2765 | |
2482 | -@cindex frame number | |
2483 | -_GDBN__ assigns numbers to all existing stack frames, starting with zero for | |
2484 | -the innermost frame, one for the frame that called it, and so on upward. | |
2485 | -These numbers do not really exist in your program; they are to give you a | |
2486 | -way of talking about stack frames in _GDBN__ commands. | |
2766 | +@smallexample | |
2767 | +$1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \ | |
2768 | += 0x54 "Pork"@} | |
2769 | +@end smallexample | |
2487 | 2770 | |
2488 | -@cindex selected frame | |
2489 | -Many _GDBN__ commands refer implicitly to one stack frame, called the | |
2490 | -@dfn{selected} stack frame. You can select any frame using one set of | |
2491 | -_GDBN__ commands, and then other commands will operate on that frame. When | |
2492 | -your program stops, _GDBN__ automatically selects the innermost frame. | |
2771 | +@noindent | |
2772 | +This is the default format. | |
2493 | 2773 | |
2494 | -@cindex frameless execution | |
2495 | -Some compilers allow functions to be compiled to run without a frame | |
2496 | -reserved for them on the stack. (For example, the _GCC__ option | |
2497 | -@samp{-fomit-frame-pointer} will generate functions without a frame.) | |
2498 | -This is occasionally done with heavily used library functions to save | |
2499 | -the frame setup time. _GDBN__ has limited facilities for dealing with these | |
2500 | -function invocations; if the innermost function invocation has no stack | |
2501 | -frame, _GDBN__ will give it a virtual stack frame of 0 and correctly allow | |
2502 | -tracing of the function call chain. Results are undefined if a function | |
2503 | -invocation besides the innermost one is frameless. | |
2774 | +@item show prettyprint | |
2775 | +@kindex show prettyprint | |
2776 | +Show which format _GDBN__ will use to print structures. | |
2504 | 2777 | |
2505 | -@node Backtrace, Selection, Frames, Stack | |
2506 | -@section Backtraces | |
2778 | +@item set unionprint on | |
2779 | +@kindex set unionprint | |
2780 | +Tell _GDBN__ to print unions which are contained in structures. This is the | |
2781 | +default setting. | |
2507 | 2782 | |
2508 | -A backtrace is a summary of how the program got where it is. It shows one | |
2509 | -line per frame, for many frames, starting with the currently executing | |
2510 | -frame (frame zero), followed by its caller (frame one), and on up the | |
2511 | -stack. | |
2783 | +@item set unionprint off | |
2784 | +Tell _GDBN__ not to print unions which are contained in structures. | |
2512 | 2785 | |
2513 | -@table @code | |
2514 | -@item backtrace | |
2515 | -@itemx bt | |
2516 | -@kindex backtrace | |
2517 | -@kindex bt | |
2518 | -Print a backtrace of the entire stack: one line per frame for all | |
2519 | -frames in the stack. | |
2786 | +@item show unionprint | |
2787 | +@kindex show unionprint | |
2788 | +Ask _GDBN__ whether or not it will print unions which are contained in | |
2789 | +structures. | |
2520 | 2790 | |
2521 | -You can stop the backtrace at any time by typing the system interrupt | |
2522 | -character, normally @kbd{Control-C}. | |
2791 | +For example, given the declarations | |
2523 | 2792 | |
2524 | -@item backtrace @var{n} | |
2525 | -@itemx bt @var{n} | |
2526 | -Similar, but print only the innermost @var{n} frames. | |
2793 | +@smallexample | |
2794 | +typedef enum @{Tree, Bug@} Species; | |
2795 | +typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms; | |
2796 | +typedef enum @{Caterpillar, Cocoon, Butterfly@} Bug_forms; | |
2527 | 2797 | |
2528 | -@item backtrace @var{-n} | |
2529 | -@itemx bt @var{-n} | |
2530 | -Similar, but print only the outermost @var{n} frames. | |
2531 | -@end table | |
2798 | +struct thing @{ | |
2799 | + Species it; | |
2800 | + union @{ | |
2801 | + Tree_forms tree; | |
2802 | + Bug_forms bug; | |
2803 | + @} form; | |
2804 | +@}; | |
2532 | 2805 | |
2533 | -@kindex where | |
2534 | -@kindex info stack | |
2535 | -The names @samp{where} and @samp{info stack} are additional aliases | |
2536 | -for @samp{backtrace}. | |
2806 | +struct thing foo = @{Tree, @{Acorn@}@}; | |
2807 | +@end smallexample | |
2537 | 2808 | |
2538 | -Every line in the backtrace shows the frame number and the function | |
2539 | -name. The program counter value is also shown---unless you use | |
2540 | -@samp{set addressprint off}. | |
2809 | +@noindent | |
2810 | +with @samp{set unionprint on} in effect @samp{p foo} would print | |
2541 | 2811 | |
2542 | -If the function is in a source file whose symbol table data has been | |
2543 | -fully read, the backtrace shows the source file name and line number, as | |
2544 | -well as the arguments to the function. When the line number is shown, | |
2545 | -the program counter value is omitted if it is at the beginning of the | |
2546 | -code for that line number. | |
2812 | +@smallexample | |
2813 | +$1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@} | |
2814 | +@end smallexample | |
2547 | 2815 | |
2548 | -Here is an example of a backtrace. It was made with the command | |
2549 | -@samp{bt 3}, so it shows the innermost three frames. | |
2816 | +@noindent | |
2817 | +and with @samp{set unionprint off} in effect it would print | |
2550 | 2818 | |
2551 | 2819 | @example |
2552 | -#0 rtx_equal_p (x=(rtx) 0x8e58c, y=(rtx) 0x1086c4) \ | |
2553 | -(/gp/rms/cc/rtlanal.c line 337) | |
2554 | -#1 0x246b0 in expand_call (...) (...) | |
2555 | -#2 0x21cfc in expand_expr (...) (...) | |
2556 | -(More stack frames follow...) | |
2820 | +$1 = @{it = Tree, form = @{...@}@} | |
2557 | 2821 | @end example |
2822 | +@end table | |
2558 | 2823 | |
2559 | -@noindent | |
2560 | -The functions @code{expand_call} and @code{expand_expr} are in a file | |
2561 | -whose symbol details have not been fully read. Full detail is available | |
2562 | -for the function @code{rtx_equal_p}, which is in the file | |
2563 | -@file{rtlanal.c}. Its arguments, named @code{x} and @code{y}, are shown | |
2564 | -with their typed values. | |
2565 | - | |
2566 | -@node Selection, Frame Info, Backtrace, Stack | |
2567 | -@section Selecting a Frame | |
2824 | +@node Output formats, Auto Display, Format options, Data | |
2825 | +@section Output formats | |
2568 | 2826 | |
2569 | -Most commands for examining the stack and other data in the program work on | |
2570 | -whichever stack frame is selected at the moment. Here are the commands for | |
2571 | -selecting a stack frame; all of them finish by printing a brief description | |
2572 | -of the stack frame just selected. | |
2827 | +@cindex formatted output | |
2828 | +@cindex output formats | |
2829 | +_GDBN__ normally prints all values according to their data types. Sometimes | |
2830 | +this is not what you want. For example, you might want to print a number | |
2831 | +in hex, or a pointer in decimal. Or you might want to view data in memory | |
2832 | +at a certain address as a character string or an instruction. These things | |
2833 | +can be done with @dfn{output formats}. | |
2573 | 2834 | |
2574 | -@table @code | |
2575 | -@item frame @var{n} | |
2576 | -@kindex frame | |
2577 | -Select frame number @var{n}. Recall that frame zero is the innermost | |
2578 | -(currently executing) frame, frame one is the frame that called the | |
2579 | -innermost one, and so on. The highest-numbered frame is @code{main}'s | |
2580 | -frame. | |
2835 | +The simplest use of output formats is to say how to print a value | |
2836 | +already computed. This is done by starting the arguments of the | |
2837 | +@samp{print} command with a slash and a format letter. The format | |
2838 | +letters supported are: | |
2581 | 2839 | |
2582 | -@item frame @var{addr} | |
2583 | -Select the frame at address @var{addr}. This is useful mainly if the | |
2584 | -chaining of stack frames has been damaged by a bug, making it | |
2585 | -impossible for _GDBN__ to assign numbers properly to all frames. In | |
2586 | -addition, this can be useful when the program has multiple stacks and | |
2587 | -switches between them. | |
2840 | +@table @samp | |
2841 | +@item x | |
2842 | +Regard the bits of the value as an integer, and print the integer in | |
2843 | +hexadecimal. | |
2588 | 2844 | |
2589 | -@item up @var{n} | |
2590 | -@kindex up | |
2591 | -Select the frame @var{n} frames up from the frame previously selected. | |
2592 | -For positive numbers @var{n}, this advances toward the outermost | |
2593 | -frame, to higher frame numbers, to frames that have existed longer. | |
2594 | -@var{n} defaults to one. | |
2845 | +@item d | |
2846 | +Print as integer in signed decimal. | |
2595 | 2847 | |
2596 | -@item down @var{n} | |
2597 | -@kindex down | |
2598 | -Select the frame @var{n} frames down from the frame previously | |
2599 | -selected. For positive numbers @var{n}, this advances toward the | |
2600 | -innermost frame, to lower frame numbers, to frames that were created | |
2601 | -more recently. @var{n} defaults to one. | |
2602 | -@end table | |
2848 | +@item u | |
2849 | +Print as integer in unsigned decimal. | |
2603 | 2850 | |
2604 | -All of these commands end by printing some information on the frame that | |
2605 | -has been selected: the frame number, the function name, the arguments, the | |
2606 | -source file and line number of execution in that frame, and the text of | |
2607 | -that source line. For example: | |
2851 | +@item o | |
2852 | +Print as integer in octal. | |
2608 | 2853 | |
2854 | +@item a | |
2855 | +Print as an address, both absolute in hex and as an offset from the | |
2856 | +nearest preceding symbol. This format can be used to discover where (in | |
2857 | +what function) an unknown address is located: | |
2609 | 2858 | @example |
2610 | -#3 main (argc=3, argv=??, env=??) at main.c:67 | |
2611 | -67 read_input_file (argv[i]); | |
2859 | +(_GDBP__) p/a 0x54320 | |
2860 | +_0__$3 = 0x54320 <_initialize_vx+396>_1__ | |
2612 | 2861 | @end example |
2613 | 2862 | |
2614 | -After such a printout, the @samp{list} command with no arguments will print | |
2615 | -ten lines centered on the point of execution in the frame. @xref{List}. | |
2616 | 2863 | |
2617 | -@table @code | |
2618 | -@item up-silently @var{n} | |
2619 | -@itemx down-silently @var{n} | |
2620 | -@kindex down-silently | |
2621 | -@kindex up-silently | |
2622 | -These two commands are variants of @samp{up} and @samp{down}, | |
2623 | -respectively; they differ in that they do their work silently, without | |
2624 | -causing display of the new frame. They are intended primarily for use | |
2625 | -in _GDBN__ command scripts, where the output might be unnecessary and | |
2626 | -distracting. | |
2864 | +@item c | |
2865 | +Regard as an integer and print it as a character constant. | |
2627 | 2866 | |
2867 | +@item f | |
2868 | +Regard the bits of the value as a floating point number and print | |
2869 | +using typical floating point syntax. | |
2628 | 2870 | @end table |
2629 | 2871 | |
2630 | -@node Frame Info, , Selection, Stack | |
2631 | -@section Information on a Frame | |
2872 | +For example, to print the program counter in hex (@pxref{Registers}), type | |
2632 | 2873 | |
2633 | -There are several other commands to print information about the selected | |
2634 | -stack frame. | |
2874 | +@example | |
2875 | +p/x $pc | |
2876 | +@end example | |
2635 | 2877 | |
2636 | -@table @code | |
2637 | -@item frame | |
2638 | -When used without any argument, this command does not change which frame | |
2639 | -is selected, but still prints a brief description of the currently | |
2640 | -selected stack frame. It can be abbreviated @samp{f}. With an | |
2641 | -argument, this command is used to select a stack frame; with no | |
2642 | -argument, it does not change which frame is selected, but still prints | |
2643 | -the same kind of information. | |
2878 | +@noindent | |
2879 | +Note that no space is required before the slash; this is because command | |
2880 | +names in _GDBN__ cannot contain a slash. | |
2644 | 2881 | |
2645 | -@item info frame | |
2646 | -@kindex info frame | |
2647 | -This command prints a verbose description of the selected stack frame, | |
2648 | -including the address of the frame, the addresses of the next frame in | |
2649 | -(called by this frame) and the next frame out (caller of this frame), | |
2650 | -the address of the frame's arguments, the program counter saved in it | |
2651 | -(the address of execution in the caller frame), and which registers | |
2652 | -were saved in the frame. The verbose description is useful when | |
2653 | -something has gone wrong that has made the stack format fail to fit | |
2654 | -the usual conventions. | |
2882 | +To reprint the last value in the value history with a different format, | |
2883 | +you can use the @samp{print} command with just a format and no | |
2884 | +expression. For example, @samp{p/x} reprints the last value in hex. | |
2655 | 2885 | |
2656 | -@item info frame @var{addr} | |
2657 | -Print a verbose description of the frame at address @var{addr}, | |
2658 | -without selecting that frame. The selected frame remains unchanged by | |
2659 | -this command. | |
2886 | +@menu | |
2887 | +* Memory:: Examining Memory | |
2888 | +@end menu | |
2660 | 2889 | |
2661 | -@item info args | |
2662 | -@kindex info args | |
2663 | -Print the arguments of the selected frame, each on a separate line. | |
2890 | +@node Memory, , Output formats, Output formats | |
2891 | +@subsection Examining Memory | |
2664 | 2892 | |
2665 | -@item info locals | |
2666 | -@kindex info locals | |
2667 | -Print the local variables of the selected frame, each on a separate | |
2668 | -line. These are all variables declared static or automatic within all | |
2669 | -program blocks that execution in this frame is currently inside of. | |
2893 | +@cindex examining memory | |
2894 | +@table @code | |
2895 | +@kindex disassemble | |
2896 | +@item disassemble | |
2897 | +This specialized command is provided to dump a range of memory as | |
2898 | +machine instructions. The default memory range is the function | |
2899 | +surrounding the program counter of the selected frame. A single | |
2900 | +argument to this command is a program counter value; the function | |
2901 | +surrounding this value will be dumped. Two arguments (separated by one | |
2902 | +or more spaces) specify a range of addresses (first inclusive, second | |
2903 | +exclusive) to be dumped. | |
2670 | 2904 | |
2671 | -@item info catch | |
2672 | -@kindex info catch | |
2673 | -@cindex catch exceptions | |
2674 | -@cindex exception handlers | |
2675 | -Print a list of all the exception handlers that are active in the | |
2676 | -current stack frame given the current value of @code{pc}. To see other | |
2677 | -exception handlers, visit the associated frame (using the @samp{up}, | |
2678 | -@samp{down}, or @samp{frame} commands); then type @samp{info catch}. | |
2679 | -@xref{Exception Handling}. | |
2905 | +@kindex x | |
2906 | +@item x | |
2907 | +The command @samp{x} (for `examine') can be used to examine memory | |
2908 | +without reference to the program's data types. The format in which you | |
2909 | +wish to examine memory is instead explicitly specified. The allowable | |
2910 | +formats are a superset of the formats described in the previous section. | |
2680 | 2911 | @end table |
2681 | 2912 | |
2682 | -@node Source, Data, Stack, Top | |
2683 | -@chapter Examining Source Files | |
2684 | - | |
2685 | -_GDBN__ knows which source files your program was compiled from, and | |
2686 | -can print parts of their text. When your program stops, _GDBN__ | |
2687 | -spontaneously prints the line it stopped in. Likewise, when you | |
2688 | -select a stack frame (@pxref{Selection}), _GDBN__ prints the line | |
2689 | -which execution in that frame has stopped in. You can also | |
2690 | -print parts of source files by explicit command. | |
2691 | - | |
2692 | -@menu | |
2693 | -* List:: Using the @samp{list} command to print source files. | |
2694 | -* Search:: Commands for searching source files. | |
2695 | -* Source Path:: Specifying the directories to search for source files. | |
2696 | -@end menu | |
2913 | +@samp{x} is followed by a slash and an output format specification, | |
2914 | +followed by an expression for an address. The expression need not have | |
2915 | +a pointer value (though it may); it is used as an integer, as the | |
2916 | +address of a byte of memory. @xref{Expressions} for more information on | |
2917 | +expressions. For example, @samp{x/4xw $sp} prints the four words of | |
2918 | +memory above the stack pointer in hexadecimal. | |
2697 | 2919 | |
2698 | -@node List, Search, Source, Source | |
2699 | -@section Printing Source Lines | |
2920 | +The output format in this case specifies both how big a unit of memory | |
2921 | +to examine and how to print the contents of that unit. It is done | |
2922 | +with one or two of the following letters: | |
2700 | 2923 | |
2701 | -@kindex list | |
2702 | -@kindex l | |
2703 | -To print lines from a source file, use the @samp{list} command | |
2704 | -(abbreviated @samp{l}). There are several ways to specify what part | |
2705 | -of the file you want to print. | |
2924 | +These letters specify just the size of unit to examine: | |
2706 | 2925 | |
2707 | -Here are the forms of the @samp{list} command most commonly used: | |
2926 | +@table @samp | |
2927 | +@item b | |
2928 | +Examine individual bytes. | |
2708 | 2929 | |
2709 | -@table @code | |
2710 | -@item list @var{linenum} | |
2711 | -Print ten lines centered around line number @var{linenum} in the | |
2712 | -current source file. | |
2930 | +@item h | |
2931 | +Examine halfwords (two bytes each). | |
2713 | 2932 | |
2714 | -@item list @var{function} | |
2715 | -Print ten lines centered around the beginning of function | |
2716 | -@var{function}. | |
2933 | +@item w | |
2934 | +Examine words (four bytes each). | |
2717 | 2935 | |
2718 | -@item list | |
2719 | -Print ten more lines. If the last lines printed were printed with a | |
2720 | -@samp{list} command, this prints ten lines following the last lines | |
2721 | -printed; however, if the last line printed was a solitary line printed | |
2722 | -as part of displaying a stack frame (@pxref{Stack}), this prints ten | |
2723 | -lines centered around that line. | |
2936 | +@cindex word | |
2937 | +Many assemblers and cpu designers still use `word' for a 16-bit quantity, | |
2938 | +as a holdover from specific predecessor machines of the 1970's that really | |
2939 | +did use two-byte words. But more generally the term `word' has always | |
2940 | +referred to the size of quantity that a machine normally operates on and | |
2941 | +stores in its registers. This is 32 bits for all the machines that _GDBN__ | |
2942 | +runs on. | |
2724 | 2943 | |
2725 | -@item list - | |
2726 | -Print ten lines just before the lines last printed. | |
2944 | +@item g | |
2945 | +Examine giant words (8 bytes). | |
2727 | 2946 | @end table |
2728 | 2947 | |
2729 | -Repeating a @samp{list} command with @key{RET} discards the argument, | |
2730 | -so it is equivalent to typing just @samp{list}. This is more useful | |
2731 | -than listing the same lines again. An exception is made for an | |
2732 | -argument of @samp{-}; that argument is preserved in repetition so that | |
2733 | -each repetition moves up in the file. | |
2948 | +These letters specify just the way to print the contents: | |
2734 | 2949 | |
2735 | -@cindex linespec | |
2736 | -In general, the @samp{list} command expects you to supply zero, one or two | |
2737 | -@dfn{linespecs}. Linespecs specify source lines; there are several ways | |
2738 | -of writing them but the effect is always to specify some source line. | |
2739 | -Here is a complete description of the possible arguments for @samp{list}: | |
2950 | +@table @samp | |
2951 | +@item x | |
2952 | +Print as integers in unsigned hexadecimal. | |
2740 | 2953 | |
2741 | -@table @code | |
2742 | -@item list @var{linespec} | |
2743 | -Print ten lines centered around the line specified by @var{linespec}. | |
2954 | +@item d | |
2955 | +Print as integers in signed decimal. | |
2744 | 2956 | |
2745 | -@item list @var{first},@var{last} | |
2746 | -Print lines from @var{first} to @var{last}. Both arguments are | |
2747 | -linespecs. | |
2957 | +@item u | |
2958 | +Print as integers in unsigned decimal. | |
2748 | 2959 | |
2749 | -@item list ,@var{last} | |
2750 | -Print ten lines ending with @var{last}. | |
2960 | +@item o | |
2961 | +Print as integers in unsigned octal. | |
2751 | 2962 | |
2752 | -@item list @var{first}, | |
2753 | -Print ten lines starting with @var{first}. | |
2963 | +@item a | |
2964 | +Print as an address, both absolute in hex and then relative | |
2965 | +to a symbol defined as an address below it. | |
2754 | 2966 | |
2755 | -@item list + | |
2756 | -Print ten lines just after the lines last printed. | |
2967 | +@item c | |
2968 | +Print as character constants. | |
2757 | 2969 | |
2758 | -@item list - | |
2759 | -Print ten lines just before the lines last printed. | |
2970 | +@item f | |
2971 | +Print as floating point. This works only with sizes @samp{w} and | |
2972 | +@samp{g}. | |
2760 | 2973 | |
2761 | -@item list | |
2762 | -As described in the preceding table. | |
2763 | -@end table | |
2974 | +@item s | |
2975 | +Print a null-terminated string of characters. The specified unit size | |
2976 | +is ignored; instead, the unit is however many bytes it takes to reach | |
2977 | +a null character (including the null character). | |
2764 | 2978 | |
2765 | -Here are the ways of specifying a single source line---all the | |
2766 | -kinds of linespec. | |
2979 | +@item i | |
2980 | +Print a machine instruction in assembler syntax (or nearly). The | |
2981 | +specified unit size is ignored; the number of bytes in an instruction | |
2982 | +varies depending on the type of machine, the opcode and the addressing | |
2983 | +modes used. The command @samp{disassemble} gives an alternative way of | |
2984 | +inspecting machine instructions. | |
2985 | +@end table | |
2767 | 2986 | |
2768 | -@table @code | |
2769 | -@item @var{linenum} | |
2770 | -Specifies line @var{linenum} of the current source file. | |
2771 | -When a @samp{list} command has two linespecs, this refers to | |
2772 | -the same source file as the first linespec. | |
2987 | +If either the manner of printing or the size of unit fails to be specified, | |
2988 | +the default is to use the same one that was used last. If you don't want | |
2989 | +to use any letters after the slash, you can omit the slash as well. | |
2773 | 2990 | |
2774 | -@item +@var{offset} | |
2775 | -Specifies the line @var{offset} lines after the last line printed. | |
2776 | -When used as the second linespec in a @samp{list} command that has | |
2777 | -two, this specifies the line @var{offset} lines down from the | |
2778 | -first linespec. | |
2991 | +You can also omit the address to examine. Then the address used is just | |
2992 | +after the last unit examined. This is why string and instruction | |
2993 | +formats actually compute a unit-size based on the data: so that the next | |
2994 | +string or instruction examined will start in the right place. | |
2779 | 2995 | |
2780 | -@item -@var{offset} | |
2781 | -Specifies the line @var{offset} lines before the last line printed. | |
2996 | +When the @samp{print} command shows a value that resides in memory, | |
2997 | +@samp{print} also sets the default address for the @samp{x} command. | |
2998 | +@samp{info line} also sets the default for @samp{x}, to the address of | |
2999 | +the start of the machine code for the specified line and @samp{info | |
3000 | +breakpoints} sets it to the address of the last breakpoint listed. | |
2782 | 3001 | |
2783 | -@item @var{filename}:@var{linenum} | |
2784 | -Specifies line @var{linenum} in the source file @var{filename}. | |
3002 | +When you use @key{RET} to repeat an @samp{x} command, the address | |
3003 | +specified previously (if any) is ignored, so that the repeated command | |
3004 | +examines the successive locations in memory rather than the same ones. | |
2785 | 3005 | |
2786 | -@item @var{function} | |
2787 | -Specifies the line of the open-brace that begins the body of the | |
2788 | -function @var{function}. | |
3006 | +You can examine several consecutive units of memory with one command by | |
3007 | +writing a repeat-count after the slash (before the format letters, if any). | |
3008 | +The repeat count must be a decimal integer. It has the same effect as | |
3009 | +repeating the @samp{x} command that many times except that the output may | |
3010 | +be more compact with several units per line. For example, | |
2789 | 3011 | |
2790 | -@item @var{filename}:@var{function} | |
2791 | -Specifies the line of the open-brace that begins the body of the | |
2792 | -function @var{function} in the file @var{filename}. The file name is | |
2793 | -needed with a function name only for disambiguation of identically | |
2794 | -named functions in different source files. | |
3012 | +@example | |
3013 | +x/10i $pc | |
3014 | +@end example | |
2795 | 3015 | |
2796 | -@item *@var{address} | |
2797 | -Specifies the line containing the program address @var{address}. | |
2798 | -@var{address} may be any expression. | |
2799 | -@end table | |
3016 | +@noindent | |
3017 | +prints ten instructions starting with the one to be executed next in the | |
3018 | +selected frame. After doing this, you could print another seven following | |
3019 | +instructions with | |
2800 | 3020 | |
2801 | -One other command is used to map source lines to program addresses. | |
3021 | +@example | |
3022 | +x/7 | |
3023 | +@end example | |
2802 | 3024 | |
2803 | -@table @code | |
2804 | -@item info line @var{linenum} | |
2805 | -@kindex info line | |
2806 | -Print the starting and ending addresses of the compiled code for | |
2807 | -source line @var{linenum}. | |
3025 | +@noindent | |
3026 | +in which the format and address are allowed to default. | |
2808 | 3027 | |
2809 | 3028 | @kindex $_ |
2810 | -The default examine address for the @samp{x} command is changed to the | |
2811 | -starting address of the line, so that @samp{x/i} is sufficient to | |
2812 | -begin examining the machine code (@pxref{Memory}). Also, this address | |
2813 | -is saved as the value of the convenience variable @code{$_} | |
2814 | -(@pxref{Convenience Vars}). | |
2815 | -@end table | |
3029 | +@kindex $__ | |
3030 | +The addresses and contents printed by the @samp{x} command are not put in | |
3031 | +the value history because there is often too much of them and they would | |
3032 | +get in the way. Instead, _GDBN__ makes these values available for subsequent | |
3033 | +use in expressions as values of the convenience variables @code{$_} and | |
3034 | +@code{$__}. | |
2816 | 3035 | |
2817 | -@node Search, Source Path, List, Source | |
2818 | -@section Searching Source Files | |
2819 | -@cindex searching | |
2820 | -@kindex search | |
2821 | -@kindex forward-search | |
2822 | -@kindex reverse-search | |
3036 | +After an @samp{x} command, the last address examined is available for use | |
3037 | +in expressions in the convenience variable @code{$_}. The contents of that | |
3038 | +address, as examined, are available in the convenience variable @code{$__}. | |
2823 | 3039 | |
2824 | -There are two commands for searching through the current source file for a | |
2825 | -regular expression. | |
3040 | +If the @samp{x} command has a repeat count, the address and contents saved | |
3041 | +are from the last memory unit printed; this is not the same as the last | |
3042 | +address printed if several units were printed on the last line of output. | |
2826 | 3043 | |
2827 | -The command @samp{forward-search @var{regexp}} checks each line, starting | |
2828 | -with the one following the last line listed, for a match for @var{regexp}. | |
2829 | -It lists the line that is found. You can abbreviate the command name | |
2830 | -as @samp{fo}. The synonym @samp{search @var{regexp}} is also supported. | |
3044 | +@node Auto Display, Value History, Output formats, Data | |
3045 | +@section Automatic Display | |
3046 | +@cindex automatic display | |
3047 | +@cindex display of expressions | |
2831 | 3048 | |
2832 | -The command @samp{reverse-search @var{regexp}} checks each line, starting | |
2833 | -with the one before the last line listed and going backward, for a match | |
2834 | -for @var{regexp}. It lists the line that is found. You can abbreviate | |
2835 | -this command with as little as @samp{rev}. | |
3049 | +If you find that you want to print the value of an expression frequently | |
3050 | +(to see how it changes), you might want to add it to the @dfn{automatic | |
3051 | +display list} so that _GDBN__ will print its value each time the program stops. | |
3052 | +Each expression added to the list is given a number to identify it; | |
3053 | +to remove an expression from the list, you specify that number. | |
3054 | +The automatic display looks like this: | |
2836 | 3055 | |
2837 | -@node Source Path, , Search, Source | |
2838 | -@section Specifying Source Directories | |
3056 | +@example | |
3057 | +2: foo = 38 | |
3058 | +3: bar[5] = (struct hack *) 0x3804 | |
3059 | +@end example | |
2839 | 3060 | |
2840 | -@cindex source path | |
2841 | -@cindex directories for source files | |
2842 | -Executable programs sometimes do not record the directories of the source | |
2843 | -files from which they were compiled, just the names. Even when they do, | |
2844 | -the directories could be moved between the compilation and your debugging | |
2845 | -session. _GDBN__ remembers a list of directories to search for source files; | |
2846 | -this is called the @dfn{source path}. Each time _GDBN__ wants a source file, | |
2847 | -it tries all the directories in the list, in the order they are present | |
2848 | -in the list, until it finds a file with the desired name. Note that | |
2849 | -the executable search path is @emph{not} used for this purpose. Neither is | |
2850 | -the current working directory, unless it happens to be in the source | |
2851 | -path. | |
3061 | +@noindent | |
3062 | +showing item numbers, expressions and their current values. | |
2852 | 3063 | |
2853 | -If it can't find a source file in the source path, and the object program | |
2854 | -records what directory it was compiled in, _GDBN__ tries that directory too. | |
2855 | -If the source path is empty, and there is no record of the compilation | |
2856 | -directory, _GDBN__ will, as a last resort, look in the current directory. | |
3064 | +If the expression refers to local variables, then it does not make sense | |
3065 | +outside the lexical context for which it was set up. Such an expression | |
3066 | +is disabled when execution enters a context where one of its variables | |
3067 | +is not defined. For example, if you give the command | |
3068 | +@samp{display name} while inside a function with an argument | |
3069 | +@code{name}, then this argument will be displayed while the program | |
3070 | +continues to stop inside that function. When it stops elsewhere---where | |
3071 | +there is no variable @samp{name}---display is disabled. The next time | |
3072 | +your program stops where @samp{name} is meaningful, you can enable the | |
3073 | +display expression once again. | |
2857 | 3074 | |
2858 | -Whenever you reset or rearrange the source path, _GDBN__ will clear out | |
2859 | -any information it has cached about where source files are found, where | |
2860 | -each line is in the file, etc. | |
3075 | +@table @code | |
3076 | +@item display @var{exp} | |
3077 | +@kindex display | |
3078 | +Add the expression @var{exp} to the list of expressions to display | |
3079 | +each time the program stops. @xref{Expressions}. | |
2861 | 3080 | |
2862 | -@kindex directory | |
2863 | -When you start _GDBN__, its source path is empty. | |
2864 | -To add other directories, use the @samp{directory} command. | |
3081 | +@item display/@var{fmt} @var{exp} | |
3082 | +For @var{fmt} specifying only a display format and not a size or | |
3083 | +count, add the expression @var{exp} to the auto-display list but | |
3084 | +arranges to display it each time in the specified format @var{fmt}. | |
2865 | 3085 | |
2866 | -@table @code | |
2867 | -@item directory @var{dirnames...} | |
2868 | -Add directory @var{dirname} to the front of the source path. Several | |
2869 | -directory names may be given to this command, separated by whitespace or | |
2870 | -@samp{:}. If a name is already in the source path, it is moved to the | |
2871 | -front of the path, so it will be searched sooner. | |
3086 | +@item display/@var{fmt} @var{addr} | |
3087 | +For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a | |
3088 | +number of units, add the expression @var{addr} as a memory address to | |
3089 | +be examined each time the program stops. Examining means in effect | |
3090 | +doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory}. | |
2872 | 3091 | |
2873 | -@item directory | |
2874 | -Reset the source path to empty again. This requires confirmation. | |
3092 | +@item undisplay @var{dnums}@dots{} | |
3093 | +@itemx delete display @var{dnums}@dots{} | |
3094 | +@kindex delete display | |
3095 | +@kindex undisplay | |
3096 | +Remove item numbers @var{dnums} from the list of expressions to display. | |
2875 | 3097 | |
2876 | -@item info directories | |
2877 | -@kindex info directories | |
2878 | -Print the source path: show which directories it contains. | |
3098 | +@item disable display @var{dnums}@dots{} | |
3099 | +@kindex disable display | |
3100 | +Disable the display of item numbers @var{dnums}. A disabled display | |
3101 | +item is not printed automatically, but is not forgotten. It may be | |
3102 | +enabled again later. | |
3103 | + | |
3104 | +@item enable display @var{dnums}@dots{} | |
3105 | +@kindex enable display | |
3106 | +Enable display of item numbers @var{dnums}. It becomes effective once | |
3107 | +again in auto display of its expression, until you specify otherwise. | |
3108 | + | |
3109 | +@item display | |
3110 | +Display the current values of the expressions on the list, just as is | |
3111 | +done when the program stops. | |
3112 | + | |
3113 | +@item info display | |
3114 | +@kindex info display | |
3115 | +Print the list of expressions previously set up to display | |
3116 | +automatically, each one with its item number, but without showing the | |
3117 | +values. This includes disabled expressions, which are marked as such. | |
3118 | +It also includes expressions which would not be displayed right now | |
3119 | +because they refer to automatic variables not currently available. | |
2879 | 3120 | @end table |
2880 | 3121 | |
2881 | -Because the @samp{directory} command, when used with arguments, adds to | |
2882 | -the front of the source path, it can affect files that _GDBN__ has already | |
2883 | -found. If the source path contains directories that you do not want, | |
2884 | -and these directories contain misleading files with names matching your | |
2885 | -source files, the way to correct the situation is as follows: | |
3122 | +@node Value History, Convenience Vars, Auto Display, Data | |
3123 | +@section Value History | |
2886 | 3124 | |
2887 | -@enumerate | |
2888 | -@item | |
2889 | -Use @samp{directory} with no argument to reset the source path to empty. | |
3125 | +@cindex value history | |
3126 | +Values printed by the @samp{print} command are saved in _GDBN__'s @dfn{value | |
3127 | +history} so that you can refer to them in other expressions. Values are | |
3128 | +kept until the symbol table is re-read or discarded (for example with | |
3129 | +the @samp{file} or @samp{symbol-file} commands). When the symbol table | |
3130 | +changes, the value history is discarded, since the values may contain | |
3131 | +pointers back to the types defined in the symbol table. | |
2890 | 3132 | |
2891 | -@item | |
2892 | -Use @samp{directory} with suitable arguments to add any other | |
2893 | -directories you want in the source path. You can add all the directories | |
2894 | -in one command. | |
2895 | -@end enumerate | |
3133 | +@cindex @code{$} | |
3134 | +@cindex @code{$$} | |
3135 | +@cindex history number | |
3136 | +The values printed are given @dfn{history numbers} for you to refer to them | |
3137 | +by. These are successive integers starting with 1. @samp{print} shows you | |
3138 | +the history number assigned to a value by printing @samp{$@var{num} = } | |
3139 | +before the value; here @var{num} is the history number. | |
2896 | 3140 | |
2897 | -@node Data, Symbols, Source, Top | |
2898 | -@chapter Examining Data | |
3141 | +To refer to any previous value, use @samp{$} followed by the value's | |
3142 | +history number. The output printed by @samp{print} is designed to | |
3143 | +remind you of this. Just @code{$} refers to the most recent value in | |
3144 | +the history, and @code{$$} refers to the value before that. | |
3145 | +@code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2} | |
3146 | +is the value just prior to @code{$$}, @code{$$1} is equivalent to | |
3147 | +@code{$$}, and @code{$$0} is equivalent to @code{$}. | |
2899 | 3148 | |
2900 | -@cindex printing data | |
2901 | -@cindex examining data | |
2902 | -@kindex print | |
2903 | -@kindex inspect | |
2904 | -The usual way to examine data in your program is with the @samp{print} | |
2905 | -command (abbreviated @samp{p}), or its synonym @samp{inspect}. It | |
2906 | -evaluates and prints the value of any valid expression of the language | |
2907 | -the program is written in (for now, C or C++). You type | |
3149 | +For example, suppose you have just printed a pointer to a structure and | |
3150 | +want to see the contents of the structure. It suffices to type | |
2908 | 3151 | |
2909 | 3152 | @example |
2910 | -print @var{exp} | |
3153 | +p *$ | |
2911 | 3154 | @end example |
2912 | 3155 | |
2913 | -@noindent | |
2914 | -where @var{exp} is any valid expression (in the source language), and | |
2915 | -the value of @var{exp} is printed in a format appropriate to its data | |
2916 | -type. | |
2917 | - | |
2918 | -A more low-level way of examining data is with the @samp{x} command. | |
2919 | -It examines data in memory at a specified address and prints it in a | |
2920 | -specified format. | |
3156 | +If you have a chain of structures where the component @samp{next} points | |
3157 | +to the next one, you can print the contents of the next one with this: | |
2921 | 3158 | |
2922 | -@menu | |
2923 | -* Expressions:: Expressions that can be computed and printed. | |
2924 | -* Variables:: Using your program's variables in expressions. | |
2925 | -* Arrays:: Examining part of memory as an array. | |
2926 | -* Format options:: Controlling how structures and arrays are printed. | |
2927 | -* Output formats:: Specifying formats for printing values. | |
2928 | -* Auto Display:: Printing certain expressions whenever program stops. | |
2929 | -* Value History:: Referring to values previously printed. | |
2930 | -* Convenience Vars:: Giving names to values for future reference. | |
2931 | -* Registers:: Referring to and storing in machine registers. | |
2932 | -@end menu | |
3159 | +@example | |
3160 | +p *$.next | |
3161 | +@end example | |
2933 | 3162 | |
2934 | -@node Expressions, Variables, Data, Data | |
2935 | -@section Expressions | |
3163 | +@noindent | |
3164 | +It might be useful to repeat this command many times by typing @key{RET}. | |
2936 | 3165 | |
2937 | -@cindex expressions | |
2938 | -Many different _GDBN__ commands accept an expression and compute its value. | |
2939 | -Any kind of constant, variable or operator defined by the programming | |
2940 | -language you are using is legal in an expression in _GDBN__. This includes | |
2941 | -conditional expressions, function calls, casts and string constants. It | |
2942 | -unfortunately does not include symbols defined by preprocessor | |
2943 | -@code{#define} commands, or C++ expressions involving @samp{::}, the | |
2944 | -name resolution operator. | |
3166 | +Note that the history records values, not expressions. If the value of | |
3167 | +@code{x} is 4 and you type this command: | |
2945 | 3168 | |
2946 | -Casts are supported in all languages, not just in C, because it is so | |
2947 | -useful to cast a number into a pointer so as to examine a structure | |
2948 | -at that address in memory. | |
3169 | +@example | |
3170 | +print x | |
3171 | +set x=5 | |
3172 | +@end example | |
2949 | 3173 | |
2950 | -_GDBN__ supports three kinds of operator in addition to those of programming | |
2951 | -languages: | |
3174 | +@noindent | |
3175 | +then the value recorded in the value history by the @samp{print} command | |
3176 | +remains 4 even though the value of @code{x} has changed. | |
2952 | 3177 | |
2953 | 3178 | @table @code |
2954 | -@item @@ | |
2955 | -@samp{@@} is a binary operator for treating parts of memory as arrays. | |
2956 | -@xref{Arrays}, for more information. | |
3179 | +@kindex info values | |
3180 | +@item info values | |
3181 | +@itemx info history | |
3182 | +@kindex info history | |
3183 | +These two commands are synonymous. Either form will print the last ten | |
3184 | +values in the value history, with their item numbers. This is like | |
3185 | +@samp{p@ $$9} repeated ten times, except that @samp{info values} does | |
3186 | +not change the history. | |
2957 | 3187 | |
2958 | -@item :: | |
2959 | -@samp{::} allows you to specify a variable in terms of the file or | |
2960 | -function it is defined in. @xref{Variables}. | |
3188 | +@item info values @var{n} | |
3189 | +Print ten history values centered on history item number @var{n}. | |
2961 | 3190 | |
2962 | -@item @{@var{type}@} @var{addr} | |
2963 | -Refers to an object of type @var{type} stored at address @var{addr} in | |
2964 | -memory. @var{addr} may be any expression whose value is an integer or | |
2965 | -pointer (but parentheses are required around nonunary operators, just as in | |
2966 | -a cast). This construct is allowed regardless of what kind of data is | |
2967 | -officially supposed to reside at @var{addr}.@refill | |
3191 | +@item info values + | |
3192 | +Print ten history values just after the values last printed. | |
2968 | 3193 | @end table |
2969 | 3194 | |
2970 | -@node Variables, Arrays, Expressions, Data | |
2971 | -@section Program Variables | |
3195 | +@node Convenience Vars, Registers, Value History, Data | |
3196 | +@section Convenience Variables | |
2972 | 3197 | |
2973 | -The most common kind of expression to use is the name of a variable | |
2974 | -in your program. | |
3198 | +@cindex convenience variables | |
3199 | +_GDBN__ provides @dfn{convenience variables} that you can use within _GDBN__ to | |
3200 | +hold on to a value and refer to it later. These variables exist entirely | |
3201 | +within _GDBN__; they are not part of your program, and setting a convenience | |
3202 | +variable has no effect on further execution of your program. That's why | |
3203 | +you can use them freely. | |
2975 | 3204 | |
2976 | -Variables in expressions are understood in the selected stack frame | |
2977 | -(@pxref{Selection}); they must either be global (or static) or be visible | |
2978 | -according to the scope rules of the programming language from the point of | |
2979 | -execution in that frame. This means that in the function | |
3205 | +Convenience variables have names starting with @samp{$}. Any name starting | |
3206 | +with @samp{$} can be used for a convenience variable, unless it is one of | |
3207 | +the predefined set of register names (@pxref{Registers}). | |
3208 | + | |
3209 | +You can save a value in a convenience variable with an assignment | |
3210 | +expression, just as you would set a variable in your program. Example: | |
2980 | 3211 | |
2981 | 3212 | @example |
2982 | -foo (a) | |
2983 | - int a; | |
2984 | -@{ | |
2985 | - bar (a); | |
2986 | - @{ | |
2987 | - int b = test (); | |
2988 | - bar (b); | |
2989 | - @} | |
2990 | -@} | |
3213 | +set $foo = *object_ptr | |
2991 | 3214 | @end example |
2992 | 3215 | |
2993 | 3216 | @noindent |
2994 | -the variable @code{a} is usable whenever the program is executing | |
2995 | -within the function @code{foo}, but the variable @code{b} is visible | |
2996 | -only while the program is executing inside the block in which @code{b} | |
2997 | -is declared. | |
3217 | +would save in @code{$foo} the value contained in the object pointed to by | |
3218 | +@code{object_ptr}. | |
2998 | 3219 | |
2999 | -As a special exception, you can refer to a variable or function whose | |
3000 | -scope is a single source file even if the current execution point is not | |
3001 | -in this file. But it is possible to have more than one such variable | |
3002 | -or function with the same name (if they are in different source files). | |
3003 | -In such a case, it is not defined which one you will get. If you wish, | |
3004 | -you can specify any one of them using the colon-colon construct: | |
3220 | +Using a convenience variable for the first time creates it; but its value | |
3221 | +is @code{void} until you assign a new value. You can alter the value with | |
3222 | +another assignment at any time. | |
3005 | 3223 | |
3006 | -@cindex colon-colon | |
3007 | -@cindex scope | |
3008 | -@kindex :: | |
3009 | -@example | |
3010 | -@var{block}::@var{variable} | |
3011 | -@end example | |
3224 | +Convenience variables have no fixed types. You can assign a convenience | |
3225 | +variable any type of value, including structures and arrays, even if | |
3226 | +that variable already has a value of a different type. The convenience | |
3227 | +variable as an expression has whatever type its current value has. | |
3012 | 3228 | |
3013 | -@noindent | |
3014 | -Here @var{block} is the name of the source file whose variable you want. | |
3229 | +@table @code | |
3230 | +@item info convenience | |
3231 | +@kindex info convenience | |
3232 | +Print a list of convenience variables used so far, and their values. | |
3233 | +Abbreviated @samp{i con}. | |
3234 | +@end table | |
3015 | 3235 | |
3016 | -@cindex name resolution (C++) | |
3017 | -Unfortunately, this use of @samp{::} conflicts with the very similar use | |
3018 | -of the same notation in C++; accordingly, _GDBN__ does not support use of | |
3019 | -the C++ name resolution operator in _GDBN__ expressions. | |
3236 | +One of the ways to use a convenience variable is as a counter to be | |
3237 | +incremented or a pointer to be advanced. For example: | |
3020 | 3238 | |
3021 | -@node Arrays, Format options, Variables, Data | |
3022 | -@section Artificial Arrays | |
3239 | +_0__@example | |
3240 | +set $i = 0 | |
3241 | +print bar[$i++]->contents | |
3242 | +@i{@dots{}repeat that command by typing @key{RET}.} | |
3243 | +_1__@end example | |
3023 | 3244 | |
3024 | -@cindex artificial array | |
3025 | -@kindex @@ | |
3026 | -It is often useful to print out several successive objects of the | |
3027 | -same type in memory; a section of an array, or an array of | |
3028 | -dynamically determined size for which only a pointer exists in the | |
3029 | -program. | |
3245 | +Some convenience variables are created automatically by _GDBN__ and given | |
3246 | +values likely to be useful. | |
3030 | 3247 | |
3031 | -This can be done by constructing an @dfn{artificial array} with the | |
3032 | -binary operator @samp{@@}. The left operand of @samp{@@} should be | |
3033 | -the first element of the desired array, as an individual object. | |
3034 | -The right operand should be the length of the array. The result is | |
3035 | -an array value whose elements are all of the type of the left argument. | |
3036 | -The first element is actually the left argument; the second element | |
3037 | -comes from bytes of memory immediately following those that hold the | |
3038 | -first element, and so on. Here is an example. If a program says | |
3248 | +@table @code | |
3249 | +@item $_ | |
3250 | +The variable @code{$_} is automatically set by the @samp{x} command to | |
3251 | +the last address examined (@pxref{Memory}). Other commands which | |
3252 | +provide a default address for @samp{x} to examine also set @code{$_} | |
3253 | +to that address; these commands include @samp{info line} and @samp{info | |
3254 | +breakpoint}. | |
3039 | 3255 | |
3040 | -@example | |
3041 | -int *array = (int *) malloc (len * sizeof (int)); | |
3042 | -@end example | |
3256 | +@item $__ | |
3257 | +The variable @code{$__} is automatically set by the @samp{x} command | |
3258 | +to the value found in the last address examined. | |
3259 | +@end table | |
3043 | 3260 | |
3044 | -@noindent | |
3045 | -you can print the contents of @code{array} with | |
3261 | +@node Registers, , Convenience Vars, Data | |
3262 | +@section Registers | |
3046 | 3263 | |
3047 | -@example | |
3048 | -p *array@@len | |
3049 | -@end example | |
3264 | +@cindex registers | |
3265 | +Machine register contents can be referred to in expressions as variables | |
3266 | +with names starting with @samp{$}. The names of registers are different | |
3267 | +for each machine; use @samp{info registers} to see the names used on your | |
3268 | +machine. The names @code{$pc} and @code{$sp} are used on most machines for | |
3269 | +the program counter register and the stack pointer. Often @code{$fp} is | |
3270 | +used for a register that contains a pointer to the current stack frame, | |
3271 | +and @code{$ps} is used for a register that contains the processor | |
3272 | +status. These standard register names may be available on your machine | |
3273 | +even though the @code{info registers} command displays them with a | |
3274 | +different name. For example, on the SPARC, @code{info registers} | |
3275 | +displays the processor status register as @code{$psr} but you can also | |
3276 | +refer to it as @code{$ps}. | |
3050 | 3277 | |
3051 | -The left operand of @samp{@@} must reside in memory. Array values made | |
3052 | -with @samp{@@} in this way behave just like other arrays in terms of | |
3053 | -subscripting, and are coerced to pointers when used in expressions. | |
3054 | -(It would probably appear in an expression via the value history, | |
3055 | -after you had printed it out.) | |
3278 | +_GDBN__ always considers the contents of an ordinary register as an integer | |
3279 | +when the register is examined in this way. Some machines have special | |
3280 | +registers which can hold nothing but floating point; these registers are | |
3281 | +considered floating point. There is no way to refer to the contents of an | |
3282 | +ordinary register as floating point value (although you can @emph{print} | |
3283 | +it as a floating point value with @samp{print/f $@var{regname}}). | |
3056 | 3284 | |
3057 | -@node Format options, Output formats, Arrays, Data | |
3058 | -@section Format options | |
3285 | +Some registers have distinct ``raw'' and ``virtual'' data formats. This | |
3286 | +means that the data format in which the register contents are saved by | |
3287 | +the operating system is not the same one that your program normally | |
3288 | +sees. For example, the registers of the 68881 floating point | |
3289 | +coprocessor are always saved in ``extended'' (raw) format, but all C | |
3290 | +programs expect to work with ``double'' (virtual) format. In such | |
3291 | +cases, _GDBN__ normally works with the virtual format only (the format that | |
3292 | +makes sense for your program), but the @samp{info registers} command | |
3293 | +prints the data in both formats. | |
3059 | 3294 | |
3060 | -@cindex format options | |
3061 | -_GDBN__ provides a few ways to control how arrays, structures, and symbols are | |
3062 | -printed. | |
3295 | +Register values are relative to the selected stack frame | |
3296 | +(@pxref{Selection}). This means that you get the value that the register | |
3297 | +would contain if all stack frames farther in were exited and their saved | |
3298 | +registers restored. In order to see the real contents of all registers, | |
3299 | +you must select the innermost frame (with @samp{frame 0}). | |
3300 | + | |
3301 | +Some registers are never saved (typically those numbered zero or one) | |
3302 | +because they are used for returning function values. In some operating | |
3303 | +systems (those using the ``caller saves'' convention), there are other | |
3304 | +registers intended for free alteration by a called routine. For these | |
3305 | +registers, relativization makes no difference. | |
3063 | 3306 | |
3064 | 3307 | @table @code |
3065 | -@item set array-max @var{number-of-elements} | |
3066 | -@kindex set array-max | |
3067 | -If _GDBN__ is printing a large array, it will stop printing after it has | |
3068 | -printed the number of elements set by the @samp{set array-max} command. | |
3069 | -This limit also applies to the display of strings. | |
3308 | +@item info registers | |
3309 | +@kindex info registers | |
3310 | +Print the names and relativized values of all registers. | |
3070 | 3311 | |
3071 | -@item show array-max | |
3072 | -@kindex show array-max | |
3073 | -Display the number of elements of a large array that _GDBN__ will print | |
3074 | -before losing patience. | |
3312 | +@item info registers @var{regname} | |
3313 | +Print the relativized value of register @var{regname}. @var{regname} | |
3314 | +may be any register name valid on the machine you are using, with | |
3315 | +or without the initial @samp{$}. | |
3316 | +@end table | |
3075 | 3317 | |
3076 | -@item set arrayprint | |
3077 | -@itemx set arrayprint on | |
3078 | -@kindex set arrayprint | |
3079 | -_GDBN__ will pretty print arrays. This format is more convenient to read, | |
3080 | -but uses more space. The default is off. | |
3318 | +@subsection Examples | |
3081 | 3319 | |
3082 | -@item set arrayprint off. | |
3083 | -Return to compressed format for arrays. | |
3320 | +You could print the program counter in hex with | |
3084 | 3321 | |
3085 | -@item show arrayprint | |
3086 | -@kindex show arrayprint | |
3087 | -Show whether compressed or pretty format is selected for displaying | |
3088 | -arrays. | |
3322 | +@example | |
3323 | +p/x $pc | |
3324 | +@end example | |
3089 | 3325 | |
3090 | -@item set demangle | |
3091 | -@itemx set demangle on | |
3092 | -@kindex set demangle | |
3093 | -Print C++ names in their source form rather than in the mangled form | |
3094 | -in which they are passed to the assembler and linker for type-safe linkage. | |
3095 | -The default is on. | |
3326 | +@noindent | |
3327 | +or print the instruction to be executed next with | |
3096 | 3328 | |
3097 | -@item show demangle | |
3098 | -@kindex show demangle | |
3099 | -Show whether C++ names will be printed in mangled or demangled form. | |
3329 | +@example | |
3330 | +x/i $pc | |
3331 | +@end example | |
3100 | 3332 | |
3101 | -@item set asm-demangle | |
3102 | -@itemx set asm-demangle on | |
3103 | -@kindex set asm-demangle | |
3104 | -Print C++ names in their source form rather than their mangled form, even | |
3105 | -in assembler code printouts such as instruction disassemblies. | |
3106 | -The default is off. | |
3333 | +@noindent | |
3334 | +or add four to the stack pointer with | |
3107 | 3335 | |
3108 | -@item show asm-demangle | |
3109 | -@kindex show asm-demangle | |
3110 | -Show whether C++ names in assembly listings will be printed in mangled | |
3111 | -or demangled form. | |
3336 | +@example | |
3337 | +set $sp += 4 | |
3338 | +@end example | |
3339 | + | |
3340 | +@noindent | |
3341 | +The last is a way of removing one word from the stack, on machines where | |
3342 | +stacks grow downward in memory (most machines, nowadays). This assumes | |
3343 | +that the innermost stack frame is selected. Setting @code{$sp} is | |
3344 | +not allowed when other stack frames are selected. (To pop entire frames | |
3345 | +off the stack, regardless of machine architecture, use @samp{return}; | |
3346 | +@pxref{Returning}.) | |
3112 | 3347 | |
3113 | -@item set vtblprint | |
3114 | -@itemx set vtblprint on | |
3115 | -@kindex set vtblprint | |
3116 | -Pretty print C++ virtual function tables. The default is off. | |
3348 | +@node Symbols, Altering, Data, Top | |
3349 | +@chapter Examining the Symbol Table | |
3117 | 3350 | |
3118 | -@item set vtblprint off | |
3119 | -Do not pretty print C++ virtual function tables. | |
3351 | +The commands described in this section allow you to inquire about the | |
3352 | +symbols (names of variables, functions and types) defined in your | |
3353 | +program. This information is found by _GDBN__ in the symbol table loaded by | |
3354 | +the @samp{symbol-file} command; it is inherent in the text of your | |
3355 | +program and does not change as the program executes. | |
3120 | 3356 | |
3121 | -@item show vtblprint | |
3122 | -@kindex show vtblprint | |
3123 | -Show whether C++ virtual function tables are pretty printed, or not. | |
3357 | +@table @code | |
3358 | +@item info address @var{symbol} | |
3359 | +@kindex info address | |
3360 | +Describe where the data for @var{symbol} is stored. For a register | |
3361 | +variable, this says which register it is kept in. For a non-register | |
3362 | +local variable, this prints the stack-frame offset at which the variable | |
3363 | +is always stored. | |
3124 | 3364 | |
3125 | -@item set addressprint | |
3126 | -@item set addressprint on | |
3127 | -@kindex set addressprint | |
3128 | -_GDBN__ will print memory addresses in stack traces, structure values, pointer | |
3129 | -values, breakpoints, etc. The default is on. | |
3365 | +Note the contrast with @samp{print &@var{symbol}}, which does not work | |
3366 | +at all for a register variables, and for a stack local variable prints | |
3367 | +the exact address of the current instantiation of the variable. | |
3130 | 3368 | |
3131 | -@item set addressprint off | |
3132 | -Do not print addresses. | |
3369 | +@item whatis @var{exp} | |
3370 | +@kindex whatis | |
3371 | +Print the data type of expression @var{exp}. @var{exp} is not | |
3372 | +actually evaluated, and any side-effecting operations (such as | |
3373 | +assignments or function calls) inside it do not take place. | |
3374 | +@xref{Expressions}. | |
3133 | 3375 | |
3134 | -@item show addressprint | |
3135 | -@kindex show addressprint | |
3136 | -Show whether or not addresses are to be printed. | |
3376 | +@item whatis | |
3377 | +Print the data type of @code{$}, the last value in the value history. | |
3137 | 3378 | |
3138 | -@item set prettyprint on | |
3139 | -@kindex set prettyprint | |
3140 | -Cause _GDBN__ to print structures in an indented format with one member per | |
3141 | -line, like this: | |
3379 | +@item ptype @var{typename} | |
3380 | +@kindex ptype | |
3381 | +Print a description of data type @var{typename}. @var{typename} may be | |
3382 | +the name of a type, or for C code it may have the form | |
3383 | +@samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or | |
3384 | +@samp{enum @var{enum-tag}}.@refill | |
3142 | 3385 | |
3143 | -@example | |
3144 | -$1 = @{ | |
3145 | - next = 0x0, | |
3146 | - flags = @{ | |
3147 | - sweet = 1, | |
3148 | - sour = 1 | |
3149 | - @}, | |
3150 | - meat = 0x54 "Pork" | |
3151 | -@} | |
3152 | -@end example | |
3386 | +@item ptype @var{exp} | |
3387 | +Print a description of the type of expression @var{exp}. This is like | |
3388 | +@samp{whatis} except it prints a detailed description, instead of just | |
3389 | +the name of the type. For example, if the type of a variable is | |
3390 | +@samp{struct complex @{double real; double imag;@}}, @samp{whatis} will | |
3391 | +print @samp{struct complex} and @samp{ptype} will print @samp{struct | |
3392 | +complex @{double real; double imag;@}} | |
3153 | 3393 | |
3154 | -@item set prettyprint off | |
3155 | -Cause _GDBN__ to print structures in a compact format, like this: | |
3394 | +@item info sources | |
3395 | +@kindex info sources | |
3396 | +Print the names of all source files in the program for which there | |
3397 | +is debugging information. | |
3156 | 3398 | |
3157 | -@smallexample | |
3158 | -$1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \ | |
3159 | -= 0x54 "Pork"@} | |
3160 | -@end smallexample | |
3399 | +@item info functions | |
3400 | +@kindex info functions | |
3401 | +Print the names and data types of all defined functions. | |
3161 | 3402 | |
3162 | -@noindent | |
3163 | -This is the default format. | |
3403 | +@item info functions @var{regexp} | |
3404 | +Print the names and data types of all defined functions | |
3405 | +whose names contain a match for regular expression @var{regexp}. | |
3406 | +Thus, @samp{info fun step} finds all functions whose names | |
3407 | +include @samp{step}; @samp{info fun ^step} finds those whose names | |
3408 | +start with @samp{step}. | |
3164 | 3409 | |
3165 | -@item show prettyprint | |
3166 | -@kindex show prettyprint | |
3167 | -Show which format _GDBN__ will use to print structures. | |
3410 | +@item info variables | |
3411 | +@kindex info variables | |
3412 | +Print the names and data types of all variables that are declared | |
3413 | +outside of functions (i.e., except for local variables). | |
3168 | 3414 | |
3169 | -@item set unionprint on | |
3170 | -@kindex set unionprint | |
3171 | -Tell _GDBN__ to print unions which are contained in structures. This is the | |
3172 | -default setting. | |
3415 | +@item info variables @var{regexp} | |
3416 | +Print the names and data types of all variables (except for local | |
3417 | +variables) whose names contain a match for regular expression | |
3418 | +@var{regexp}. | |
3173 | 3419 | |
3174 | -@item set unionprint off | |
3175 | -Tell _GDBN__ not to print unions which are contained in structures. | |
3176 | 3420 | |
3177 | -@item show unionprint | |
3178 | -@kindex show unionprint | |
3179 | -Ask _GDBN__ whether or not it will print unions which are contained in | |
3180 | -structures. | |
3421 | +@ignore | |
3422 | +This was never implemented. | |
3423 | +@item info methods | |
3424 | +@itemx info methods @var{regexp} | |
3425 | +@kindex info methods | |
3426 | +The @samp{info-methods} command permits the user to examine all defined | |
3427 | +methods within C++ program, or (with the @var{regexp} argument) a | |
3428 | +specific set of methods found in the various C++ classes. Many | |
3429 | +C++ classes provide a large number of methods. Thus, the output | |
3430 | +from the @samp{ptype} command can be overwhelming and hard to use. The | |
3431 | +@samp{info-methods} command filters the methods, printing only those | |
3432 | +which match the regular-expression @var{regexp}. | |
3433 | +@end ignore | |
3181 | 3434 | |
3182 | -For example, given the declarations | |
3435 | +@item printsyms @var{filename} | |
3436 | +@kindex printsyms | |
3437 | +Write a complete dump of the debugger's symbol data into the | |
3438 | +file @var{filename}. | |
3439 | +@end table | |
3183 | 3440 | |
3184 | -@smallexample | |
3185 | -typedef enum @{Tree, Bug@} Species; | |
3186 | -typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms; | |
3187 | -typedef enum @{Caterpillar, Cocoon, Butterfly@} Bug_forms; | |
3441 | +@node Altering, Sequences, Symbols, Top | |
3442 | +@chapter Altering Execution | |
3188 | 3443 | |
3189 | -struct thing @{ | |
3190 | - Species it; | |
3191 | - union @{ | |
3192 | - Tree_forms tree; | |
3193 | - Bug_forms bug; | |
3194 | - @} form; | |
3195 | -@}; | |
3444 | +Once you think you have found an error in the program, you might want to | |
3445 | +find out for certain whether correcting the apparent error would lead to | |
3446 | +correct results in the rest of the run. You can find the answer by | |
3447 | +experiment, using the _GDBN__ features for altering execution of the | |
3448 | +program. | |
3196 | 3449 | |
3197 | -struct thing foo = @{Tree, @{Acorn@}@}; | |
3198 | -@end smallexample | |
3450 | +For example, you can store new values into variables or memory | |
3451 | +locations, give the program a signal, restart it at a different address, | |
3452 | +or even return prematurely from a function to its caller. | |
3199 | 3453 | |
3200 | -@noindent | |
3201 | -with @samp{set unionprint on} in effect @samp{p foo} would print | |
3454 | +@menu | |
3455 | +* Assignment:: Altering variable values or memory contents. | |
3456 | +* Jumping:: Altering control flow. | |
3457 | +* Signaling:: Making signals happen in the program. | |
3458 | +* Returning:: Making a function return prematurely. | |
3459 | +* Calling:: Calling functions from your program | |
3460 | +@end menu | |
3202 | 3461 | |
3203 | -@smallexample | |
3204 | -$1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@} | |
3205 | -@end smallexample | |
3462 | +@node Assignment, Jumping, Altering, Altering | |
3463 | +@section Assignment to Variables | |
3206 | 3464 | |
3207 | -@noindent | |
3208 | -and with @samp{set unionprint off} in effect it would print | |
3465 | +@cindex assignment | |
3466 | +@cindex setting variables | |
3467 | +To alter the value of a variable, evaluate an assignment expression. | |
3468 | +@xref{Expressions}. For example, | |
3209 | 3469 | |
3210 | 3470 | @example |
3211 | -$1 = @{it = Tree, form = @{...@}@} | |
3471 | +print x=4 | |
3212 | 3472 | @end example |
3213 | -@end table | |
3214 | - | |
3215 | -@node Output formats, Auto Display, Format options, Data | |
3216 | -@section Output formats | |
3217 | 3473 | |
3218 | -@cindex formatted output | |
3219 | -@cindex output formats | |
3220 | -_GDBN__ normally prints all values according to their data types. Sometimes | |
3221 | -this is not what you want. For example, you might want to print a number | |
3222 | -in hex, or a pointer in decimal. Or you might want to view data in memory | |
3223 | -at a certain address as a character string or an instruction. These things | |
3224 | -can be done with @dfn{output formats}. | |
3474 | +@noindent | |
3475 | +would store the value 4 into the variable @code{x}, and then print | |
3476 | +the value of the assignment expression (which is 4). | |
3225 | 3477 | |
3226 | -The simplest use of output formats is to say how to print a value | |
3227 | -already computed. This is done by starting the arguments of the | |
3228 | -@samp{print} command with a slash and a format letter. The format | |
3229 | -letters supported are: | |
3478 | +All the assignment operators of C are supported, including the | |
3479 | +increment operators @samp{++} and @samp{--}, and combining | |
3480 | +assignments such as @samp{+=} and _0__@samp{<<=}_1__. | |
3230 | 3481 | |
3231 | -@table @samp | |
3232 | -@item x | |
3233 | -Regard the bits of the value as an integer, and print the integer in | |
3234 | -hexadecimal. | |
3482 | +@kindex set | |
3483 | +@kindex set variable | |
3484 | +@cindex variables, setting | |
3485 | +If you are not interested in seeing the value of the assignment, use the | |
3486 | +@samp{set} command instead of the @samp{print} command. @samp{set} is | |
3487 | +really the same as @samp{print} except that the expression's value is not | |
3488 | +printed and is not put in the value history (@pxref{Value History}). The | |
3489 | +expression is evaluated only for side effects. | |
3235 | 3490 | |
3236 | -@item d | |
3237 | -Print as integer in signed decimal. | |
3491 | +Note that if the beginning of the argument string of the @samp{set} command | |
3492 | +appears identical to a @samp{set} subcommand, it may be necessary to use | |
3493 | +the @samp{set variable} command. This command is identical to @samp{set} | |
3494 | +except for its lack of subcommands. | |
3238 | 3495 | |
3239 | -@item u | |
3240 | -Print as integer in unsigned decimal. | |
3496 | +_GDBN__ allows more implicit conversions in assignments than C does; you can | |
3497 | +freely store an integer value into a pointer variable or vice versa, and | |
3498 | +any structure can be converted to any other structure that is the same | |
3499 | +length or shorter. | |
3500 | +@comment FIXME: how do structs align/pad in these conversions? | |
3501 | +@comment /pesch@cygnus.com 18dec1990 | |
3241 | 3502 | |
3242 | -@item o | |
3243 | -Print as integer in octal. | |
3503 | +To store values into arbitrary places in memory, use the @samp{@{@dots{}@}} | |
3504 | +construct to generate a value of specified type at a specified address | |
3505 | +(@pxref{Expressions}). For example, @code{@{int@}0x83040} would refer | |
3506 | +to memory location 0x83040 as an integer (which implies a certain size | |
3507 | +and representation in memory), and | |
3244 | 3508 | |
3245 | -@item a | |
3246 | -Print as an address, both absolute in hex and as an offset from the | |
3247 | -nearest preceding symbol. This format can be used to discover where (in | |
3248 | -what function) an unknown address is located: | |
3249 | 3509 | @example |
3250 | -(_GDBP__) p/a 0x54320 | |
3251 | -$3 = 0x54320 <_initialize_vx+396> | |
3510 | +set @{int@}0x83040 = 4 | |
3252 | 3511 | @end example |
3253 | 3512 | |
3513 | +would store the value 4 into that memory location. | |
3514 | + | |
3515 | +@node Jumping, Signaling, Assignment, Altering | |
3516 | +@section Continuing at a Different Address | |
3517 | + | |
3518 | +Ordinarily, when you continue the program, you do so at the place where | |
3519 | +it stopped, with the @samp{cont} command. You can instead continue at | |
3520 | +an address of your own choosing, with the following commands: | |
3521 | + | |
3522 | +@table @code | |
3523 | +@item jump @var{linenum} | |
3524 | +@kindex jump | |
3525 | +Resume execution at line number @var{linenum}. Execution may stop | |
3526 | +immediately if there is a breakpoint there. | |
3254 | 3527 | |
3255 | -@item c | |
3256 | -Regard as an integer and print it as a character constant. | |
3528 | +The @samp{jump} command does not change the current stack frame, or | |
3529 | +the stack pointer, or the contents of any memory location or any | |
3530 | +register other than the program counter. If line @var{linenum} is in | |
3531 | +a different function from the one currently executing, the results may | |
3532 | +be bizarre if the two functions expect different patterns of arguments or | |
3533 | +of local variables. For this reason, the @samp{jump} command requests | |
3534 | +confirmation if the specified line is not in the function currently | |
3535 | +executing. However, even bizarre results are predictable based on | |
3536 | +careful study of the machine-language code of the program. | |
3257 | 3537 | |
3258 | -@item f | |
3259 | -Regard the bits of the value as a floating point number and print | |
3260 | -using typical floating point syntax. | |
3538 | +@item jump *@var{address} | |
3539 | +Resume execution at the instruction at address @var{address}. | |
3261 | 3540 | @end table |
3262 | 3541 | |
3263 | -For example, to print the program counter in hex (@pxref{Registers}), type | |
3542 | +You can get much the same effect as the @code{jump} command by storing a | |
3543 | +new value into the register @code{$pc}. The difference is that this | |
3544 | +does not start the program running; it only changes the address where it | |
3545 | +@emph{will} run when it is continued. For example, | |
3264 | 3546 | |
3265 | 3547 | @example |
3266 | -p/x $pc | |
3548 | +set $pc = 0x485 | |
3267 | 3549 | @end example |
3268 | 3550 | |
3269 | 3551 | @noindent |
3270 | -Note that no space is required before the slash; this is because command | |
3271 | -names in _GDBN__ cannot contain a slash. | |
3272 | - | |
3273 | -To reprint the last value in the value history with a different format, | |
3274 | -you can use the @samp{print} command with just a format and no | |
3275 | -expression. For example, @samp{p/x} reprints the last value in hex. | |
3552 | +causes the next @samp{cont} command or stepping command to execute at | |
3553 | +address 0x485, rather than at the address where the program stopped. | |
3554 | +@xref{Stepping}. | |
3276 | 3555 | |
3277 | -@menu | |
3278 | -* Memory:: Examining Memory | |
3279 | -@end menu | |
3556 | +The most common occasion to use the @samp{jump} command is to back up, | |
3557 | +perhaps with more breakpoints set, over a portion of a program that has | |
3558 | +already executed. | |
3280 | 3559 | |
3281 | -@node Memory, , Output formats, Output formats | |
3282 | -@subsection Examining Memory | |
3560 | +@node Signaling, Returning, Jumping, Altering | |
3561 | +@section Giving the Program a Signal | |
3283 | 3562 | |
3284 | -@cindex examining memory | |
3285 | 3563 | @table @code |
3286 | -@kindex disassemble | |
3287 | -@item disassemble | |
3288 | -This specialized command is provided to dump a range of memory as | |
3289 | -machine instructions. The default memory range is the function | |
3290 | -surrounding the program counter of the selected frame. A single | |
3291 | -argument to this command is a program counter value; the function | |
3292 | -surrounding this value will be dumped. Two arguments (separated by one | |
3293 | -or more spaces) specify a range of addresses (first inclusive, second | |
3294 | -exclusive) to be dumped. | |
3564 | +@item signal @var{signalnum} | |
3565 | +@kindex signal | |
3566 | +Resume execution where the program stopped, but give it immediately the | |
3567 | +signal number @var{signalnum}. | |
3295 | 3568 | |
3296 | -@kindex x | |
3297 | -@item x | |
3298 | -The command @samp{x} (for `examine') can be used to examine memory | |
3299 | -without reference to the program's data types. The format in which you | |
3300 | -wish to examine memory is instead explicitly specified. The allowable | |
3301 | -formats are a superset of the formats described in the previous section. | |
3569 | +Alternatively, if @var{signalnum} is zero, continue execution without | |
3570 | +giving a signal. This is useful when the program stopped on account of | |
3571 | +a signal and would ordinary see the signal when resumed with the | |
3572 | +@samp{cont} command; @samp{signal 0} causes it to resume without a | |
3573 | +signal. | |
3302 | 3574 | @end table |
3303 | 3575 | |
3304 | -@samp{x} is followed by a slash and an output format specification, | |
3305 | -followed by an expression for an address. The expression need not have | |
3306 | -a pointer value (though it may); it is used as an integer, as the | |
3307 | -address of a byte of memory. @xref{Expressions} for more information on | |
3308 | -expressions. For example, @samp{x/4xw $sp} prints the four words of | |
3309 | -memory above the stack pointer in hexadecimal. | |
3576 | +@node Returning, Calling, Signaling, Altering | |
3577 | +@section Returning from a Function | |
3310 | 3578 | |
3311 | -The output format in this case specifies both how big a unit of memory | |
3312 | -to examine and how to print the contents of that unit. It is done | |
3313 | -with one or two of the following letters: | |
3579 | +@table @code | |
3580 | +@item return | |
3581 | +@cindex returning from a function | |
3582 | +@kindex return | |
3583 | +You can cancel execution of a function call with the @samp{return} | |
3584 | +command. | |
3585 | +@end table | |
3314 | 3586 | |
3315 | -These letters specify just the size of unit to examine: | |
3587 | +This command has the effect of discarding the selected stack | |
3588 | +frame (and all frames within it), so that control moves to the caller of | |
3589 | +that function. You can think of this as making the discarded frame | |
3590 | +return prematurely. | |
3316 | 3591 | |
3317 | -@table @samp | |
3318 | -@item b | |
3319 | -Examine individual bytes. | |
3592 | +First select the stack frame that you wish to return from | |
3593 | +(@pxref{Selection}). Then type the @samp{return} command. If you wish | |
3594 | +to specify the value to be returned, give that as an argument. | |
3320 | 3595 | |
3321 | -@item h | |
3322 | -Examine halfwords (two bytes each). | |
3596 | +This pops the selected stack frame (and any other frames inside of it), | |
3597 | +leaving its caller as the innermost remaining frame. That frame becomes | |
3598 | +selected. The specified value is stored in the registers used for | |
3599 | +returning values of functions. | |
3323 | 3600 | |
3324 | -@item w | |
3325 | -Examine words (four bytes each). | |
3601 | +The @samp{return} command does not resume execution; it leaves the | |
3602 | +program stopped in the state that would exist if the function had just | |
3603 | +returned. Contrast this with the @samp{finish} command | |
3604 | +(@pxref{Stepping}), which resumes execution until the selected stack | |
3605 | +frame returns @emph{naturally}. | |
3326 | 3606 | |
3327 | -@cindex word | |
3328 | -Many assemblers and cpu designers still use `word' for a 16-bit quantity, | |
3329 | -as a holdover from specific predecessor machines of the 1970's that really | |
3330 | -did use two-byte words. But more generally the term `word' has always | |
3331 | -referred to the size of quantity that a machine normally operates on and | |
3332 | -stores in its registers. This is 32 bits for all the machines that _GDBN__ | |
3333 | -runs on. | |
3607 | +@node Calling, , Returning, Altering | |
3608 | +@comment node-name, next, previous, up | |
3609 | +@section Calling your Program's Functions | |
3334 | 3610 | |
3335 | -@item g | |
3336 | -Examine giant words (8 bytes). | |
3611 | +@cindex calling functions | |
3612 | +@kindex call | |
3613 | +@table @code | |
3614 | +@item call @var{expr} | |
3615 | +Evaluate the expression @var{expr} without displaying @code{void} | |
3616 | +returned values. | |
3337 | 3617 | @end table |
3338 | 3618 | |
3339 | -These letters specify just the way to print the contents: | |
3340 | - | |
3341 | -@table @samp | |
3342 | -@item x | |
3343 | -Print as integers in unsigned hexadecimal. | |
3344 | - | |
3345 | -@item d | |
3346 | -Print as integers in signed decimal. | |
3619 | +You can use this variant of the @samp{print} command if you want to | |
3620 | +execute some piece of your program, but without cluttering the output | |
3621 | +with @code{void} returned values. The result is printed and saved in | |
3622 | +the value history, if it is not void. | |
3347 | 3623 | |
3348 | -@item u | |
3349 | -Print as integers in unsigned decimal. | |
3624 | +@node Files,,, | |
3625 | +@chapter _GDBN__'s Files | |
3350 | 3626 | |
3351 | -@item o | |
3352 | -Print as integers in unsigned octal. | |
3627 | +@section Commands to Specify Files | |
3628 | +@cindex core dump file | |
3629 | +@cindex symbol table | |
3630 | +_GDBN__ needs to know the file name of the program to be debugged, both in | |
3631 | +order to read its symbol table and in order to start the program. To | |
3632 | +debug a core dump of a previous run, _GDBN__ must be told the file name of | |
3633 | +the core dump. | |
3353 | 3634 | |
3354 | -@item a | |
3355 | -Print as an address, both absolute in hex and then relative | |
3356 | -to a symbol defined as an address below it. | |
3635 | +The usual way to specify the executable and core dump file names is with | |
3636 | +the command arguments given when you start _GDBN__, as discussed in | |
3637 | +@pxref{Invocation}. | |
3357 | 3638 | |
3358 | -@item c | |
3359 | -Print as character constants. | |
3639 | +But occasionally it is necessary to change to a different file during a | |
3640 | +_GDBN__ session. Or you may run _GDBN__ and forget to specify the files you | |
3641 | +want to use. In these situations the _GDBN__ commands to specify new files | |
3642 | +are useful. | |
3360 | 3643 | |
3361 | -@item f | |
3362 | -Print as floating point. This works only with sizes @samp{w} and | |
3363 | -@samp{g}. | |
3644 | +@table @code | |
3645 | +@item file @var{filename} | |
3646 | +@cindex executable file | |
3647 | +@kindex file | |
3648 | +Use @var{filename} as the program to be debugged. It is read for its | |
3649 | +symbols, for getting the contents of pure memory, and it is the program | |
3650 | +executed when you use the @samp{run} command. If you do not specify a | |
3651 | +directory and the file is not found in _GDBN__'s working directory, | |
3652 | +_GDBN__ will use the environment variable @code{PATH} as a list of | |
3653 | +directories to search, just as the shell does when looking for a program | |
3654 | +to run. | |
3364 | 3655 | |
3365 | -@item s | |
3366 | -Print a null-terminated string of characters. The specified unit size | |
3367 | -is ignored; instead, the unit is however many bytes it takes to reach | |
3368 | -a null character (including the null character). | |
3656 | +@samp{file} with no argument makes both executable file and symbol | |
3657 | +table become unspecified. | |
3369 | 3658 | |
3370 | -@item i | |
3371 | -Print a machine instruction in assembler syntax (or nearly). The | |
3372 | -specified unit size is ignored; the number of bytes in an instruction | |
3373 | -varies depending on the type of machine, the opcode and the addressing | |
3374 | -modes used. The command @samp{disassemble} gives an alternative way of | |
3375 | -inspecting machine instructions. | |
3376 | -@end table | |
3659 | +@item exec-file @var{filename} | |
3660 | +@kindex exec-file | |
3661 | +Specify that the program to be run (but not the symbol table) is found | |
3662 | +in @var{filename}. _GDBN__ will search the environment variable @code{PATH} | |
3663 | +if necessary to locate the program. | |
3377 | 3664 | |
3378 | -If either the manner of printing or the size of unit fails to be specified, | |
3379 | -the default is to use the same one that was used last. If you don't want | |
3380 | -to use any letters after the slash, you can omit the slash as well. | |
3665 | +@item symbol-file @var{filename} | |
3666 | +@kindex symbol-file | |
3667 | +Read symbol table information from file @var{filename}. @code{PATH} is | |
3668 | +searched when necessary. Use the @samp{file} command to get both symbol | |
3669 | +table and program to run from the same file. | |
3381 | 3670 | |
3382 | -You can also omit the address to examine. Then the address used is just | |
3383 | -after the last unit examined. This is why string and instruction | |
3384 | -formats actually compute a unit-size based on the data: so that the next | |
3385 | -string or instruction examined will start in the right place. | |
3671 | +@samp{symbol-file} with no argument clears out _GDBN__'s information on your | |
3672 | +program's symbol table. | |
3386 | 3673 | |
3387 | -When the @samp{print} command shows a value that resides in memory, | |
3388 | -@samp{print} also sets the default address for the @samp{x} command. | |
3389 | -@samp{info line} also sets the default for @samp{x}, to the address of | |
3390 | -the start of the machine code for the specified line and @samp{info | |
3391 | -breakpoints} sets it to the address of the last breakpoint listed. | |
3674 | +The @samp{symbol-file} command causes _GDBN__ to forget the contents of its | |
3675 | +convenience variables, the value history, and all breakpoints and | |
3676 | +auto-display expressions. This is because they may contain pointers to | |
3677 | +the internal data recording symbols and data types, which are part of | |
3678 | +the old symbol table data being discarded inside _GDBN__. | |
3392 | 3679 | |
3393 | -When you use @key{RET} to repeat an @samp{x} command, the address | |
3394 | -specified previously (if any) is ignored, so that the repeated command | |
3395 | -examines the successive locations in memory rather than the same ones. | |
3680 | +On some kinds of object files, the @samp{symbol-file} command does not | |
3681 | +actually read the symbol table in full right away. Instead, it scans | |
3682 | +the symbol table quickly to find which source files and which symbols | |
3683 | +are present. The details are read later, one source file at a time, | |
3684 | +when they are needed. | |
3396 | 3685 | |
3397 | -You can examine several consecutive units of memory with one command by | |
3398 | -writing a repeat-count after the slash (before the format letters, if any). | |
3399 | -The repeat count must be a decimal integer. It has the same effect as | |
3400 | -repeating the @samp{x} command that many times except that the output may | |
3401 | -be more compact with several units per line. For example, | |
3686 | +The purpose of this two-stage reading strategy is to make _GDBN__ start up | |
3687 | +faster. For the most part, it is invisible except for occasional pauses | |
3688 | +while the symbol table details for a particular source file are being | |
3689 | +read. (The @samp{set verbose} command can turn these pauses into | |
3690 | +messages if desired. @xref{User Interface}). | |
3402 | 3691 | |
3403 | -@example | |
3404 | -x/10i $pc | |
3405 | -@end example | |
3692 | +When the symbol table is stored in COFF format, @samp{symbol-file} does | |
3693 | +read the symbol table data in full right away. We haven't implemented | |
3694 | +the two-stage strategy for COFF yet. | |
3406 | 3695 | |
3407 | -@noindent | |
3408 | -prints ten instructions starting with the one to be executed next in the | |
3409 | -selected frame. After doing this, you could print another seven following | |
3410 | -instructions with | |
3696 | +When _GDBN__ is configured for a particular environment, it will understand | |
3697 | +debugging information in whatever format is the standard generated for | |
3698 | +that environment; you may use either the GNU compiler _GCC__, or other | |
3699 | +compilers that adhere to the local conventions. Best results are | |
3700 | +usually obtained from _GCC__; for example, using _GCC__ you can generate | |
3701 | +debugging information for optimized code. | |
3411 | 3702 | |
3412 | -@example | |
3413 | -x/7 | |
3414 | -@end example | |
3703 | +@item core-file @var{filename} | |
3704 | +@itemx core @var{filename} | |
3705 | +@kindex core | |
3706 | +@kindex core-file | |
3707 | +Specify the whereabouts of a core dump file to be used as the ``contents | |
3708 | +of memory''. Traditionally, core files contain only some parts of the | |
3709 | +address space of the process that generated them; _GDBN__ can access the | |
3710 | +executable file itself for other parts. | |
3415 | 3711 | |
3416 | -@noindent | |
3417 | -in which the format and address are allowed to default. | |
3712 | +@samp{core-file} with no argument specifies that no core file is | |
3713 | +to be used. | |
3418 | 3714 | |
3419 | -@kindex $_ | |
3420 | -@kindex $__ | |
3421 | -The addresses and contents printed by the @samp{x} command are not put in | |
3422 | -the value history because there is often too much of them and they would | |
3423 | -get in the way. Instead, _GDBN__ makes these values available for subsequent | |
3424 | -use in expressions as values of the convenience variables @code{$_} and | |
3425 | -@code{$__}. | |
3715 | +Note that the core file is ignored when your program is actually running | |
3716 | +under _GDBN__. So, if you have been running the program and you wish to | |
3717 | +debug a core file instead, you must kill the subprocess in which the | |
3718 | +program is running. To do this, use the @samp{kill} command | |
3719 | +(@pxref{Kill Process}). | |
3426 | 3720 | |
3427 | -After an @samp{x} command, the last address examined is available for use | |
3428 | -in expressions in the convenience variable @code{$_}. The contents of that | |
3429 | -address, as examined, are available in the convenience variable @code{$__}. | |
3721 | +@item load @var{filename} | |
3722 | +@kindex load | |
3723 | +This command will dynamically link @var{filename} on the current target, | |
3724 | +performing any necessary downloads, then add @var{filename}'s symbol | |
3725 | +table in the same way as the @samp{add-syms} command. | |
3430 | 3726 | |
3431 | -If the @samp{x} command has a repeat count, the address and contents saved | |
3432 | -are from the last memory unit printed; this is not the same as the last | |
3433 | -address printed if several units were printed on the last line of output. | |
3727 | +@item add-syms @var{filename} @var{address} | |
3728 | +@kindex add-syms | |
3729 | +@cindex dynamic linking | |
3730 | +The @samp{add-syms} command reads additional symbol table information | |
3731 | +from the file @var{filename}. You would use this command when that file | |
3732 | +has been dynamically loaded (by some other means) into the program that | |
3733 | +is running. @var{address} should be the memory address at which the | |
3734 | +file has been loaded; _GDBN__ cannot figure this out for itself. | |
3434 | 3735 | |
3435 | -@node Auto Display, Value History, Output formats, Data | |
3436 | -@section Automatic Display | |
3437 | -@cindex automatic display | |
3438 | -@cindex display of expressions | |
3736 | +The symbol table of the file @var{filename} is added to the symbol table | |
3737 | +originally read with the @samp{symbol-file} command. You can use the | |
3738 | +@samp{add-syms} command any number of times; the new symbol data thus | |
3739 | +read keeps adding to the old. The @samp{symbol-file} command forgets | |
3740 | +all the symbol data _GDBN__ has read. | |
3439 | 3741 | |
3440 | -If you find that you want to print the value of an expression frequently | |
3441 | -(to see how it changes), you might want to add it to the @dfn{automatic | |
3442 | -display list} so that _GDBN__ will print its value each time the program stops. | |
3443 | -Each expression added to the list is given a number to identify it; | |
3444 | -to remove an expression from the list, you specify that number. | |
3445 | -The automatic display looks like this: | |
3742 | +@item info files | |
3743 | +@itemx info target | |
3744 | +@kindex info files | |
3745 | +@kindex info target | |
3746 | +@samp{info files} and @samp{info target} are synonymous; both print the | |
3747 | +current targets (@pxref{Targets}), including the names of the | |
3748 | +executable and core dump files currently in use by _GDBN__, and the files | |
3749 | +from which symbols were loaded. | |
3446 | 3750 | |
3447 | -@example | |
3448 | -2: foo = 38 | |
3449 | -3: bar[5] = (struct hack *) 0x3804 | |
3450 | -@end example | |
3751 | +Beware: the similar command @samp{info targets} lists all possible | |
3752 | +targets rather than current ones. | |
3451 | 3753 | |
3452 | -@noindent | |
3453 | -showing item numbers, expressions and their current values. | |
3754 | +@end table | |
3454 | 3755 | |
3455 | -If the expression refers to local variables, then it does not make sense | |
3456 | -outside the lexical context for which it was set up. Such an expression | |
3457 | -is disabled when execution enters a context where one of its variables | |
3458 | -is not defined. For example, if you give the command | |
3459 | -@samp{display name} while inside a function with an argument | |
3460 | -@code{name}, then this argument will be displayed while the program | |
3461 | -continues to stop inside that function. When it stops elsewhere---where | |
3462 | -there is no variable @samp{name}---display is disabled. The next time | |
3463 | -your program stops where @samp{name} is meaningful, you can enable the | |
3464 | -display expression once again. | |
3756 | +While all three file-specifying commands allow both absolute and relative | |
3757 | +file names as arguments, _GDBN__ always converts the file name to an absolute | |
3758 | +one and remembers it that way. | |
3465 | 3759 | |
3466 | -@table @code | |
3467 | -@item display @var{exp} | |
3468 | -@kindex display | |
3469 | -Add the expression @var{exp} to the list of expressions to display | |
3470 | -each time the program stops. @xref{Expressions}. | |
3760 | +@kindex sharedlibrary | |
3761 | +@kindex share | |
3762 | +@cindex shared libraries | |
3471 | 3763 | |
3472 | -@item display/@var{fmt} @var{exp} | |
3473 | -For @var{fmt} specifying only a display format and not a size or | |
3474 | -count, add the expression @var{exp} to the auto-display list but | |
3475 | -arranges to display it each time in the specified format @var{fmt}. | |
3764 | +_GDBN__ supports the SunOS shared library format. Symbols from a shared | |
3765 | +library cannot be referenced before the shared library has been linked | |
3766 | +with the program. (That is to say, after one types @samp{run} and | |
3767 | +the function @code{main()} has been entered; or when examining core | |
3768 | +files.) Once the shared library has been linked in, you can use the | |
3769 | +following commands: | |
3476 | 3770 | |
3477 | -@item display/@var{fmt} @var{addr} | |
3478 | -For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a | |
3479 | -number of units, add the expression @var{addr} as a memory address to | |
3480 | -be examined each time the program stops. Examining means in effect | |
3481 | -doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory}. | |
3771 | +@table @code | |
3772 | +@item sharedlibrary @var{regex} | |
3773 | +@itemx share @var{regex} | |
3774 | +Load shared object library symbols for files matching a UNIX regular | |
3775 | +expression. | |
3482 | 3776 | |
3483 | -@item undisplay @var{dnums}@dots{} | |
3484 | -@itemx delete display @var{dnums}@dots{} | |
3485 | -@kindex delete display | |
3486 | -@kindex undisplay | |
3487 | -Remove item numbers @var{dnums} from the list of expressions to display. | |
3777 | +@item share | |
3778 | +@itemx sharedlibrary | |
3779 | +Load symbols for all shared libraries. | |
3488 | 3780 | |
3489 | -@item disable display @var{dnums}@dots{} | |
3490 | -@kindex disable display | |
3491 | -Disable the display of item numbers @var{dnums}. A disabled display | |
3492 | -item is not printed automatically, but is not forgotten. It may be | |
3493 | -enabled again later. | |
3781 | +@item info share | |
3782 | +@itemx info sharedlibrary | |
3783 | +@kindex info sharedlibrary | |
3784 | +@kindex info share | |
3785 | +Print the names of the shared libraries which are currently loaded. | |
3786 | +@end table | |
3494 | 3787 | |
3495 | -@item enable display @var{dnums}@dots{} | |
3496 | -@kindex enable display | |
3497 | -Enable display of item numbers @var{dnums}. It becomes effective once | |
3498 | -again in auto display of its expression, until you specify otherwise. | |
3788 | +@section Errors Reading Symbols | |
3789 | +While a symbol file is being read, _GDBN__ will occasionally encounter | |
3790 | +problems, such as symbol types it does not recognize, or known bugs in | |
3791 | +compiler output. By default, it prints one message about each such | |
3792 | +type of problem, no matter how many times the problem occurs. You can | |
3793 | +ask it to print more messages, to see how many times the problems occur, | |
3794 | +or can shut the messages off entirely, with the @samp{set | |
3795 | +complaints} command (@xref{User Interface}). | |
3499 | 3796 | |
3500 | -@item display | |
3501 | -Display the current values of the expressions on the list, just as is | |
3502 | -done when the program stops. | |
3797 | +The messages currently printed, and their meanings, are: | |
3503 | 3798 | |
3504 | -@item info display | |
3505 | -@kindex info display | |
3506 | -Print the list of expressions previously set up to display | |
3507 | -automatically, each one with its item number, but without showing the | |
3508 | -values. This includes disabled expressions, which are marked as such. | |
3509 | -It also includes expressions which would not be displayed right now | |
3510 | -because they refer to automatic variables not currently available. | |
3511 | -@end table | |
3799 | +@table @code | |
3800 | +@item inner block not inside outer block in @var{symbol} | |
3512 | 3801 | |
3513 | -@node Value History, Convenience Vars, Auto Display, Data | |
3514 | -@section Value History | |
3802 | +The symbol information shows where symbol scopes begin and end | |
3803 | +(such as at the start of a function or a block of statements). This | |
3804 | +error indicates that an inner scope block is not fully contained | |
3805 | +in its outer scope blocks. _GDBN__ circumvents the problem by treating | |
3806 | +the inner block as if it had the same scope as the outer block. | |
3807 | +@var{symbol} may be ``(don't know)'' if the outer block is not | |
3808 | +a function. | |
3515 | 3809 | |
3516 | -@cindex value history | |
3517 | -Values printed by the @samp{print} command are saved in _GDBN__'s @dfn{value | |
3518 | -history} so that you can refer to them in other expressions. Values are | |
3519 | -kept until the symbol table is re-read or discarded (for example with | |
3520 | -the @samp{file} or @samp{symbol-file} commands). When the symbol table | |
3521 | -changes, the value history is discarded, since the values may contain | |
3522 | -pointers back to the types defined in the symbol table. | |
3810 | +@item block at @var{address} out of order | |
3523 | 3811 | |
3524 | -@cindex @code{$} | |
3525 | -@cindex @code{$$} | |
3526 | -@cindex history number | |
3527 | -The values printed are given @dfn{history numbers} for you to refer to them | |
3528 | -by. These are successive integers starting with 1. @samp{print} shows you | |
3529 | -the history number assigned to a value by printing @samp{$@var{num} = } | |
3530 | -before the value; here @var{num} is the history number. | |
3812 | +The symbol information for symbol scope blocks should occur in | |
3813 | +order of increasing addresses. This error indicates that it does not | |
3814 | +do so. _GDBN__ does not circumvent this problem, and will have trouble | |
3815 | +locating symbols in the source file whose symbols being read. (You | |
3816 | +can often determine what source file is affected by turning on | |
3817 | +@samp{info verbose}. @xref{User Interface}.) | |
3531 | 3818 | |
3532 | -To refer to any previous value, use @samp{$} followed by the value's | |
3533 | -history number. The output printed by @samp{print} is designed to | |
3534 | -remind you of this. Just @code{$} refers to the most recent value in | |
3535 | -the history, and @code{$$} refers to the value before that. | |
3536 | -@code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2} | |
3537 | -is the value just prior to @code{$$}, @code{$$1} is equivalent to | |
3538 | -@code{$$}, and @code{$$0} is equivalent to @code{$}. | |
3819 | +@item bad block start address patched | |
3539 | 3820 | |
3540 | -For example, suppose you have just printed a pointer to a structure and | |
3541 | -want to see the contents of the structure. It suffices to type | |
3821 | +The symbol information for a symbol scope block has a start address | |
3822 | +smaller than the address of the preceding source line. This is known | |
3823 | +to occur in the SunOS 4.1.1 (and earlier) C compiler. _GDBN__ circumvents | |
3824 | +the problem by treating the symbol scope block as starting on the | |
3825 | +previous source line. | |
3542 | 3826 | |
3543 | -@example | |
3544 | -p *$ | |
3545 | -@end example | |
3827 | +@comment @item{encountered DBX-style class variable debugging information. | |
3828 | +@comment You seem to have compiled your program with "g++ -g0" instead of "g++ -g". | |
3829 | +@comment Therefore _GDBN__ will not know about your class variables} | |
3830 | +@comment | |
3831 | +@comment This error indicates that the symbol information produced for a C++ | |
3832 | +@comment program includes zero-size fields, which indicated static fields in | |
3833 | +@comment a previous release of the G++ compiler. This message is probably | |
3834 | +@comment obsolete. | |
3835 | +@comment | |
3836 | +@item bad string table offset in symbol @var{n} | |
3546 | 3837 | |
3547 | -If you have a chain of structures where the component @samp{next} points | |
3548 | -to the next one, you can print the contents of the next one with this: | |
3838 | +Symbol number @var{n} contains a pointer into the string table which is | |
3839 | +larger than the size of the string table. _GDBN__ circumvents the problem | |
3840 | +by considering the symbol to have the name @code{foo}, which may cause | |
3841 | +other problems if many symbols end up with this name. @cindex{foo} | |
3549 | 3842 | |
3550 | -@example | |
3551 | -p *$.next | |
3552 | -@end example | |
3843 | +@item unknown symbol type @code{0xNN} | |
3553 | 3844 | |
3554 | -@noindent | |
3555 | -It might be useful to repeat this command many times by typing @key{RET}. | |
3845 | +The symbol information contains new data types that _GDBN__ does not yet | |
3846 | +know how to read. @code{0xNN} is the symbol type of the misunderstood | |
3847 | +information, in hexadecimal. _GDBN__ circumvents the error by ignoring | |
3848 | +this symbol information. This will usually allow the program to be | |
3849 | +debugged, though certain symbols will not be accessible. If you | |
3850 | +encounter such a problem and feel like debugging it, you can debug _GDBP__ | |
3851 | +with itself, breakpoint on "complain", then go "up" to | |
3852 | +read_dbx_symtab() and examine *bufp to see the symbol. | |
3556 | 3853 | |
3557 | -Note that the history records values, not expressions. If the value of | |
3558 | -@code{x} is 4 and you type this command: | |
3854 | +@c @item stub type has NULL name | |
3855 | +@c | |
3856 | +@c FIXME, Mike Tiemann needs to write about what this means. | |
3559 | 3857 | |
3560 | -@example | |
3561 | -print x | |
3562 | -set x=5 | |
3563 | -@end example | |
3858 | +@item const/volatile indicator missing, got 'X' | |
3564 | 3859 | |
3565 | -@noindent | |
3566 | -then the value recorded in the value history by the @samp{print} command | |
3567 | -remains 4 even though the value of @code{x} has changed. | |
3860 | +The symbol information for a C++ type is missing some information that | |
3861 | +the compiler should have output for it. | |
3568 | 3862 | |
3569 | -@table @code | |
3570 | -@kindex info values | |
3571 | -@item info values | |
3572 | -@itemx info history | |
3573 | -@kindex info history | |
3574 | -These two commands are synonymous. Either form will print the last ten | |
3575 | -values in the value history, with their item numbers. This is like | |
3576 | -@samp{p@ $$9} repeated ten times, except that @samp{info values} does | |
3577 | -not change the history. | |
3863 | +@item C++ type mismatch between compiler and debugger | |
3578 | 3864 | |
3579 | -@item info values @var{n} | |
3580 | -Print ten history values centered on history item number @var{n}. | |
3865 | +The debugger could not parse a type specification output by the compiler | |
3866 | +for some C++ object. | |
3581 | 3867 | |
3582 | -@item info values + | |
3583 | -Print ten history values just after the values last printed. | |
3584 | 3868 | @end table |
3585 | 3869 | |
3586 | -@node Convenience Vars, Registers, Value History, Data | |
3587 | -@section Convenience Variables | |
3870 | +@node Targets, Running, Compilation, Top | |
3871 | +@chapter Specifying a Debugging Target | |
3872 | +@cindex debugging target | |
3873 | +@kindex target | |
3874 | +A @dfn{target} is an interface between the debugger and a particular | |
3875 | +kind of file or process. | |
3588 | 3876 | |
3589 | -@cindex convenience variables | |
3590 | -_GDBN__ provides @dfn{convenience variables} that you can use within _GDBN__ to | |
3591 | -hold on to a value and refer to it later. These variables exist entirely | |
3592 | -within _GDBN__; they are not part of your program, and setting a convenience | |
3593 | -variable has no effect on further execution of your program. That's why | |
3594 | -you can use them freely. | |
3877 | +Often, you will be able to run _GDBN__ in the same host environment as the | |
3878 | +program you are debugging; in that case, the debugging target can just be | |
3879 | +specified as a side effect of the @samp{file} or @samp{core} commands. | |
3880 | +When you need more flexibility---for example, running _GDBN__ on a | |
3881 | +physically separate host, controlling standalone systems over a | |
3882 | +serial port, or realtime systems over a TCP/IP connection---you can use | |
3883 | +the @samp{target} command. | |
3595 | 3884 | |
3596 | -Convenience variables have names starting with @samp{$}. Any name starting | |
3597 | -with @samp{$} can be used for a convenience variable, unless it is one of | |
3598 | -the predefined set of register names (@pxref{Registers}). | |
3885 | +@menu | |
3886 | +* Active Targets:: Active Targets | |
3887 | +* Target Commands:: Commands for Managing Targets | |
3888 | +@end menu | |
3599 | 3889 | |
3600 | -You can save a value in a convenience variable with an assignment | |
3601 | -expression, just as you would set a variable in your program. Example: | |
3890 | +@node Active Targets, Target Commands, Targets, Targets | |
3891 | +@section Active Targets | |
3892 | +@cindex stacking targets | |
3893 | +@cindex active targets | |
3894 | +@cindex multiple targets | |
3602 | 3895 | |
3603 | -@example | |
3604 | -set $foo = *object_ptr | |
3605 | -@end example | |
3896 | +Targets are managed in three @dfn{strata} that correspond to different | |
3897 | +classes of target: processes, core files, and executable files. This | |
3898 | +allows you to (for example) start a process and inspect its activity | |
3899 | +without abandoning your work on a core file. | |
3606 | 3900 | |
3607 | -@noindent | |
3608 | -would save in @code{$foo} the value contained in the object pointed to by | |
3609 | -@code{object_ptr}. | |
3901 | +More than one target can potentially respond to a request. In | |
3902 | +particular, when you access memory _GDBN__ will walk down the three strata of | |
3903 | +targets until it finds a target that can handle that particular address. | |
3610 | 3904 | |
3611 | -Using a convenience variable for the first time creates it; but its value | |
3612 | -is @code{void} until you assign a new value. You can alter the value with | |
3613 | -another assignment at any time. | |
3905 | +Strata are always examined in a fixed order: first a process if there is | |
3906 | +one, then a core file if there is one, and finally an executable file if | |
3907 | +there is one of those. | |
3614 | 3908 | |
3615 | -Convenience variables have no fixed types. You can assign a convenience | |
3616 | -variable any type of value, including structures and arrays, even if | |
3617 | -that variable already has a value of a different type. The convenience | |
3618 | -variable as an expression has whatever type its current value has. | |
3909 | +When you specify a new target in a given stratum, it replaces any target | |
3910 | +previously in that stratum. | |
3619 | 3911 | |
3620 | -@table @code | |
3621 | -@item info convenience | |
3622 | -@kindex info convenience | |
3623 | -Print a list of convenience variables used so far, and their values. | |
3624 | -Abbreviated @samp{i con}. | |
3625 | -@end table | |
3912 | +To get rid of a target without replacing it, use the @samp{detach} | |
3913 | +command. The related command @samp{attach} provides you with a way of | |
3914 | +choosing a particular running process as a new target. @xref{Attach}. | |
3626 | 3915 | |
3627 | -One of the ways to use a convenience variable is as a counter to be | |
3628 | -incremented or a pointer to be advanced. For example: | |
3916 | +@node Target Commands, , Active Targets, Targets | |
3917 | +@section Commands for Managing Targets | |
3629 | 3918 | |
3919 | +@table @code | |
3920 | +@item target @var{type} @var{parameters} | |
3921 | +Connects the _GDBN__ host environment to a target machine or process. A | |
3922 | +target is typically a protocol for talking to debugging facilities. You | |
3923 | +use the argument @var{type} to specify the type or protocol of the | |
3924 | +target machine; for example, @samp{target vxworks} for a TCP/IP link to | |
3925 | +a VxWorks system. | |
3926 | + | |
3927 | +Further @var{parameters} are interpreted by the target protocol, but | |
3928 | +typically include things like device names or host names to connect | |
3929 | +with, process numbers, and baud rates. Executing | |
3630 | 3930 | @example |
3631 | -set $i = 0 | |
3632 | -print bar[$i++]->contents | |
3633 | -@i{@dots{}repeat that command by typing @key{RET}.} | |
3931 | + target @var{type} | |
3634 | 3932 | @end example |
3635 | 3933 | |
3636 | -Some convenience variables are created automatically by _GDBN__ and given | |
3637 | -values likely to be useful. | |
3638 | - | |
3639 | -@table @code | |
3640 | -@item $_ | |
3641 | -The variable @code{$_} is automatically set by the @samp{x} command to | |
3642 | -the last address examined (@pxref{Memory}). Other commands which | |
3643 | -provide a default address for @samp{x} to examine also set @code{$_} | |
3644 | -to that address; these commands include @samp{info line} and @samp{info | |
3645 | -breakpoint}. | |
3934 | +@noindent | |
3935 | +(without any parameters) will issue a message about what | |
3936 | +parameters are required for that target type. | |
3646 | 3937 | |
3647 | -@item $__ | |
3648 | -The variable @code{$__} is automatically set by the @samp{x} command | |
3649 | -to the value found in the last address examined. | |
3938 | +@item info targets | |
3939 | +@kindex info targets | |
3940 | +Displays the names of all targets available. Beware: the similar | |
3941 | +command @samp{info target} displays targets currently in use rather than | |
3942 | +all available ones. @samp{info files} gives the same information as | |
3943 | +@samp{info target} (@pxref{Files}). | |
3650 | 3944 | @end table |
3651 | 3945 | |
3652 | -@node Registers, , Convenience Vars, Data | |
3653 | -@section Registers | |
3946 | +Here are some common targets (available, or not, depending on _GDBN__ | |
3947 | +configuration): | |
3654 | 3948 | |
3655 | -@cindex registers | |
3656 | -Machine register contents can be referred to in expressions as variables | |
3657 | -with names starting with @samp{$}. The names of registers are different | |
3658 | -for each machine; use @samp{info registers} to see the names used on your | |
3659 | -machine. The names @code{$pc} and @code{$sp} are used on most machines for | |
3660 | -the program counter register and the stack pointer. Often @code{$fp} is | |
3661 | -used for a register that contains a pointer to the current stack frame, | |
3662 | -and @code{$ps} is used for a register that contains the processor | |
3663 | -status. These standard register names may be available on your machine | |
3664 | -even though the @code{info registers} command displays them with a | |
3665 | -different name. For example, on the SPARC, @code{info registers} | |
3666 | -displays the processor status register as @code{$psr} but you can also | |
3667 | -refer to it as @code{$ps}. | |
3949 | +@table @code | |
3950 | +@item target exec @var{prog} | |
3951 | +@kindex target exec | |
3952 | +An executable file. @samp{target exec @var{prog}} is the same as | |
3953 | +@samp{exec-file @var{prog}}. | |
3668 | 3954 | |
3669 | -_GDBN__ always considers the contents of an ordinary register as an integer | |
3670 | -when the register is examined in this way. Some machines have special | |
3671 | -registers which can hold nothing but floating point; these registers are | |
3672 | -considered floating point. There is no way to refer to the contents of an | |
3673 | -ordinary register as floating point value (although you can @emph{print} | |
3674 | -it as a floating point value with @samp{print/f $@var{regname}}). | |
3955 | +@item target core @var{filename} | |
3956 | +@kindex target core | |
3957 | +A core dump file. @samp{target core @var{filename}} is the same as | |
3958 | +@samp{core-file @var{filename}}. | |
3675 | 3959 | |
3676 | -Some registers have distinct ``raw'' and ``virtual'' data formats. This | |
3677 | -means that the data format in which the register contents are saved by | |
3678 | -the operating system is not the same one that your program normally | |
3679 | -sees. For example, the registers of the 68881 floating point | |
3680 | -coprocessor are always saved in ``extended'' (raw) format, but all C | |
3681 | -programs expect to work with ``double'' (virtual) format. In such | |
3682 | -cases, _GDBN__ normally works with the virtual format only (the format that | |
3683 | -makes sense for your program), but the @samp{info registers} command | |
3684 | -prints the data in both formats. | |
3960 | +@item target remote @var{dev} | |
3961 | +@kindex target remote | |
3962 | +Remote serial target in _GDBP__-specific protocol. The argument @var{dev} | |
3963 | +specifies what serial device to use for the connection (e.g. | |
3964 | +@code{/dev/ttya}). | |
3685 | 3965 | |
3686 | -Register values are relative to the selected stack frame | |
3687 | -(@pxref{Selection}). This means that you get the value that the register | |
3688 | -would contain if all stack frames farther in were exited and their saved | |
3689 | -registers restored. In order to see the real contents of all registers, | |
3690 | -you must select the innermost frame (with @samp{frame 0}). | |
3966 | +_if__(_AMD29K__) | |
3967 | +@item target amd-eb @var{dev} @var{speed} @var{PROG} | |
3968 | +@kindex target amd-eb | |
3969 | +@cindex AMD EB29K | |
3970 | +Remote PC-resident AMD EB29K board, attached over serial lines. | |
3971 | +@var{dev} is the serial device, as for @samp{target remote}; | |
3972 | +@samp{speed} allows you to specify the linespeed; and @var{PROG} is the | |
3973 | +name of the program to be debugged, as it appears to DOS on the PC. | |
3974 | +@xref{EB29K Remote}. | |
3691 | 3975 | |
3692 | -Some registers are never saved (typically those numbered zero or one) | |
3693 | -because they are used for returning function values. In some operating | |
3694 | -systems (those using the ``caller saves'' convention), there are other | |
3695 | -registers intended for free alteration by a called routine. For these | |
3696 | -registers, relativization makes no difference. | |
3976 | +_fi__(_AMD29K__) | |
3977 | +_if__(_I960__) | |
3978 | +@item target nindy @var{devicename} | |
3979 | +@kindex target nindy | |
3980 | +An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is | |
3981 | +the name of the serial device to use for the connection, e.g. | |
3982 | +@samp{/dev/ttya}. | |
3697 | 3983 | |
3698 | -@table @code | |
3699 | -@item info registers | |
3700 | -@kindex info registers | |
3701 | -Print the names and relativized values of all registers. | |
3984 | +_fi__(_I960__) | |
3985 | +_if__(_VXWORKS__) | |
3986 | +@item target vxworks @var{machinename} | |
3987 | +@kindex target vxworks | |
3988 | +A VxWorks system, attached via TCP/IP. The argument @var{machinename} | |
3989 | +is the target system's machine name or IP address. | |
3702 | 3990 | |
3703 | -@item info registers @var{regname} | |
3704 | -Print the relativized value of register @var{regname}. @var{regname} | |
3705 | -may be any register name valid on the machine you are using, with | |
3706 | -or without the initial @samp{$}. | |
3991 | +_fi__(_VXWORKS__) | |
3707 | 3992 | @end table |
3708 | 3993 | |
3709 | -@subsection Examples | |
3710 | - | |
3711 | -You could print the program counter in hex with | |
3994 | +_if__(_GENERIC__) | |
3995 | +Different targets are available on different configurations of _GDBN__; your | |
3996 | +configuration may have more or fewer targets. | |
3997 | +_fi__(_GENERIC__) | |
3712 | 3998 | |
3713 | -@example | |
3714 | -p/x $pc | |
3715 | -@end example | |
3999 | +@node Remote,,, | |
4000 | +@section Remote Debugging | |
4001 | +@cindex remote debugging | |
3716 | 4002 | |
3717 | -@noindent | |
3718 | -or print the instruction to be executed next with | |
4003 | +If you are trying to debug a program running on a machine that can't run | |
4004 | +_GDBN__ in the usual way, it is often useful to use remote debugging. For | |
4005 | +example, you might be debugging an operating system kernel, or debugging | |
4006 | +a small system which does not have a general purpose operating system | |
4007 | +powerful enough to run a full-featured debugger. Currently _GDBN__ supports | |
4008 | +remote debugging over a serial connection, and (using Sun RPC) over a | |
4009 | +TCP/IP connection. | |
3719 | 4010 | |
3720 | -@example | |
3721 | -x/i $pc | |
3722 | -@end example | |
4011 | +The program to be debugged on the remote machine needs to contain a | |
4012 | +debugging device driver which talks to _GDBN__ over the serial line. The | |
4013 | +same version of _GDBN__ that is used ordinarily can be used for this. | |
4014 | +Several sample remote debugging drivers are distributed with _GDBN__; see | |
4015 | +the @file{README} file in the _GDBN__ distribution for more information. | |
3723 | 4016 | |
3724 | -@noindent | |
3725 | -or add four to the stack pointer with | |
4017 | +@menu | |
4018 | +* Remote Commands:: Commands used to start and finish remote debugging. | |
4019 | +@end menu | |
3726 | 4020 | |
3727 | -@example | |
3728 | -set $sp += 4 | |
3729 | -@end example | |
4021 | +For details of the communication protocol, see the comments in the _GDBN__ | |
4022 | +source file @file{remote.c}. | |
3730 | 4023 | |
3731 | -@noindent | |
3732 | -The last is a way of removing one word from the stack, on machines where | |
3733 | -stacks grow downward in memory (most machines, nowadays). This assumes | |
3734 | -that the innermost stack frame is selected. Setting @code{$sp} is | |
3735 | -not allowed when other stack frames are selected. (To pop entire frames | |
3736 | -off the stack, regardless of machine architecture, use @samp{return}; | |
3737 | -@pxref{Returning}.) | |
4024 | +@node Remote Commands, , Remote, Remote | |
4025 | +@subsection Commands for Remote Debugging | |
3738 | 4026 | |
3739 | -@node Symbols, Altering, Data, Top | |
3740 | -@chapter Examining the Symbol Table | |
4027 | +To start remote debugging, first run _GDBN__ and specify as an executable file | |
4028 | +the program that is running in the remote machine. This tells _GDBN__ how | |
4029 | +to find the program's symbols and the contents of its pure text. Then | |
4030 | +establish communication using the @samp{target remote} command with a device | |
4031 | +name as an argument. For example: | |
3741 | 4032 | |
3742 | -The commands described in this section allow you to inquire about the | |
3743 | -symbols (names of variables, functions and types) defined in your | |
3744 | -program. This information is found by _GDBN__ in the symbol table loaded by | |
3745 | -the @samp{symbol-file} command; it is inherent in the text of your | |
3746 | -program and does not change as the program executes. | |
4033 | +@example | |
4034 | +target remote /dev/ttyb | |
4035 | +@end example | |
3747 | 4036 | |
3748 | -@table @code | |
3749 | -@item info address @var{symbol} | |
3750 | -@kindex info address | |
3751 | -Describe where the data for @var{symbol} is stored. For a register | |
3752 | -variable, this says which register it is kept in. For a non-register | |
3753 | -local variable, this prints the stack-frame offset at which the variable | |
3754 | -is always stored. | |
4037 | +@noindent | |
4038 | +if the serial line is connected to the device named @file{/dev/ttyb}. This | |
4039 | +will stop the remote machine if it is not already stopped. | |
3755 | 4040 | |
3756 | -Note the contrast with @samp{print &@var{symbol}}, which does not work | |
3757 | -at all for a register variables, and for a stack local variable prints | |
3758 | -the exact address of the current instantiation of the variable. | |
4041 | +Now you can use all the usual commands to examine and change data and to | |
4042 | +step and continue the remote program. | |
3759 | 4043 | |
3760 | -@item whatis @var{exp} | |
3761 | -@kindex whatis | |
3762 | -Print the data type of expression @var{exp}. @var{exp} is not | |
3763 | -actually evaluated, and any side-effecting operations (such as | |
3764 | -assignments or function calls) inside it do not take place. | |
3765 | -@xref{Expressions}. | |
4044 | +To resume the remote program and stop debugging it, use the @samp{detach} | |
4045 | +command. | |
3766 | 4046 | |
3767 | -@item whatis | |
3768 | -Print the data type of @code{$}, the last value in the value history. | |
4047 | +Other remote targets be available in your | |
4048 | +configuration of _GDBN__; use @samp{info targets} to list them. | |
3769 | 4049 | |
3770 | -@item ptype @var{typename} | |
3771 | -@kindex ptype | |
3772 | -Print a description of data type @var{typename}. @var{typename} may be | |
3773 | -the name of a type, or for C code it may have the form | |
3774 | -@samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or | |
3775 | -@samp{enum @var{enum-tag}}.@refill | |
4050 | +@table @code | |
4051 | +@item reset | |
4052 | +@kindex reset | |
4053 | +For a target attached through a serial line, this command sends a | |
4054 | +``break'' to the remote target system; this is only useful if the target | |
4055 | +has been equipped with a circuit to perform a hard reset (or some other | |
4056 | +interesting action) when a break is detected. | |
4057 | +@end table | |
3776 | 4058 | |
3777 | -@item ptype @var{exp} | |
3778 | -Print a description of the type of expression @var{exp}. This is like | |
3779 | -@samp{whatis} except it prints a detailed description, instead of just | |
3780 | -the name of the type. For example, if the type of a variable is | |
3781 | -@samp{struct complex @{double real; double imag;@}}, @samp{whatis} will | |
3782 | -print @samp{struct complex} and @samp{ptype} will print @samp{struct | |
3783 | -complex @{double real; double imag;@}} | |
4059 | +@node Controlling _GDBN__,,, | |
4060 | +@chapter Controlling _GDBN__ | |
3784 | 4061 | |
3785 | -@item info sources | |
3786 | -@kindex info sources | |
3787 | -Print the names of all source files in the program for which there | |
3788 | -is debugging information. | |
4062 | +You can alter many aspects of _GDBN__'s interaction with you by using | |
4063 | +the @samp{set} command. | |
3789 | 4064 | |
3790 | -@item info functions | |
3791 | -@kindex info functions | |
3792 | -Print the names and data types of all defined functions. | |
4065 | +@node Prompt,,, | |
4066 | +@section Prompt | |
4067 | +@cindex prompt | |
4068 | +_GDBN__ indicates its readiness to read a command by printing a string | |
4069 | +called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You can | |
4070 | +change the prompt string with the @samp{set prompt} command. For | |
4071 | +instance, when debugging _GDBN__ with _GDBN__, it is useful to change the prompt | |
4072 | +in one of the _GDBN__s so that you tell which one you are talking to. | |
3793 | 4073 | |
3794 | -@item info functions @var{regexp} | |
3795 | -Print the names and data types of all defined functions | |
3796 | -whose names contain a match for regular expression @var{regexp}. | |
3797 | -Thus, @samp{info fun step} finds all functions whose names | |
3798 | -include @samp{step}; @samp{info fun ^step} finds those whose names | |
3799 | -start with @samp{step}. | |
4074 | +@table @code | |
4075 | +@item set prompt @var{newprompt} | |
4076 | +@kindex set prompt | |
4077 | +Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth. | |
4078 | +@kindex show prompt | |
4079 | +@item show prompt | |
4080 | +Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} | |
4081 | +@end table | |
3800 | 4082 | |
3801 | -@item info variables | |
3802 | -@kindex info variables | |
3803 | -Print the names and data types of all variables that are declared | |
3804 | -outside of functions (i.e., except for local variables). | |
4083 | +@node Editing/History,,, | |
4084 | +@section Command Editing and History | |
4085 | +@cindex readline | |
4086 | +@cindex command line editing | |
4087 | +@cindex history substitution | |
4088 | +_GDBN__ reads its input commands via the @code{readline} interface. This | |
4089 | +GNU library provides consistent behavior for programs which provide a | |
4090 | +command line interface to the user. Advantages are @samp{emacs}-style | |
4091 | +or @samp{vi}-style inline editing of commands, @samp{csh}-like history | |
4092 | +substitution, and a storage and recall of command history across | |
4093 | +debugging sessions. | |
3805 | 4094 | |
3806 | -@item info variables @var{regexp} | |
3807 | -Print the names and data types of all variables (except for local | |
3808 | -variables) whose names contain a match for regular expression | |
3809 | -@var{regexp}. | |
4095 | +You may control the behavior of command line editing in _GDBN__ with the | |
4096 | +command @samp{set}. You may check the status of any of these settings | |
4097 | +with the command @samp{show}. | |
3810 | 4098 | |
4099 | +@table @code | |
4100 | +@kindex set editing | |
4101 | +@cindex editing | |
4102 | +@item set editing | |
4103 | +@itemx set editing on | |
4104 | +Enable command line editing (enabled by default). | |
3811 | 4105 | |
3812 | -@ignore | |
3813 | -This was never implemented. | |
3814 | -@item info methods | |
3815 | -@itemx info methods @var{regexp} | |
3816 | -@kindex info methods | |
3817 | -The @samp{info-methods} command permits the user to examine all defined | |
3818 | -methods within C++ program, or (with the @var{regexp} argument) a | |
3819 | -specific set of methods found in the various C++ classes. Many | |
3820 | -C++ classes provide a large number of methods. Thus, the output | |
3821 | -from the @samp{ptype} command can be overwhelming and hard to use. The | |
3822 | -@samp{info-methods} command filters the methods, printing only those | |
3823 | -which match the regular-expression @var{regexp}. | |
3824 | -@end ignore | |
4106 | +@item set editing off | |
4107 | +Disable command line editing. | |
3825 | 4108 | |
3826 | -@item printsyms @var{filename} | |
3827 | -@kindex printsyms | |
3828 | -Write a complete dump of the debugger's symbol data into the | |
3829 | -file @var{filename}. | |
3830 | -@end table | |
4109 | +@kindex show editing | |
4110 | +@item show editing | |
4111 | +Show whether command line editing is enabled. | |
3831 | 4112 | |
3832 | -@node Altering, Sequences, Symbols, Top | |
3833 | -@chapter Altering Execution | |
4113 | +@cindex history file | |
4114 | +@kindex set history file | |
4115 | +@item set history file @var{filename} | |
4116 | +Set the name of the _GDBN__ command history file to @samp{filename}. This is | |
4117 | +the file from which _GDBN__ will read an initial command history | |
4118 | +list or to which it will write this list when it exits. This list is | |
4119 | +accessed through history expansion or through the history | |
4120 | +command editing characters listed below. This file defaults to the | |
4121 | +value of the environmental variable @code{GDBHISTFILE}, or to | |
4122 | +@code{./.gdb_history} if this variable is not set. | |
3834 | 4123 | |
3835 | -Once you think you have found an error in the program, you might want to | |
3836 | -find out for certain whether correcting the apparent error would lead to | |
3837 | -correct results in the rest of the run. You can find the answer by | |
3838 | -experiment, using the _GDBN__ features for altering execution of the | |
3839 | -program. | |
4124 | +@cindex history write | |
4125 | +@kindex set history write | |
4126 | +@item set history write | |
4127 | +@itemx set history write on | |
4128 | +Make _GDBN__ record command history in a file, whose name may be specified with the | |
4129 | +@samp{set history file} command. By default, this option is disabled. | |
3840 | 4130 | |
3841 | -For example, you can store new values into variables or memory | |
3842 | -locations, give the program a signal, restart it at a different address, | |
3843 | -or even return prematurely from a function to its caller. | |
4131 | +@item set history write off | |
4132 | +Make _GDBN__ stop recording command history in a file. | |
3844 | 4133 | |
3845 | -@menu | |
3846 | -* Assignment:: Altering variable values or memory contents. | |
3847 | -* Jumping:: Altering control flow. | |
3848 | -* Signaling:: Making signals happen in the program. | |
3849 | -* Returning:: Making a function return prematurely. | |
3850 | -* Calling:: Calling functions from your program | |
3851 | -@end menu | |
4134 | +@cindex history size | |
4135 | +@kindex set history size | |
4136 | +@item set history size @var{size} | |
4137 | +Set the number of commands which _GDBN__ will keep in its history list. | |
4138 | +This defaults to the value of the environmental variable | |
4139 | +@code{HISTSIZE}, or to 256 if this variable is not set. | |
4140 | +@end table | |
3852 | 4141 | |
3853 | -@node Assignment, Jumping, Altering, Altering | |
3854 | -@section Assignment to Variables | |
4142 | +@cindex history expansion | |
4143 | +History expansion assigns special meaning to the character @samp{!} | |
4144 | +(@pxref{Event Designators}). Since @samp{!} is also the logical not | |
4145 | +operator in C, history expansion is off by default. If you decide to | |
4146 | +enable history expansion with the @samp{set history expansion on} | |
4147 | +command, you may sometimes need to follow @samp{!} (when it is used as | |
4148 | +logical not, in an expression) with a space or a tab to prevent it from | |
4149 | +being expanded. The @code{readline} history facilities will not attempt | |
4150 | +substitution on the strings @samp{!=} and @samp{!(}, even when history | |
4151 | +expansion is enabled. | |
3855 | 4152 | |
3856 | -@cindex assignment | |
3857 | -@cindex setting variables | |
3858 | -To alter the value of a variable, evaluate an assignment expression. | |
3859 | -@xref{Expressions}. For example, | |
4153 | +The commands to control history expansion are: | |
3860 | 4154 | |
3861 | -@example | |
3862 | -print x=4 | |
3863 | -@end example | |
4155 | +@table @code | |
3864 | 4156 | |
3865 | -@noindent | |
3866 | -would store the value 4 into the variable @code{x}, and then print | |
3867 | -the value of the assignment expression (which is 4). | |
4157 | +@kindex set history expansion | |
4158 | +@item set history expansion on | |
4159 | +@itemx set history expansion | |
4160 | +Enable history expansion. History expansion is off by default. | |
3868 | 4161 | |
3869 | -All the assignment operators of C are supported, including the | |
3870 | -increment operators @samp{++} and @samp{--}, and combining | |
3871 | -assignments such as @samp{+=} and @samp{<<=}. | |
4162 | +@item set history expansion off | |
4163 | +Disable history expansion. | |
3872 | 4164 | |
3873 | -@kindex set | |
3874 | -@kindex set variable | |
3875 | -@cindex variables, setting | |
3876 | -If you are not interested in seeing the value of the assignment, use the | |
3877 | -@samp{set} command instead of the @samp{print} command. @samp{set} is | |
3878 | -really the same as @samp{print} except that the expression's value is not | |
3879 | -printed and is not put in the value history (@pxref{Value History}). The | |
3880 | -expression is evaluated only for side effects. | |
4165 | +The @code{readline} code comes with more complete documentation of | |
4166 | +editing and history expansion features. Users unfamiliar with @samp{emacs} | |
4167 | +or @samp{vi} may wish to read it. @xref{Command Line Editing}. | |
3881 | 4168 | |
3882 | -Note that if the beginning of the argument string of the @samp{set} command | |
3883 | -appears identical to a @samp{set} subcommand, it may be necessary to use | |
3884 | -the @samp{set variable} command. This command is identical to @samp{set} | |
3885 | -except for its lack of subcommands. | |
4169 | +@kindex show history | |
4170 | +@item show history | |
4171 | +@itemx show history file | |
4172 | +@itemx show history write | |
4173 | +@itemx show history size | |
4174 | +@itemx show history expansion | |
4175 | +These commands display the state of the _GDBN__ history parameters. | |
4176 | +@samp{show history} by itself displays all four states. | |
3886 | 4177 | |
3887 | -_GDBN__ allows more implicit conversions in assignments than C does; you can | |
3888 | -freely store an integer value into a pointer variable or vice versa, and | |
3889 | -any structure can be converted to any other structure that is the same | |
3890 | -length or shorter. | |
3891 | -@comment FIXME: how do structs align/pad in these conversions? | |
3892 | -@comment /pesch@cygnus.com 18dec1990 | |
4178 | +@end table | |
3893 | 4179 | |
3894 | -To store values into arbitrary places in memory, use the @samp{@{@dots{}@}} | |
3895 | -construct to generate a value of specified type at a specified address | |
3896 | -(@pxref{Expressions}). For example, @code{@{int@}0x83040} would refer | |
3897 | -to memory location 0x83040 as an integer (which implies a certain size | |
3898 | -and representation in memory), and | |
4180 | +@table @code | |
4181 | +@kindex info editing | |
4182 | +@item info editing | |
4183 | +Display the last ten commands in the command history. | |
3899 | 4184 | |
3900 | -@example | |
3901 | -set @{int@}0x83040 = 4 | |
3902 | -@end example | |
4185 | +@item info editing @var{n} | |
4186 | +Print ten commands centered on command number @var{n}. | |
3903 | 4187 | |
3904 | -would store the value 4 into that memory location. | |
4188 | +@item info editing + | |
4189 | +Print ten commands just after the commands last printed. | |
3905 | 4190 | |
3906 | -@node Jumping, Signaling, Assignment, Altering | |
3907 | -@section Continuing at a Different Address | |
4191 | +@end table | |
3908 | 4192 | |
3909 | -Ordinarily, when you continue the program, you do so at the place where | |
3910 | -it stopped, with the @samp{cont} command. You can instead continue at | |
3911 | -an address of your own choosing, with the following commands: | |
4193 | +@node Screen Size,,, | |
4194 | +@section Screen Size | |
4195 | +@cindex size of screen | |
4196 | +@cindex pauses in output | |
4197 | +Certain commands to _GDBN__ may produce large amounts of information output | |
4198 | +to the screen. To help you read all of it, _GDBN__ pauses and asks you for | |
4199 | +input at the end of each page of output. Type @key{RET} when you want | |
4200 | +to continue the output. Normally _GDBN__ knows the size of the screen from | |
4201 | +the termcap data base together with the value of the @code{TERM} | |
4202 | +environment variable and the @code{stty rows} and @code{stty cols} | |
4203 | +settings. If this is not correct, you can override it with | |
4204 | +the @samp{set screen-height} and @samp{set screen-width} commands: | |
3912 | 4205 | |
3913 | -@table @code | |
3914 | -@item jump @var{linenum} | |
3915 | -@kindex jump | |
3916 | -Resume execution at line number @var{linenum}. Execution may stop | |
3917 | -immediately if there is a breakpoint there. | |
4206 | +_GDBN__ also uses the screen width setting to determine when to wrap lines | |
4207 | +of output. Depending what is being printed, it tries to break the | |
4208 | +line at a readable place, rather than simply letting it overflow onto | |
4209 | +the following line. | |
3918 | 4210 | |
3919 | -The @samp{jump} command does not change the current stack frame, or | |
3920 | -the stack pointer, or the contents of any memory location or any | |
3921 | -register other than the program counter. If line @var{linenum} is in | |
3922 | -a different function from the one currently executing, the results may | |
3923 | -be bizarre if the two functions expect different patterns of arguments or | |
3924 | -of local variables. For this reason, the @samp{jump} command requests | |
3925 | -confirmation if the specified line is not in the function currently | |
3926 | -executing. However, even bizarre results are predictable based on | |
3927 | -careful study of the machine-language code of the program. | |
4211 | +@table @code | |
4212 | +@item set screen-height @var{lpp} | |
4213 | +@itemx show screen-height | |
4214 | +@itemx set screen-width @var{cpl} | |
4215 | +@itemx show screen-width | |
4216 | +@kindex set screen-height | |
4217 | +@kindex set screen-width | |
4218 | +@kindex show screen-width | |
4219 | +@kindex show screen-height | |
4220 | +These @samp{set} commands specify a screen height of @var{lpp} lines and | |
4221 | +a screen width of @var{cpl} characters. The associated @samp{show} | |
4222 | +commands display the current settings. | |
3928 | 4223 | |
3929 | -@item jump *@var{address} | |
3930 | -Resume execution at the instruction at address @var{address}. | |
4224 | +If you specify a height of zero lines, _GDBN__ will not pause during output | |
4225 | +no matter how long the output is. This is useful if output is to a file | |
4226 | +or to an editor buffer. | |
3931 | 4227 | @end table |
3932 | 4228 | |
3933 | -You can get much the same effect as the @code{jump} command by storing a | |
3934 | -new value into the register @code{$pc}. The difference is that this | |
3935 | -does not start the program running; it only changes the address where it | |
3936 | -@emph{will} run when it is continued. For example, | |
4229 | +@node Numbers,,, | |
4230 | +@section Numbers | |
4231 | +@cindex number representation | |
4232 | +@cindex entering numbers | |
4233 | +You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by | |
4234 | +the usual conventions: octal numbers begin with @samp{0}, decimal | |
4235 | +numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}. | |
4236 | +Numbers that begin with none of these are, by default, entered in base | |
4237 | +10; likewise, the default display for numbers---when no particular | |
4238 | +format is specified---is base 10. You can change the default base for | |
4239 | +both input and output with the @samp{set radix} command. | |
4240 | + | |
4241 | +@table @code | |
4242 | +@kindex set radix | |
4243 | +@item set radix @var{base} | |
4244 | +Set the default base for numeric input and display. Supported choices | |
4245 | +for @var{base} are decimal 8, 10, 16. @var{base} must itself be | |
4246 | +specified either unambiguously or using the current default radix; for | |
4247 | +example, any of | |
3937 | 4248 | |
3938 | 4249 | @example |
3939 | -set $pc = 0x485 | |
4250 | +set radix 012 | |
4251 | +set radix 10. | |
4252 | +set radix 0xa | |
3940 | 4253 | @end example |
3941 | 4254 | |
3942 | 4255 | @noindent |
3943 | -causes the next @samp{cont} command or stepping command to execute at | |
3944 | -address 0x485, rather than at the address where the program stopped. | |
3945 | -@xref{Stepping}. | |
4256 | +will set the base to decimal. On the other hand, @samp{set radix 10} | |
4257 | +will leave the radix unchanged no matter what it was. | |
3946 | 4258 | |
3947 | -The most common occasion to use the @samp{jump} command is to back up, | |
3948 | -perhaps with more breakpoints set, over a portion of a program that has | |
3949 | -already executed. | |
4259 | +@kindex show radix | |
4260 | +@item show radix | |
4261 | +Display the current default base for numeric input and display. | |
3950 | 4262 | |
3951 | -@node Signaling, Returning, Jumping, Altering | |
3952 | -@section Giving the Program a Signal | |
4263 | +@end table | |
4264 | + | |
4265 | +@node Messages/Warnings,,, | |
4266 | +@section Optional Warnings and Messages | |
4267 | +By default, _GDBN__ is silent about its inner workings. If you are running | |
4268 | +on a slow machine, you may want to use the @samp{set verbose} command. | |
4269 | +It will make _GDBN__ tell you when it does a lengthy internal operation, so | |
4270 | +you won't think it has crashed. | |
4271 | + | |
4272 | +Currently, the messages controlled by @samp{set verbose} are those which | |
4273 | +announce that the symbol table for a source file is being read | |
4274 | +(@pxref{Files}, in the description of the command | |
4275 | +@samp{symbol-file}). | |
4276 | +@c The following is the right way to do it, but emacs 18.55 doesn't support | |
4277 | +@c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo | |
4278 | +@c is released. | |
4279 | +@ignore | |
4280 | +see @samp{symbol-file} in @ref{Files}). | |
4281 | +@end ignore | |
3953 | 4282 | |
3954 | 4283 | @table @code |
3955 | -@item signal @var{signalnum} | |
3956 | -@kindex signal | |
3957 | -Resume execution where the program stopped, but give it immediately the | |
3958 | -signal number @var{signalnum}. | |
4284 | +@kindex set verbose | |
4285 | +@item set verbose on | |
4286 | +Enables _GDBN__'s output of certain informational messages. | |
3959 | 4287 | |
3960 | -Alternatively, if @var{signalnum} is zero, continue execution without | |
3961 | -giving a signal. This is useful when the program stopped on account of | |
3962 | -a signal and would ordinary see the signal when resumed with the | |
3963 | -@samp{cont} command; @samp{signal 0} causes it to resume without a | |
3964 | -signal. | |
4288 | +@item set verbose off | |
4289 | +Disables _GDBN__'s output of certain informational messages. | |
4290 | + | |
4291 | +@kindex show verbose | |
4292 | +@item show verbose | |
4293 | +Displays whether @samp{set verbose} is on or off. | |
3965 | 4294 | @end table |
3966 | 4295 | |
3967 | -@node Returning, Calling, Signaling, Altering | |
3968 | -@section Returning from a Function | |
4296 | +By default, if _GDBN__ encounters bugs in the symbol table of an object file, | |
4297 | +it prints a single message about each type of problem it finds, then | |
4298 | +shuts up. You can suppress these messages, or allow more than one such | |
4299 | +message to be printed if you want to see how frequent the problems are. | |
4300 | +@xref{Files}. | |
3969 | 4301 | |
3970 | 4302 | @table @code |
3971 | -@item return | |
3972 | -@cindex returning from a function | |
3973 | -@kindex return | |
3974 | -You can cancel execution of a function call with the @samp{return} | |
3975 | -command. | |
4303 | +@kindex set complaints | |
4304 | +@item set complaints @var{limit} | |
4305 | +Permits _GDBN__ to output @var{limit} complaints about each type of unusual | |
4306 | +symbols before becoming silent about the problem. Set @var{limit} to | |
4307 | +zero to suppress all complaints; set it to a large number to prevent | |
4308 | +complaints from being suppressed. | |
4309 | + | |
4310 | +@kindex show complaints | |
4311 | +@item show complaints | |
4312 | +Displays how many symbol complaints _GDBN__ is permitted to produce. | |
3976 | 4313 | @end table |
3977 | 4314 | |
3978 | -This command has the effect of discarding the selected stack | |
3979 | -frame (and all frames within it), so that control moves to the caller of | |
3980 | -that function. You can think of this as making the discarded frame | |
3981 | -return prematurely. | |
4315 | +By default, _GDBN__ is cautious, and asks what sometimes seem to be a lot of | |
4316 | +stupid questions. For example, if you try to run a program which is | |
4317 | +already running: | |
4318 | +@example | |
3982 | 4319 | |
3983 | -First select the stack frame that you wish to return from | |
3984 | -(@pxref{Selection}). Then type the @samp{return} command. If you wish | |
3985 | -to specify the value to be returned, give that as an argument. | |
4320 | +(_GDBP__) run | |
4321 | +The program being debugged has been started already. | |
4322 | +Start it from the beginning? (y or n) | |
4323 | +@end example | |
3986 | 4324 | |
3987 | -This pops the selected stack frame (and any other frames inside of it), | |
3988 | -leaving its caller as the innermost remaining frame. That frame becomes | |
3989 | -selected. The specified value is stored in the registers used for | |
3990 | -returning values of functions. | |
4325 | +If you're willing to unflinchingly face the consequences of your own | |
4326 | +commands, you can disable this ``feature'': | |
3991 | 4327 | |
3992 | -The @samp{return} command does not resume execution; it leaves the | |
3993 | -program stopped in the state that would exist if the function had just | |
3994 | -returned. Contrast this with the @samp{finish} command | |
3995 | -(@pxref{Stepping}), which resumes execution until the selected stack | |
3996 | -frame returns @emph{naturally}. | |
4328 | +@table @code | |
4329 | +@kindex set caution | |
4330 | +@cindex flinching | |
4331 | +@cindex stupid questions | |
4332 | +@item set caution off | |
4333 | +Disables cautious questions. | |
3997 | 4334 | |
3998 | -@node Calling, , Returning, Altering | |
3999 | -@comment node-name, next, previous, up | |
4000 | -@section Calling your Program's Functions | |
4335 | +@item set caution on | |
4336 | +Enables cautious questions (the default). | |
4001 | 4337 | |
4002 | -@cindex calling functions | |
4003 | -@kindex call | |
4004 | -@table @code | |
4005 | -@item call @var{expr} | |
4006 | -Evaluate the expression @var{expr} without displaying @code{void} | |
4007 | -returned values. | |
4338 | +@item show caution | |
4339 | +@kindex show caution | |
4340 | +Displays state of cautious questions. | |
4008 | 4341 | @end table |
4009 | 4342 | |
4010 | -You can use this variant of the @samp{print} command if you want to | |
4011 | -execute some piece of your program, but without cluttering the output | |
4012 | -with @code{void} returned values. The result is printed and saved in | |
4013 | -the value history, if it is not void. | |
4014 | - | |
4015 | 4343 | @node Sequences, Emacs, Altering, Top |
4016 | 4344 | @chapter Canned Sequences of Commands |
4017 | 4345 |
@@ -4205,7 +4533,7 @@ All the facilities of Emacs' Shell mode are available for this purpose. | ||
4205 | 4533 | @item |
4206 | 4534 | _GDBN__ displays source code through Emacs. Each time _GDBN__ displays a |
4207 | 4535 | stack frame, Emacs automatically finds the source file for that frame |
4208 | -and puts an arrow (@samp{=>}) at the left margin of the current line. | |
4536 | +and puts an arrow (_0__@samp{=>}_1__) at the left margin of the current line. | |
4209 | 4537 | Emacs uses a separate buffer for source display, and splits the window |
4210 | 4538 | to show both your _GDBN__ session and the source. |
4211 | 4539 |
@@ -4330,66 +4658,6 @@ environment. Users of this environment can use a new command, | ||
4330 | 4658 | each value is printed in its own window. |
4331 | 4659 | @end ignore |
4332 | 4660 | |
4333 | -@node Remote, _GDBN__ Bugs, Emacs, Top | |
4334 | -@chapter Remote Debugging | |
4335 | -@cindex remote debugging | |
4336 | - | |
4337 | -If you are trying to debug a program running on a machine that can't run | |
4338 | -_GDBN__ in the usual way, it is often useful to use remote debugging. For | |
4339 | -example, you might be debugging an operating system kernel, or debugging | |
4340 | -a small system which does not have a general purpose operating system | |
4341 | -powerful enough to run a full-featured debugger. Currently _GDBN__ supports | |
4342 | -remote debugging over a serial connection, and (using Sun RPC) over a | |
4343 | -TCP/IP connection. | |
4344 | - | |
4345 | -The program to be debugged on the remote machine needs to contain a | |
4346 | -debugging device driver which talks to _GDBN__ over the serial line. The | |
4347 | -same version of _GDBN__ that is used ordinarily can be used for this. | |
4348 | -Several sample remote debugging drivers are distributed with _GDBN__; see | |
4349 | -the @file{README} file in the _GDBN__ distribution for more information. | |
4350 | - | |
4351 | -@menu | |
4352 | -* Remote Commands:: Commands used to start and finish remote debugging. | |
4353 | -@end menu | |
4354 | - | |
4355 | -For details of the communication protocol, see the comments in the _GDBN__ | |
4356 | -source file @file{remote.c}. | |
4357 | - | |
4358 | -@node Remote Commands, , Remote, Remote | |
4359 | -@section Commands for Remote Debugging | |
4360 | - | |
4361 | -To start remote debugging, first run _GDBN__ and specify as an executable file | |
4362 | -the program that is running in the remote machine. This tells _GDBN__ how | |
4363 | -to find the program's symbols and the contents of its pure text. Then | |
4364 | -establish communication using the @samp{target remote} command with a device | |
4365 | -name as an argument. For example: | |
4366 | - | |
4367 | -@example | |
4368 | -target remote /dev/ttyb | |
4369 | -@end example | |
4370 | - | |
4371 | -@noindent | |
4372 | -if the serial line is connected to the device named @file{/dev/ttyb}. This | |
4373 | -will stop the remote machine if it is not already stopped. | |
4374 | - | |
4375 | -Now you can use all the usual commands to examine and change data and to | |
4376 | -step and continue the remote program. | |
4377 | - | |
4378 | -To resume the remote program and stop debugging it, use the @samp{detach} | |
4379 | -command. | |
4380 | - | |
4381 | -Other remote targets be available in your | |
4382 | -configuration of _GDBN__; use @samp{info targets} to list them. | |
4383 | - | |
4384 | -@table @code | |
4385 | -@item reset | |
4386 | -@kindex reset | |
4387 | -For a target attached through a serial line, this command sends a | |
4388 | -``break'' to the remote target system; this is only useful if the target | |
4389 | -has been equipped with a circuit to perform a hard reset (or some other | |
4390 | -interesting action) when a break is detected. | |
4391 | -@end table | |
4392 | - | |
4393 | 4661 | @node _GDBN__ Bugs, Installing _GDBN__, Remote, Top |
4394 | 4662 | @comment node-name, next, previous, up |
4395 | 4663 | @chapter Reporting Bugs in _GDBN__ |
@@ -4445,23 +4713,12 @@ for improvement of _GDBN__ are welcome in any case. | ||
4445 | 4713 | @cindex Bug Reports |
4446 | 4714 | @cindex Compiler Bugs, Reporting |
4447 | 4715 | |
4448 | -@comment The following is meant to be neutral and helpful, not just a plug for | |
4449 | -@comment Cygnus; feedback on the issue (to "pesch@cygnus.com" or | |
4450 | -@comment "info@cygnus.com"---the latter will reach all of Cygnus) | |
4451 | -@comment is welcome. | |
4452 | 4716 | A number of companies and individuals offer support for GNU products. |
4453 | 4717 | If you obtained _GDBN__ from a support organization, we recommend you |
4454 | 4718 | contact that organization first. |
4455 | 4719 | |
4456 | -Among these organizations are Cygnus Support (Palo Alto CA, USA); C2V | |
4457 | -(Paris, France); Dynamix Corporation (King of Prussia PA, USA); The Nice | |
4458 | -Computer Company (Perth, Australia); Optimal Solutions (Seattle WA, | |
4459 | -USA); and The Pharos Group (Las Cruces NM, USA). | |
4460 | - | |
4461 | -Full contact information is in the file @samp{etc/SERVICE} in the GNU | |
4462 | -Emacs distribution. Numerous individual consultants are also listed | |
4463 | -there. | |
4464 | -@comment END NEUTRAL+HELPFUL section | |
4720 | +Contact information for many support companies and individuals is | |
4721 | +available in the file @samp{etc/SERVICE} in the GNU Emacs distribution. | |
4465 | 4722 | |
4466 | 4723 | In any event, we also recommend that you send bug reports for _GDBN__ to one |
4467 | 4724 | of these addresses: |
@@ -4520,8 +4777,8 @@ To enable us to fix the bug, you should include all these things: | ||
4520 | 4777 | |
4521 | 4778 | @itemize @bullet |
4522 | 4779 | @item |
4523 | -The version of _GDBN__. _GDBN__ announces it on startup; you can also print it | |
4524 | -at any time using @samp{info version}. | |
4780 | +The version of _GDBN__. _GDBN__ announces it if you start with no | |
4781 | +arguments; you can also print it at any time using @samp{show version}. | |
4525 | 4782 | |
4526 | 4783 | Without this, we won't know whether there is any point in looking for |
4527 | 4784 | the bug in the current version of _GDBN__. |
@@ -4972,15 +5229,25 @@ Ty Coon, President of Vice | ||
4972 | 5229 | |
4973 | 5230 | That's all there is to it! |
4974 | 5231 | |
4975 | -@node Commands, Concepts, License, Top | |
4976 | -@unnumbered Command Index | |
4977 | - | |
4978 | -@printindex ky | |
4979 | - | |
4980 | -@node Concepts, , Commands, Top | |
5232 | +@node Index,,, | |
4981 | 5233 | @unnumbered Index |
4982 | 5234 | |
4983 | 5235 | @printindex cp |
4984 | 5236 | |
5237 | +@tex | |
5238 | +% I think something like @colophon should be in texinfo. In the | |
5239 | +% meantime: | |
5240 | +\long\def\colophon{\hbox to0pt{}\vfill | |
5241 | +\centerline{The body of this manual is set in} | |
5242 | +\centerline{\fontname\tenrm,} | |
5243 | +\centerline{with headings in {\bf\fontname\tenbf}} | |
5244 | +\centerline{and examples in {\tt\fontname\tentt}.} | |
5245 | +\centerline{{\it\fontname\tenit\/} and} | |
5246 | +\centerline{{\sl\fontname\tensl\/}} | |
5247 | +\centerline{are used for emphasis.}\vfill} | |
5248 | +\page\colophon | |
5249 | +% Blame: pesch@cygnus.com, 28mar91. | |
5250 | +@end tex | |
5251 | + | |
4985 | 5252 | @contents |
4986 | 5253 | @bye |