1 \input texinfo @c -*-texinfo-*-
2 @c Copyright (c) 1988 1989 1990 1991 1992 1993 Free Software Foundation, Inc.
5 @c makeinfo ignores cmds prev to setfilename, so its arg cannot make use
6 @c of @set vars. However, we can override filename with makeinfo -o.
9 @include gdb-config.texi
12 @settitle Debugging with @value{GDBN}
15 @settitle Debugging with @value{GDBN} (@value{HOST})
17 @setchapternewpage odd
25 @c Include the readline documentation in the TeX output,
26 @c but not in the Info output.
27 @c Eventually, we should make a cross reference to the Readline Info
28 @c nodes; but this requires that the nodes exist and be in an expected
29 @c place. Wait for a standard, complete GNU distribution. Meanwhile,
30 @c cross references are only in the printed TeX output, and only when
31 @c `have-readline-appendices' is set.
33 @c The readline documentation is distributed with the readline code
34 @c and consists of the two following files:
38 @set have-readline-appendices
41 @clear have-readline-appendices
47 @c readline appendices use @vindex
51 @c Determine the edition number in *three* places by hand:
52 @c 1. First ifinfo section 2. title page 3. top node
53 @c To find the locations, search for !!set
55 @c GDB CHANGELOG CONSULTED BETWEEN:
56 @c Fri Oct 11 23:27:06 1991 John Gilmore (gnu at cygnus.com)
57 @c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint)
59 @c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly.
62 @c This is a dir.info fragment to support semi-automated addition of
63 @c manuals to an info tree. zoo@cygnus.com is developing this facility.
66 * Gdb: (gdb). The GNU debugger.
73 This file documents the GNU debugger @value{GDBN}.
75 @c !!set edition, date, version
76 This is Edition 4.07, January 1993,
77 of @cite{Debugging with @value{GDBN}: the GNU Source-Level Debugger}
78 for GDB Version @value{GDBVN}.
80 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
82 Permission is granted to make and distribute verbatim copies of
83 this manual provided the copyright notice and this permission notice
84 are preserved on all copies.
87 Permission is granted to process this file through TeX and print the
88 results, provided the printed document carries copying permission
89 notice identical to this one except for the removal of this paragraph
90 (this paragraph not being relevant to the printed manual).
93 Permission is granted to copy and distribute modified versions of this
94 manual under the conditions for verbatim copying, provided also that the
95 section entitled ``GNU General Public License'' is included exactly as
96 in the original, and provided that the entire resulting derived work is
97 distributed under the terms of a permission notice identical to this
100 Permission is granted to copy and distribute translations of this manual
101 into another language, under the above conditions for modified versions,
102 except that the section entitled ``GNU General Public License'' may be
103 included in a translation approved by the Free Software Foundation
104 instead of in the original English.
108 @title Debugging with @value{GDBN}
109 @subtitle The GNU Source-Level Debugger
111 @subtitle on @value{HOST} Systems
114 @c !!set edition, date, version
115 @subtitle Edition 4.07, for @value{GDBN} version @value{GDBVN}
116 @subtitle January 1993
117 @author by Richard M. Stallman and Roland H. Pesch
121 \hfill (Send bugs and comments on @value{GDBN} to bug-gdb\@prep.ai.mit.edu.)\par
122 \hfill {\it Debugging with @value{GDBN}}\par
123 \hfill \TeX{}info \texinfoversion\par
124 \hfill pesch\@cygnus.com\par
128 @vskip 0pt plus 1filll
129 Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
131 Permission is granted to make and distribute verbatim copies of
132 this manual provided the copyright notice and this permission notice
133 are preserved on all copies.
135 Permission is granted to copy and distribute modified versions of this
136 manual under the conditions for verbatim copying, provided also that the
137 section entitled ``GNU General Public License'' is included exactly as
138 in the original, and provided that the entire resulting derived work is
139 distributed under the terms of a permission notice identical to this
142 Permission is granted to copy and distribute translations of this manual
143 into another language, under the above conditions for modified versions,
144 except that the section entitled ``GNU General Public License'' may be
145 included in a translation approved by the Free Software Foundation
146 instead of in the original English.
152 @top Debugging with @value{GDBN}
154 This file describes @value{GDBN}, the GNU symbolic debugger.
156 @c !!set edition, date, version
157 This is Edition 4.07, January 1993, for GDB Version @value{GDBVN}.
159 @c Makeinfo node defaulting gets very confused by conditionals in menus,
160 @c unfortunately. Otherwise we would use the following ignored menu,
161 @c which involves four switches:
164 * Summary:: Summary of @value{GDBN}
166 * New Features:: New features since GDB version 3.5
169 * Sample Session:: A sample @value{GDBN} session
171 * Invocation:: Getting in and out of @value{GDBN}
172 * Commands:: @value{GDBN} commands
173 * Running:: Running programs under @value{GDBN}
174 * Stopping:: Stopping and continuing
175 * Stack:: Examining the stack
176 * Source:: Examining source files
177 * Data:: Examining data
179 * Languages:: Using @value{GDBN} with different languages
184 * Symbols:: Examining the symbol table
185 * Altering:: Altering execution
186 * GDB Files:: @value{GDBN} files
187 * Targets:: Specifying a debugging target
188 * Controlling GDB:: Controlling @value{GDBN}
189 * Sequences:: Canned sequences of commands
191 * Emacs:: Using @value{GDBN} under GNU Emacs
193 * GDB Bugs:: Reporting bugs in @value{GDBN}
197 * Formatting Documentation:: How to format and print GDB documentation
198 * Installing GDB:: Installing GDB
199 * Copying:: GNU GENERAL PUBLIC LICENSE
204 @c Since that does not work, we must unroll the above into 16 cases:
206 @c Menu for NOVEL && !BARETARGET && !CONLY && !DOSHOST
212 * Summary:: Summary of @value{GDBN}
213 * New Features:: New features since GDB version 3.5
214 * Sample Session:: A sample @value{GDBN} session
215 * Invocation:: Getting in and out of @value{GDBN}
216 * Commands:: @value{GDBN} commands
217 * Running:: Running programs under @value{GDBN}
218 * Stopping:: Stopping and continuing
219 * Stack:: Examining the stack
220 * Source:: Examining source files
221 * Data:: Examining data
222 * Languages:: Using @value{GDBN} with different languages
223 * Symbols:: Examining the symbol table
224 * Altering:: Altering execution
225 * GDB Files:: @value{GDBN} files
226 * Targets:: Specifying a debugging target
227 * Controlling GDB:: Controlling @value{GDBN}
228 * Sequences:: Canned sequences of commands
229 * Emacs:: Using @value{GDBN} under GNU Emacs
230 * GDB Bugs:: Reporting bugs in @value{GDBN}
232 * Formatting Documentation:: How to format and print GDB documentation
233 * Installing GDB:: Installing GDB
234 * Copying:: GNU GENERAL PUBLIC LICENSE
242 @c Menu for NOVEL && !BARETARGET && !CONLY && DOSHOST
248 * Summary:: Summary of @value{GDBN}
249 * New Features:: New features since GDB version 3.5
250 * Sample Session:: A sample @value{GDBN} session
251 * Invocation:: Getting in and out of @value{GDBN}
252 * Commands:: @value{GDBN} commands
253 * Running:: Running programs under @value{GDBN}
254 * Stopping:: Stopping and continuing
255 * Stack:: Examining the stack
256 * Source:: Examining source files
257 * Data:: Examining data
258 * Languages:: Using @value{GDBN} with different languages
259 * Symbols:: Examining the symbol table
260 * Altering:: Altering execution
261 * GDB Files:: @value{GDBN} files
262 * Targets:: Specifying a debugging target
263 * Controlling GDB:: Controlling @value{GDBN}
264 * Sequences:: Canned sequences of commands
265 * GDB Bugs:: Reporting bugs in @value{GDBN}
267 * Formatting Documentation:: How to format and print GDB documentation
268 * Installing GDB:: Installing GDB
269 * Copying:: GNU GENERAL PUBLIC LICENSE
277 @c Menu for NOVEL && !BARETARGET && CONLY && !DOSHOST
283 * Summary:: Summary of @value{GDBN}
284 * New Features:: New features since GDB version 3.5
285 * Sample Session:: A sample @value{GDBN} session
286 * Invocation:: Getting in and out of @value{GDBN}
287 * Commands:: @value{GDBN} commands
288 * Running:: Running programs under @value{GDBN}
289 * Stopping:: Stopping and continuing
290 * Stack:: Examining the stack
291 * Source:: Examining source files
292 * Data:: Examining data
293 * C:: C Language Support
294 * Symbols:: Examining the symbol table
295 * Altering:: Altering execution
296 * GDB Files:: @value{GDBN} files
297 * Targets:: Specifying a debugging target
298 * Controlling GDB:: Controlling @value{GDBN}
299 * Sequences:: Canned sequences of commands
300 * Emacs:: Using @value{GDBN} under GNU Emacs
301 * GDB Bugs:: Reporting bugs in @value{GDBN}
303 * Formatting Documentation:: How to format and print GDB documentation
304 * Installing GDB:: Installing GDB
305 * Copying:: GNU GENERAL PUBLIC LICENSE
313 @c Menu for NOVEL && !BARETARGET && CONLY && DOSHOST
319 * Summary:: Summary of @value{GDBN}
320 * New Features:: New features since GDB version 3.5
321 * Sample Session:: A sample @value{GDBN} session
322 * Invocation:: Getting in and out of @value{GDBN}
323 * Commands:: @value{GDBN} commands
324 * Running:: Running programs under @value{GDBN}
325 * Stopping:: Stopping and continuing
326 * Stack:: Examining the stack
327 * Source:: Examining source files
328 * Data:: Examining data
329 * C:: C Language Support
330 * Symbols:: Examining the symbol table
331 * Altering:: Altering execution
332 * GDB Files:: @value{GDBN} files
333 * Targets:: Specifying a debugging target
334 * Controlling GDB:: Controlling @value{GDBN}
335 * Sequences:: Canned sequences of commands
336 * GDB Bugs:: Reporting bugs in @value{GDBN}
338 * Formatting Documentation:: How to format and print GDB documentation
339 * Installing GDB:: Installing GDB
340 * Copying:: GNU GENERAL PUBLIC LICENSE
348 @c Menu for NOVEL && BARETARGET && !CONLY && !DOSHOST
354 * Summary:: Summary of @value{GDBN}
355 * New Features:: New features since GDB version 3.5
356 * Invocation:: Getting in and out of @value{GDBN}
357 * Commands:: @value{GDBN} commands
358 * Running:: Running programs under @value{GDBN}
359 * Stopping:: Stopping and continuing
360 * Stack:: Examining the stack
361 * Source:: Examining source files
362 * Data:: Examining data
363 * Languages:: Using @value{GDBN} with different languages
364 * Symbols:: Examining the symbol table
365 * Altering:: Altering execution
366 * GDB Files:: @value{GDBN} files
367 * Targets:: Specifying a debugging target
368 * Controlling GDB:: Controlling @value{GDBN}
369 * Sequences:: Canned sequences of commands
370 * Emacs:: Using @value{GDBN} under GNU Emacs
371 * GDB Bugs:: Reporting bugs in @value{GDBN}
373 * Formatting Documentation:: How to format and print GDB documentation
374 * Installing GDB:: Installing GDB
375 * Copying:: GNU GENERAL PUBLIC LICENSE
383 @c Menu for NOVEL && BARETARGET && !CONLY && DOSHOST
389 * Summary:: Summary of @value{GDBN}
390 * New Features:: New features since GDB version 3.5
391 * Invocation:: Getting in and out of @value{GDBN}
392 * Commands:: @value{GDBN} commands
393 * Running:: Running programs under @value{GDBN}
394 * Stopping:: Stopping and continuing
395 * Stack:: Examining the stack
396 * Source:: Examining source files
397 * Data:: Examining data
398 * Languages:: Using @value{GDBN} with different languages
399 * Symbols:: Examining the symbol table
400 * Altering:: Altering execution
401 * GDB Files:: @value{GDBN} files
402 * Targets:: Specifying a debugging target
403 * Controlling GDB:: Controlling @value{GDBN}
404 * Sequences:: Canned sequences of commands
405 * GDB Bugs:: Reporting bugs in @value{GDBN}
407 * Formatting Documentation:: How to format and print GDB documentation
408 * Installing GDB:: Installing GDB
409 * Copying:: GNU GENERAL PUBLIC LICENSE
417 @c Menu for NOVEL && BARETARGET && CONLY && !DOSHOST
423 * Summary:: Summary of @value{GDBN}
424 * New Features:: New features since GDB version 3.5
425 * Invocation:: Getting in and out of @value{GDBN}
426 * Commands:: @value{GDBN} commands
427 * Running:: Running programs under @value{GDBN}
428 * Stopping:: Stopping and continuing
429 * Stack:: Examining the stack
430 * Source:: Examining source files
431 * Data:: Examining data
432 * C:: C Language support
433 * Symbols:: Examining the symbol table
434 * Altering:: Altering execution
435 * GDB Files:: @value{GDBN} files
436 * Targets:: Specifying a debugging target
437 * Controlling GDB:: Controlling @value{GDBN}
438 * Sequences:: Canned sequences of commands
439 * Emacs:: Using @value{GDBN} under GNU Emacs
440 * GDB Bugs:: Reporting bugs in @value{GDBN}
442 * Formatting Documentation:: How to format and print GDB documentation
443 * Installing GDB:: Installing GDB
444 * Copying:: GNU GENERAL PUBLIC LICENSE
452 @c Menu for NOVEL && BARETARGET && CONLY && DOSHOST
458 * Summary:: Summary of @value{GDBN}
459 * New Features:: New features since GDB version 3.5
460 * Invocation:: Getting in and out of @value{GDBN}
461 * Commands:: @value{GDBN} commands
462 * Running:: Running programs under @value{GDBN}
463 * Stopping:: Stopping and continuing
464 * Stack:: Examining the stack
465 * Source:: Examining source files
466 * Data:: Examining data
467 * C:: C Language support
468 * Symbols:: Examining the symbol table
469 * Altering:: Altering execution
470 * GDB Files:: @value{GDBN} files
471 * Targets:: Specifying a debugging target
472 * Controlling GDB:: Controlling @value{GDBN}
473 * Sequences:: Canned sequences of commands
474 * GDB Bugs:: Reporting bugs in @value{GDBN}
476 * Formatting Documentation:: How to format and print GDB documentation
477 * Installing GDB:: Installing GDB
478 * Copying:: GNU GENERAL PUBLIC LICENSE
486 @c Menu for !NOVEL && !BARETARGET && !CONLY && !DOSHOST
492 * Summary:: Summary of @value{GDBN}
493 * Sample Session:: A sample @value{GDBN} session
494 * Invocation:: Getting in and out of @value{GDBN}
495 * Commands:: @value{GDBN} commands
496 * Running:: Running programs under @value{GDBN}
497 * Stopping:: Stopping and continuing
498 * Stack:: Examining the stack
499 * Source:: Examining source files
500 * Data:: Examining data
501 * Languages:: Using @value{GDBN} with different languages
502 * Symbols:: Examining the symbol table
503 * Altering:: Altering execution
504 * GDB Files:: @value{GDBN} files
505 * Targets:: Specifying a debugging target
506 * Controlling GDB:: Controlling @value{GDBN}
507 * Sequences:: Canned sequences of commands
508 * Emacs:: Using @value{GDBN} under GNU Emacs
509 * GDB Bugs:: Reporting bugs in @value{GDBN}
510 * Formatting Documentation:: How to format and print GDB documentation
511 * Installing GDB:: Installing GDB
512 * Copying:: GNU GENERAL PUBLIC LICENSE
520 @c Menu for !NOVEL && !BARETARGET && !CONLY && DOSHOST
526 * Summary:: Summary of @value{GDBN}
527 * Sample Session:: A sample @value{GDBN} session
528 * Invocation:: Getting in and out of @value{GDBN}
529 * Commands:: @value{GDBN} commands
530 * Running:: Running programs under @value{GDBN}
531 * Stopping:: Stopping and continuing
532 * Stack:: Examining the stack
533 * Source:: Examining source files
534 * Data:: Examining data
535 * Languages:: Using @value{GDBN} with different languages
536 * Symbols:: Examining the symbol table
537 * Altering:: Altering execution
538 * GDB Files:: @value{GDBN} files
539 * Targets:: Specifying a debugging target
540 * Controlling GDB:: Controlling @value{GDBN}
541 * Sequences:: Canned sequences of commands
542 * GDB Bugs:: Reporting bugs in @value{GDBN}
543 * Formatting Documentation:: How to format and print GDB documentation
544 * Installing GDB:: Installing GDB
545 * Copying:: GNU GENERAL PUBLIC LICENSE
553 @c Menu for !NOVEL && !BARETARGET && CONLY && !DOSHOST
559 * Summary:: Summary of @value{GDBN}
560 * Sample Session:: A sample @value{GDBN} session
561 * Invocation:: Getting in and out of @value{GDBN}
562 * Commands:: @value{GDBN} commands
563 * Running:: Running programs under @value{GDBN}
564 * Stopping:: Stopping and continuing
565 * Stack:: Examining the stack
566 * Source:: Examining source files
567 * Data:: Examining data
568 * C:: C Language support
569 * Symbols:: Examining the symbol table
570 * Altering:: Altering execution
571 * GDB Files:: @value{GDBN} files
572 * Targets:: Specifying a debugging target
573 * Controlling GDB:: Controlling @value{GDBN}
574 * Sequences:: Canned sequences of commands
575 * Emacs:: Using @value{GDBN} under GNU Emacs
576 * GDB Bugs:: Reporting bugs in @value{GDBN}
577 * Formatting Documentation:: How to format and print GDB documentation
578 * Installing GDB:: Installing GDB
579 * Copying:: GNU GENERAL PUBLIC LICENSE
587 @c Menu for !NOVEL && !BARETARGET && CONLY && DOSHOST
593 * Summary:: Summary of @value{GDBN}
594 * Sample Session:: A sample @value{GDBN} session
595 * Invocation:: Getting in and out of @value{GDBN}
596 * Commands:: @value{GDBN} commands
597 * Running:: Running programs under @value{GDBN}
598 * Stopping:: Stopping and continuing
599 * Stack:: Examining the stack
600 * Source:: Examining source files
601 * Data:: Examining data
602 * C:: C Language support
603 * Symbols:: Examining the symbol table
604 * Altering:: Altering execution
605 * GDB Files:: @value{GDBN} files
606 * Targets:: Specifying a debugging target
607 * Controlling GDB:: Controlling @value{GDBN}
608 * Sequences:: Canned sequences of commands
609 * GDB Bugs:: Reporting bugs in @value{GDBN}
610 * Formatting Documentation:: How to format and print GDB documentation
611 * Installing GDB:: Installing GDB
612 * Copying:: GNU GENERAL PUBLIC LICENSE
620 @c Menu for !NOVEL && BARETARGET && !CONLY && !DOSHOST
626 * Summary:: Summary of @value{GDBN}
627 * Invocation:: Getting in and out of @value{GDBN}
628 * Commands:: @value{GDBN} commands
629 * Running:: Running programs under @value{GDBN}
630 * Stopping:: Stopping and continuing
631 * Stack:: Examining the stack
632 * Source:: Examining source files
633 * Data:: Examining data
634 * Languages:: Using @value{GDBN} with different languages
635 * Symbols:: Examining the symbol table
636 * Altering:: Altering execution
637 * GDB Files:: @value{GDBN} files
638 * Targets:: Specifying a debugging target
639 * Controlling GDB:: Controlling @value{GDBN}
640 * Sequences:: Canned sequences of commands
641 * Emacs:: Using @value{GDBN} under GNU Emacs
642 * GDB Bugs:: Reporting bugs in @value{GDBN}
643 * Formatting Documentation:: How to format and print GDB documentation
644 * Installing GDB:: Installing GDB
645 * Copying:: GNU GENERAL PUBLIC LICENSE
653 @c Menu for !NOVEL && BARETARGET && !CONLY && DOSHOST
659 * Summary:: Summary of @value{GDBN}
660 * Invocation:: Getting in and out of @value{GDBN}
661 * Commands:: @value{GDBN} commands
662 * Running:: Running programs under @value{GDBN}
663 * Stopping:: Stopping and continuing
664 * Stack:: Examining the stack
665 * Source:: Examining source files
666 * Data:: Examining data
667 * Languages:: Using @value{GDBN} with different languages
668 * Symbols:: Examining the symbol table
669 * Altering:: Altering execution
670 * GDB Files:: @value{GDBN} files
671 * Targets:: Specifying a debugging target
672 * Controlling GDB:: Controlling @value{GDBN}
673 * Sequences:: Canned sequences of commands
674 * GDB Bugs:: Reporting bugs in @value{GDBN}
675 * Formatting Documentation:: How to format and print GDB documentation
676 * Installing GDB:: Installing GDB
677 * Copying:: GNU GENERAL PUBLIC LICENSE
685 @c Menu for !NOVEL && BARETARGET && CONLY && !DOSHOST
691 * Summary:: Summary of @value{GDBN}
692 * Invocation:: Getting in and out of @value{GDBN}
693 * Commands:: @value{GDBN} commands
694 * Running:: Running programs under @value{GDBN}
695 * Stopping:: Stopping and continuing
696 * Stack:: Examining the stack
697 * Source:: Examining source files
698 * Data:: Examining data
699 * C:: C Language Support
700 * Symbols:: Examining the symbol table
701 * Altering:: Altering execution
702 * GDB Files:: @value{GDBN} files
703 * Targets:: Specifying a debugging target
704 * Controlling GDB:: Controlling @value{GDBN}
705 * Sequences:: Canned sequences of commands
706 * Emacs:: Using @value{GDBN} under GNU Emacs
707 * GDB Bugs:: Reporting bugs in @value{GDBN}
708 * Formatting Documentation:: How to format and print GDB documentation
709 * Installing GDB:: Installing GDB
710 * Copying:: GNU GENERAL PUBLIC LICENSE
718 @c Menu for !NOVEL && BARETARGET && CONLY && DOSHOST
724 * Summary:: Summary of @value{GDBN}
725 * Invocation:: Getting in and out of @value{GDBN}
726 * Commands:: @value{GDBN} commands
727 * Running:: Running programs under @value{GDBN}
728 * Stopping:: Stopping and continuing
729 * Stack:: Examining the stack
730 * Source:: Examining source files
731 * Data:: Examining data
732 * C:: C Language Support
733 * Symbols:: Examining the symbol table
734 * Altering:: Altering execution
735 * GDB Files:: @value{GDBN} files
736 * Targets:: Specifying a debugging target
737 * Controlling GDB:: Controlling @value{GDBN}
738 * Sequences:: Canned sequences of commands
739 * GDB Bugs:: Reporting bugs in @value{GDBN}
740 * Formatting Documentation:: How to format and print GDB documentation
741 * Installing GDB:: Installing GDB
742 * Copying:: GNU GENERAL PUBLIC LICENSE
753 @unnumbered Summary of @value{GDBN}
755 The purpose of a debugger such as @value{GDBN} is to allow you to see what is
756 going on ``inside'' another program while it executes---or what another
757 program was doing at the moment it crashed.
759 @value{GDBN} can do four main kinds of things (plus other things in support of
760 these) to help you catch bugs in the act:
764 Start your program, specifying anything that might affect its behavior.
767 Make your program stop on specified conditions.
770 Examine what has happened, when your program has stopped.
773 Change things in your program, so you can experiment with correcting the
774 effects of one bug and go on to learn about another.
778 You can use @value{GDBN} to debug programs written in C, C++, and Modula-2.
779 Fortran support will be added when a GNU Fortran compiler is ready.
783 * Free Software:: Freely redistributable software
784 * Contributors:: Contributors to GDB
788 @unnumberedsec Free software
790 @value{GDBN} is @dfn{free software}, protected by the GNU General Public License
791 (GPL). The GPL gives you the freedom to copy or adapt a licensed
792 program---but every person getting a copy also gets with it the
793 freedom to modify that copy (which means that they must get access to
794 the source code), and the freedom to distribute further copies.
795 Typical software companies use copyrights to limit your freedoms; the
796 Free Software Foundation uses the GPL to preserve these freedoms.
798 Fundamentally, the General Public License is a license which says that
799 you have these freedoms and that you cannot take these freedoms away
802 @ifclear AGGLOMERATION
803 For full details, @pxref{Copying, ,GNU GENERAL PUBLIC LICENSE}.
807 @unnumberedsec Contributors to GDB
809 Richard Stallman was the original author of GDB, and of many other GNU
810 programs. Many others have contributed to its development. This
811 section attempts to credit major contributors. One of the virtues of
812 free software is that everyone is free to contribute to it; with
813 regret, we cannot actually acknowledge everyone here. The file
814 @file{ChangeLog} in the GDB distribution approximates a blow-by-blow
817 Changes much prior to version 2.0 are lost in the mists of time.
820 @emph{Plea:} Additions to this section are particularly welcome. If you
821 or your friends (or enemies, to be evenhanded) have been unfairly
822 omitted from this list, we would like to add your names!
825 So that they may not regard their long labor as thankless, we
826 particularly thank those who shepherded GDB through major releases: Stu
827 Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, 4.4), John Gilmore
828 (releases 4.3, 4.2, 4.1, 4.0, and 3.9); Jim Kingdon (releases 3.5, 3.4,
829 3.3); and Randy Smith (releases 3.2, 3.1, 3.0). As major maintainer of
830 GDB for some period, each contributed significantly to the structure,
831 stability, and capabilities of the entire debugger.
833 Richard Stallman, assisted at various times by Pete TerMaat, Chris
834 Hanson, and Richard Mlynarik, handled releases through 2.8.
836 Michael Tiemann is the author of most of the GNU C++ support in GDB,
837 with significant additional contributions from Per Bothner. James
838 Clark wrote the GNU C++ demangler. Early work on C++ was by Peter
839 TerMaat (who also did much general update work leading to release 3.0).
841 GDB 4 uses the BFD subroutine library to examine multiple
842 object-file formats; BFD was a joint project of David V.
843 Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
845 David Johnson wrote the original COFF support; Pace Willison did
846 the original support for encapsulated COFF.
848 Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
849 Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
850 support. Jean-Daniel Fekete contributed Sun 386i support. Chris
851 Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki
852 Hasei contributed Sony/News OS 3 support. David Johnson contributed
853 Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support.
854 Keith Packard contributed NS32K support. Doug Rabson contributed
855 Acorn Risc Machine support. Chris Smith contributed Convex support
856 (and Fortran debugging). Jonathan Stone contributed Pyramid support.
857 Michael Tiemann contributed SPARC support. Tim Tucker contributed
858 support for the Gould NP1 and Gould Powernode. Pace Willison
859 contributed Intel 386 support. Jay Vosburgh contributed Symmetry
862 Rich Schaefer and Peter Schauer helped with support of SunOS shared
865 Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about
866 several machine instruction sets.
868 Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
869 develop remote debugging. Intel Corporation and Wind River Systems
870 contributed remote debugging modules for their products.
872 Brian Fox is the author of the readline libraries providing
873 command-line editing and command history.
875 Andrew Beers of SUNY Buffalo wrote the language-switching code and
876 the Modula-2 support, and contributed the Languages chapter of this
879 Fred Fish wrote most of the support for Unix System Vr4, and enhanced
880 the command-completion support to cover C++ overloaded symbols.
884 @unnumbered New Features since GDB Version 3.5
888 Using the new command @code{target}, you can select at runtime whether
889 you are debugging local files, local processes, standalone systems over
890 a serial port, realtime systems over a TCP/IP connection, etc. The
891 command @code{load} can download programs into a remote system. Serial
892 stubs are available for Motorola 680x0, Intel 80386, and Sparc remote
893 systems; GDB also supports debugging realtime processes running under
894 VxWorks, using SunRPC Remote Procedure Calls over TCP/IP to talk to a
895 debugger stub on the target system. Internally, GDB now uses a function
896 vector to mediate access to different targets; if you need to add your
897 own support for a remote protocol, this makes it much easier.
900 GDB now sports watchpoints as well as breakpoints. You can use a
901 watchpoint to stop execution whenever the value of an expression
902 changes, without having to predict a particular place in your program
903 where this may happen.
906 Commands that issue wide output now insert newlines at places designed
907 to make the output more readable.
909 @item Object Code Formats
910 GDB uses a new library called the Binary File Descriptor (BFD)
911 Library to permit it to switch dynamically, without reconfiguration or
912 recompilation, between different object-file formats. Formats currently
913 supported are COFF, a.out, and the Intel 960 b.out; files may be read as
914 .o files, archive libraries, or core dumps. BFD is available as a
915 subroutine library so that other programs may take advantage of it, and
916 the other GNU binary utilities are being converted to use it.
918 @item Configuration and Ports
919 Compile-time configuration (to select a particular architecture and
920 operating system) is much easier. The script @code{configure} now
921 allows you to configure GDB as either a native debugger or a
922 cross-debugger. @xref{Installing GDB}, for details on how to
926 The user interface to the GDB control variables is simpler,
927 and is consolidated in two commands, @code{set} and @code{show}. Output
928 lines are now broken at readable places, rather than overflowing onto
929 the next line. You can suppress output of machine-level addresses,
930 displaying only source language information.
933 GDB now supports C++ multiple inheritance (if used with a GCC
934 version 2 compiler), and also has limited support for C++ exception
935 handling, with the commands @code{catch} and @code{info catch}: GDB
936 can break when an exception is raised, before the stack is peeled back
937 to the exception handler's context.
940 GDB now has preliminary support for the GNU Modula-2 compiler, currently
941 under development at the State University of New York at Buffalo.
942 Coordinated development of both GDB and the GNU Modula-2 compiler will
943 continue. Other Modula-2 compilers are currently not supported, and
944 attempting to debug programs compiled with them will likely result in an
945 error as the symbol table of the executable is read in.
947 @item Command Rationalization
948 Many GDB commands have been renamed to make them easier to remember
949 and use. In particular, the subcommands of @code{info} and
950 @code{show}/@code{set} are grouped to make the former refer to the state
951 of your program, and the latter refer to the state of GDB itself.
952 @xref{Renamed Commands}, for details on what commands were renamed.
954 @item Shared Libraries
955 GDB 4 can debug programs and core files that use SunOS, SVR4, or IBM RS/6000
959 GDB 4 has a reference card. @xref{Formatting Documentation,,Formatting
960 the Documentation}, for instructions about how to print it.
962 @item Work in Progress
963 Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture
970 @chapter A Sample @value{GDBN} Session
972 You can use this manual at your leisure to read all about @value{GDBN}.
973 However, a handful of commands are enough to get started using the
974 debugger. This chapter illustrates those commands.
977 In this sample session, we emphasize user input like this: @b{input},
978 to make it easier to pick out from the surrounding output.
981 @c FIXME: this example may not be appropriate for some configs, where
982 @c FIXME...primary interest is in remote use.
984 One of the preliminary versions of GNU @code{m4} (a generic macro
985 processor) exhibits the following bug: sometimes, when we change its
986 quote strings from the default, the commands used to capture one macro
987 definition within another stop working. In the following short @code{m4}
988 session, we define a macro @code{foo} which expands to @code{0000}; we
989 then use the @code{m4} built-in @code{defn} to define @code{bar} as the
990 same thing. However, when we change the open quote string to
991 @code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same
992 procedure fails to define a new synonym @code{baz}:
1001 @b{define(bar,defn(`foo'))}
1005 @b{changequote(<QUOTE>,<UNQUOTE>)}
1007 @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
1010 m4: End of input: 0: fatal error: EOF in string
1014 Let us use @value{GDBN} to try to see what is going on.
1017 $ @b{@value{GDBP} m4}
1018 @c FIXME: this falsifies the exact text played out, to permit smallbook
1019 @c FIXME... format to come out better.
1020 GDB is free software and you are welcome to distribute copies
1021 of it under certain conditions; type "show copying" to see
1023 There is absolutely no warranty for GDB; type "show warranty"
1025 GDB @value{GDBVN}, Copyright 1993 Free Software Foundation, Inc...
1030 @value{GDBN} reads only enough symbol data to know where to find the rest when
1031 needed; as a result, the first prompt comes up very quickly. We now
1032 tell @value{GDBN} to use a narrower display width than usual, so that examples
1033 will fit in this manual.
1036 (@value{GDBP}) @b{set width 70}
1040 We need to see how the @code{m4} built-in @code{changequote} works.
1041 Having looked at the source, we know the relevant subroutine is
1042 @code{m4_changequote}, so we set a breakpoint there with the @value{GDBN}
1043 @code{break} command.
1046 (@value{GDBP}) @b{break m4_changequote}
1047 Breakpoint 1 at 0x62f4: file builtin.c, line 879.
1051 Using the @code{run} command, we start @code{m4} running under @value{GDBN}
1052 control; as long as control does not reach the @code{m4_changequote}
1053 subroutine, the program runs as usual:
1056 (@value{GDBP}) @b{run}
1057 Starting program: /work/Editorial/gdb/gnu/m4/m4
1058 @b{define(foo,0000)}
1065 To trigger the breakpoint, we call @code{changequote}. @value{GDBN}
1066 suspends execution of @code{m4}, displaying information about the
1067 context where it stops.
1070 @b{changequote(<QUOTE>,<UNQUOTE>)}
1072 Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
1074 879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
1078 Now we use the command @code{n} (@code{next}) to advance execution to
1079 the next line of the current function.
1082 (@value{GDBP}) @b{n}
1083 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
1088 @code{set_quotes} looks like a promising subroutine. We can go into it
1089 by using the command @code{s} (@code{step}) instead of @code{next}.
1090 @code{step} goes to the next line to be executed in @emph{any}
1091 subroutine, so it steps into @code{set_quotes}.
1094 (@value{GDBP}) @b{s}
1095 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
1097 530 if (lquote != def_lquote)
1101 The display that shows the subroutine where @code{m4} is now
1102 suspended (and its arguments) is called a stack frame display. It
1103 shows a summary of the stack. We can use the @code{backtrace}
1104 command (which can also be spelled @code{bt}), to see where we are
1105 in the stack as a whole: the @code{backtrace} command displays a
1106 stack frame for each active subroutine.
1109 (@value{GDBP}) @b{bt}
1110 #0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
1112 #1 0x6344 in m4_changequote (argc=3, argv=0x33c70)
1114 #2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
1115 #3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
1117 #4 0x79dc in expand_input () at macro.c:40
1118 #5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
1122 We will step through a few more lines to see what happens. The first two
1123 times, we can use @samp{s}; the next two times we use @code{n} to avoid
1124 falling into the @code{xstrdup} subroutine.
1127 (@value{GDBP}) @b{s}
1128 0x3b5c 532 if (rquote != def_rquote)
1129 (@value{GDBP}) @b{s}
1130 0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \
1131 def_lquote : xstrdup(lq);
1132 (@value{GDBP}) @b{n}
1133 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
1135 (@value{GDBP}) @b{n}
1136 538 len_lquote = strlen(rquote);
1140 The last line displayed looks a little odd; we can examine the variables
1141 @code{lquote} and @code{rquote} to see if they are in fact the new left
1142 and right quotes we specified. We use the command @code{p}
1143 (@code{print}) to see their values.
1146 (@value{GDBP}) @b{p lquote}
1147 $1 = 0x35d40 "<QUOTE>"
1148 (@value{GDBP}) @b{p rquote}
1149 $2 = 0x35d50 "<UNQUOTE>"
1153 @code{lquote} and @code{rquote} are indeed the new left and right quotes.
1154 To look at some context, we can display ten lines of source
1155 surrounding the current line with the @code{l} (@code{list}) command.
1158 (@value{GDBP}) @b{l}
1161 535 lquote = (lq == nil || *lq == '\0') ? def_lquote\
1163 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
1166 538 len_lquote = strlen(rquote);
1167 539 len_rquote = strlen(lquote);
1174 Let us step past the two lines that set @code{len_lquote} and
1175 @code{len_rquote}, and then examine the values of those variables.
1178 (@value{GDBP}) @b{n}
1179 539 len_rquote = strlen(lquote);
1180 (@value{GDBP}) @b{n}
1182 (@value{GDBP}) @b{p len_lquote}
1184 (@value{GDBP}) @b{p len_rquote}
1189 That certainly looks wrong, assuming @code{len_lquote} and
1190 @code{len_rquote} are meant to be the lengths of @code{lquote} and
1191 @code{rquote} respectively. We can set them to better values using
1192 the @code{p} command, since it can print the value of
1193 any expression---and that expression can include subroutine calls and
1197 (@value{GDBP}) @b{p len_lquote=strlen(lquote)}
1199 (@value{GDBP}) @b{p len_rquote=strlen(rquote)}
1204 Is that enough to fix the problem of using the new quotes with the
1205 @code{m4} built-in @code{defn}? We can allow @code{m4} to continue
1206 executing with the @code{c} (@code{continue}) command, and then try the
1207 example that caused trouble initially:
1210 (@value{GDBP}) @b{c}
1213 @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
1220 Success! The new quotes now work just as well as the default ones. The
1221 problem seems to have been just the two typos defining the wrong
1222 lengths. We allow @code{m4} exit by giving it an EOF as input:
1226 Program exited normally.
1230 The message @samp{Program exited normally.} is from @value{GDBN}; it
1231 indicates @code{m4} has finished executing. We can end our @value{GDBN}
1232 session with the @value{GDBN} @code{quit} command.
1235 (@value{GDBP}) @b{quit}
1240 @chapter Getting In and Out of @value{GDBN}
1242 This chapter discusses how to start @value{GDBN}, and how to get out of it.
1243 (The essentials: type @samp{@value{GDBP}} to start GDB, and type @kbd{quit}
1244 or @kbd{C-d} to exit.)
1247 @c original form of menu, pre-unfolding:
1249 * Invoking GDB:: How to start @value{GDBN}
1250 * Quitting GDB:: How to quit @value{GDBN}
1252 * Shell Commands:: How to use shell commands inside @value{GDBN}
1259 * Invoking GDB:: How to start @value{GDBN}
1260 * Quitting GDB:: How to quit @value{GDBN}
1261 * Shell Commands:: How to use shell commands inside @value{GDBN}
1267 * Invoking GDB:: How to start @value{GDBN}
1268 * Quitting GDB:: How to quit @value{GDBN}
1273 @section Invoking @value{GDBN}
1275 @ifset HviiiEXCLUSIVE
1276 For details on starting up @value{GDBP} as a
1277 remote debugger attached to a Hitachi H8/300 board, see @ref{Hitachi
1278 H8/300 Remote,,@value{GDBN} and the Hitachi H8/300}.
1281 Invoke @value{GDBN} by running the program @code{@value{GDBP}}. Once started,
1282 @value{GDBN} reads commands from the terminal until you tell it to exit.
1284 You can also run @code{@value{GDBP}} with a variety of arguments and options,
1285 to specify more of your debugging environment at the outset.
1288 The command-line options described here are designed
1289 to cover a variety of situations; in some environments, some of these
1290 options may effectively be unavailable.
1293 The most usual way to start @value{GDBN} is with one argument,
1294 specifying an executable program:
1297 @value{GDBP} @var{program}
1302 You can also start with both an executable program and a core file
1306 @value{GDBP} @var{program} @var{core}
1309 You can, instead, specify a process ID as a second argument, if you want
1310 to debug a running process:
1313 @value{GDBP} @var{program} 1234
1317 would attach @value{GDBN} to process @code{1234} (unless you also have a file
1318 named @file{1234}; @value{GDBN} does check for a core file first).
1320 Taking advantage of the second command-line argument requires a fairly
1321 complete operating system; when you use @value{GDBN} as a remote debugger
1322 attached to a bare board, there may not be any notion of ``process'',
1323 and there is often no way to get a core dump.
1327 You can further control how @value{GDBN} starts up by using command-line
1328 options. @value{GDBN} itself can remind you of the options available.
1338 to display all available options and briefly describe their use
1339 (@samp{@value{GDBP} -h} is a shorter equivalent).
1341 All options and command line arguments you give are processed
1342 in sequential order. The order makes a difference when the
1343 @samp{-x} option is used.
1347 @c original, intended form of this menu (pre-unfolding):
1351 * Remote Serial:: @value{GDBN} remote serial protocol
1354 * i960-Nindy Remote:: @value{GDBN} with a remote i960 (Nindy)
1357 * UDI29K Remote:: @value{GDBN} and the UDI protocol for AMD29K
1358 * EB29K Remote:: @value{GDBN} with a remote EB29K
1361 * VxWorks Remote:: @value{GDBN} and VxWorks
1364 * ST2000 Remote:: @value{GDBN} with a Tandem ST2000
1367 * Hitachi H8/300 Remote:: @value{GDBN} and the Hitachi H8/300
1370 * Simulator:: Simulated CPU target
1373 * File Options:: Choosing files
1374 * Mode Options:: Choosing modes
1379 @c Sigh--- GENERIC plus 7 switches mean 1+2^7 forms of this menu!
1380 @c Add them only on demand; no point in including forms for which
1381 @c there's no defined config file. Maybe by the time all are needed,
1382 @c makeinfo will be capable of dealing with menus like the above.
1386 * File Options:: Choosing files
1387 * Mode Options:: Choosing modes
1391 @c Hviii config: !GENERIC && Hviii && nothing else
1401 * Hitachi H8/300 Remote:: @value{GDBN} and the Hitachi H8/300
1402 * Simulator:: Simulated CPU target
1403 * File Options:: Choosing files
1404 * Mode Options:: Choosing modes
1416 @include gdbinv-s.texi
1420 @subsection Choosing files
1423 When @value{GDBN} starts, it reads any arguments other than options as
1424 specifying an executable file and core file (or process ID). This is
1425 the same as if the arguments were specified by the @samp{-se} and
1426 @samp{-c} options respectively. (@value{GDBN} reads the first argument
1427 that does not have an associated option flag as equivalent to the
1428 @samp{-se} option followed by that argument; and the second argument
1429 that does not have an associated option flag, if any, as equivalent to
1430 the @samp{-c} option followed by that argument.)
1433 When @value{GDBN} starts, it reads any argument other than options as
1434 specifying an executable file. This is the same as if the argument was
1435 specified by the @samp{-se} option.
1438 Many options have both long and short forms; both are shown in the
1439 following list. @value{GDBN} also recognizes the long forms if you truncate
1440 them, so long as enough of the option is present to be unambiguous.
1441 (If you prefer, you can flag option arguments with @samp{--} rather
1442 than @samp{-}, though we illustrate the more usual convention.)
1445 @item -symbols=@var{file}
1446 @itemx -s @var{file}
1447 Read symbol table from file @var{file}.
1449 @item -exec=@var{file}
1450 @itemx -e @var{file}
1451 Use file @var{file} as the executable file to execute when
1452 appropriate, and for examining pure data in conjunction with a core
1455 @item -se=@var{file}
1456 Read symbol table from file @var{file} and use it as the executable
1460 @item -core=@var{file}
1461 @itemx -c @var{file}
1462 Use file @var{file} as a core dump to examine.
1465 @item -command=@var{file}
1466 @itemx -x @var{file}
1467 Execute @value{GDBN} commands from file @var{file}. @xref{Command
1468 Files,, Command files}.
1470 @item -directory=@var{directory}
1471 @itemx -d @var{directory}
1472 Add @var{directory} to the path to search for source files.
1477 @emph{Warning: this option depends on operating system facilities that are not
1478 supported on all systems.}@*
1479 If memory-mapped files are available on your system through the @code{mmap}
1480 system call, you can use this option
1481 to have @value{GDBN} write the symbols from your
1482 program into a reusable file in the current directory. If the program you are debugging is
1483 called @file{/tmp/fred}, the mapped symbol file will be @file{./fred.syms}.
1484 Future @value{GDBN} debugging sessions will notice the presence of this file,
1485 and will quickly map in symbol information from it, rather than reading
1486 the symbol table from the executable program.
1488 The @file{.syms} file is specific to the host machine on which @value{GDBN} is run.
1489 It holds an exact image of the internal @value{GDBN} symbol table. It cannot be
1490 shared across multiple host platforms.
1495 Read each symbol file's entire symbol table immediately, rather than
1496 the default, which is to read it incrementally as it is needed.
1497 This makes startup slower, but makes future operations faster.
1501 The @code{-mapped} and @code{-readnow} options are typically combined in
1502 order to build a @file{.syms} file that contains complete symbol
1503 information. (@xref{Files,,Commands to specify files}, for information
1504 on @file{.syms} files.) A simple GDB invocation to do nothing but build
1505 a @file{.syms} file for future use is:
1508 gdb -batch -nx -mapped -readnow programname
1513 @subsection Choosing modes
1515 You can run @value{GDBN} in various alternative modes---for example, in
1516 batch mode or quiet mode.
1521 Do not execute commands from any @file{@value{GDBINIT}} initialization files.
1522 Normally, the commands in these files are executed after all the
1523 command options and arguments have been processed.
1524 @xref{Command Files,,Command files}.
1528 ``Quiet''. Do not print the introductory and copyright messages. These
1529 messages are also suppressed in batch mode.
1532 Run in batch mode. Exit with status @code{0} after processing all the command
1533 files specified with @samp{-x} (and @file{@value{GDBINIT}}, if not inhibited).
1534 Exit with nonzero status if an error occurs in executing the @value{GDBN}
1535 commands in the command files.
1537 Batch mode may be useful for running @value{GDBN} as a filter, for example to
1538 download and run a program on another computer; in order to make this
1539 more useful, the message
1542 Program exited normally.
1546 (which is ordinarily issued whenever a program running under @value{GDBN} control
1547 terminates) is not issued when running in batch mode.
1549 @item -cd=@var{directory}
1550 Run @value{GDBN} using @var{directory} as its working directory,
1551 instead of the current directory.
1554 @item -context @var{authentication}
1555 When the Energize programming system starts up @value{GDBN}, it uses this
1556 option to trigger an alternate mode of interaction.
1557 @var{authentication} is a pair of numeric codes that identify @value{GDBN}
1558 as a client in the Energize environment. Avoid this option when you run
1559 @value{GDBN} directly from the command line. See @ref{Energize,,Using
1560 @value{GDBN} with Energize} for more discussion of using @value{GDBN} with Energize.
1565 Emacs sets this option when it runs @value{GDBN} as a subprocess. It tells @value{GDBN}
1566 to output the full file name and line number in a standard,
1567 recognizable fashion each time a stack frame is displayed (which
1568 includes each time your program stops). This recognizable format looks
1569 like two @samp{\032} characters, followed by the file name, line number
1570 and character position separated by colons, and a newline. The
1571 Emacs-to-@value{GDBN} interface program uses the two @samp{\032} characters as
1572 a signal to display the source code for the frame.
1576 Set the line speed (baud rate or bits per second) of any serial
1577 interface used by @value{GDBN} for remote debugging.
1579 @item -tty=@var{device}
1580 Run using @var{device} for your program's standard input and output.
1581 @c FIXME: kingdon thinks there is more to -tty. Investigate.
1586 @section Quitting @value{GDBN}
1587 @cindex exiting @value{GDBN}
1588 @cindex leaving @value{GDBN}
1594 To exit @value{GDBN}, use the @code{quit} command (abbreviated @code{q}), or type
1595 an end-of-file character (usually @kbd{C-d}).
1599 An interrupt (often @kbd{C-c}) will not exit from @value{GDBN}, but rather
1600 will terminate the action of any @value{GDBN} command that is in progress and
1601 return to @value{GDBN} command level. It is safe to type the interrupt
1602 character at any time because @value{GDBN} does not allow it to take effect
1603 until a time when it is safe.
1606 If you have been using @value{GDBN} to control an attached process or
1607 device, you can release it with the @code{detach} command
1608 (@pxref{Attach, ,Debugging an already-running process}).
1612 @node Shell Commands
1613 @section Shell commands
1615 If you need to execute occasional shell commands during your
1616 debugging session, there is no need to leave or suspend @value{GDBN}; you can
1617 just use the @code{shell} command.
1620 @item shell @var{command string}
1622 @cindex shell escape
1623 Directs @value{GDBN} to invoke an inferior shell to execute @var{command
1624 string}. If it exists, the environment variable @code{SHELL} is used
1625 for the name of the shell to run. Otherwise @value{GDBN} uses
1629 The utility @code{make} is often needed in development environments.
1630 You do not have to use the @code{shell} command for this purpose in @value{GDBN}:
1633 @item make @var{make-args}
1635 @cindex calling make
1636 Causes @value{GDBN} to execute an inferior @code{make} program with the specified
1637 arguments. This is equivalent to @samp{shell make @var{make-args}}.
1642 @chapter @value{GDBN} Commands
1644 You can abbreviate a @value{GDBN} command to the first few letters of the command
1645 name, if that abbreviation is unambiguous; and you can repeat certain
1646 @value{GDBN} commands by typing just @key{RET}. You can also use the @key{TAB}
1647 key to get @value{GDBN} to fill out the rest of a word in a command (or to
1648 show you the alternatives available, if there is more than one possibility).
1651 * Command Syntax:: How to give commands to @value{GDBN}
1652 * Completion:: Command completion
1653 * Help:: How to ask @value{GDBN} for help
1656 @node Command Syntax
1657 @section Command syntax
1659 A @value{GDBN} command is a single line of input. There is no limit on
1660 how long it can be. It starts with a command name, which is followed by
1661 arguments whose meaning depends on the command name. For example, the
1662 command @code{step} accepts an argument which is the number of times to
1663 step, as in @samp{step 5}. You can also use the @code{step} command
1664 with no arguments. Some command names do not allow any arguments.
1666 @cindex abbreviation
1667 @value{GDBN} command names may always be truncated if that abbreviation is
1668 unambiguous. Other possible command abbreviations are listed in the
1669 documentation for individual commands. In some cases, even ambiguous
1670 abbreviations are allowed; for example, @code{s} is specially defined as
1671 equivalent to @code{step} even though there are other commands whose
1672 names start with @code{s}. You can test abbreviations by using them as
1673 arguments to the @code{help} command.
1675 @cindex repeating commands
1677 A blank line as input to @value{GDBN} (typing just @key{RET}) means to
1678 repeat the previous command. Certain commands (for example, @code{run})
1679 will not repeat this way; these are commands for which unintentional
1680 repetition might cause trouble and which you are unlikely to want to
1683 The @code{list} and @code{x} commands, when you repeat them with
1684 @key{RET}, construct new arguments rather than repeating
1685 exactly as typed. This permits easy scanning of source or memory.
1687 @value{GDBN} can also use @key{RET} in another way: to partition lengthy
1688 output, in a way similar to the common utility @code{more}
1689 (@pxref{Screen Size,,Screen size}). Since it is easy to press one
1690 @key{RET} too many in this situation, @value{GDBN} disables command
1691 repetition after any command that generates this sort of display.
1695 Any text from a @kbd{#} to the end of the line is a comment; it does
1696 nothing. This is useful mainly in command files (@pxref{Command
1697 Files,,Command files}).
1700 @section Command completion
1703 @cindex word completion
1704 @value{GDBN} can fill in the rest of a word in a command for you, if there is
1705 only one possibility; it can also show you what the valid possibilities
1706 are for the next word in a command, at any time. This works for @value{GDBN}
1707 commands, @value{GDBN} subcommands, and the names of symbols in your program.
1709 Press the @key{TAB} key whenever you want @value{GDBN} to fill out the rest
1710 of a word. If there is only one possibility, @value{GDBN} will fill in the
1711 word, and wait for you to finish the command (or press @key{RET} to
1712 enter it). For example, if you type
1714 @c FIXME "@key" does not distinguish its argument sufficiently to permit
1715 @c complete accuracy in these examples; space introduced for clarity.
1716 @c If texinfo enhancements make it unnecessary, it would be nice to
1717 @c replace " @key" by "@key" in the following...
1719 (@value{GDBP}) info bre @key{TAB}
1723 @value{GDBN} fills in the rest of the word @samp{breakpoints}, since that is
1724 the only @code{info} subcommand beginning with @samp{bre}:
1727 (@value{GDBP}) info breakpoints
1731 You can either press @key{RET} at this point, to run the @code{info
1732 breakpoints} command, or backspace and enter something else, if
1733 @samp{breakpoints} does not look like the command you expected. (If you
1734 were sure you wanted @code{info breakpoints} in the first place, you
1735 might as well just type @key{RET} immediately after @samp{info bre},
1736 to exploit command abbreviations rather than command completion).
1738 If there is more than one possibility for the next word when you press
1739 @key{TAB}, @value{GDBN} will sound a bell. You can either supply more
1740 characters and try again, or just press @key{TAB} a second time, and
1741 @value{GDBN} will display all the possible completions for that word. For
1742 example, you might want to set a breakpoint on a subroutine whose name
1743 begins with @samp{make_}, but when you type @kbd{b make_@key{TAB}} @value{GDBN}
1744 just sounds the bell. Typing @key{TAB} again will display all the
1745 function names in your program that begin with those characters, for
1749 (@value{GDBP}) b make_ @key{TAB}
1750 @exdent @value{GDBN} sounds bell; press @key{TAB} again, to see:
1751 make_a_section_from_file make_environ
1752 make_abs_section make_function_type
1753 make_blockvector make_pointer_type
1754 make_cleanup make_reference_type
1755 make_command make_symbol_completion_list
1756 (@value{GDBP}) b make_
1760 After displaying the available possibilities, @value{GDBN} copies your
1761 partial input (@samp{b make_} in the example) so you can finish the
1764 If you just want to see the list of alternatives in the first place, you
1765 can press @kbd{M-?} rather than pressing @key{TAB} twice. @kbd{M-?}
1766 means @kbd{@key{META} ?}. You can type this
1768 either by holding down a
1769 key designated as the @key{META} shift on your keyboard (if there is
1770 one) while typing @kbd{?}, or
1772 as @key{ESC} followed by @kbd{?}.
1774 @cindex quotes in commands
1775 @cindex completion of quoted strings
1776 Sometimes the string you need, while logically a ``word'', may contain
1777 parentheses or other characters that @value{GDBN} normally excludes from its
1778 notion of a word. To permit word completion to work in this situation,
1779 you may enclose words in @code{'} (single quote marks) in @value{GDBN} commands.
1781 The most likely situation where you might need this is in typing the
1782 name of a C++ function. This is because C++ allows function overloading
1783 (multiple definitions of the same function, distinguished by argument
1784 type). For example, when you want to set a breakpoint you may need to
1785 distinguish whether you mean the version of @code{name} that takes an
1786 @code{int} parameter, @code{name(int)}, or the version that takes a
1787 @code{float} parameter, @code{name(float)}. To use the word-completion
1788 facilities in this situation, type a single quote @code{'} at the
1789 beginning of the function name. This alerts @value{GDBN} that it may need to
1790 consider more information than usual when you press @key{TAB} or
1791 @kbd{M-?} to request word completion:
1794 (@value{GDBP}) b 'bubble( @key{M-?}
1795 bubble(double,double) bubble(int,int)
1796 (@value{GDBP}) b 'bubble(
1799 In some cases, @value{GDBN} can tell that completing a name will require
1800 quotes. When this happens, @value{GDBN} will insert the quote for you (while
1801 completing as much as it can) if you do not type the quote in the first
1805 (@value{GDBP}) b bub @key{TAB}
1806 @exdent @value{GDBN} alters your input line to the following, and rings a bell:
1807 (@value{GDBP}) b 'bubble(
1811 In general, @value{GDBN} can tell that a quote is needed (and inserts it) if
1812 you have not yet started typing the argument list when you ask for
1813 completion on an overloaded symbol.
1817 @section Getting help
1818 @cindex online documentation
1821 You can always ask @value{GDBN} itself for information on its commands, using the
1822 command @code{help}.
1828 You can use @code{help} (abbreviated @code{h}) with no arguments to
1829 display a short list of named classes of commands:
1833 List of classes of commands:
1835 running -- Running the program
1836 stack -- Examining the stack
1837 data -- Examining data
1838 breakpoints -- Making program stop at certain points
1839 files -- Specifying and examining files
1840 status -- Status inquiries
1841 support -- Support facilities
1842 user-defined -- User-defined commands
1843 aliases -- Aliases of other commands
1844 obscure -- Obscure features
1846 Type "help" followed by a class name for a list of
1847 commands in that class.
1848 Type "help" followed by command name for full
1850 Command name abbreviations are allowed if unambiguous.
1854 @item help @var{class}
1855 Using one of the general help classes as an argument, you can get a
1856 list of the individual commands in that class. For example, here is the
1857 help display for the class @code{status}:
1860 (@value{GDBP}) help status
1865 show -- Generic command for showing things set with "set"
1866 info -- Generic command for printing status
1868 Type "help" followed by command name for full
1870 Command name abbreviations are allowed if unambiguous.
1874 @item help @var{command}
1875 With a command name as @code{help} argument, @value{GDBN} will display a
1876 short paragraph on how to use that command.
1879 In addition to @code{help}, you can use the @value{GDBN} commands @code{info}
1880 and @code{show} to inquire about the state of your program, or the state
1881 of @value{GDBN} itself. Each command supports many topics of inquiry; this
1882 manual introduces each of them in the appropriate context. The listings
1883 under @code{info} and under @code{show} in the Index point to
1884 all the sub-commands. @xref{Index}.
1891 This command (abbreviated @code{i}) is for describing the state of your
1892 program. For example, you can list the arguments given to your program
1893 with @code{info args}, list the registers currently in use with @code{info
1894 registers}, or list the breakpoints you have set with @code{info breakpoints}.
1895 You can get a complete list of the @code{info} sub-commands with
1896 @w{@code{help info}}.
1900 In contrast, @code{show} is for describing the state of @value{GDBN} itself.
1901 You can change most of the things you can @code{show}, by using the
1902 related command @code{set}; for example, you can control what number
1903 system is used for displays with @code{set radix}, or simply inquire
1904 which is currently in use with @code{show radix}.
1907 To display all the settable parameters and their current
1908 values, you can use @code{show} with no arguments; you may also use
1909 @code{info set}. Both commands produce the same display.
1910 @c FIXME: "info set" violates the rule that "info" is for state of
1911 @c FIXME...program. Ck w/ GNU: "info set" to be called something else,
1912 @c FIXME...or change desc of rule---eg "state of prog and debugging session"?
1916 Here are three miscellaneous @code{show} subcommands, all of which are
1917 exceptional in lacking corresponding @code{set} commands:
1920 @kindex show version
1921 @cindex version number
1923 Show what version of @value{GDBN} is running. You should include this
1924 information in @value{GDBN} bug-reports. If multiple versions of @value{GDBN} are in
1925 use at your site, you may occasionally want to determine which version
1926 of @value{GDBN} you are running; as @value{GDBN} evolves, new commands are introduced,
1927 and old ones may wither away. The version number is also announced
1928 when you start @value{GDBN} with no arguments.
1930 @kindex show copying
1932 Display information about permission for copying @value{GDBN}.
1934 @kindex show warranty
1936 Display the GNU ``NO WARRANTY'' statement.
1940 @chapter Running Programs Under @value{GDBN}
1942 When you run a program under @value{GDBN}, you must first generate
1943 debugging information when you compile it. You may start it with its
1944 arguments, if any, in an environment of your choice. You may redirect
1945 your program's input and output, debug an already running process, or
1946 kill a child process.
1951 * Compilation:: Compiling for debugging
1952 * Starting:: Starting your program
1954 * Arguments:: Your program's arguments
1955 * Environment:: Your program's environment
1956 * Working Directory:: Your program's working directory
1957 * Input/Output:: Your program's input and output
1958 * Attach:: Debugging an already-running process
1959 * Kill Process:: Killing the child process
1960 * Process Information:: Additional process information
1967 * Compilation:: Compiling for debugging
1968 * Starting:: Starting your program
1969 * Arguments:: Your program's arguments
1970 * Environment:: Your program's environment
1971 * Working Directory:: Your program's working directory
1972 * Input/Output:: Your program's input and output
1973 * Attach:: Debugging an already-running process
1974 * Kill Process:: Killing the child process
1975 * Process Information:: Additional process information
1981 * Compilation:: Compiling for debugging
1982 * Starting:: Starting your program
1987 @section Compiling for debugging
1989 In order to debug a program effectively, you need to generate
1990 debugging information when you compile it. This debugging information
1991 is stored in the object file; it describes the data type of each
1992 variable or function and the correspondence between source line numbers
1993 and addresses in the executable code.
1995 To request debugging information, specify the @samp{-g} option when you run
1998 Many C compilers are unable to handle the @samp{-g} and @samp{-O}
1999 options together. Using those compilers, you cannot generate optimized
2000 executables containing debugging information.
2002 @value{NGCC}, the GNU C compiler, supports @samp{-g} with or without
2003 @samp{-O}, making it possible to debug optimized code. We recommend
2004 that you @emph{always} use @samp{-g} whenever you compile a program.
2005 You may think your program is correct, but there is no sense in pushing
2008 @cindex optimized code, debugging
2009 @cindex debugging optimized code
2010 When you debug a program compiled with @samp{-g -O}, remember that the
2011 optimizer is rearranging your code; the debugger will show you what is
2012 really there. Do not be too surprised when the execution path does not
2013 exactly match your source file! An extreme example: if you define a
2014 variable, but never use it, @value{GDBN} will never see that
2015 variable---because the compiler optimizes it out of existence.
2017 Some things do not work as well with @samp{-g -O} as with just
2018 @samp{-g}, particularly on machines with instruction scheduling. If in
2019 doubt, recompile with @samp{-g} alone, and if this fixes the problem,
2020 please report it as a bug (including a test case!).
2022 Older versions of the GNU C compiler permitted a variant option
2023 @w{@samp{-gg}} for debugging information. @value{GDBN} no longer supports this
2024 format; if your GNU C compiler has this option, do not use it.
2027 @comment As far as I know, there are no cases in which @value{GDBN} will
2028 @comment produce strange output in this case. (but no promises).
2029 If your program includes archives made with the @code{ar} program, and
2030 if the object files used as input to @code{ar} were compiled without the
2031 @samp{-g} option and have names longer than 15 characters, @value{GDBN} will get
2032 confused reading your program's symbol table. No error message will be
2033 given, but @value{GDBN} may behave strangely. The reason for this problem is a
2034 deficiency in the Unix archive file format, which cannot represent file
2035 names longer than 15 characters.
2037 To avoid this problem, compile the archive members with the @samp{-g}
2038 option or use shorter file names. Alternatively, use a version of GNU
2039 @code{ar} dated more recently than August 1989.
2043 @section Starting your program
2051 Use the @code{run} command to start your program under @value{GDBN}. You must
2052 first specify the program name
2056 with an argument to @value{GDBN} (@pxref{Invocation, ,Getting In and
2057 Out of @value{GDBN}}), or by using the @code{file} or @code{exec-file}
2058 command (@pxref{Files, ,Commands to specify files}).
2063 If you are running your program in an execution environment that
2064 supports processes, @code{run} creates an inferior process and makes
2065 that process run your program. (In environments without processes,
2066 @code{run} jumps to the start of your program.)
2068 The execution of a program is affected by certain information it
2069 receives from its superior. @value{GDBN} provides ways to specify this
2070 information, which you must do @emph{before} starting your program. (You
2071 can change it after starting your program, but such changes will only affect
2072 your program the next time you start it.) This information may be
2073 divided into four categories:
2076 @item The @emph{arguments.}
2077 Specify the arguments to give your program as the arguments of the
2078 @code{run} command. If a shell is available on your target, the shell
2079 is used to pass the arguments, so that you may use normal conventions
2080 (such as wildcard expansion or variable substitution) in describing
2081 the arguments. In Unix systems, you can control which shell is used
2082 with the @code{SHELL} environment variable. @xref{Arguments, ,Your
2083 program's arguments}.
2085 @item The @emph{environment.}
2086 Your program normally inherits its environment from @value{GDBN}, but you can
2087 use the @value{GDBN} commands @code{set environment} and @code{unset
2088 environment} to change parts of the environment that will be given to
2089 your program. @xref{Environment, ,Your program's environment}.
2091 @item The @emph{working directory.}
2092 Your program inherits its working directory from @value{GDBN}. You can set
2093 the @value{GDBN} working directory with the @code{cd} command in @value{GDBN}.
2094 @xref{Working Directory, ,Your program's working directory}.
2096 @item The @emph{standard input and output.}
2097 Your program normally uses the same device for standard input and
2098 standard output as @value{GDBN} is using. You can redirect input and output
2099 in the @code{run} command line, or you can use the @code{tty} command to
2100 set a different device for your program.
2101 @xref{Input/Output, ,Your program's input and output}.
2104 @emph{Warning:} While input and output redirection work, you cannot use
2105 pipes to pass the output of the program you are debugging to another
2106 program; if you attempt this, @value{GDBN} is likely to wind up debugging the
2111 When you issue the @code{run} command, your program begins to execute
2112 immediately. @xref{Stopping, ,Stopping and continuing}, for discussion
2113 of how to arrange for your program to stop. Once your program has
2114 stopped, you may calls functions in your program, using the @code{print}
2115 or @code{call} commands. @xref{Data, ,Examining Data}.
2117 If the modification time of your symbol file has changed since the
2118 last time @value{GDBN} read its symbols, @value{GDBN} will discard its symbol table and
2119 re-read it. When it does this, @value{GDBN} tries to retain your current
2124 @section Your program's arguments
2126 @cindex arguments (to your program)
2127 The arguments to your program can be specified by the arguments of the
2128 @code{run} command. They are passed to a shell, which expands wildcard
2129 characters and performs redirection of I/O, and thence to your program.
2130 @value{GDBN} uses the shell indicated by your @code{SHELL} environment
2131 variable if it exists; otherwise, @value{GDBN} uses @code{/bin/sh}.
2133 @code{run} with no arguments uses the same arguments used by the previous
2134 @code{run}, or those set by the @code{set args} command.
2139 Specify the arguments to be used the next time your program is run. If
2140 @code{set args} has no arguments, @code{run} will execute your program
2141 with no arguments. Once you have run your program with arguments,
2142 using @code{set args} before the next @code{run} is the only way to run
2143 it again without arguments.
2147 Show the arguments to give your program when it is started.
2151 @section Your program's environment
2153 @cindex environment (of your program)
2154 The @dfn{environment} consists of a set of environment variables and
2155 their values. Environment variables conventionally record such things as
2156 your user name, your home directory, your terminal type, and your search
2157 path for programs to run. Usually you set up environment variables with
2158 the shell and they are inherited by all the other programs you run. When
2159 debugging, it can be useful to try running your program with a modified
2160 environment without having to start @value{GDBN} over again.
2163 @item path @var{directory}
2165 Add @var{directory} to the front of the @code{PATH} environment variable
2166 (the search path for executables), for both @value{GDBN} and your program.
2167 You may specify several directory names, separated by @samp{:} or
2168 whitespace. If @var{directory} is already in the path, it is moved to
2169 the front, so it will be searched sooner.
2171 You can use the string @samp{$cwd} to refer to whatever is the current
2172 working directory at the time @value{GDBN} searches the path. If you use
2173 @samp{.} instead, it refers to the directory where you executed the
2174 @code{path} command. @value{GDBN} fills in the current path where needed in
2175 the @var{directory} argument, before adding it to the search path.
2176 @c 'path' is explicitly nonrepeatable, but RMS points out it is silly to
2177 @c document that, since repeating it would be a no-op.
2181 Display the list of search paths for executables (the @code{PATH}
2182 environment variable).
2184 @item show environment @r{[}@var{varname}@r{]}
2185 @kindex show environment
2186 Print the value of environment variable @var{varname} to be given to
2187 your program when it starts. If you do not supply @var{varname},
2188 print the names and values of all environment variables to be given to
2189 your program. You can abbreviate @code{environment} as @code{env}.
2191 @item set environment @var{varname} @r{[}=@r{]} @var{value}
2192 @kindex set environment
2193 Set environment variable @var{varname} to @var{value}. The value
2194 changes for your program only, not for @value{GDBN} itself. @var{value} may
2195 be any string; the values of environment variables are just strings, and
2196 any interpretation is supplied by your program itself. The @var{value}
2197 parameter is optional; if it is eliminated, the variable is set to a
2199 @c "any string" here does not include leading, trailing
2200 @c blanks. Gnu asks: does anyone care?
2202 For example, this command:
2209 tells a Unix program, when subsequently run, that its user is named
2210 @samp{foo}. (The spaces around @samp{=} are used for clarity here; they
2211 are not actually required.)
2213 @item unset environment @var{varname}
2214 @kindex unset environment
2215 Remove variable @var{varname} from the environment to be passed to your
2216 program. This is different from @samp{set env @var{varname} =};
2217 @code{unset environment} removes the variable from the environment,
2218 rather than assigning it an empty value.
2221 @node Working Directory
2222 @section Your program's working directory
2224 @cindex working directory (of your program)
2225 Each time you start your program with @code{run}, it inherits its
2226 working directory from the current working directory of @value{GDBN}.
2227 The @value{GDBN} working directory is initially whatever it inherited
2228 from its parent process (typically the shell), but you can specify a new
2229 working directory in @value{GDBN} with the @code{cd} command.
2231 The @value{GDBN} working directory also serves as a default for the commands
2232 that specify files for @value{GDBN} to operate on. @xref{Files, ,Commands to
2236 @item cd @var{directory}
2238 Set the @value{GDBN} working directory to @var{directory}.
2242 Print the @value{GDBN} working directory.
2246 @section Your program's input and output
2251 By default, the program you run under @value{GDBN} does input and output to
2252 the same terminal that @value{GDBN} uses. @value{GDBN} switches the terminal to
2253 its own terminal modes to interact with you, but it records the terminal
2254 modes your program was using and switches back to them when you continue
2255 running your program.
2259 @kindex info terminal
2260 Displays information recorded by @value{GDBN} about the terminal modes your
2264 You can redirect your program's input and/or output using shell
2265 redirection with the @code{run} command. For example,
2272 starts your program, diverting its output to the file @file{outfile}.
2275 @cindex controlling terminal
2276 Another way to specify where your program should do input and output is
2277 with the @code{tty} command. This command accepts a file name as
2278 argument, and causes this file to be the default for future @code{run}
2279 commands. It also resets the controlling terminal for the child
2280 process, for future @code{run} commands. For example,
2287 directs that processes started with subsequent @code{run} commands
2288 default to do input and output on the terminal @file{/dev/ttyb} and have
2289 that as their controlling terminal.
2291 An explicit redirection in @code{run} overrides the @code{tty} command's
2292 effect on the input/output device, but not its effect on the controlling
2295 When you use the @code{tty} command or redirect input in the @code{run}
2296 command, only the input @emph{for your program} is affected. The input
2297 for @value{GDBN} still comes from your terminal.
2300 @section Debugging an already-running process
2305 @item attach @var{process-id}
2307 attaches to a running process---one that was started outside @value{GDBN}.
2308 (@code{info files} will show your active targets.) The command takes as
2309 argument a process ID. The usual way to find out the process-id of
2310 a Unix process is with the @code{ps} utility, or with the @samp{jobs -l}
2313 @code{attach} will not repeat if you press @key{RET} a second time after
2314 executing the command.
2317 To use @code{attach}, you must be debugging in an environment which
2318 supports processes. You must also have permission to send the process a
2319 signal, and it must have the same effective user ID as the @value{GDBN}
2322 When using @code{attach}, you should first use the @code{file} command
2323 to specify the program running in the process and load its symbol table.
2324 @xref{Files, ,Commands to Specify Files}.
2326 The first thing @value{GDBN} does after arranging to debug the specified
2327 process is to stop it. You can examine and modify an attached process
2328 with all the @value{GDBN} commands that are ordinarily available when you start
2329 processes with @code{run}. You can insert breakpoints; you can step and
2330 continue; you can modify storage. If you would rather the process
2331 continue running, you may use the @code{continue} command after
2332 attaching @value{GDBN} to the process.
2337 When you have finished debugging the attached process, you can use the
2338 @code{detach} command to release it from @value{GDBN} control. Detaching
2339 the process continues its execution. After the @code{detach} command,
2340 that process and @value{GDBN} become completely independent once more, and you
2341 are ready to @code{attach} another process or start one with @code{run}.
2342 @code{detach} will not repeat if you press @key{RET} again after
2343 executing the command.
2346 If you exit @value{GDBN} or use the @code{run} command while you have an attached
2347 process, you kill that process. By default, you will be asked for
2348 confirmation if you try to do either of these things; you can control
2349 whether or not you need to confirm by using the @code{set confirm} command
2350 (@pxref{Messages/Warnings, ,Optional warnings and messages}).
2354 @section Killing the child process
2359 Kill the child process in which your program is running under @value{GDBN}.
2362 This command is useful if you wish to debug a core dump instead of a
2363 running process. @value{GDBN} ignores any core dump file while your program
2367 On some operating systems, a program cannot be executed outside @value{GDBN}
2368 while you have breakpoints set on it inside @value{GDBN}. You can use the
2369 @code{kill} command in this situation to permit running your program
2370 outside the debugger.
2372 The @code{kill} command is also useful if you wish to recompile and
2373 relink your program, since on many systems it is impossible to modify an
2374 executable file while it is running in a process. In this case, when you
2375 next type @code{run}, @value{GDBN} will notice that the file has changed, and
2376 will re-read the symbol table (while trying to preserve your current
2377 breakpoint settings).
2379 @node Process Information
2380 @section Additional process information
2383 @cindex process image
2384 Some operating systems provide a facility called @samp{/proc} that can
2385 be used to examine the image of a running process using file-system
2386 subroutines. If @value{GDBN} is configured for an operating system with this
2387 facility, the command @code{info proc} is available to report on several
2388 kinds of information about the process running your program.
2393 Summarize available information about the process.
2395 @item info proc mappings
2396 @kindex info proc mappings
2397 Report on the address ranges accessible in the program, with information
2398 on whether your program may read, write, or execute each range.
2400 @item info proc times
2401 @kindex info proc times
2402 Starting time, user CPU time, and system CPU time for your program and
2406 @kindex info proc id
2407 Report on the process IDs related to your program: its own process ID,
2408 the ID of its parent, the process group ID, and the session ID.
2410 @item info proc status
2411 @kindex info proc status
2412 General information on the state of the process. If the process is
2413 stopped, this report includes the reason for stopping, and any signal
2417 Show all the above information about the process.
2422 @chapter Stopping and Continuing
2424 The principal purposes of using a debugger are so that you can stop your
2425 program before it terminates; or so that, if your program runs into
2426 trouble, you can investigate and find out why.
2428 Inside @value{GDBN}, your program may stop for any of several reasons, such
2429 as a signal, a breakpoint, or reaching a new line after a @value{GDBN}
2430 command such as @code{step}. You may then examine and change
2431 variables, set new breakpoints or remove old ones, and then continue
2432 execution. Usually, the messages shown by @value{GDBN} provide ample
2433 explanation of the status of your program---but you can also explicitly
2434 request this information at any time.
2438 @kindex info program
2439 Display information about the status of your program: whether it is
2440 running or not, what process it is, and why it stopped.
2447 * Breakpoints:: Breakpoints, watchpoints, and exceptions
2450 * Breakpoints:: Breakpoints and watchpoints
2452 * Continuing and Stepping:: Resuming execution
2463 * Breakpoints:: Breakpoints, watchpoints, and exceptions
2464 * Continuing and Stepping:: Resuming execution
2474 * Breakpoints:: Breakpoints and watchpoints
2475 * Continuing and Stepping:: Resuming execution
2485 * Breakpoints:: Breakpoints, watchpoints, and exceptions
2486 * Continuing and Stepping:: Resuming execution
2495 * Breakpoints:: Breakpoints and watchpoints
2496 * Continuing and Stepping:: Resuming execution
2501 @c node-defaulting requires adjacency of @node and sectioning cmds
2502 @c ...hence distribute @node Breakpoints over two possible @if expansions.
2506 @section Breakpoints, watchpoints, and exceptions
2510 @section Breakpoints and watchpoints
2514 A @dfn{breakpoint} makes your program stop whenever a certain point in
2515 the program is reached. For each breakpoint, you can add various
2516 conditions to control in finer detail whether your program will stop.
2517 You can set breakpoints with the @code{break} command and its variants
2518 (@pxref{Set Breaks, ,Setting breakpoints}), to specify the place where
2519 your program should stop by line number, function name or exact address
2522 In languages with exception handling (such as GNU C++), you can also set
2523 breakpoints where an exception is raised (@pxref{Exception Handling,
2524 ,Breakpoints and exceptions}).
2528 @cindex memory tracing
2529 @cindex breakpoint on memory address
2530 @cindex breakpoint on variable modification
2531 A @dfn{watchpoint} is a special breakpoint that stops your program
2532 when the value of an expression changes. You must use a different
2533 command to set watchpoints (@pxref{Set Watchpoints, ,Setting
2534 watchpoints}), but aside from that, you can manage a watchpoint like
2535 any other breakpoint: you enable, disable, and delete both breakpoints
2536 and watchpoints using the same commands.
2538 You can arrange to have values from your program displayed automatically
2539 whenever @value{GDBN} stops at a breakpoint. @xref{Auto Display,
2540 ,Automatic display}.
2542 @cindex breakpoint numbers
2543 @cindex numbers for breakpoints
2544 @value{GDBN} assigns a number to each breakpoint or watchpoint when you
2545 create it; these numbers are successive integers starting with one. In
2546 many of the commands for controlling various features of breakpoints you
2547 use the breakpoint number to say which breakpoint you want to change.
2548 Each breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has
2549 no effect on your program until you enable it again.
2552 * Set Breaks:: Setting breakpoints
2553 * Set Watchpoints:: Setting watchpoints
2554 * Exception Handling:: Breakpoints and exceptions
2555 * Delete Breaks:: Deleting breakpoints
2556 * Disabling:: Disabling breakpoints
2557 * Conditions:: Break conditions
2558 * Break Commands:: Breakpoint command lists
2559 * Breakpoint Menus:: Breakpoint menus
2560 * Error in Breakpoints:: ``Cannot insert breakpoints''
2564 @subsection Setting breakpoints
2566 @c FIXME LMB what does GDB do if no code on line of breakpt?
2567 @c consider in particular declaration with/without initialization.
2569 @c FIXME 2 is there stuff on this already? break at fun start, already init?
2574 @cindex latest breakpoint
2575 Breakpoints are set with the @code{break} command (abbreviated
2576 @code{b}). The debugger convenience variable @samp{$bpnum} records the
2577 number of the beakpoint you've set most recently; see @ref{Convenience
2578 Vars,, Convenience variables}, for a discussion of what you can do with
2579 convenience variables.
2581 You have several ways to say where the breakpoint should go.
2584 @item break @var{function}
2585 Set a breakpoint at entry to function @var{function}.
2587 When using source languages that permit overloading of symbols, such as
2588 C++, @var{function} may refer to more than one possible place to break.
2589 @xref{Breakpoint Menus,,Breakpoint menus}, for a discussion of that situation.
2592 @item break +@var{offset}
2593 @itemx break -@var{offset}
2594 Set a breakpoint some number of lines forward or back from the position
2595 at which execution stopped in the currently selected frame.
2597 @item break @var{linenum}
2598 Set a breakpoint at line @var{linenum} in the current source file.
2599 That file is the last file whose source text was printed. This
2600 breakpoint will stop your program just before it executes any of the
2603 @item break @var{filename}:@var{linenum}
2604 Set a breakpoint at line @var{linenum} in source file @var{filename}.
2606 @item break @var{filename}:@var{function}
2607 Set a breakpoint at entry to function @var{function} found in file
2608 @var{filename}. Specifying a file name as well as a function name is
2609 superfluous except when multiple files contain similarly named
2612 @item break *@var{address}
2613 Set a breakpoint at address @var{address}. You can use this to set
2614 breakpoints in parts of your program which do not have debugging
2615 information or source files.
2618 When called without any arguments, @code{break} sets a breakpoint at
2619 the next instruction to be executed in the selected stack frame
2620 (@pxref{Stack, ,Examining the Stack}). In any selected frame but the
2621 innermost, this will cause your program to stop as soon as control
2622 returns to that frame. This is similar to the effect of a
2623 @code{finish} command in the frame inside the selected frame---except
2624 that @code{finish} does not leave an active breakpoint. If you use
2625 @code{break} without an argument in the innermost frame, @value{GDBN} will stop
2626 the next time it reaches the current location; this may be useful
2629 @value{GDBN} normally ignores breakpoints when it resumes execution, until at
2630 least one instruction has been executed. If it did not do this, you
2631 would be unable to proceed past a breakpoint without first disabling the
2632 breakpoint. This rule applies whether or not the breakpoint already
2633 existed when your program stopped.
2635 @item break @dots{} if @var{cond}
2636 Set a breakpoint with condition @var{cond}; evaluate the expression
2637 @var{cond} each time the breakpoint is reached, and stop only if the
2638 value is nonzero---that is, if @var{cond} evaluates as true.
2639 @samp{@dots{}} stands for one of the possible arguments described
2640 above (or no argument) specifying where to break. @xref{Conditions,
2641 ,Break conditions}, for more information on breakpoint conditions.
2643 @item tbreak @var{args}
2645 Set a breakpoint enabled only for one stop. @var{args} are the
2646 same as for the @code{break} command, and the breakpoint is set in the same
2647 way, but the breakpoint is automatically disabled after the first time your
2648 program stops there. @xref{Disabling, ,Disabling breakpoints}.
2650 @item rbreak @var{regex}
2652 @cindex regular expression
2653 @c FIXME what kind of regexp?
2654 Set breakpoints on all functions matching the regular expression
2655 @var{regex}. This command
2656 sets an unconditional breakpoint on all matches, printing a list of all
2657 breakpoints it set. Once these breakpoints are set, they are treated
2658 just like the breakpoints set with the @code{break} command. They can
2659 be deleted, disabled, made conditional, etc., in the standard ways.
2662 When debugging C++ programs, @code{rbreak} is useful for setting
2663 breakpoints on overloaded functions that are not members of any special
2667 @kindex info breakpoints
2668 @cindex @code{$_} and @code{info breakpoints}
2669 @item info breakpoints @r{[}@var{n}@r{]}
2670 @itemx info break @r{[}@var{n}@r{]}
2671 @itemx info watchpoints @r{[}@var{n}@r{]}
2672 Print a table of all breakpoints and watchpoints set and not
2673 deleted, with the following columns for each breakpoint:
2676 @item Breakpoint Numbers
2678 Breakpoint or watchpoint.
2680 Whether the breakpoint is marked to be disabled or deleted when hit.
2681 @item Enabled or Disabled
2682 Enabled breakpoints are marked with @samp{y}. @samp{n} marks breakpoints
2683 that are not enabled.
2685 Where the breakpoint is in your program, as a memory address
2687 Where the breakpoint is in the source for your program, as a file and
2692 Breakpoint commands, if any, are listed after the line for the
2693 corresponding breakpoint.
2696 @code{info break} with a breakpoint
2697 number @var{n} as argument lists only that breakpoint. The
2698 convenience variable @code{$_} and the default examining-address for
2699 the @code{x} command are set to the address of the last breakpoint
2700 listed (@pxref{Memory, ,Examining memory}).
2703 @value{GDBN} allows you to set any number of breakpoints at the same place in
2704 your program. There is nothing silly or meaningless about this. When
2705 the breakpoints are conditional, this is even useful
2706 (@pxref{Conditions, ,Break conditions}).
2708 @cindex negative breakpoint numbers
2709 @cindex internal @value{GDBN} breakpoints
2710 @value{GDBN} itself sometimes sets breakpoints in your program for special
2711 purposes, such as proper handling of @code{longjmp} (in C programs).
2712 These internal breakpoints are assigned negative numbers, starting with
2713 @code{-1}; @samp{info breakpoints} does not display them.
2715 You can see these breakpoints with the @value{GDBN} maintenance command
2716 @samp{maint info breakpoints}.
2719 @kindex maint info breakpoints
2720 @item maint info breakpoints
2721 Using the same format as @samp{info breakpoints}, display both the
2722 breakpoints you've set explicitly, and those @value{GDBN} is using for
2723 internal purposes. Internal breakpoints are shown with negative
2724 breakpoint numbers. The type column identifies what kind of breakpoint
2729 Normal, explicitly set breakpoint.
2732 Normal, explicitly set watchpoint.
2735 Internal breakpoint, used to handle correctly stepping through
2736 @code{longjmp} calls.
2738 @item longjmp resume
2739 Internal breakpoint at the target of a @code{longjmp}.
2742 Temporary internal breakpoint used by the @value{GDBN} @code{until} command.
2745 Temporary internal breakpoint used by the @value{GDBN} @code{finish} command.
2751 @node Set Watchpoints
2752 @subsection Setting watchpoints
2753 @cindex setting watchpoints
2755 You can use a watchpoint to stop execution whenever the value of an
2756 expression changes, without having to predict a particular place
2757 where this may happen.
2759 Watchpoints currently execute two orders of magnitude more slowly than
2760 other breakpoints, but this can well be worth it to catch errors where
2761 you have no clue what part of your program is the culprit. Some
2762 processors provide special hardware to support watchpoint evaluation; future
2763 releases of @value{GDBN} will use such hardware if it is available.
2767 @item watch @var{expr}
2768 Set a watchpoint for an expression.
2770 @kindex info watchpoints
2771 @item info watchpoints
2772 This command prints a list of watchpoints and breakpoints; it is the
2773 same as @code{info break}.
2776 @node Exception Handling
2777 @subsection Breakpoints and exceptions
2778 @cindex exception handlers
2780 Some languages, such as GNU C++, implement exception handling. You can
2781 use @value{GDBN} to examine what caused your program to raise an exception,
2782 and to list the exceptions your program is prepared to handle at a
2783 given point in time.
2786 @item catch @var{exceptions}
2788 You can set breakpoints at active exception handlers by using the
2789 @code{catch} command. @var{exceptions} is a list of names of exceptions
2793 You can use @code{info catch} to list active exception handlers.
2794 @xref{Frame Info, ,Information about a frame}.
2796 There are currently some limitations to exception handling in @value{GDBN}.
2797 These will be corrected in a future release.
2801 If you call a function interactively, @value{GDBN} normally returns
2802 control to you when the function has finished executing. If the call
2803 raises an exception, however, the call may bypass the mechanism that
2804 returns control to you and cause your program to simply continue
2805 running until it hits a breakpoint, catches a signal that @value{GDBN} is
2806 listening for, or exits.
2808 You cannot raise an exception interactively.
2810 You cannot interactively install an exception handler.
2813 @cindex raise exceptions
2814 Sometimes @code{catch} is not the best way to debug exception handling:
2815 if you need to know exactly where an exception is raised, it is better to
2816 stop @emph{before} the exception handler is called, since that way you
2817 can see the stack before any unwinding takes place. If you set a
2818 breakpoint in an exception handler instead, it may not be easy to find
2819 out where the exception was raised.
2821 To stop just before an exception handler is called, you need some
2822 knowledge of the implementation. In the case of GNU C++, exceptions are
2823 raised by calling a library function named @code{__raise_exception}
2824 which has the following ANSI C interface:
2827 /* @var{addr} is where the exception identifier is stored.
2828 ID is the exception identifier. */
2829 void __raise_exception (void **@var{addr}, void *@var{id});
2833 To make the debugger catch all exceptions before any stack
2834 unwinding takes place, set a breakpoint on @code{__raise_exception}
2836 (@pxref{Breakpoints, ,Breakpoints; watchpoints; and exceptions}).
2839 (@pxref{Breakpoints, ,Breakpoints and watchpoints}).
2842 With a conditional breakpoint (@pxref{Conditions, ,Break conditions})
2843 that depends on the value of @var{id}, you can stop your program when
2844 a specific exception is raised. You can use multiple conditional
2845 breakpoints to stop your program when any of a number of exceptions are
2849 @subsection Deleting breakpoints
2851 @cindex clearing breakpoints, watchpoints
2852 @cindex deleting breakpoints, watchpoints
2853 It is often necessary to eliminate a breakpoint or watchpoint once it
2854 has done its job and you no longer want your program to stop there. This
2855 is called @dfn{deleting} the breakpoint. A breakpoint that has been
2856 deleted no longer exists; it is forgotten.
2858 With the @code{clear} command you can delete breakpoints according to
2859 where they are in your program. With the @code{delete} command you can
2860 delete individual breakpoints or watchpoints by specifying their
2863 It is not necessary to delete a breakpoint to proceed past it. @value{GDBN}
2864 automatically ignores breakpoints on the first instruction to be executed
2865 when you continue execution without changing the execution address.
2870 Delete any breakpoints at the next instruction to be executed in the
2871 selected stack frame (@pxref{Selection, ,Selecting a frame}). When
2872 the innermost frame is selected, this is a good way to delete a
2873 breakpoint where your program just stopped.
2875 @item clear @var{function}
2876 @itemx clear @var{filename}:@var{function}
2877 Delete any breakpoints set at entry to the function @var{function}.
2879 @item clear @var{linenum}
2880 @itemx clear @var{filename}:@var{linenum}
2881 Delete any breakpoints set at or within the code of the specified line.
2883 @item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
2884 @cindex delete breakpoints
2887 Delete the breakpoints or watchpoints of the numbers specified as
2888 arguments. If no argument is specified, delete all breakpoints (@value{GDBN}
2889 asks confirmation, unless you have @code{set confirm off}). You
2890 can abbreviate this command as @code{d}.
2894 @subsection Disabling breakpoints
2896 @cindex disabled breakpoints
2897 @cindex enabled breakpoints
2898 Rather than deleting a breakpoint or watchpoint, you might prefer to
2899 @dfn{disable} it. This makes the breakpoint inoperative as if it had
2900 been deleted, but remembers the information on the breakpoint so that
2901 you can @dfn{enable} it again later.
2903 You disable and enable breakpoints and watchpoints with the
2904 @code{enable} and @code{disable} commands, optionally specifying one or
2905 more breakpoint numbers as arguments. Use @code{info break} or
2906 @code{info watch} to print a list of breakpoints or watchpoints if you
2907 do not know which numbers to use.
2909 A breakpoint or watchpoint can have any of four different states of
2914 Enabled. The breakpoint will stop your program. A breakpoint set
2915 with the @code{break} command starts out in this state.
2917 Disabled. The breakpoint has no effect on your program.
2919 Enabled once. The breakpoint will stop your program, but
2920 when it does so it will become disabled. A breakpoint set
2921 with the @code{tbreak} command starts out in this state.
2923 Enabled for deletion. The breakpoint will stop your program, but
2924 immediately after it does so it will be deleted permanently.
2927 You can use the following commands to enable or disable breakpoints and
2931 @item disable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
2932 @kindex disable breakpoints
2935 Disable the specified breakpoints---or all breakpoints, if none are
2936 listed. A disabled breakpoint has no effect but is not forgotten. All
2937 options such as ignore-counts, conditions and commands are remembered in
2938 case the breakpoint is enabled again later. You may abbreviate
2939 @code{disable} as @code{dis}.
2941 @item enable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
2942 @kindex enable breakpoints
2944 Enable the specified breakpoints (or all defined breakpoints). They
2945 become effective once again in stopping your program.
2947 @item enable @r{[}breakpoints@r{]} once @var{bnums}@dots{}
2948 Enable the specified breakpoints temporarily. Each will be disabled
2949 again the next time it stops your program.
2951 @item enable @r{[}breakpoints@r{]} delete @var{bnums}@dots{}
2952 Enable the specified breakpoints to work once and then die. Each of
2953 the breakpoints will be deleted the next time it stops your program.
2956 Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks,
2957 ,Setting breakpoints}), breakpoints that you set are initially enabled;
2958 subsequently, they become disabled or enabled only when you use one of
2959 the commands above. (The command @code{until} can set and delete a
2960 breakpoint of its own, but it will not change the state of your other
2961 breakpoints; see @ref{Continuing and Stepping, ,Continuing and
2965 @subsection Break conditions
2966 @cindex conditional breakpoints
2967 @cindex breakpoint conditions
2969 @c FIXME what is scope of break condition expr? Context where wanted?
2970 @c in particular for a watchpoint?
2971 The simplest sort of breakpoint breaks every time your program reaches a
2972 specified place. You can also specify a @dfn{condition} for a
2973 breakpoint. A condition is just a Boolean expression in your
2974 programming language (@pxref{Expressions, ,Expressions}). A breakpoint with
2975 a condition evaluates the expression each time your program reaches it,
2976 and your program stops only if the condition is @emph{true}.
2978 This is the converse of using assertions for program validation; in that
2979 situation, you want to stop when the assertion is violated---that is,
2980 when the condition is false. In C, if you want to test an assertion expressed
2981 by the condition @var{assert}, you should set the condition
2982 @samp{! @var{assert}} on the appropriate breakpoint.
2984 Conditions are also accepted for watchpoints; you may not need them,
2985 since a watchpoint is inspecting the value of an expression anyhow---but
2986 it might be simpler, say, to just set a watchpoint on a variable name,
2987 and specify a condition that tests whether the new value is an interesting
2990 Break conditions can have side effects, and may even call functions in
2991 your program. This can be useful, for example, to activate functions
2992 that log program progress, or to use your own print functions to
2993 format special data structures. The effects are completely predictable
2994 unless there is another enabled breakpoint at the same address. (In
2995 that case, @value{GDBN} might see the other breakpoint first and stop your
2996 program without checking the condition of this one.) Note that
2997 breakpoint commands are usually more convenient and flexible for the
2998 purpose of performing side effects when a breakpoint is reached
2999 (@pxref{Break Commands, ,Breakpoint command lists}).
3001 Break conditions can be specified when a breakpoint is set, by using
3002 @samp{if} in the arguments to the @code{break} command. @xref{Set
3003 Breaks, ,Setting breakpoints}. They can also be changed at any time
3004 with the @code{condition} command. The @code{watch} command does not
3005 recognize the @code{if} keyword; @code{condition} is the only way to
3006 impose a further condition on a watchpoint.
3009 @item condition @var{bnum} @var{expression}
3011 Specify @var{expression} as the break condition for breakpoint or
3012 watchpoint number @var{bnum}. From now on, this breakpoint will stop
3013 your program only if the value of @var{expression} is true (nonzero, in
3014 C). When you use @code{condition}, @value{GDBN} checks @var{expression}
3015 immediately for syntactic correctness, and to determine whether symbols
3016 in it have referents in the context of your breakpoint.
3017 @c FIXME so what does GDB do if there is no referent? Moreover, what
3018 @c about watchpoints?
3020 not actually evaluate @var{expression} at the time the @code{condition}
3021 command is given, however. @xref{Expressions, ,Expressions}.
3023 @item condition @var{bnum}
3024 Remove the condition from breakpoint number @var{bnum}. It becomes
3025 an ordinary unconditional breakpoint.
3028 @cindex ignore count (of breakpoint)
3029 A special case of a breakpoint condition is to stop only when the
3030 breakpoint has been reached a certain number of times. This is so
3031 useful that there is a special way to do it, using the @dfn{ignore
3032 count} of the breakpoint. Every breakpoint has an ignore count, which
3033 is an integer. Most of the time, the ignore count is zero, and
3034 therefore has no effect. But if your program reaches a breakpoint whose
3035 ignore count is positive, then instead of stopping, it just decrements
3036 the ignore count by one and continues. As a result, if the ignore count
3037 value is @var{n}, the breakpoint will not stop the next @var{n} times it
3041 @item ignore @var{bnum} @var{count}
3043 Set the ignore count of breakpoint number @var{bnum} to @var{count}.
3044 The next @var{count} times the breakpoint is reached, your program's
3045 execution will not stop; other than to decrement the ignore count, @value{GDBN}
3048 To make the breakpoint stop the next time it is reached, specify
3051 @item continue @var{count}
3052 @itemx c @var{count}
3053 @itemx fg @var{count}
3054 @kindex continue @var{count}
3055 Continue execution of your program, setting the ignore count of the
3056 breakpoint where your program stopped to @var{count} minus one.
3057 Thus, your program will not stop at this breakpoint until the
3058 @var{count}'th time it is reached.
3060 An argument to this command is meaningful only when your program stopped
3061 due to a breakpoint. At other times, the argument to @code{continue} is
3064 The synonym @code{fg} is provided purely for convenience, and has
3065 exactly the same behavior as other forms of the command.
3068 If a breakpoint has a positive ignore count and a condition, the condition
3069 is not checked. Once the ignore count reaches zero, the condition will
3072 You could achieve the effect of the ignore count with a condition such
3073 as @w{@samp{$foo-- <= 0}} using a debugger convenience variable that
3074 is decremented each time. @xref{Convenience Vars, ,Convenience
3077 @node Break Commands
3078 @subsection Breakpoint command lists
3080 @cindex breakpoint commands
3081 You can give any breakpoint (or watchpoint) a series of commands to
3082 execute when your program stops due to that breakpoint. For example, you
3083 might want to print the values of certain expressions, or enable other
3087 @item commands @r{[}@var{bnum}@r{]}
3088 @itemx @dots{} @var{command-list} @dots{}
3092 Specify a list of commands for breakpoint number @var{bnum}. The commands
3093 themselves appear on the following lines. Type a line containing just
3094 @code{end} to terminate the commands.
3096 To remove all commands from a breakpoint, type @code{commands} and
3097 follow it immediately with @code{end}; that is, give no commands.
3099 With no @var{bnum} argument, @code{commands} refers to the last
3100 breakpoint or watchpoint set (not to the breakpoint most recently
3104 Pressing @key{RET} as a means of repeating the last @value{GDBN} command is
3105 disabled within a @var{command-list}.
3107 You can use breakpoint commands to start your program up again. Simply
3108 use the @code{continue} command, or @code{step}, or any other command
3109 that resumes execution.
3111 Any other commands in the command list, after a command that resumes
3112 execution, are ignored. This is because any time you resume execution
3113 (even with a simple @code{next} or @code{step}), you may encounter
3114 another breakpoint---which could have its own command list, leading to
3115 ambiguities about which list to execute.
3118 If the first command you specify in a command list is @code{silent}, the
3119 usual message about stopping at a breakpoint is not printed. This may
3120 be desirable for breakpoints that are to print a specific message and
3121 then continue. If none of the remaining commands print anything, you
3122 will see no sign that the breakpoint was reached. @code{silent} is
3123 meaningful only at the beginning of a breakpoint command list.
3125 The commands @code{echo} and @code{output} that allow you to print
3126 precisely controlled output are often useful in silent breakpoints.
3127 @xref{Output, ,Commands for controlled output}.
3129 For example, here is how you could use breakpoint commands to print the
3130 value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
3143 One application for breakpoint commands is to compensate for one bug so
3144 you can test for another. Put a breakpoint just after the erroneous line
3145 of code, give it a condition to detect the case in which something
3146 erroneous has been done, and give it commands to assign correct values
3147 to any variables that need them. End with the @code{continue} command
3148 so that your program does not stop, and start with the @code{silent}
3149 command so that no output is produced. Here is an example:
3161 One deficiency in the operation of automatically continuing breakpoints
3162 under Unix appears when your program uses raw mode for the terminal.
3163 @value{GDBN} switches back to its own terminal modes (not raw) before executing
3164 commands, and then must switch back to raw mode when your program is
3165 continued. This causes any pending terminal input to be lost.
3166 @c FIXME: revisit below when GNU sys avail.
3167 @c In the GNU system, this will be fixed by changing the behavior of
3170 Under Unix, you can get around this problem by writing actions into
3171 the breakpoint condition rather than in commands. For example,
3174 condition 5 (x = y + 4), 0
3178 specifies a condition expression (@pxref{Expressions, ,Expressions}) that will
3179 change @code{x} as needed, then always have the value zero so your
3180 program will not stop. No input is lost here, because @value{GDBN} evaluates
3181 break conditions without changing the terminal modes. When you want
3182 to have nontrivial conditions for performing the side effects, the
3183 operators @samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful.
3185 @node Breakpoint Menus
3186 @subsection Breakpoint menus
3188 @cindex symbol overloading
3190 Some programming languages (notably C++) permit a single function name
3191 to be defined several times, for application in different contexts.
3192 This is called @dfn{overloading}. When a function name is overloaded,
3193 @samp{break @var{function}} is not enough to tell @value{GDBN} where you want
3194 a breakpoint. If you realize this will be a problem, you can use
3195 something like @samp{break @var{function}(@var{types})} to specify which
3196 particular version of the function you want. Otherwise, @value{GDBN} offers
3197 you a menu of numbered choices for different possible breakpoints, and
3198 waits for your selection with the prompt @samp{>}. The first two
3199 options are always @samp{[0] cancel} and @samp{[1] all}. Typing @kbd{1}
3200 sets a breakpoint at each definition of @var{function}, and typing
3201 @kbd{0} aborts the @code{break} command without setting any new
3204 For example, the following session excerpt shows an attempt to set a
3205 breakpoint at the overloaded symbol @code{String::after}.
3206 We choose three particular definitions of that function name:
3208 @c FIXME! This is likely to change to show arg type lists, at least
3210 (@value{GDBP}) b String::after
3213 [2] file:String.cc; line number:867
3214 [3] file:String.cc; line number:860
3215 [4] file:String.cc; line number:875
3216 [5] file:String.cc; line number:853
3217 [6] file:String.cc; line number:846
3218 [7] file:String.cc; line number:735
3220 Breakpoint 1 at 0xb26c: file String.cc, line 867.
3221 Breakpoint 2 at 0xb344: file String.cc, line 875.
3222 Breakpoint 3 at 0xafcc: file String.cc, line 846.
3223 Multiple breakpoints were set.
3224 Use the "delete" command to delete unwanted breakpoints.
3228 @node Error in Breakpoints
3229 @subsection ``Cannot insert breakpoints''
3231 @c FIXME: "cannot insert breakpoints" error, v unclear.
3232 @c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91
3233 @c some light may be shed by looking at instances of
3234 @c ONE_PROCESS_WRITETEXT. But error message seems possible otherwise
3235 @c too. pesch, 20sep91
3236 Under some operating systems, breakpoints cannot be used in a program if
3237 any other process is running that program. In this situation,
3238 attempting to run or continue a program with a breakpoint causes @value{GDBN}
3239 to stop the other process.
3241 When this happens, you have three ways to proceed:
3245 Remove or disable the breakpoints, then continue.
3248 Suspend @value{GDBN}, and copy the file containing your program to a new name.
3249 Resume @value{GDBN} and use the @code{exec-file} command to specify that @value{GDBN}
3250 should run your program under that name. Then start your program again.
3252 @c FIXME: RMS commented here "Show example". Maybe when someone
3253 @c explains the first FIXME: in this section...
3256 Relink your program so that the text segment is nonsharable, using the
3257 linker option @samp{-N}. The operating system limitation may not apply
3258 to nonsharable executables.
3261 @node Continuing and Stepping
3262 @section Continuing and stepping
3266 @cindex resuming execution
3267 @dfn{Continuing} means resuming program execution until your program
3268 completes normally. In contrast, @dfn{stepping} means executing just
3269 one more ``step'' of your program, where ``step'' may mean either one
3270 line of source code, or one machine instruction (depending on what
3271 particular command you use). Either when continuing
3272 or when stepping, your program may stop even sooner, due to
3277 a breakpoint or to a signal. (If due to a signal, you may want to use
3278 @code{handle}, or use @samp{signal 0} to resume execution.
3279 @xref{Signals, ,Signals}.)
3283 @item continue @r{[}@var{ignore-count}@r{]}
3285 Resume program execution, at the address where your program last stopped;
3286 any breakpoints set at that address are bypassed. The optional argument
3287 @var{ignore-count} allows you to specify a further number of times to
3288 ignore a breakpoint at this location; its effect is like that of
3289 @code{ignore} (@pxref{Conditions, ,Break conditions}).
3291 To resume execution at a different place, you can use @code{return}
3292 (@pxref{Returning, ,Returning from a function}) to go back to the
3293 calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a
3294 different address}) to go to an arbitrary location in your program.
3297 A typical technique for using stepping is to set a breakpoint
3299 (@pxref{Breakpoints, ,Breakpoints; watchpoints; and exceptions})
3302 (@pxref{Breakpoints, ,Breakpoints and watchpoints})
3305 beginning of the function or the section of your program where a
3306 problem is believed to lie, run your program until it stops at that
3307 breakpoint, and then step through the suspect area, examining the
3308 variables that are interesting, until you see the problem happen.
3314 Continue running your program until control reaches a different source
3315 line, then stop it and return control to @value{GDBN}. This command is
3316 abbreviated @code{s}.
3319 @emph{Warning:} If you use the @code{step} command while control is
3320 within a function that was compiled without debugging information,
3321 execution will proceed until control reaches another function.
3324 @item step @var{count}
3325 Continue running as in @code{step}, but do so @var{count} times. If a
3326 breakpoint is reached or a signal not related to stepping occurs before
3327 @var{count} steps, stepping stops right away.
3329 @item next @r{[}@var{count}@r{]}
3332 Continue to the next source line in the current (innermost) stack frame.
3333 Similar to @code{step}, but any function calls appearing within the line
3334 of code are executed without stopping. Execution stops when control
3335 reaches a different line of code at the stack level which was executing
3336 when the @code{next} command was given. This command is abbreviated
3339 An argument @var{count} is a repeat count, as for @code{step}.
3341 @code{next} within a function that lacks debugging information acts like
3342 @code{step}, but any function calls appearing within the code of the
3343 function are executed without stopping.
3347 Continue running until just after function in the selected stack frame
3348 returns. Print the returned value (if any).
3350 Contrast this with the @code{return} command (@pxref{Returning,
3351 ,Returning from a function}).
3357 Continue running until a source line past the current line, in the
3358 current stack frame, is reached. This command is used to avoid single
3359 stepping through a loop more than once. It is like the @code{next}
3360 command, except that when @code{until} encounters a jump, it
3361 automatically continues execution until the program counter is greater
3362 than the address of the jump.
3364 This means that when you reach the end of a loop after single stepping
3365 though it, @code{until} will cause your program to continue execution
3366 until the loop is exited. In contrast, a @code{next} command at the end
3367 of a loop will simply step back to the beginning of the loop, which
3368 would force you to step through the next iteration.
3370 @code{until} always stops your program if it attempts to exit the current
3373 @code{until} may produce somewhat counterintuitive results if the order
3374 of machine code does not match the order of the source lines. For
3375 example, in the following excerpt from a debugging session, the @code{f}
3376 (@code{frame}) command shows that execution is stopped at line
3377 @code{206}; yet when we use @code{until}, we get to line @code{195}:
3381 #0 main (argc=4, argv=0xf7fffae8) at m4.c:206
3383 (@value{GDBP}) until
3384 195 for ( ; argc > 0; NEXTARG) @{
3387 This happened because, for execution efficiency, the compiler had
3388 generated code for the loop closure test at the end, rather than the
3389 start, of the loop---even though the test in a C @code{for}-loop is
3390 written before the body of the loop. The @code{until} command appeared
3391 to step back to the beginning of the loop when it advanced to this
3392 expression; however, it has not really gone to an earlier
3393 statement---not in terms of the actual machine code.
3395 @code{until} with no argument works by means of single
3396 instruction stepping, and hence is slower than @code{until} with an
3399 @item until @var{location}
3400 @item u @var{location}
3401 Continue running your program until either the specified location is
3402 reached, or the current stack frame returns. @var{location} is any of
3403 the forms of argument acceptable to @code{break} (@pxref{Set Breaks,
3404 ,Setting breakpoints}). This form of the command uses breakpoints,
3405 and hence is quicker than @code{until} without an argument.
3411 Execute one machine instruction, then stop and return to the debugger.
3413 It is often useful to do @samp{display/i $pc} when stepping by machine
3414 instructions. This will cause the next instruction to be executed to
3415 be displayed automatically at each stop. @xref{Auto Display,
3416 ,Automatic display}.
3418 An argument is a repeat count, as in @code{step}.
3425 Execute one machine instruction, but if it is a function call,
3426 proceed until the function returns.
3428 An argument is a repeat count, as in @code{next}.
3436 A signal is an asynchronous event that can happen in a program. The
3437 operating system defines the possible kinds of signals, and gives each
3438 kind a name and a number. For example, in Unix @code{SIGINT} is the
3439 signal a program gets when you type an interrupt (often @kbd{C-c});
3440 @code{SIGSEGV} is the signal a program gets from referencing a place in
3441 memory far away from all the areas in use; @code{SIGALRM} occurs when
3442 the alarm clock timer goes off (which happens only if your program has
3443 requested an alarm).
3445 @cindex fatal signals
3446 Some signals, including @code{SIGALRM}, are a normal part of the
3447 functioning of your program. Others, such as @code{SIGSEGV}, indicate
3448 errors; these signals are @dfn{fatal} (kill your program immediately) if the
3449 program has not specified in advance some other way to handle the signal.
3450 @code{SIGINT} does not indicate an error in your program, but it is normally
3451 fatal so it can carry out the purpose of the interrupt: to kill the program.
3453 @value{GDBN} has the ability to detect any occurrence of a signal in your
3454 program. You can tell @value{GDBN} in advance what to do for each kind of
3457 @cindex handling signals
3458 Normally, @value{GDBN} is set up to ignore non-erroneous signals like @code{SIGALRM}
3459 (so as not to interfere with their role in the functioning of your program)
3460 but to stop your program immediately whenever an error signal happens.
3461 You can change these settings with the @code{handle} command.
3465 @kindex info signals
3466 Print a table of all the kinds of signals and how @value{GDBN} has been told to
3467 handle each one. You can use this to see the signal numbers of all
3468 the defined types of signals.
3470 @item handle @var{signal} @var{keywords}@dots{}
3472 Change the way @value{GDBN} handles signal @var{signal}. @var{signal} can be the
3473 number of a signal or its name (with or without the @samp{SIG} at the
3474 beginning). The @var{keywords} say what change to make.
3478 The keywords allowed by the @code{handle} command can be abbreviated.
3479 Their full names are:
3483 @value{GDBN} should not stop your program when this signal happens. It may
3484 still print a message telling you that the signal has come in.
3487 @value{GDBN} should stop your program when this signal happens. This implies
3488 the @code{print} keyword as well.
3491 @value{GDBN} should print a message when this signal happens.
3494 @value{GDBN} should not mention the occurrence of the signal at all. This
3495 implies the @code{nostop} keyword as well.
3498 @value{GDBN} should allow your program to see this signal; your program will be
3499 able to handle the signal, or may be terminated if the signal is fatal
3503 @value{GDBN} should not allow your program to see this signal.
3507 When a signal stops your program, the signal is not visible until you
3508 continue. Your program will see the signal then, if @code{pass} is in
3509 effect for the signal in question @emph{at that time}. In other words,
3510 after @value{GDBN} reports a signal, you can use the @code{handle}
3511 command with @code{pass} or @code{nopass} to control whether that
3512 signal will be seen by your program when you later continue it.
3514 You can also use the @code{signal} command to prevent your program from
3515 seeing a signal, or cause it to see a signal it normally would not see,
3516 or to give it any signal at any time. For example, if your program stopped
3517 due to some sort of memory reference error, you might store correct
3518 values into the erroneous variables and continue, hoping to see more
3519 execution; but your program would probably terminate immediately as
3520 a result of the fatal signal once it saw the signal. To prevent this,
3521 you can continue with @samp{signal 0}. @xref{Signaling, ,Giving your
3526 @chapter Examining the Stack
3528 When your program has stopped, the first thing you need to know is where it
3529 stopped and how it got there.
3532 Each time your program performs a function call, the information about
3533 where in your program the call was made from is saved in a block of data
3534 called a @dfn{stack frame}. The frame also contains the arguments of the
3535 call and the local variables of the function that was called. All the
3536 stack frames are allocated in a region of memory called the @dfn{call
3539 When your program stops, the @value{GDBN} commands for examining the
3540 stack allow you to see all of this information.
3542 @cindex selected frame
3543 One of the stack frames is @dfn{selected} by @value{GDBN} and many
3544 @value{GDBN} commands refer implicitly to the selected frame. In
3545 particular, whenever you ask @value{GDBN} for the value of a variable in
3546 your program, the value is found in the selected frame. There are
3547 special @value{GDBN} commands to select whichever frame you are
3550 When your program stops, @value{GDBN} automatically selects the
3551 currently executing frame and describes it briefly as the @code{frame}
3552 command does (@pxref{Frame Info, ,Information about a frame}).
3555 * Frames:: Stack frames
3556 * Backtrace:: Backtraces
3557 * Selection:: Selecting a frame
3558 * Frame Info:: Information on a frame
3562 @section Stack frames
3566 The call stack is divided up into contiguous pieces called @dfn{stack
3567 frames}, or @dfn{frames} for short; each frame is the data associated
3568 with one call to one function. The frame contains the arguments given
3569 to the function, the function's local variables, and the address at
3570 which the function is executing.
3572 @cindex initial frame
3573 @cindex outermost frame
3574 @cindex innermost frame
3575 When your program is started, the stack has only one frame, that of the
3576 function @code{main}. This is called the @dfn{initial} frame or the
3577 @dfn{outermost} frame. Each time a function is called, a new frame is
3578 made. Each time a function returns, the frame for that function invocation
3579 is eliminated. If a function is recursive, there can be many frames for
3580 the same function. The frame for the function in which execution is
3581 actually occurring is called the @dfn{innermost} frame. This is the most
3582 recently created of all the stack frames that still exist.
3584 @cindex frame pointer
3585 Inside your program, stack frames are identified by their addresses. A
3586 stack frame consists of many bytes, each of which has its own address; each
3587 kind of computer has a convention for choosing one of those bytes whose
3588 address serves as the address of the frame. Usually this address is kept
3589 in a register called the @dfn{frame pointer register} while execution is
3590 going on in that frame.
3592 @cindex frame number
3593 @value{GDBN} assigns numbers to all existing stack frames, starting with
3594 zero for the innermost frame, one for the frame that called it,
3595 and so on upward. These numbers do not really exist in your program;
3596 they are assigned by @value{GDBN} to give you a way of designating stack
3597 frames in @value{GDBN} commands.
3599 @cindex frameless execution
3600 Some compilers allow functions to be compiled so that they operate
3601 without stack frames. (For example, the @code{@value{GCC}} option
3602 @samp{-fomit-frame-pointer} will generate functions without a frame.)
3603 This is occasionally done with heavily used library functions to save
3604 the frame setup time. @value{GDBN} has limited facilities for dealing with
3605 these function invocations. If the innermost function invocation has no
3606 stack frame, @value{GDBN} will nevertheless regard it as though it had a
3607 separate frame, which is numbered zero as usual, allowing correct
3608 tracing of the function call chain. However, @value{GDBN} has no provision
3609 for frameless functions elsewhere in the stack.
3614 A backtrace is a summary of how your program got where it is. It shows one
3615 line per frame, for many frames, starting with the currently executing
3616 frame (frame zero), followed by its caller (frame one), and on up the
3624 Print a backtrace of the entire stack: one line per frame for all
3625 frames in the stack.
3627 You can stop the backtrace at any time by typing the system interrupt
3628 character, normally @kbd{C-c}.
3630 @item backtrace @var{n}
3632 Similar, but print only the innermost @var{n} frames.
3634 @item backtrace -@var{n}
3636 Similar, but print only the outermost @var{n} frames.
3642 The names @code{where} and @code{info stack} (abbreviated @code{info s})
3643 are additional aliases for @code{backtrace}.
3645 Each line in the backtrace shows the frame number and the function name.
3646 The program counter value is also shown---unless you use @code{set
3647 print address off}. The backtrace also shows the source file name and
3648 line number, as well as the arguments to the function. The program
3649 counter value is omitted if it is at the beginning of the code for that
3652 Here is an example of a backtrace. It was made with the command
3653 @samp{bt 3}, so it shows the innermost three frames.
3657 #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
3659 #1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
3660 #2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
3662 (More stack frames follow...)
3667 The display for frame zero does not begin with a program counter
3668 value, indicating that your program has stopped at the beginning of the
3669 code for line @code{993} of @code{builtin.c}.
3672 @section Selecting a frame
3674 Most commands for examining the stack and other data in your program work on
3675 whichever stack frame is selected at the moment. Here are the commands for
3676 selecting a stack frame; all of them finish by printing a brief description
3677 of the stack frame just selected.
3684 Select frame number @var{n}. Recall that frame zero is the innermost
3685 (currently executing) frame, frame one is the frame that called the
3686 innermost one, and so on. The highest-numbered frame is the one for
3689 @item frame @var{addr}
3691 Select the frame at address @var{addr}. This is useful mainly if the
3692 chaining of stack frames has been damaged by a bug, making it
3693 impossible for @value{GDBN} to assign numbers properly to all frames. In
3694 addition, this can be useful when your program has multiple stacks and
3695 switches between them.
3698 On the SPARC architecture, @code{frame} needs two addresses to
3699 select an arbitrary frame: a frame pointer and a stack pointer.
3700 @c note to future updaters: this is conditioned on a flag
3701 @c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used
3702 @c by SPARC, hence the specific attribution. Generalize or list all
3703 @c possibilities if more supported machines start doing this.
3708 Move @var{n} frames up the stack. For positive numbers @var{n}, this
3709 advances toward the outermost frame, to higher frame numbers, to frames
3710 that have existed longer. @var{n} defaults to one.
3715 Move @var{n} frames down the stack. For positive numbers @var{n}, this
3716 advances toward the innermost frame, to lower frame numbers, to frames
3717 that were created more recently. @var{n} defaults to one. You may
3718 abbreviate @code{down} as @code{do}.
3721 All of these commands end by printing two lines of output describing the
3722 frame. The first line shows the frame number, the function name, the
3723 arguments, and the source file and line number of execution in that
3724 frame. The second line shows the text of that source line.
3730 #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
3732 10 read_input_file (argv[i]);
3736 After such a printout, the @code{list} command with no arguments will
3737 print ten lines centered on the point of execution in the frame.
3738 @xref{List, ,Printing source lines}.
3741 @item up-silently @var{n}
3742 @itemx down-silently @var{n}
3743 @kindex down-silently
3745 These two commands are variants of @code{up} and @code{down},
3746 respectively; they differ in that they do their work silently, without
3747 causing display of the new frame. They are intended primarily for use
3748 in @value{GDBN} command scripts, where the output might be unnecessary and
3753 @section Information about a frame
3755 There are several other commands to print information about the selected
3761 When used without any argument, this command does not change which
3762 frame is selected, but prints a brief description of the currently
3763 selected stack frame. It can be abbreviated @code{f}. With an
3764 argument, this command is used to select a stack frame.
3765 @xref{Selection, ,Selecting a frame}.
3771 This command prints a verbose description of the selected stack frame,
3772 including the address of the frame, the addresses of the next frame down
3773 (called by this frame) and the next frame up (caller of this frame), the
3774 language that the source code corresponding to this frame was written in,
3775 the address of the frame's arguments, the program counter saved in it
3776 (the address of execution in the caller frame), and which registers
3777 were saved in the frame. The verbose description is useful when
3778 something has gone wrong that has made the stack format fail to fit
3779 the usual conventions.
3781 @item info frame @var{addr}
3782 @itemx info f @var{addr}
3783 Print a verbose description of the frame at address @var{addr},
3784 without selecting that frame. The selected frame remains unchanged by
3789 Print the arguments of the selected frame, each on a separate line.
3793 Print the local variables of the selected frame, each on a separate
3794 line. These are all variables (declared either static or automatic)
3795 accessible at the point of execution of the selected frame.
3799 @cindex catch exceptions
3800 @cindex exception handlers
3801 Print a list of all the exception handlers that are active in the
3802 current stack frame at the current point of execution. To see other
3803 exception handlers, visit the associated frame (using the @code{up},
3804 @code{down}, or @code{frame} commands); then type @code{info catch}.
3805 @xref{Exception Handling, ,Breakpoints and exceptions}.
3809 @chapter Examining Source Files
3811 @value{GDBN} can print parts of your program's source, since the debugging
3812 information recorded in the program tells @value{GDBN} what source files were
3813 used to build it. When your program stops, @value{GDBN} spontaneously prints
3814 the line where it stopped. Likewise, when you select a stack frame
3815 (@pxref{Selection, ,Selecting a frame}), @value{GDBN} prints the line where
3816 execution in that frame has stopped. You can print other portions of
3817 source files by explicit command.
3820 If you use @value{GDBN} through its GNU Emacs interface, you may prefer to use
3821 Emacs facilities to view source; @pxref{Emacs, ,Using @value{GDBN} under GNU
3826 @c pre-unfolded menu
3828 * List:: Printing source lines
3830 * Search:: Searching source files
3832 * Source Path:: Specifying source directories
3833 * Machine Code:: Source and machine code
3839 * List:: Printing source lines
3840 * Search:: Searching source files
3841 * Source Path:: Specifying source directories
3842 * Machine Code:: Source and machine code
3848 * List:: Printing source lines
3849 * Source Path:: Specifying source directories
3850 * Machine Code:: Source and machine code
3855 @section Printing source lines
3859 To print lines from a source file, use the @code{list} command
3860 (abbreviated @code{l}). There are several ways to specify what part
3861 of the file you want to print.
3863 Here are the forms of the @code{list} command most commonly used:
3866 @item list @var{linenum}
3867 Print lines centered around line number @var{linenum} in the
3868 current source file.
3870 @item list @var{function}
3871 Print lines centered around the beginning of function
3875 Print more lines. If the last lines printed were printed with a
3876 @code{list} command, this prints lines following the last lines
3877 printed; however, if the last line printed was a solitary line printed
3878 as part of displaying a stack frame (@pxref{Stack, ,Examining the
3879 Stack}), this prints lines centered around that line.
3882 Print lines just before the lines last printed.
3885 By default, @value{GDBN} prints ten source lines with any of these forms of
3886 the @code{list} command. You can change this using @code{set listsize}:
3889 @item set listsize @var{count}
3890 @kindex set listsize
3891 Make the @code{list} command display @var{count} source lines (unless
3892 the @code{list} argument explicitly specifies some other number).
3895 @kindex show listsize
3896 Display the number of lines that @code{list} will currently display by
3900 Repeating a @code{list} command with @key{RET} discards the argument,
3901 so it is equivalent to typing just @code{list}. This is more useful
3902 than listing the same lines again. An exception is made for an
3903 argument of @samp{-}; that argument is preserved in repetition so that
3904 each repetition moves up in the source file.
3907 In general, the @code{list} command expects you to supply zero, one or two
3908 @dfn{linespecs}. Linespecs specify source lines; there are several ways
3909 of writing them but the effect is always to specify some source line.
3910 Here is a complete description of the possible arguments for @code{list}:
3913 @item list @var{linespec}
3914 Print lines centered around the line specified by @var{linespec}.
3916 @item list @var{first},@var{last}
3917 Print lines from @var{first} to @var{last}. Both arguments are
3920 @item list ,@var{last}
3921 Print lines ending with @var{last}.
3923 @item list @var{first},
3924 Print lines starting with @var{first}.
3927 Print lines just after the lines last printed.
3930 Print lines just before the lines last printed.
3933 As described in the preceding table.
3936 Here are the ways of specifying a single source line---all the
3941 Specifies line @var{number} of the current source file.
3942 When a @code{list} command has two linespecs, this refers to
3943 the same source file as the first linespec.
3946 Specifies the line @var{offset} lines after the last line printed.
3947 When used as the second linespec in a @code{list} command that has
3948 two, this specifies the line @var{offset} lines down from the
3952 Specifies the line @var{offset} lines before the last line printed.
3954 @item @var{filename}:@var{number}
3955 Specifies line @var{number} in the source file @var{filename}.
3957 @item @var{function}
3958 @c FIXME: "of the open-brace" is C-centric. When we add other langs...
3959 Specifies the line of the open-brace that begins the body of the
3960 function @var{function}.
3962 @item @var{filename}:@var{function}
3963 Specifies the line of the open-brace that begins the body of the
3964 function @var{function} in the file @var{filename}. You only need the
3965 file name with a function name to avoid ambiguity when there are
3966 identically named functions in different source files.
3968 @item *@var{address}
3969 Specifies the line containing the program address @var{address}.
3970 @var{address} may be any expression.
3975 @section Searching source files
3977 @kindex reverse-search
3979 There are two commands for searching through the current source file for a
3983 @item forward-search @var{regexp}
3984 @itemx search @var{regexp}
3986 @kindex forward-search
3987 The command @samp{forward-search @var{regexp}} checks each line,
3988 starting with the one following the last line listed, for a match for
3989 @var{regexp}. It lists the line that is found. You can use
3990 synonym @samp{search @var{regexp}} or abbreviate the command name as
3993 @item reverse-search @var{regexp}
3994 The command @samp{reverse-search @var{regexp}} checks each line, starting
3995 with the one before the last line listed and going backward, for a match
3996 for @var{regexp}. It lists the line that is found. You can abbreviate
3997 this command as @code{rev}.
4002 @section Specifying source directories
4005 @cindex directories for source files
4006 Executable programs sometimes do not record the directories of the source
4007 files from which they were compiled, just the names. Even when they do,
4008 the directories could be moved between the compilation and your debugging
4009 session. @value{GDBN} has a list of directories to search for source files;
4010 this is called the @dfn{source path}. Each time @value{GDBN} wants a source file,
4011 it tries all the directories in the list, in the order they are present
4012 in the list, until it finds a file with the desired name. Note that
4013 the executable search path is @emph{not} used for this purpose. Neither is
4014 the current working directory, unless it happens to be in the source
4017 If @value{GDBN} cannot find a source file in the source path, and the object
4018 program records a directory, @value{GDBN} tries that directory too. If the
4019 source path is empty, and there is no record of the compilation
4020 directory, @value{GDBN} will, as a last resort, look in the current
4023 Whenever you reset or rearrange the source path, @value{GDBN} will clear out
4024 any information it has cached about where source files are found, where
4025 each line is in the file, etc.
4028 When you start @value{GDBN}, its source path is empty.
4029 To add other directories, use the @code{directory} command.
4032 @item directory @var{dirname} @dots{}
4033 Add directory @var{dirname} to the front of the source path. Several
4034 directory names may be given to this command, separated by @samp{:} or
4035 whitespace. You may specify a directory that is already in the source
4036 path; this moves it forward, so it will be searched sooner.
4038 You can use the string @samp{$cdir} to refer to the compilation
4039 directory (if one is recorded), and @samp{$cwd} to refer to the current
4040 working directory. @samp{$cwd} is not the same as @samp{.}---the former
4041 tracks the current working directory as it changes during your @value{GDBN}
4042 session, while the latter is immediately expanded to the current
4043 directory at the time you add an entry to the source path.
4046 Reset the source path to empty again. This requires confirmation.
4048 @c RET-repeat for @code{directory} is explicitly disabled, but since
4049 @c repeating it would be a no-op we do not say that. (thanks to RMS)
4051 @item show directories
4052 @kindex show directories
4053 Print the source path: show which directories it contains.
4056 If your source path is cluttered with directories that are no longer of
4057 interest, @value{GDBN} may sometimes cause confusion by finding the wrong
4058 versions of source. You can correct the situation as follows:
4062 Use @code{directory} with no argument to reset the source path to empty.
4065 Use @code{directory} with suitable arguments to reinstall the
4066 directories you want in the source path. You can add all the
4067 directories in one command.
4071 @section Source and machine code
4073 You can use the command @code{info line} to map source lines to program
4074 addresses (and vice versa), and the command @code{disassemble} to display
4075 a range of addresses as machine instructions.
4078 @item info line @var{linespec}
4080 Print the starting and ending addresses of the compiled code for
4081 source line @var{linespec}. You can specify source lines in any of
4082 the ways understood by the @code{list} command (@pxref{List, ,Printing
4086 For example, we can use @code{info line} to discover the location of
4087 the object code for the first line of function
4088 @code{m4_changequote}:
4091 (@value{GDBP}) info line m4_changecom
4092 Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
4096 We can also inquire (using @code{*@var{addr}} as the form for
4097 @var{linespec}) what source line covers a particular address:
4099 (@value{GDBP}) info line *0x63ff
4100 Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
4103 @cindex @code{$_} and @code{info line}
4104 After @code{info line}, the default address for the @code{x} command
4105 is changed to the starting address of the line, so that @samp{x/i} is
4106 sufficient to begin examining the machine code (@pxref{Memory,
4107 ,Examining memory}). Also, this address is saved as the value of the
4108 convenience variable @code{$_} (@pxref{Convenience Vars, ,Convenience
4114 This specialized command dumps a range of memory as machine
4115 instructions. The default memory range is the function surrounding the
4116 program counter of the selected frame. A single argument to this
4117 command is a program counter value; the function surrounding this value
4118 will be dumped. Two arguments specify a range of addresses (first
4119 inclusive, second exclusive) to dump.
4122 @ifclear HviiiEXCLUSIVE
4123 We can use @code{disassemble} to inspect the object code
4124 range shown in the last @code{info line} example (the example
4125 shows SPARC machine instructions):
4129 (@value{GDBP}) disas 0x63e4 0x6404
4130 Dump of assembler code from 0x63e4 to 0x6404:
4131 0x63e4 <builtin_init+5340>: ble 0x63f8 <builtin_init+5360>
4132 0x63e8 <builtin_init+5344>: sethi %hi(0x4c00), %o0
4133 0x63ec <builtin_init+5348>: ld [%i1+4], %o0
4134 0x63f0 <builtin_init+5352>: b 0x63fc <builtin_init+5364>
4135 0x63f4 <builtin_init+5356>: ld [%o0+4], %o0
4136 0x63f8 <builtin_init+5360>: or %o0, 0x1a4, %o0
4137 0x63fc <builtin_init+5364>: call 0x9288 <path_search>
4138 0x6400 <builtin_init+5368>: nop
4139 End of assembler dump.
4143 @ifset HviiiEXCLUSIVE
4144 For example, here is the beginning of the output for the
4145 disassembly of a function @code{fact}:
4149 (@value{GDBP}) disas fact
4150 Dump of assembler code for function fact:
4152 0x802c <fact>: 6d f2 mov.w r2,@@-r7
4153 0x802e <fact+2>: 6d f3 mov.w r3,@@-r7
4154 0x8030 <fact+4>: 6d f6 mov.w r6,@@-r7
4155 0x8032 <fact+6>: 0d 76 mov.w r7,r6
4156 0x8034 <fact+8>: 6f 70 00 08 mov.w @@(0x8,r7),r0
4157 0x8038 <fact+12> 19 11 sub.w r1,r1
4165 @chapter Examining Data
4167 @cindex printing data
4168 @cindex examining data
4171 @c "inspect" is not quite a synonym if you are using Epoch, which we do not
4172 @c document because it is nonstandard... Under Epoch it displays in a
4173 @c different window or something like that.
4174 The usual way to examine data in your program is with the @code{print}
4175 command (abbreviated @code{p}), or its synonym @code{inspect}.
4177 It evaluates and prints the value of an expression of the language your
4178 program is written in (@pxref{Languages, ,Using @value{GDBN} with Different
4183 @item print @var{exp}
4184 @itemx print /@var{f} @var{exp}
4185 @var{exp} is an expression (in the source language). By default the
4186 value of @var{exp} is printed in a format appropriate to its data type;
4187 you can choose a different format by specifying @samp{/@var{f}}, where
4188 @var{f} is a letter specifying the format; @pxref{Output Formats,,Output
4192 @itemx print /@var{f}
4193 If you omit @var{exp}, @value{GDBN} displays the last value again (from the
4194 @dfn{value history}; @pxref{Value History, ,Value history}). This allows you to
4195 conveniently inspect the same value in an alternative format.
4198 A more low-level way of examining data is with the @code{x} command.
4199 It examines data in memory at a specified address and prints it in a
4200 specified format. @xref{Memory, ,Examining memory}.
4202 If you are interested in information about types, or about how the fields
4203 of a struct or class are declared, use the @code{ptype @var{exp}}
4204 command rather than @code{print}. @xref{Symbols, ,Examining the Symbol Table}.
4209 * Expressions:: Expressions
4210 * Variables:: Program variables
4211 * Arrays:: Artificial arrays
4212 * Output formats:: Output formats
4213 * Memory:: Examining memory
4214 * Auto Display:: Automatic display
4215 * Print Settings:: Print settings
4216 * Value History:: Value history
4217 * Convenience Vars:: Convenience variables
4218 * Registers:: Registers
4219 @ifclear HviiiEXCLUSIVE
4220 * Floating Point Hardware:: Floating point hardware
4225 @ifclear HviiiEXCLUSIVE
4227 * Expressions:: Expressions
4228 * Variables:: Program variables
4229 * Arrays:: Artificial arrays
4230 * Output Formats:: Output formats
4231 * Memory:: Examining memory
4232 * Auto Display:: Automatic display
4233 * Print Settings:: Print settings
4234 * Value History:: Value history
4235 * Convenience Vars:: Convenience variables
4236 * Registers:: Registers
4237 * Floating Point Hardware:: Floating point hardware
4241 @ifset HviiiEXCLUSIVE
4243 * Expressions:: Expressions
4244 * Variables:: Program variables
4245 * Arrays:: Artificial arrays
4246 * Output Formats:: Output formats
4247 * Memory:: Examining memory
4248 * Auto Display:: Automatic display
4249 * Print Settings:: Print settings
4250 * Value History:: Value history
4251 * Convenience Vars:: Convenience variables
4252 * Registers:: Registers
4257 @section Expressions
4260 @code{print} and many other @value{GDBN} commands accept an expression and
4261 compute its value. Any kind of constant, variable or operator defined
4262 by the programming language you are using is valid in an expression in
4263 @value{GDBN}. This includes conditional expressions, function calls, casts
4264 and string constants. It unfortunately does not include symbols defined
4265 by preprocessor @code{#define} commands.
4268 Because C is so widespread, most of the expressions shown in examples in
4269 this manual are in C. @xref{Languages, , Using @value{GDBN} with Different
4270 Languages}, for information on how to use expressions in other
4273 In this section, we discuss operators that you can use in @value{GDBN}
4274 expressions regardless of your programming language.
4276 Casts are supported in all languages, not just in C, because it is so
4277 useful to cast a number into a pointer so as to examine a structure
4278 at that address in memory.
4279 @c FIXME: casts supported---Mod2 true?
4282 @value{GDBN} supports these operators in addition to those of programming
4287 @samp{@@} is a binary operator for treating parts of memory as arrays.
4288 @xref{Arrays, ,Artificial arrays}, for more information.
4291 @samp{::} allows you to specify a variable in terms of the file or
4292 function where it is defined. @xref{Variables, ,Program variables}.
4294 @item @{@var{type}@} @var{addr}
4295 @cindex @{@var{type}@}
4296 @cindex type casting memory
4297 @cindex memory, viewing as typed object
4298 @cindex casts, to view memory
4299 Refers to an object of type @var{type} stored at address @var{addr} in
4300 memory. @var{addr} may be any expression whose value is an integer or
4301 pointer (but parentheses are required around binary operators, just as in
4302 a cast). This construct is allowed regardless of what kind of data is
4303 normally supposed to reside at @var{addr}.
4307 @section Program variables
4309 The most common kind of expression to use is the name of a variable
4312 Variables in expressions are understood in the selected stack frame
4313 (@pxref{Selection, ,Selecting a frame}); they must either be global
4314 (or static) or be visible according to the scope rules of the
4315 programming language from the point of execution in that frame. This
4316 means that in the function
4331 you can examine and use the variable @code{a} whenever your program is
4332 executing within the function @code{foo}, but you can only use or
4333 examine the variable @code{b} while your program is executing inside
4334 the block where @code{b} is declared.
4336 @cindex variable name conflict
4337 There is an exception: you can refer to a variable or function whose
4338 scope is a single source file even if the current execution point is not
4339 in this file. But it is possible to have more than one such variable or
4340 function with the same name (in different source files). If that
4341 happens, referring to that name has unpredictable effects. If you wish,
4342 you can specify a static variable in a particular function or file,
4343 using the colon-colon notation:
4347 @c info cannot cope with a :: index entry, but why deprive hard copy readers?
4351 @var{file}::@var{variable}
4352 @var{function}::@var{variable}
4356 Here @var{file} or @var{function} is the name of the context for the
4357 static @var{variable}. In the case of file names, you can use quotes to
4358 make sure @value{GDBN} parses the file name as a single word---for example,
4359 to print a global value of @code{x} defined in @file{f2.c}:
4362 (@value{GDBP}) p 'f2.c'::x
4366 @cindex C++ scope resolution
4367 This use of @samp{::} is very rarely in conflict with the very similar
4368 use of the same notation in C++. @value{GDBN} also supports use of the C++
4369 scope resolution operator in @value{GDBN} expressions.
4370 @c FIXME: Um, so what happens in one of those rare cases where it's in
4374 @cindex wrong values
4375 @cindex variable values, wrong
4377 @emph{Warning:} Occasionally, a local variable may appear to have the
4378 wrong value at certain points in a function---just after entry to the
4379 function, and just before exit. You may see this problem when you are
4380 stepping by machine instructions. This is because on most machines, it
4381 takes more than one instruction to set up a stack frame (including local
4382 variable definitions); if you are stepping by machine instructions,
4383 variables may appear to have the wrong values until the stack frame is
4384 completely built. On function exit, it usually also takes more than one
4385 machine instruction to destroy a stack frame; after you begin stepping
4386 through that group of instructions, local variable definitions may be
4391 @section Artificial arrays
4393 @cindex artificial array
4395 It is often useful to print out several successive objects of the
4396 same type in memory; a section of an array, or an array of
4397 dynamically determined size for which only a pointer exists in the
4400 You can do this by referring to a contiguous span of memory as an
4401 @dfn{artificial array}, using the binary operator @samp{@@}. The left
4402 operand of @samp{@@} should be the first element of the desired array,
4403 as an individual object. The right operand should be the desired length
4404 of the array. The result is an array value whose elements are all of
4405 the type of the left argument. The first element is actually the left
4406 argument; the second element comes from bytes of memory immediately
4407 following those that hold the first element, and so on. Here is an
4408 example. If a program says
4411 int *array = (int *) malloc (len * sizeof (int));
4415 you can print the contents of @code{array} with
4421 The left operand of @samp{@@} must reside in memory. Array values made
4422 with @samp{@@} in this way behave just like other arrays in terms of
4423 subscripting, and are coerced to pointers when used in expressions.
4424 Artificial arrays most often appear in expressions via the value history
4425 (@pxref{Value History, ,Value history}), after printing one out.)
4427 Sometimes the artificial array mechanism is not quite enough; in
4428 moderately complex data structures, the elements of interest may not
4429 actually be adjacent---for example, if you are interested in the values
4430 of pointers in an array. One useful work-around in this situation is
4431 to use a convenience variable (@pxref{Convenience Vars, ,Convenience
4432 variables}) as a counter in an expression that prints the first
4433 interesting value, and then repeat that expression via @key{RET}. For
4434 instance, suppose you have an array @code{dtab} of pointers to
4435 structures, and you are interested in the values of a field @code{fv}
4436 in each structure. Here is an example of what you might type:
4446 @node Output Formats
4447 @section Output formats
4449 @cindex formatted output
4450 @cindex output formats
4451 By default, @value{GDBN} prints a value according to its data type. Sometimes
4452 this is not what you want. For example, you might want to print a number
4453 in hex, or a pointer in decimal. Or you might want to view data in memory
4454 at a certain address as a character string or as an instruction. To do
4455 these things, specify an @dfn{output format} when you print a value.
4457 The simplest use of output formats is to say how to print a value
4458 already computed. This is done by starting the arguments of the
4459 @code{print} command with a slash and a format letter. The format
4460 letters supported are:
4464 Regard the bits of the value as an integer, and print the integer in
4468 Print as integer in signed decimal.
4471 Print as integer in unsigned decimal.
4474 Print as integer in octal.
4477 Print as integer in binary. The letter @samp{t} stands for ``two''.
4478 @footnote{@samp{b} cannot be used because these format letters are also
4479 used with the @code{x} command, where @samp{b} stands for ``byte'';
4480 @pxref{Memory,,Examining memory}.}
4483 Print as an address, both absolute in hex and as an offset from the
4484 nearest preceding symbol. This format can be used to discover where (in
4485 what function) an unknown address is located:
4488 (@value{GDBP}) p/a 0x54320
4489 $3 = 0x54320 <_initialize_vx+396>
4493 Regard as an integer and print it as a character constant.
4496 Regard the bits of the value as a floating point number and print
4497 using typical floating point syntax.
4500 For example, to print the program counter in hex (@pxref{Registers}), type
4507 Note that no space is required before the slash; this is because command
4508 names in @value{GDBN} cannot contain a slash.
4510 To reprint the last value in the value history with a different format,
4511 you can use the @code{print} command with just a format and no
4512 expression. For example, @samp{p/x} reprints the last value in hex.
4515 @section Examining memory
4517 You can use the command @code{x} (for ``examine'') to examine memory in
4518 any of several formats, independently of your program's data types.
4520 @cindex examining memory
4523 @item x/@var{nfu} @var{addr}
4526 Use the @code{x} command to examine memory.
4529 @var{n}, @var{f}, and @var{u} are all optional parameters that specify how
4530 much memory to display and how to format it; @var{addr} is an
4531 expression giving the address where you want to start displaying memory.
4532 If you use defaults for @var{nfu}, you need not type the slash @samp{/}.
4533 Several commands set convenient defaults for @var{addr}.
4536 @item @var{n}, the repeat count
4537 The repeat count is a decimal integer; the default is 1. It specifies
4538 how much memory (counting by units @var{u}) to display.
4539 @c This really is **decimal**; unaffected by 'set radix' as of GDB
4542 @item @var{f}, the display format
4543 The display format is one of the formats used by @code{print},
4544 or @samp{s} (null-terminated string) or @samp{i} (machine instruction).
4545 The default is @samp{x} (hexadecimal) initially, or the format from the
4546 last time you used either @code{x} or @code{print}.
4548 @item @var{u}, the unit size
4549 The unit size is any of
4555 Halfwords (two bytes).
4557 Words (four bytes). This is the initial default.
4559 Giant words (eight bytes).
4562 Each time you specify a unit size with @code{x}, that size becomes the
4563 default unit the next time you use @code{x}. (For the @samp{s} and
4564 @samp{i} formats, the unit size is ignored and is normally not written.)
4566 @item @var{addr}, starting display address
4567 @var{addr} is the address where you want @value{GDBN} to begin displaying
4568 memory. The expression need not have a pointer value (though it may);
4569 it is always interpreted as an integer address of a byte of memory.
4570 @xref{Expressions, ,Expressions}, for more information on expressions. The default for
4571 @var{addr} is usually just after the last address examined---but several
4572 other commands also set the default address: @code{info breakpoints} (to
4573 the address of the last breakpoint listed), @code{info line} (to the
4574 starting address of a line), and @code{print} (if you use it to display
4575 a value from memory).
4578 For example, @samp{x/3uh 0x54320} is a request to display three halfwords
4579 (@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}),
4580 starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four
4581 words (@samp{w}) of memory above the stack pointer (here, @samp{$sp};
4582 @pxref{Registers}) in hexadecimal (@samp{x}).
4584 Since the letters indicating unit sizes are all distinct from the
4585 letters specifying output formats, you do not have to remember whether
4586 unit size or format comes first; either order will work. The output
4587 specifications @samp{4xw} and @samp{4wx} mean exactly the same thing.
4588 (However, the count @var{n} must come first; @samp{wx4} will not work.)
4590 Even though the unit size @var{u} is ignored for the formats @samp{s}
4591 and @samp{i}, you might still want to use a count @var{n}; for example,
4592 @samp{3i} specifies that you want to see three machine instructions,
4593 including any operands. The command @code{disassemble} gives an
4594 alternative way of inspecting machine instructions; @pxref{Machine
4595 Code,,Source and machine code}.
4597 All the defaults for the arguments to @code{x} are designed to make it
4598 easy to continue scanning memory with minimal specifications each time
4599 you use @code{x}. For example, after you have inspected three machine
4600 instructions with @samp{x/3i @var{addr}}, you can inspect the next seven
4601 with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command,
4602 the repeat count @var{n} is used again; the other arguments default as
4603 for successive uses of @code{x}.
4605 @cindex @code{$_}, @code{$__}, and value history
4606 The addresses and contents printed by the @code{x} command are not saved
4607 in the value history because there is often too much of them and they
4608 would get in the way. Instead, @value{GDBN} makes these values available for
4609 subsequent use in expressions as values of the convenience variables
4610 @code{$_} and @code{$__}. After an @code{x} command, the last address
4611 examined is available for use in expressions in the convenience variable
4612 @code{$_}. The contents of that address, as examined, are available in
4613 the convenience variable @code{$__}.
4615 If the @code{x} command has a repeat count, the address and contents saved
4616 are from the last memory unit printed; this is not the same as the last
4617 address printed if several units were printed on the last line of output.
4620 @section Automatic display
4621 @cindex automatic display
4622 @cindex display of expressions
4624 If you find that you want to print the value of an expression frequently
4625 (to see how it changes), you might want to add it to the @dfn{automatic
4626 display list} so that @value{GDBN} will print its value each time your program stops.
4627 Each expression added to the list is given a number to identify it;
4628 to remove an expression from the list, you specify that number.
4629 The automatic display looks like this:
4633 3: bar[5] = (struct hack *) 0x3804
4637 This display shows item numbers, expressions and their current values. As with
4638 displays you request manually using @code{x} or @code{print}, you can
4639 specify the output format you prefer; in fact, @code{display} decides
4640 whether to use @code{print} or @code{x} depending on how elaborate your
4641 format specification is---it uses @code{x} if you specify a unit size,
4642 or one of the two formats (@samp{i} and @samp{s}) that are only
4643 supported by @code{x}; otherwise it uses @code{print}.
4646 @item display @var{exp}
4648 Add the expression @var{exp} to the list of expressions to display
4649 each time your program stops. @xref{Expressions, ,Expressions}.
4651 @code{display} will not repeat if you press @key{RET} again after using it.
4653 @item display/@var{fmt} @var{exp}
4654 For @var{fmt} specifying only a display format and not a size or
4655 count, add the expression @var{exp} to the auto-display list but
4656 arranges to display it each time in the specified format @var{fmt}.
4657 @xref{Output Formats,,Output formats}.
4659 @item display/@var{fmt} @var{addr}
4660 For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
4661 number of units, add the expression @var{addr} as a memory address to
4662 be examined each time your program stops. Examining means in effect
4663 doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory, ,Examining memory}.
4666 For example, @samp{display/i $pc} can be helpful, to see the machine
4667 instruction about to be executed each time execution stops (@samp{$pc}
4668 is a common name for the program counter; @pxref{Registers}).
4671 @item undisplay @var{dnums}@dots{}
4672 @itemx delete display @var{dnums}@dots{}
4673 @kindex delete display
4675 Remove item numbers @var{dnums} from the list of expressions to display.
4677 @code{undisplay} will not repeat if you press @key{RET} after using it.
4678 (Otherwise you would just get the error @samp{No display number @dots{}}.)
4680 @item disable display @var{dnums}@dots{}
4681 @kindex disable display
4682 Disable the display of item numbers @var{dnums}. A disabled display
4683 item is not printed automatically, but is not forgotten. It may be
4684 enabled again later.
4686 @item enable display @var{dnums}@dots{}
4687 @kindex enable display
4688 Enable display of item numbers @var{dnums}. It becomes effective once
4689 again in auto display of its expression, until you specify otherwise.
4692 Display the current values of the expressions on the list, just as is
4693 done when your program stops.
4696 @kindex info display
4697 Print the list of expressions previously set up to display
4698 automatically, each one with its item number, but without showing the
4699 values. This includes disabled expressions, which are marked as such.
4700 It also includes expressions which would not be displayed right now
4701 because they refer to automatic variables not currently available.
4704 If a display expression refers to local variables, then it does not make
4705 sense outside the lexical context for which it was set up. Such an
4706 expression is disabled when execution enters a context where one of its
4707 variables is not defined. For example, if you give the command
4708 @code{display last_char} while inside a function with an argument
4709 @code{last_char}, then this argument will be displayed while your program
4710 continues to stop inside that function. When it stops elsewhere---where
4711 there is no variable @code{last_char}---display is disabled. The next time
4712 your program stops where @code{last_char} is meaningful, you can enable the
4713 display expression once again.
4715 @node Print Settings
4716 @section Print settings
4718 @cindex format options
4719 @cindex print settings
4720 @value{GDBN} provides the following ways to control how arrays, structures,
4721 and symbols are printed.
4724 These settings are useful for debugging programs in any language:
4727 @item set print address
4728 @item set print address on
4729 @kindex set print address
4730 @value{GDBN} will print memory addresses showing the location of stack
4731 traces, structure values, pointer values, breakpoints, and so forth,
4732 even when it also displays the contents of those addresses. The default
4733 is on. For example, this is what a stack frame display looks like, with
4734 @code{set print address on}:
4739 #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
4741 530 if (lquote != def_lquote)
4745 @item set print address off
4746 Do not print addresses when displaying their contents. For example,
4747 this is the same stack frame displayed with @code{set print address off}:
4751 (@value{GDBP}) set print addr off
4753 #0 set_quotes (lq="<<", rq=">>") at input.c:530
4754 530 if (lquote != def_lquote)
4758 You can use @samp{set print address off} to eliminate all machine
4759 dependent displays from the @value{GDBN} interface. For example, with
4760 @code{print address off}, you should get the same text for backtraces on
4761 all machines---whether or not they involve pointer arguments.
4763 @item show print address
4764 @kindex show print address
4765 Show whether or not addresses are to be printed.
4767 @item set print array
4768 @itemx set print array on
4769 @kindex set print array
4770 @value{GDBN} will pretty-print arrays. This format is more convenient to read,
4771 but uses more space. The default is off.
4773 @item set print array off
4774 Return to compressed format for arrays.
4776 @item show print array
4777 @kindex show print array
4778 Show whether compressed or pretty format is selected for displaying
4781 @item set print elements @var{number-of-elements}
4782 @kindex set print elements
4783 If @value{GDBN} is printing a large array, it will stop printing after it has
4784 printed the number of elements set by the @code{set print elements} command.
4785 This limit also applies to the display of strings.
4787 @item show print elements
4788 @kindex show print elements
4789 Display the number of elements of a large array that @value{GDBN} will print
4790 before losing patience.
4792 @item set print pretty on
4793 @kindex set print pretty
4794 Cause @value{GDBN} to print structures in an indented format with one member per
4810 @item set print pretty off
4811 Cause @value{GDBN} to print structures in a compact format, like this:
4815 $1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, \
4816 meat = 0x54 "Pork"@}
4821 This is the default format.
4823 @item show print pretty
4824 @kindex show print pretty
4825 Show which format @value{GDBN} will use to print structures.
4827 @item set print sevenbit-strings on
4828 @kindex set print sevenbit-strings
4829 Print using only seven-bit characters; if this option is set,
4830 @value{GDBN} will display any eight-bit characters (in strings or character
4831 values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is
4832 displayed as @code{\341}.
4834 @item set print sevenbit-strings off
4835 Print using either seven-bit or eight-bit characters, as required. This
4838 @item show print sevenbit-strings
4839 @kindex show print sevenbit-strings
4840 Show whether or not @value{GDBN} will print only seven-bit characters.
4842 @item set print union on
4843 @kindex set print union
4844 Tell @value{GDBN} to print unions which are contained in structures. This is the
4847 @item set print union off
4848 Tell @value{GDBN} not to print unions which are contained in structures.
4850 @item show print union
4851 @kindex show print union
4852 Ask @value{GDBN} whether or not it will print unions which are contained in
4855 For example, given the declarations
4858 typedef enum @{Tree, Bug@} Species;
4859 typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
4860 typedef enum @{Caterpillar, Cocoon, Butterfly@}
4871 struct thing foo = @{Tree, @{Acorn@}@};
4875 with @code{set print union on} in effect @samp{p foo} would print
4878 $1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
4882 and with @code{set print union off} in effect it would print
4885 $1 = @{it = Tree, form = @{...@}@}
4888 @item set print max-symbolic-offset @var{maxoff}
4889 @kindex set print max-symbolic-offset
4890 Tell @value{GDBN} to only display the symbolic form of an address if the
4891 offset between the closest earlier symbol and the address is less than
4892 @var{maxoff}. The default is 0, which means to always print the
4893 symbolic form of an address, if any symbol precedes it.
4895 @item show print max-symbolic-offset
4896 @kindex show print max-symbolic-offset
4897 Ask how large the maximum offset is that @value{GDBN} will print in a
4903 These settings are of interest when debugging C++ programs:
4906 @item set print demangle
4907 @itemx set print demangle on
4908 @kindex set print demangle
4909 Print C++ names in their source form rather than in the encoded
4910 (``mangled'') form passed to the assembler and linker for type-safe
4911 linkage. The default is @samp{on}.
4913 @item show print demangle
4914 @kindex show print demangle
4915 Show whether C++ names will be printed in mangled or demangled form.
4917 @item set print asm-demangle
4918 @itemx set print asm-demangle on
4919 @kindex set print asm-demangle
4920 Print C++ names in their source form rather than their mangled form, even
4921 in assembler code printouts such as instruction disassemblies.
4924 @item show print asm-demangle
4925 @kindex show print asm-demangle
4926 Show whether C++ names in assembly listings will be printed in mangled
4929 @item set demangle-style @var{style}
4930 @kindex set demangle-style
4931 @cindex C++ symbol decoding style
4932 @cindex symbol decoding style, C++
4933 Choose among several encoding schemes used by different compilers to
4934 represent C++ names. The choices for @var{style} are currently:
4938 Allow @value{GDBN} to choose a decoding style by inspecting your program.
4941 Decode based on the GNU C++ compiler (@code{g++}) encoding algorithm.
4944 Decode based on the Lucid C++ compiler (@code{lcc}) encoding algorithm.
4947 Decode using the algorithm in the @cite{C++ Annotated Reference Manual}.
4948 @strong{Warning:} despite the name, this setting alone is not sufficient
4949 to allow debugging @code{cfront}-generated executables. @value{GDBN}
4950 would require further enhancement to permit that.
4953 @item show demangle-style
4954 @kindex show demangle-style
4955 Display the encoding style currently in use for decoding C++ symbols.
4957 @item set print object
4958 @itemx set print object on
4959 @kindex set print object
4960 When displaying a pointer to an object, identify the @emph{actual}
4961 (derived) type of the object rather than the @emph{declared} type, using
4962 the virtual function table.
4964 @item set print object off
4965 Display only the declared type of objects, without reference to the
4966 virtual function table. This is the default setting.
4968 @item show print object
4969 @kindex show print object
4970 Show whether actual, or declared, object types will be displayed.
4972 @item set print vtbl
4973 @itemx set print vtbl on
4974 @kindex set print vtbl
4975 Pretty print C++ virtual function tables. The default is off.
4977 @item set print vtbl off
4978 Do not pretty print C++ virtual function tables.
4980 @item show print vtbl
4981 @kindex show print vtbl
4982 Show whether C++ virtual function tables are pretty printed, or not.
4986 @section Value history
4988 @cindex value history
4989 Values printed by the @code{print} command are saved in the @value{GDBN} @dfn{value
4990 history} so that you can refer to them in other expressions. Values are
4991 kept until the symbol table is re-read or discarded (for example with
4992 the @code{file} or @code{symbol-file} commands). When the symbol table
4993 changes, the value history is discarded, since the values may contain
4994 pointers back to the types defined in the symbol table.
4998 @cindex history number
4999 The values printed are given @dfn{history numbers} for you to refer to them
5000 by. These are successive integers starting with one. @code{print} shows you
5001 the history number assigned to a value by printing @samp{$@var{num} = }
5002 before the value; here @var{num} is the history number.
5004 To refer to any previous value, use @samp{$} followed by the value's
5005 history number. The way @code{print} labels its output is designed to
5006 remind you of this. Just @code{$} refers to the most recent value in
5007 the history, and @code{$$} refers to the value before that.
5008 @code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
5009 is the value just prior to @code{$$}, @code{$$1} is equivalent to
5010 @code{$$}, and @code{$$0} is equivalent to @code{$}.
5012 For example, suppose you have just printed a pointer to a structure and
5013 want to see the contents of the structure. It suffices to type
5019 If you have a chain of structures where the component @code{next} points
5020 to the next one, you can print the contents of the next one with this:
5027 You can print successive links in the chain by repeating this
5028 command---which you can do by just typing @key{RET}.
5030 Note that the history records values, not expressions. If the value of
5031 @code{x} is 4 and you type these commands:
5039 then the value recorded in the value history by the @code{print} command
5040 remains 4 even though the value of @code{x} has changed.
5045 Print the last ten values in the value history, with their item numbers.
5046 This is like @samp{p@ $$9} repeated ten times, except that @code{show
5047 values} does not change the history.
5049 @item show values @var{n}
5050 Print ten history values centered on history item number @var{n}.
5053 Print ten history values just after the values last printed. If no more
5054 values are available, produces no display.
5057 Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the
5058 same effect as @samp{show values +}.
5060 @node Convenience Vars
5061 @section Convenience variables
5063 @cindex convenience variables
5064 @value{GDBN} provides @dfn{convenience variables} that you can use within
5065 @value{GDBN} to hold on to a value and refer to it later. These variables
5066 exist entirely within @value{GDBN}; they are not part of your program, and
5067 setting a convenience variable has no direct effect on further execution
5068 of your program. That is why you can use them freely.
5070 Convenience variables are prefixed with @samp{$}. Any name preceded by
5071 @samp{$} can be used for a convenience variable, unless it is one of
5072 the predefined machine-specific register names (@pxref{Registers}).
5073 (Value history references, in contrast, are @emph{numbers} preceded
5074 by @samp{$}. @xref{Value History, ,Value history}.)
5076 You can save a value in a convenience variable with an assignment
5077 expression, just as you would set a variable in your program.
5081 set $foo = *object_ptr
5085 would save in @code{$foo} the value contained in the object pointed to by
5088 Using a convenience variable for the first time creates it; but its value
5089 is @code{void} until you assign a new value. You can alter the value with
5090 another assignment at any time.
5092 Convenience variables have no fixed types. You can assign a convenience
5093 variable any type of value, including structures and arrays, even if
5094 that variable already has a value of a different type. The convenience
5095 variable, when used as an expression, has the type of its current value.
5098 @item show convenience
5099 @kindex show convenience
5100 Print a list of convenience variables used so far, and their values.
5101 Abbreviated @code{show con}.
5104 One of the ways to use a convenience variable is as a counter to be
5105 incremented or a pointer to be advanced. For example, to print
5106 a field from successive elements of an array of structures:
5110 print bar[$i++]->contents
5111 @i{@dots{} repeat that command by typing @key{RET}.}
5114 Some convenience variables are created automatically by @value{GDBN} and given
5115 values likely to be useful.
5120 The variable @code{$_} is automatically set by the @code{x} command to
5121 the last address examined (@pxref{Memory, ,Examining memory}). Other
5122 commands which provide a default address for @code{x} to examine also
5123 set @code{$_} to that address; these commands include @code{info line}
5124 and @code{info breakpoint}. The type of @code{$_} is @code{void *}
5125 except when set by the @code{x} command, in which case it is a pointer
5126 to the type of @code{$__}.
5130 The variable @code{$__} is automatically set by the @code{x} command
5131 to the value found in the last address examined. Its type is chosen
5132 to match the format in which the data was printed.
5139 You can refer to machine register contents, in expressions, as variables
5140 with names starting with @samp{$}. The names of registers are different
5141 for each machine; use @code{info registers} to see the names used on
5145 @item info registers
5146 @kindex info registers
5147 Print the names and values of all registers except floating-point
5148 registers (in the selected stack frame).
5150 @item info all-registers
5151 @kindex info all-registers
5152 @cindex floating point registers
5153 Print the names and values of all registers, including floating-point
5156 @item info registers @var{regname} @dots{}
5157 Print the relativized value of each specified register @var{regname}.
5158 @var{regname} may be any register name valid on the machine you are using, with
5159 or without the initial @samp{$}.
5162 @value{GDBN} has four ``standard'' register names that are available (in
5163 expressions) on most machines---whenever they do not conflict with an
5164 architecture's canonical mnemonics for registers. The register names
5165 @code{$pc} and @code{$sp} are used for the program counter register and
5166 the stack pointer. @code{$fp} is used for a register that contains a
5167 pointer to the current stack frame, and @code{$ps} is used for a
5168 register that contains the processor status. For example,
5169 you could print the program counter in hex with
5176 or print the instruction to be executed next with
5183 or add four to the stack pointer@footnote{This is a way of removing
5184 one word from the stack, on machines where stacks grow downward in
5185 memory (most machines, nowadays). This assumes that the innermost
5186 stack frame is selected; setting @code{$sp} is not allowed when other
5187 stack frames are selected. To pop entire frames off the stack,
5188 regardless of machine architecture, use @code{return};
5189 @pxref{Returning, ,Returning from a function}.} with
5195 Whenever possible, these four standard register names are available on
5196 your machine even though the machine has different canonical mnemonics,
5197 so long as there is no conflict. The @code{info registers} command
5198 shows the canonical names. For example, on the SPARC, @code{info
5199 registers} displays the processor status register as @code{$psr} but you
5200 can also refer to it as @code{$ps}.
5202 @value{GDBN} always considers the contents of an ordinary register as an
5203 integer when the register is examined in this way. Some machines have
5204 special registers which can hold nothing but floating point; these
5205 registers are considered to have floating point values. There is no way
5206 to refer to the contents of an ordinary register as floating point value
5207 (although you can @emph{print} it as a floating point value with
5208 @samp{print/f $@var{regname}}).
5210 Some registers have distinct ``raw'' and ``virtual'' data formats. This
5211 means that the data format in which the register contents are saved by
5212 the operating system is not the same one that your program normally
5213 sees. For example, the registers of the 68881 floating point
5214 coprocessor are always saved in ``extended'' (raw) format, but all C
5215 programs expect to work with ``double'' (virtual) format. In such
5216 cases, @value{GDBN} normally works with the virtual format only (the format that
5217 makes sense for your program), but the @code{info registers} command
5218 prints the data in both formats.
5220 Normally, register values are relative to the selected stack frame
5221 (@pxref{Selection, ,Selecting a frame}). This means that you get the
5222 value that the register would contain if all stack frames farther in
5223 were exited and their saved registers restored. In order to see the
5224 true contents of hardware registers, you must select the innermost
5225 frame (with @samp{frame 0}).
5227 However, @value{GDBN} must deduce where registers are saved, from the machine
5228 code generated by your compiler. If some registers are not saved, or if
5229 @value{GDBN} is unable to locate the saved registers, the selected stack
5230 frame will make no difference.
5234 @item set rstack_high_address @var{address}
5235 @kindex set rstack_high_address
5236 @cindex AMD 29K register stack
5237 @cindex register stack, AMD29K
5238 On AMD 29000 family processors, registers are saved in a separate
5239 ``register stack''. There is no way for @value{GDBN} to determine the extent
5240 of this stack. Normally, @value{GDBN} just assumes that the stack is ``large
5241 enough''. This may result in @value{GDBN} referencing memory locations that
5242 do not exist. If necessary, you can get around this problem by
5243 specifying the ending address of the register stack with the @code{set
5244 rstack_high_address} command. The argument should be an address, which
5245 you will probably want to precede with @samp{0x} to specify in
5248 @item show rstack_high_address
5249 @kindex show rstack_high_address
5250 Display the current limit of the register stack, on AMD 29000 family
5255 @ifclear HviiiEXCLUSIVE
5256 @node Floating Point Hardware
5257 @section Floating point hardware
5258 @cindex floating point
5260 Depending on the host machine architecture, @value{GDBN} may be able to give
5261 you more information about the status of the floating point hardware.
5266 If available, provides hardware-dependent information about the floating
5267 point unit. The exact contents and layout vary depending on the
5268 floating point chip.
5270 @c FIXME: this is a cop-out. Try to get examples, explanations. Only
5271 @c FIXME...supported currently on arm's and 386's. Mark properly with
5272 @c FIXME... m4 macros to isolate general statements from hardware-dep,
5273 @c FIXME... at that point.
5278 @chapter Using @value{GDBN} with Different Languages
5281 Although programming languages generally have common aspects, they are
5282 rarely expressed in the same manner. For instance, in ANSI C,
5283 dereferencing a pointer @code{p} is accomplished by @code{*p}, but in
5284 Modula-2, it is accomplished by @code{p^}. Values can also be
5285 represented (and displayed) differently. Hex numbers in C are written
5286 like @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}.
5288 @cindex working language
5289 Language-specific information is built into @value{GDBN} for some languages,
5290 allowing you to express operations like the above in your program's
5291 native language, and allowing @value{GDBN} to output values in a manner
5292 consistent with the syntax of your program's native language. The
5293 language you use to build expressions, called the @dfn{working
5294 language}, can be selected manually, or @value{GDBN} can set it
5298 * Setting:: Switching between source languages
5299 * Show:: Displaying the language
5300 * Checks:: Type and range checks
5301 * Support:: Supported languages
5305 @section Switching between source languages
5307 There are two ways to control the working language---either have @value{GDBN}
5308 set it automatically, or select it manually yourself. You can use the
5309 @code{set language} command for either purpose. On startup, @value{GDBN}
5310 defaults to setting the language automatically.
5313 * Manually:: Setting the working language manually
5314 * Automatically:: Having @value{GDBN} infer the source language
5318 @subsection Setting the working language
5320 If you allow @value{GDBN} to set the language automatically,
5321 expressions are interpreted the same way in your debugging session and
5324 @kindex set language
5325 If you wish, you may set the language manually. To do this, issue the
5326 command @samp{set language @var{lang}}, where @var{lang} is the name of
5327 a language, such as @code{c} or @code{modula-2}. For a list of the supported
5328 languages, type @samp{set language}.
5329 @c FIXME: rms: eventually this command should be "help set language".
5331 Setting the language manually prevents @value{GDBN} from updating the working
5332 language automatically. This can lead to confusion if you try
5333 to debug a program when the working language is not the same as the
5334 source language, when an expression is acceptable to both
5335 languages---but means different things. For instance, if the current
5336 source file were written in C, and @value{GDBN} was parsing Modula-2, a
5344 might not have the effect you intended. In C, this means to add
5345 @code{b} and @code{c} and place the result in @code{a}. The result
5346 printed would be the value of @code{a}. In Modula-2, this means to compare
5347 @code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value.
5350 @subsection Having @value{GDBN} infer the source language
5352 To have @value{GDBN} set the working language automatically, use @samp{set
5353 language local} or @samp{set language auto}. @value{GDBN} then infers the
5354 language that a program was written in by looking at the name of its
5355 source files, and examining their extensions:
5359 Modula-2 source file
5369 This information is recorded for each function or procedure in a source
5370 file. When your program stops in a frame (usually by encountering a
5371 breakpoint), @value{GDBN} sets the working language to the language recorded
5372 for the function in that frame. If the language for a frame is unknown
5373 (that is, if the function or block corresponding to the frame was
5374 defined in a source file that does not have a recognized extension), the
5375 current working language is not changed, and @value{GDBN} issues a warning.
5377 This may not seem necessary for most programs, which are written
5378 entirely in one source language. However, program modules and libraries
5379 written in one source language can be used by a main program written in
5380 a different source language. Using @samp{set language auto} in this
5381 case frees you from having to set the working language manually.
5384 @section Displaying the language
5386 The following commands will help you find out which language is the
5387 working language, and also what language source files were written in.
5389 @kindex show language
5394 Display the current working language. This is the
5395 language you can use with commands such as @code{print} to
5396 build and compute expressions that may involve variables in your program.
5399 Among the other information listed here (@pxref{Frame Info, ,Information
5400 about a frame}) is the source language for this frame. This is the
5401 language that will become the working language if you ever use an
5402 identifier that is in this frame.
5405 Among the other information listed here (@pxref{Symbols, ,Examining the
5406 Symbol Table}) is the source language of this source file.
5410 @section Type and range checking
5413 @emph{Warning:} In this release, the @value{GDBN} commands for type and range
5414 checking are included, but they do not yet have any effect. This
5415 section documents the intended facilities.
5417 @c FIXME remove warning when type/range code added
5419 Some languages are designed to guard you against making seemingly common
5420 errors through a series of compile- and run-time checks. These include
5421 checking the type of arguments to functions and operators, and making
5422 sure mathematical overflows are caught at run time. Checks such as
5423 these help to ensure a program's correctness once it has been compiled
5424 by eliminating type mismatches, and providing active checks for range
5425 errors when your program is running.
5427 @value{GDBN} can check for conditions like the above if you wish.
5428 Although @value{GDBN} will not check the statements in your program, it
5429 can check expressions entered directly into @value{GDBN} for evaluation via
5430 the @code{print} command, for example. As with the working language,
5431 @value{GDBN} can also decide whether or not to check automatically based on
5432 your program's source language. @xref{Support, ,Supported languages},
5433 for the default settings of supported languages.
5436 * Type Checking:: An overview of type checking
5437 * Range Checking:: An overview of range checking
5440 @cindex type checking
5441 @cindex checks, type
5443 @subsection An overview of type checking
5445 Some languages, such as Modula-2, are strongly typed, meaning that the
5446 arguments to operators and functions have to be of the correct type,
5447 otherwise an error occurs. These checks prevent type mismatch
5448 errors from ever causing any run-time problems. For example,
5456 The second example fails because the @code{CARDINAL} 1 is not
5457 type-compatible with the @code{REAL} 2.3.
5459 For expressions you use in @value{GDBN} commands, you can tell the @value{GDBN}
5460 type checker to skip checking; to treat any mismatches as errors and
5461 abandon the expression; or only issue warnings when type mismatches
5462 occur, but evaluate the expression anyway. When you choose the last of
5463 these, @value{GDBN} evaluates expressions like the second example above, but
5464 also issues a warning.
5466 Even though you may turn type checking off, other type-based reasons may
5467 prevent @value{GDBN} from evaluating an expression. For instance, @value{GDBN} does not
5468 know how to add an @code{int} and a @code{struct foo}. These particular
5469 type errors have nothing to do with the language in use, and usually
5470 arise from expressions, such as the one described above, which make
5471 little sense to evaluate anyway.
5473 Each language defines to what degree it is strict about type. For
5474 instance, both Modula-2 and C require the arguments to arithmetical
5475 operators to be numbers. In C, enumerated types and pointers can be
5476 represented as numbers, so that they are valid arguments to mathematical
5477 operators. @xref{Support, ,Supported languages}, for further
5478 details on specific languages.
5480 @value{GDBN} provides some additional commands for controlling the type checker:
5483 @kindex set check type
5484 @kindex show check type
5486 @item set check type auto
5487 Set type checking on or off based on the current working language.
5488 @xref{Support, ,Supported languages}, for the default settings for
5491 @item set check type on
5492 @itemx set check type off
5493 Set type checking on or off, overriding the default setting for the
5494 current working language. Issue a warning if the setting does not
5495 match the language default. If any type mismatches occur in
5496 evaluating an expression while typechecking is on, @value{GDBN} prints a
5497 message and aborts evaluation of the expression.
5499 @item set check type warn
5500 Cause the type checker to issue warnings, but to always attempt to
5501 evaluate the expression. Evaluating the expression may still
5502 be impossible for other reasons. For example, @value{GDBN} cannot add
5503 numbers and structures.
5506 Show the current setting of the type checker, and whether or not @value{GDBN} is
5507 setting it automatically.
5510 @cindex range checking
5511 @cindex checks, range
5512 @node Range Checking
5513 @subsection An overview of range checking
5515 In some languages (such as Modula-2), it is an error to exceed the
5516 bounds of a type; this is enforced with run-time checks. Such range
5517 checking is meant to ensure program correctness by making sure
5518 computations do not overflow, or indices on an array element access do
5519 not exceed the bounds of the array.
5521 For expressions you use in @value{GDBN} commands, you can tell
5522 @value{GDBN} to treat range errors in one of three ways: ignore them,
5523 always treat them as errors and abandon the expression, or issue
5524 warnings but evaluate the expression anyway.
5526 A range error can result from numerical overflow, from exceeding an
5527 array index bound, or when you type a constant that is not a member
5528 of any type. Some languages, however, do not treat overflows as an
5529 error. In many implementations of C, mathematical overflow causes the
5530 result to ``wrap around'' to lower values---for example, if @var{m} is
5531 the largest integer value, and @var{s} is the smallest, then
5534 @var{m} + 1 @result{} @var{s}
5537 This, too, is specific to individual languages, and in some cases
5538 specific to individual compilers or machines. @xref{Support, ,
5539 Supported languages}, for further details on specific languages.
5541 @value{GDBN} provides some additional commands for controlling the range checker:
5544 @kindex set check range
5545 @kindex show check range
5547 @item set check range auto
5548 Set range checking on or off based on the current working language.
5549 @xref{Support, ,Supported languages}, for the default settings for
5552 @item set check range on
5553 @itemx set check range off
5554 Set range checking on or off, overriding the default setting for the
5555 current working language. A warning is issued if the setting does not
5556 match the language default. If a range error occurs, then a message
5557 is printed and evaluation of the expression is aborted.
5559 @item set check range warn
5560 Output messages when the @value{GDBN} range checker detects a range error,
5561 but attempt to evaluate the expression anyway. Evaluating the
5562 expression may still be impossible for other reasons, such as accessing
5563 memory that the process does not own (a typical example from many UNIX
5567 Show the current setting of the range checker, and whether or not it is
5568 being set automatically by @value{GDBN}.
5572 @section Supported languages
5574 @value{GDBN} 4 supports C, C++, and Modula-2. Some @value{GDBN}
5575 features may be used in expressions regardless of the language you
5576 use: the @value{GDBN} @code{@@} and @code{::} operators, and the
5577 @samp{@{type@}addr} construct (@pxref{Expressions, ,Expressions}) can be
5578 used with the constructs of any of the supported languages.
5580 The following sections detail to what degree each of these
5581 source languages is supported by @value{GDBN}. These sections are
5582 not meant to be language tutorials or references, but serve only as a
5583 reference guide to what the @value{GDBN} expression parser will accept, and
5584 what input and output formats should look like for different languages.
5585 There are many good books written on each of these languages; please
5586 look to these for a language reference or tutorial.
5590 * Modula-2:: Modula-2
5594 @subsection C and C++
5596 @cindex expressions in C or C++
5598 Since C and C++ are so closely related, many features of @value{GDBN} apply
5599 to both languages. Whenever this is the case, we discuss both languages
5605 The C++ debugging facilities are jointly implemented by the GNU C++
5606 compiler and @value{GDBN}. Therefore, to debug your C++ code effectively,
5607 you must compile your C++ programs with the GNU C++ compiler,
5612 @chapter C Language Support
5614 @cindex expressions in C
5616 Information specific to the C language is built into @value{GDBN} so that you
5617 can use C expressions while degugging. This also permits @value{GDBN} to
5618 output values in a manner consistent with C conventions.
5621 * C Operators:: C operators
5622 * C Constants:: C constants
5623 * Debugging C:: @value{GDBN} and C
5628 * C Operators:: C and C++ operators
5629 * C Constants:: C and C++ constants
5630 * Cplus expressions:: C++ expressions
5631 * C Defaults:: Default settings for C and C++
5632 * C Checks:: C and C++ type and range checks
5633 * Debugging C:: @value{GDBN} and C
5634 * Debugging C plus plus:: Special features for C++
5639 @cindex C and C++ operators
5641 @subsubsection C and C++ operators
5646 @section C operators
5649 Operators must be defined on values of specific types. For instance,
5650 @code{+} is defined on numbers, but not on structures. Operators are
5651 often defined on groups of types.
5654 For the purposes of C and C++, the following definitions hold:
5659 @emph{Integral types} include @code{int} with any of its storage-class
5660 specifiers; @code{char}; and @code{enum}.
5663 @emph{Floating-point types} include @code{float} and @code{double}.
5666 @emph{Pointer types} include all types defined as @code{(@var{type}
5670 @emph{Scalar types} include all of the above.
5674 The following operators are supported. They are listed here
5675 in order of increasing precedence:
5679 The comma or sequencing operator. Expressions in a comma-separated list
5680 are evaluated from left to right, with the result of the entire
5681 expression being the last expression evaluated.
5684 Assignment. The value of an assignment expression is the value
5685 assigned. Defined on scalar types.
5688 Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}},
5689 and translated to @w{@code{@var{a} = @var{a op b}}}.
5690 @w{@code{@var{op}=}} and @code{=} have the same precendence.
5691 @var{op} is any one of the operators @code{|}, @code{^}, @code{&},
5692 @code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}.
5695 The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought
5696 of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an
5700 Logical @sc{or}. Defined on integral types.
5703 Logical @sc{and}. Defined on integral types.
5706 Bitwise @sc{or}. Defined on integral types.
5709 Bitwise exclusive-@sc{or}. Defined on integral types.
5712 Bitwise @sc{and}. Defined on integral types.
5715 Equality and inequality. Defined on scalar types. The value of these
5716 expressions is 0 for false and non-zero for true.
5718 @item <@r{, }>@r{, }<=@r{, }>=
5719 Less than, greater than, less than or equal, greater than or equal.
5720 Defined on scalar types. The value of these expressions is 0 for false
5721 and non-zero for true.
5724 left shift, and right shift. Defined on integral types.
5727 The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
5730 Addition and subtraction. Defined on integral types, floating-point types and
5733 @item *@r{, }/@r{, }%
5734 Multiplication, division, and modulus. Multiplication and division are
5735 defined on integral and floating-point types. Modulus is defined on
5739 Increment and decrement. When appearing before a variable, the
5740 operation is performed before the variable is used in an expression;
5741 when appearing after it, the variable's value is used before the
5742 operation takes place.
5745 Pointer dereferencing. Defined on pointer types. Same precedence as
5749 Address operator. Defined on variables. Same precedence as @code{++}.
5752 For debugging C++, @value{GDBN} implements a use of @samp{&} beyond what is
5753 allowed in the C++ language itself: you can use @samp{&(&@var{ref})}
5754 (or, if you prefer, simply @samp{&&@var{ref}} to examine the address
5755 where a C++ reference variable (declared with @samp{&@var{ref}}) is
5760 Negative. Defined on integral and floating-point types. Same
5761 precedence as @code{++}.
5764 Logical negation. Defined on integral types. Same precedence as
5768 Bitwise complement operator. Defined on integral types. Same precedence as
5773 Structure member, and pointer-to-structure member. For convenience,
5774 @value{GDBN} regards the two as equivalent, choosing whether to dereference a
5775 pointer based on the stored type information.
5776 Defined on @code{struct} and @code{union} data.
5779 Array indexing. @code{@var{a}[@var{i}]} is defined as
5780 @code{*(@var{a}+@var{i})}. Same precedence as @code{->}.
5783 Function parameter list. Same precedence as @code{->}.
5787 C++ scope resolution operator. Defined on
5788 @code{struct}, @code{union}, and @code{class} types.
5796 represent the @value{GDBN} scope operator (@pxref{Expressions,
5799 Same precedence as @code{::}, above.
5804 @cindex C and C++ constants
5806 @subsubsection C and C++ constants
5808 @value{GDBN} allows you to express the constants of C and C++ in the
5814 @section C constants
5816 @value{GDBN} allows you to express the constants of C in the
5822 Integer constants are a sequence of digits. Octal constants are
5823 specified by a leading @samp{0} (ie. zero), and hexadecimal constants by
5824 a leading @samp{0x} or @samp{0X}. Constants may also end with a letter
5825 @samp{l}, specifying that the constant should be treated as a
5829 Floating point constants are a sequence of digits, followed by a decimal
5830 point, followed by a sequence of digits, and optionally followed by an
5831 exponent. An exponent is of the form:
5832 @samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another
5833 sequence of digits. The @samp{+} is optional for positive exponents.
5836 Enumerated constants consist of enumerated identifiers, or their
5837 integral equivalents.
5840 Character constants are a single character surrounded by single quotes
5841 (@code{'}), or a number---the ordinal value of the corresponding character
5842 (usually its @sc{ASCII} value). Within quotes, the single character may
5843 be represented by a letter or by @dfn{escape sequences}, which are of
5844 the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation
5845 of the character's ordinal value; or of the form @samp{\@var{x}}, where
5846 @samp{@var{x}} is a predefined special character---for example,
5847 @samp{\n} for newline.
5850 String constants are a sequence of character constants surrounded
5851 by double quotes (@code{"}).
5854 Pointer constants are an integral value. You can also write pointers
5855 to constants using the C operator @samp{&}.
5858 Array constants are comma-separated lists surrounded by braces @samp{@{}
5859 and @samp{@}}; for example, @samp{@{1,2,3@}} is a three-element array of
5860 integers, @samp{@{@{1,2@}, @{3,4@}, @{5,6@}@}} is a three-by-two array,
5861 and @samp{@{&"hi", &"there", &"fred"@}} is a three-element array of pointers.
5865 @node Cplus expressions
5866 @subsubsection C++ expressions
5868 @cindex expressions in C++
5869 @value{GDBN} expression handling has a number of extensions to
5870 interpret a significant subset of C++ expressions.
5872 @cindex C++ support, not in @sc{coff}
5873 @cindex @sc{coff} versus C++
5874 @cindex C++ and object formats
5875 @cindex object formats and C++
5876 @cindex a.out and C++
5877 @cindex @sc{ecoff} and C++
5878 @cindex @sc{xcoff} and C++
5879 @cindex @sc{elf}/stabs and C++
5880 @cindex @sc{elf}/@sc{dwarf} and C++
5882 @emph{Warning:} Most of these extensions depend on the use of additional
5883 debugging information in the symbol table, and thus require a rich,
5884 extendable object code format. In particular, if your system uses
5885 a.out, MIPS @sc{ecoff}, RS/6000 @sc{xcoff}, or Sun @sc{elf} with stabs
5886 extensions to the symbol table, these facilities are all available.
5887 Where the object code format is standard @sc{coff}, on the other hand,
5888 most of the C++ support in @value{GDBN} will @emph{not} work, nor can it.
5889 For the standard SVr4 debugging format, @sc{dwarf} in @sc{elf}, the
5890 standard is still evolving, so the C++ support in @value{GDBN} is still
5891 fragile; when this debugging format stabilizes, however, C++ support
5892 will also be available on systems that use it.
5897 @cindex member functions
5899 Member function calls are allowed; you can use expressions like
5902 count = aml->GetOriginal(x, y)
5906 @cindex namespace in C++
5908 While a member function is active (in the selected stack frame), your
5909 expressions have the same namespace available as the member function;
5910 that is, @value{GDBN} allows implicit references to the class instance
5911 pointer @code{this} following the same rules as C++.
5913 @cindex call overloaded functions
5914 @cindex type conversions in C++
5916 You can call overloaded functions; @value{GDBN} will resolve the function
5917 call to the right definition, with one restriction---you must use
5918 arguments of the type required by the function that you want to call.
5919 @value{GDBN} will not perform conversions requiring constructors or
5920 user-defined type operators.
5922 @cindex reference declarations
5924 @value{GDBN} understands variables declared as C++ references; you can use them in
5925 expressions just as you do in C++ source---they are automatically
5928 In the parameter list shown when @value{GDBN} displays a frame, the values of
5929 reference variables are not displayed (unlike other variables); this
5930 avoids clutter, since references are often used for large structures.
5931 The @emph{address} of a reference variable is always shown, unless
5932 you have specified @samp{set print address off}.
5935 @value{GDBN} supports the C++ name resolution operator @code{::}---your
5936 expressions can use it just as expressions in your program do. Since
5937 one scope may be defined in another, you can use @code{::} repeatedly if
5938 necessary, for example in an expression like
5939 @samp{@var{scope1}::@var{scope2}::@var{name}}. @value{GDBN} also allows
5940 resolving name scope by reference to source files, in both C and C++
5941 debugging (@pxref{Variables, ,Program variables}).
5945 @subsubsection C and C++ defaults
5946 @cindex C and C++ defaults
5948 If you allow @value{GDBN} to set type and range checking automatically, they
5949 both default to @code{off} whenever the working language changes to
5950 C or C++. This happens regardless of whether you, or @value{GDBN},
5951 selected the working language.
5953 If you allow @value{GDBN} to set the language automatically, it sets the
5954 working language to C or C++ on entering code compiled from a source file
5955 whose name ends with @file{.c}, @file{.C}, or @file{.cc}.
5956 @xref{Automatically, ,Having @value{GDBN} infer the source language}, for
5960 @subsubsection C and C++ type and range checks
5961 @cindex C and C++ checks
5963 By default, when @value{GDBN} parses C or C++ expressions, type checking
5964 is not used. However, if you turn type checking on, @value{GDBN} will
5965 consider two variables type equivalent if:
5969 The two variables are structured and have the same structure, union, or
5973 Two two variables have the same type name, or types that have been
5974 declared equivalent through @code{typedef}.
5977 @c leaving this out because neither J Gilmore nor R Pesch understand it.
5980 The two @code{struct}, @code{union}, or @code{enum} variables are
5981 declared in the same declaration. (Note: this may not be true for all C
5986 Range checking, if turned on, is done on mathematical operations. Array
5987 indices are not checked, since they are often used to index a pointer
5988 that is not itself an array.
5993 @subsubsection @value{GDBN} and C
5997 @section @value{GDBN} and C
6000 The @code{set print union} and @code{show print union} commands apply to
6001 the @code{union} type. When set to @samp{on}, any @code{union} that is
6002 inside a @code{struct} or @code{class} will also be printed.
6003 Otherwise, it will appear as @samp{@{...@}}.
6005 The @code{@@} operator aids in the debugging of dynamic arrays, formed
6006 with pointers and a memory allocation function. @xref{Expressions,
6010 @node Debugging C plus plus
6011 @subsubsection @value{GDBN} features for C++
6013 @cindex commands for C++
6014 Some @value{GDBN} commands are particularly useful with C++, and some are
6015 designed specifically for use with C++. Here is a summary:
6018 @cindex break in overloaded functions
6019 @item @r{breakpoint menus}
6020 When you want a breakpoint in a function whose name is overloaded,
6021 @value{GDBN} breakpoint menus help you specify which function definition
6022 you want. @xref{Breakpoint Menus,,Breakpoint menus}.
6024 @cindex overloading in C++
6025 @item rbreak @var{regex}
6026 Setting breakpoints using regular expressions is helpful for setting
6027 breakpoints on overloaded functions that are not members of any special
6029 @xref{Set Breaks, ,Setting breakpoints}.
6031 @cindex C++ exception handling
6032 @item catch @var{exceptions}
6034 Debug C++ exception handling using these commands. @xref{Exception
6035 Handling, ,Breakpoints and exceptions}.
6038 @item ptype @var{typename}
6039 Print inheritance relationships as well as other information for type
6041 @xref{Symbols, ,Examining the Symbol Table}.
6043 @cindex C++ symbol display
6044 @item set print demangle
6045 @itemx show print demangle
6046 @itemx set print asm-demangle
6047 @itemx show print asm-demangle
6048 Control whether C++ symbols display in their source form, both when
6049 displaying code as C++ source and when displaying disassemblies.
6050 @xref{Print Settings, ,Print settings}.
6052 @item set print object
6053 @itemx show print object
6054 Choose whether to print derived (actual) or declared types of objects.
6055 @xref{Print Settings, ,Print settings}.
6057 @item set print vtbl
6058 @itemx show print vtbl
6059 Control the format for printing virtual function tables.
6060 @xref{Print Settings, ,Print settings}.
6062 @item @r{Overloaded symbol names}
6063 You can specify a particular definition of an overloaded symbol, using
6064 the same notation that is used to declare such symbols in C++: type
6065 @code{@var{symbol}(@var{types})} rather than just @var{symbol}. You can
6066 also use the @value{GDBN} command-line word completion facilities to list the
6067 available choices, or to finish the type list for you.
6068 @xref{Completion,, Command completion}, for details on how to do this.
6072 @subsection Modula-2
6075 The extensions made to @value{GDBN} to support Modula-2 only support
6076 output from the GNU Modula-2 compiler (which is currently being
6077 developed). Other Modula-2 compilers are not currently supported, and
6078 attempting to debug executables produced by them will most likely
6079 result in an error as @value{GDBN} reads in the executable's symbol
6082 @cindex expressions in Modula-2
6084 * M2 Operators:: Built-in operators
6085 * Built-In Func/Proc:: Built-in functions and procedures
6086 * M2 Constants:: Modula-2 constants
6087 * M2 Defaults:: Default settings for Modula-2
6088 * Deviations:: Deviations from standard Modula-2
6089 * M2 Checks:: Modula-2 type and range checks
6090 * M2 Scope:: The scope operators @code{::} and @code{.}
6091 * GDB/M2:: @value{GDBN} and Modula-2
6095 @subsubsection Operators
6096 @cindex Modula-2 operators
6098 Operators must be defined on values of specific types. For instance,
6099 @code{+} is defined on numbers, but not on structures. Operators are
6100 often defined on groups of types. For the purposes of Modula-2, the
6101 following definitions hold:
6106 @emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and
6110 @emph{Character types} consist of @code{CHAR} and its subranges.
6113 @emph{Floating-point types} consist of @code{REAL}.
6116 @emph{Pointer types} consist of anything declared as @code{POINTER TO
6120 @emph{Scalar types} consist of all of the above.
6123 @emph{Set types} consist of @code{SET} and @code{BITSET} types.
6126 @emph{Boolean types} consist of @code{BOOLEAN}.
6130 The following operators are supported, and appear in order of
6131 increasing precedence:
6135 Function argument or array index separator.
6138 Assignment. The value of @var{var} @code{:=} @var{value} is
6142 Less than, greater than on integral, floating-point, or enumerated
6146 Less than, greater than, less than or equal to, greater than or equal to
6147 on integral, floating-point and enumerated types, or set inclusion on
6148 set types. Same precedence as @code{<}.
6150 @item =@r{, }<>@r{, }#
6151 Equality and two ways of expressing inequality, valid on scalar types.
6152 Same precedence as @code{<}. In @value{GDBN} scripts, only @code{<>} is
6153 available for inequality, since @code{#} conflicts with the script
6157 Set membership. Defined on set types and the types of their members.
6158 Same precedence as @code{<}.
6161 Boolean disjunction. Defined on boolean types.
6164 Boolean conjuction. Defined on boolean types.
6167 The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
6170 Addition and subtraction on integral and floating-point types, or union
6171 and difference on set types.
6174 Multiplication on integral and floating-point types, or set intersection
6178 Division on floating-point types, or symmetric set difference on set
6179 types. Same precedence as @code{*}.
6182 Integer division and remainder. Defined on integral types. Same
6183 precedence as @code{*}.
6186 Negative. Defined on @code{INTEGER} and @code{REAL} data.
6189 Pointer dereferencing. Defined on pointer types.
6192 Boolean negation. Defined on boolean types. Same precedence as
6196 @code{RECORD} field selector. Defined on @code{RECORD} data. Same
6197 precedence as @code{^}.
6200 Array indexing. Defined on @code{ARRAY} data. Same precedence as @code{^}.
6203 Procedure argument list. Defined on @code{PROCEDURE} objects. Same precedence
6207 @value{GDBN} and Modula-2 scope operators.
6211 @emph{Warning:} Sets and their operations are not yet supported, so @value{GDBN}
6212 will treat the use of the operator @code{IN}, or the use of operators
6213 @code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#},
6214 @code{<=}, and @code{>=} on sets as an error.
6217 @cindex Modula-2 built-ins
6218 @node Built-In Func/Proc
6219 @subsubsection Built-in functions and procedures
6221 Modula-2 also makes available several built-in procedures and functions.
6222 In describing these, the following metavariables are used:
6227 represents an @code{ARRAY} variable.
6230 represents a @code{CHAR} constant or variable.
6233 represents a variable or constant of integral type.
6236 represents an identifier that belongs to a set. Generally used in the
6237 same function with the metavariable @var{s}. The type of @var{s} should
6238 be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}.
6241 represents a variable or constant of integral or floating-point type.
6244 represents a variable or constant of floating-point type.
6250 represents a variable.
6253 represents a variable or constant of one of many types. See the
6254 explanation of the function for details.
6257 All Modula-2 built-in procedures also return a result, described below.
6261 Returns the absolute value of @var{n}.
6264 If @var{c} is a lower case letter, it returns its upper case
6265 equivalent, otherwise it returns its argument
6268 Returns the character whose ordinal value is @var{i}.
6271 Decrements the value in the variable @var{v}. Returns the new value.
6273 @item DEC(@var{v},@var{i})
6274 Decrements the value in the variable @var{v} by @var{i}. Returns the
6277 @item EXCL(@var{m},@var{s})
6278 Removes the element @var{m} from the set @var{s}. Returns the new
6281 @item FLOAT(@var{i})
6282 Returns the floating point equivalent of the integer @var{i}.
6285 Returns the index of the last member of @var{a}.
6288 Increments the value in the variable @var{v}. Returns the new value.
6290 @item INC(@var{v},@var{i})
6291 Increments the value in the variable @var{v} by @var{i}. Returns the
6294 @item INCL(@var{m},@var{s})
6295 Adds the element @var{m} to the set @var{s} if it is not already
6296 there. Returns the new set.
6299 Returns the maximum value of the type @var{t}.
6302 Returns the minimum value of the type @var{t}.
6305 Returns boolean TRUE if @var{i} is an odd number.
6308 Returns the ordinal value of its argument. For example, the ordinal
6309 value of a character is its ASCII value (on machines supporting the
6310 ASCII character set). @var{x} must be of an ordered type, which include
6311 integral, character and enumerated types.
6314 Returns the size of its argument. @var{x} can be a variable or a type.
6316 @item TRUNC(@var{r})
6317 Returns the integral part of @var{r}.
6319 @item VAL(@var{t},@var{i})
6320 Returns the member of the type @var{t} whose ordinal value is @var{i}.
6324 @emph{Warning:} Sets and their operations are not yet supported, so
6325 @value{GDBN} will treat the use of procedures @code{INCL} and @code{EXCL} as
6329 @cindex Modula-2 constants
6331 @subsubsection Constants
6333 @value{GDBN} allows you to express the constants of Modula-2 in the following
6339 Integer constants are simply a sequence of digits. When used in an
6340 expression, a constant is interpreted to be type-compatible with the
6341 rest of the expression. Hexadecimal integers are specified by a
6342 trailing @samp{H}, and octal integers by a trailing @samp{B}.
6345 Floating point constants appear as a sequence of digits, followed by a
6346 decimal point and another sequence of digits. An optional exponent can
6347 then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where
6348 @samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the
6349 digits of the floating point constant must be valid decimal (base 10)
6353 Character constants consist of a single character enclosed by a pair of
6354 like quotes, either single (@code{'}) or double (@code{"}). They may
6355 also be expressed by their ordinal value (their ASCII value, usually)
6356 followed by a @samp{C}.
6359 String constants consist of a sequence of characters enclosed by a
6360 pair of like quotes, either single (@code{'}) or double (@code{"}).
6361 Escape sequences in the style of C are also allowed. @xref{C
6362 Constants, ,C and C++ constants}, for a brief explanation of escape
6366 Enumerated constants consist of an enumerated identifier.
6369 Boolean constants consist of the identifiers @code{TRUE} and
6373 Pointer constants consist of integral values only.
6376 Set constants are not yet supported.
6380 @subsubsection Modula-2 defaults
6381 @cindex Modula-2 defaults
6383 If type and range checking are set automatically by @value{GDBN}, they
6384 both default to @code{on} whenever the working language changes to
6385 Modula-2. This happens regardless of whether you, or @value{GDBN},
6386 selected the working language.
6388 If you allow @value{GDBN} to set the language automatically, then entering
6389 code compiled from a file whose name ends with @file{.mod} will set the
6390 working language to Modula-2. @xref{Automatically, ,Having @value{GDBN} set
6391 the language automatically}, for further details.
6394 @subsubsection Deviations from standard Modula-2
6395 @cindex Modula-2, deviations from
6397 A few changes have been made to make Modula-2 programs easier to debug.
6398 This is done primarily via loosening its type strictness:
6402 Unlike in standard Modula-2, pointer constants can be formed by
6403 integers. This allows you to modify pointer variables during
6404 debugging. (In standard Modula-2, the actual address contained in a
6405 pointer variable is hidden from you; it can only be modified
6406 through direct assignment to another pointer variable or expression that
6407 returned a pointer.)
6410 C escape sequences can be used in strings and characters to represent
6411 non-printable characters. @value{GDBN} will print out strings with these
6412 escape sequences embedded. Single non-printable characters are
6413 printed using the @samp{CHR(@var{nnn})} format.
6416 The assignment operator (@code{:=}) returns the value of its right-hand
6420 All built-in procedures both modify @emph{and} return their argument.
6424 @subsubsection Modula-2 type and range checks
6425 @cindex Modula-2 checks
6428 @emph{Warning:} in this release, @value{GDBN} does not yet perform type or
6431 @c FIXME remove warning when type/range checks added
6433 @value{GDBN} considers two Modula-2 variables type equivalent if:
6437 They are of types that have been declared equivalent via a @code{TYPE
6438 @var{t1} = @var{t2}} statement
6441 They have been declared on the same line. (Note: This is true of the
6442 GNU Modula-2 compiler, but it may not be true of other compilers.)
6445 As long as type checking is enabled, any attempt to combine variables
6446 whose types are not equivalent is an error.
6448 Range checking is done on all mathematical operations, assignment, array
6449 index bounds, and all built-in functions and procedures.
6452 @subsubsection The scope operators @code{::} and @code{.}
6455 @cindex colon, doubled as scope operator
6458 @c Info cannot handle :: but TeX can.
6464 There are a few subtle differences between the Modula-2 scope operator
6465 (@code{.}) and the @value{GDBN} scope operator (@code{::}). The two have
6470 @var{module} . @var{id}
6471 @var{scope} :: @var{id}
6475 where @var{scope} is the name of a module or a procedure,
6476 @var{module} the name of a module, and @var{id} is any declared
6477 identifier within your program, except another module.
6479 Using the @code{::} operator makes @value{GDBN} search the scope
6480 specified by @var{scope} for the identifier @var{id}. If it is not
6481 found in the specified scope, then @value{GDBN} will search all scopes
6482 enclosing the one specified by @var{scope}.
6484 Using the @code{.} operator makes @value{GDBN} search the current scope for
6485 the identifier specified by @var{id} that was imported from the
6486 definition module specified by @var{module}. With this operator, it is
6487 an error if the identifier @var{id} was not imported from definition
6488 module @var{module}, or if @var{id} is not an identifier in
6492 @subsubsection @value{GDBN} and Modula-2
6494 Some @value{GDBN} commands have little use when debugging Modula-2 programs.
6495 Five subcommands of @code{set print} and @code{show print} apply
6496 specifically to C and C++: @samp{vtbl}, @samp{demangle},
6497 @samp{asm-demangle}, @samp{object}, and @samp{union}. The first four
6498 apply to C++, and the last to the C @code{union} type, which has no direct
6499 analogue in Modula-2.
6501 The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available
6502 while using any language, is not useful with Modula-2. Its
6503 intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be
6504 created in Modula-2 as they can in C or C++. However, because an
6505 address can be specified by an integral constant, the construct
6506 @samp{@{@var{type}@}@var{adrexp}} is still useful. (@pxref{Expressions, ,Expressions})
6508 @cindex @code{#} in Modula-2
6509 In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is
6510 interpreted as the beginning of a comment. Use @code{<>} instead.
6515 @chapter Examining the Symbol Table
6517 The commands described in this section allow you to inquire about the
6518 symbols (names of variables, functions and types) defined in your
6519 program. This information is inherent in the text of your program and
6520 does not change as your program executes. @value{GDBN} finds it in your
6521 program's symbol table, in the file indicated when you started @value{GDBN}
6522 (@pxref{File Options, ,Choosing files}), or by one of the
6523 file-management commands (@pxref{Files, ,Commands to specify files}).
6525 @c FIXME! This might be intentionally specific to C and C++; if so, move
6526 @c to someplace in C section of lang chapter.
6527 @cindex symbol names
6528 @cindex names of symbols
6529 @cindex quoting names
6530 Occasionally, you may need to refer to symbols that contain unusual
6531 characters, which @value{GDBN} ordinarily treats as word delimiters. The
6532 most frequent case is in referring to static variables in other
6533 source files (@pxref{Variables,,Program variables}). File names
6534 are recorded in object files as debugging symbols, but @value{GDBN} would
6535 ordinarily parse a typical file name, like @file{foo.c}, as the three words
6536 @samp{foo} @samp{.} @samp{c}. To allow @value{GDBN} to recognize
6537 @samp{foo.c} as a single symbol, enclose it in single quotes; for example,
6544 looks up the value of @code{x} in the scope of the file @file{foo.c}.
6547 @item info address @var{symbol}
6548 @kindex info address
6549 Describe where the data for @var{symbol} is stored. For a register
6550 variable, this says which register it is kept in. For a non-register
6551 local variable, this prints the stack-frame offset at which the variable
6554 Note the contrast with @samp{print &@var{symbol}}, which does not work
6555 at all for a register variables, and for a stack local variable prints
6556 the exact address of the current instantiation of the variable.
6558 @item whatis @var{exp}
6560 Print the data type of expression @var{exp}. @var{exp} is not
6561 actually evaluated, and any side-effecting operations (such as
6562 assignments or function calls) inside it do not take place.
6563 @xref{Expressions, ,Expressions}.
6566 Print the data type of @code{$}, the last value in the value history.
6568 @item ptype @var{typename}
6570 Print a description of data type @var{typename}. @var{typename} may be
6571 the name of a type, or for C code it may have the form
6572 @samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or
6573 @samp{enum @var{enum-tag}}.
6575 @item ptype @var{exp}
6577 Print a description of the type of expression @var{exp}. @code{ptype}
6578 differs from @code{whatis} by printing a detailed description, instead
6579 of just the name of the type.
6581 For example, for this variable declaration:
6584 struct complex @{double real; double imag;@} v;
6588 the two commands give this output:
6592 (@value{GDBP}) whatis v
6593 type = struct complex
6594 (@value{GDBP}) ptype v
6595 type = struct complex @{
6603 As with @code{whatis}, using @code{ptype} without an argument refers to
6604 the type of @code{$}, the last value in the value history.
6606 @item info types @var{regexp}
6609 Print a brief description of all types whose name matches @var{regexp}
6610 (or all types in your program, if you supply no argument). Each
6611 complete typename is matched as though it were a complete line; thus,
6612 @samp{i type value} gives information on all types in your program whose
6613 name includes the string @code{value}, but @samp{i type ^value$} gives
6614 information only on types whose complete name is @code{value}.
6616 This command differs from @code{ptype} in two ways: first, like
6617 @code{whatis}, it does not print a detailed description; second, it
6618 lists all source files where a type is defined.
6622 Show the name of the current source file---that is, the source file for
6623 the function containing the current point of execution---and the language
6627 @kindex info sources
6628 Print the names of all source files in your program for which there is
6629 debugging information, organized into two lists: files whose symbols
6630 have already been read, and files whose symbols will be read when needed.
6632 @item info functions
6633 @kindex info functions
6634 Print the names and data types of all defined functions.
6636 @item info functions @var{regexp}
6637 Print the names and data types of all defined functions
6638 whose names contain a match for regular expression @var{regexp}.
6639 Thus, @samp{info fun step} finds all functions whose names
6640 include @code{step}; @samp{info fun ^step} finds those whose names
6641 start with @code{step}.
6643 @item info variables
6644 @kindex info variables
6645 Print the names and data types of all variables that are declared
6646 outside of functions (i.e., excluding local variables).
6648 @item info variables @var{regexp}
6649 Print the names and data types of all variables (except for local
6650 variables) whose names contain a match for regular expression
6654 This was never implemented.
6656 @itemx info methods @var{regexp}
6657 @kindex info methods
6658 The @code{info methods} command permits the user to examine all defined
6659 methods within C++ program, or (with the @var{regexp} argument) a
6660 specific set of methods found in the various C++ classes. Many
6661 C++ classes provide a large number of methods. Thus, the output
6662 from the @code{ptype} command can be overwhelming and hard to use. The
6663 @code{info-methods} command filters the methods, printing only those
6664 which match the regular-expression @var{regexp}.
6667 @item maint print symbols @var{filename}
6668 @itemx maint print psymbols @var{filename}
6669 @itemx maint print msymbols @var{filename}
6670 @kindex maint print symbols
6672 @kindex maint print psymbols
6673 @cindex partial symbol dump
6674 Write a dump of debugging symbol data into the file @var{filename}.
6675 These commands are used to debug the @value{GDBN} symbol-reading code. Only
6676 symbols with debugging data are included. If you use @samp{maint print
6677 symbols}, @value{GDBN} includes all the symbols for which it has already
6678 collected full details: that is, @var{filename} reflects symbols for
6679 only those files whose symbols @value{GDBN} has read. You can use the
6680 command @code{info sources} to find out which files these are. If you
6681 use @samp{maint print psymbols} instead, the dump shows information about
6682 symbols that @value{GDBN} only knows partially---that is, symbols defined in
6683 files that @value{GDBN} has skimmed, but not yet read completely. Finally,
6684 @samp{maint print msymbols} dumps just the minimal symbol information
6685 required for each object file from which @value{GDBN} has read some symbols.
6686 The description of @code{symbol-file} explains how @value{GDBN} reads
6687 symbols; both @code{info source} and @code{symbol-file} are described in
6688 @ref{Files, ,Commands to specify files}.
6692 @chapter Altering Execution
6694 Once you think you have found an error in your program, you might want to
6695 find out for certain whether correcting the apparent error would lead to
6696 correct results in the rest of the run. You can find the answer by
6697 experiment, using the @value{GDBN} features for altering execution of the
6700 For example, you can store new values into variables or memory
6701 locations, give your program a signal, restart it at a different address,
6702 or even return prematurely from a function to its caller.
6707 * Assignment:: Assignment to variables
6708 * Jumping:: Continuing at a different address
6710 * Signaling:: Giving your program a signal
6712 * Returning:: Returning from a function
6713 * Calling:: Calling your program's functions
6714 * Patching:: Patching your program
6720 * Assignment:: Assignment to variables
6721 * Jumping:: Continuing at a different address
6722 * Signaling:: Giving your program a signal
6723 * Returning:: Returning from a function
6724 * Calling:: Calling your program's functions
6725 * Patching:: Patching your program
6731 * Assignment:: Assignment to variables
6732 * Jumping:: Continuing at a different address
6733 * Returning:: Returning from a function
6734 * Calling:: Calling your program's functions
6735 * Patching:: Patching your program
6740 @section Assignment to variables
6743 @cindex setting variables
6744 To alter the value of a variable, evaluate an assignment expression.
6745 @xref{Expressions, ,Expressions}. For example,
6752 stores the value 4 into the variable @code{x}, and then prints the
6753 value of the assignment expression (which is 4).
6755 @xref{Languages, ,Using @value{GDBN} with Different Languages}, for more
6756 information on operators in supported languages.
6759 @kindex set variable
6760 @cindex variables, setting
6761 If you are not interested in seeing the value of the assignment, use the
6762 @code{set} command instead of the @code{print} command. @code{set} is
6763 really the same as @code{print} except that the expression's value is
6764 not printed and is not put in the value history (@pxref{Value History,
6765 ,Value history}). The expression is evaluated only for its effects.
6767 If the beginning of the argument string of the @code{set} command
6768 appears identical to a @code{set} subcommand, use the @code{set
6769 variable} command instead of just @code{set}. This command is identical
6770 to @code{set} except for its lack of subcommands. For example, if
6771 your program has a variable @code{width}, you get
6772 an error if you try to set a new value with just @samp{set width=13},
6773 because @value{GDBN} has the command @code{set width}:
6776 (@value{GDBP}) whatis width
6778 (@value{GDBP}) p width
6780 (@value{GDBP}) set width=47
6781 Invalid syntax in expression.
6785 The invalid expression, of course, is @samp{=47}. In
6786 order to actually set the program's variable @code{width}, use
6789 (@value{GDBP}) set var width=47
6792 @value{GDBN} allows more implicit conversions in assignments than C; you can
6793 freely store an integer value into a pointer variable or vice versa,
6794 and you can convert any structure to any other structure that is the
6795 same length or shorter.
6796 @comment FIXME: how do structs align/pad in these conversions?
6797 @comment /pesch@cygnus.com 18dec1990
6799 To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
6800 construct to generate a value of specified type at a specified address
6801 (@pxref{Expressions, ,Expressions}). For example, @code{@{int@}0x83040} refers
6802 to memory location @code{0x83040} as an integer (which implies a certain size
6803 and representation in memory), and
6806 set @{int@}0x83040 = 4
6810 stores the value 4 into that memory location.
6813 @section Continuing at a different address
6815 Ordinarily, when you continue your program, you do so at the place where
6816 it stopped, with the @code{continue} command. You can instead continue at
6817 an address of your own choosing, with the following commands:
6820 @item jump @var{linespec}
6822 Resume execution at line @var{linespec}. Execution will stop
6823 immediately if there is a breakpoint there. @xref{List, ,Printing
6824 source lines}, for a description of the different forms of
6827 The @code{jump} command does not change the current stack frame, or
6828 the stack pointer, or the contents of any memory location or any
6829 register other than the program counter. If line @var{linespec} is in
6830 a different function from the one currently executing, the results may
6831 be bizarre if the two functions expect different patterns of arguments or
6832 of local variables. For this reason, the @code{jump} command requests
6833 confirmation if the specified line is not in the function currently
6834 executing. However, even bizarre results are predictable if you are
6835 well acquainted with the machine-language code of your program.
6837 @item jump *@var{address}
6838 Resume execution at the instruction at address @var{address}.
6841 You can get much the same effect as the @code{jump} command by storing a
6842 new value into the register @code{$pc}. The difference is that this
6843 does not start your program running; it only changes the address where it
6844 @emph{will} run when it is continued. For example,
6851 causes the next @code{continue} command or stepping command to execute at
6852 address @code{0x485}, rather than at the address where your program stopped.
6853 @xref{Continuing and Stepping, ,Continuing and stepping}.
6855 The most common occasion to use the @code{jump} command is to back up,
6856 perhaps with more breakpoints set, over a portion of a program that has
6857 already executed, in order to examine its execution in more detail.
6862 @section Giving your program a signal
6865 @item signal @var{signalnum}
6867 Resume execution where your program stopped, but give it immediately the
6868 signal number @var{signalnum}.
6870 Alternatively, if @var{signalnum} is zero, continue execution without
6871 giving a signal. This is useful when your program stopped on account of
6872 a signal and would ordinary see the signal when resumed with the
6873 @code{continue} command; @samp{signal 0} causes it to resume without a
6876 @code{signal} does not repeat when you press @key{RET} a second time
6877 after executing the command.
6883 @section Returning from a function
6887 @itemx return @var{expression}
6888 @cindex returning from a function
6890 You can cancel execution of a function call with the @code{return}
6891 command. If you give an
6892 @var{expression} argument, its value is used as the function's return
6896 When you use @code{return}, @value{GDBN} discards the selected stack frame
6897 (and all frames within it). You can think of this as making the
6898 discarded frame return prematurely. If you wish to specify a value to
6899 be returned, give that value as the argument to @code{return}.
6901 This pops the selected stack frame (@pxref{Selection, ,Selecting a
6902 frame}), and any other frames inside of it, leaving its caller as the
6903 innermost remaining frame. That frame becomes selected. The
6904 specified value is stored in the registers used for returning values
6907 The @code{return} command does not resume execution; it leaves the
6908 program stopped in the state that would exist if the function had just
6909 returned. In contrast, the @code{finish} command (@pxref{Continuing
6910 and Stepping, ,Continuing and stepping}) resumes execution until the
6911 selected stack frame returns naturally.
6914 @section Calling program functions
6916 @cindex calling functions
6919 @item call @var{expr}
6920 Evaluate the expression @var{expr} without displaying @code{void}
6924 You can use this variant of the @code{print} command if you want to
6925 execute a function from your program, but without cluttering the output
6926 with @code{void} returned values. The result is printed and saved in
6927 the value history, if it is not void.
6930 @section Patching programs
6931 @cindex patching binaries
6932 @cindex writing into executables
6933 @cindex writing into corefiles
6935 By default, @value{GDBN} opens the file containing your program's executable
6936 code (or the corefile) read-only. This prevents accidental alterations
6937 to machine code; but it also prevents you from intentionally patching
6938 your program's binary.
6940 If you'd like to be able to patch the binary, you can specify that
6941 explicitly with the @code{set write} command. For example, you might
6942 want to turn on internal debugging flags, or even to make emergency
6947 @itemx set write off
6949 If you specify @samp{set write on}, @value{GDBN} will open executable
6953 files for both reading and writing; if you specify @samp{set write
6954 off} (the default), @value{GDBN} will open them read-only.
6956 If you have already loaded a file, you must load it
6957 again (using the @code{exec-file} or @code{core-file} command) after
6958 changing @code{set write}, for your new setting to take effect.
6962 Display whether executable files
6966 will be opened for writing as well as reading.
6970 @chapter @value{GDBN} Files
6972 @value{GDBN} needs to know the file name of the program to be debugged, both in
6973 order to read its symbol table and in order to start your program.
6975 To debug a core dump of a previous run, you must also tell @value{GDBN}
6976 the name of the core dump file.
6980 * Files:: Commands to specify files
6981 * Symbol Errors:: Errors reading symbol files
6985 @section Commands to specify files
6986 @cindex symbol table
6989 @cindex core dump file
6990 The usual way to specify executable and core dump file names is with
6991 the command arguments given when you start @value{GDBN} (@pxref{Invocation,
6992 ,Getting In and Out of @value{GDBN}}.
6995 The usual way to specify an executable file name is with
6996 the command argument given when you start @value{GDBN}, (@pxref{Invocation,
6997 ,Getting In and Out of @value{GDBN}}.
7000 Occasionally it is necessary to change to a different file during a
7001 @value{GDBN} session. Or you may run @value{GDBN} and forget to specify
7002 a file you want to use. In these situations the @value{GDBN} commands
7003 to specify new files are useful.
7006 @item file @var{filename}
7007 @cindex executable file
7009 Use @var{filename} as the program to be debugged. It is read for its
7010 symbols and for the contents of pure memory. It is also the program
7011 executed when you use the @code{run} command. If you do not specify a
7012 directory and the file is not found in the @value{GDBN} working directory, @value{GDBN}
7013 uses the environment variable @code{PATH} as a list of directories to
7014 search, just as the shell does when looking for a program to run. You
7015 can change the value of this variable, for both @value{GDBN} and your program,
7016 using the @code{path} command.
7018 On systems with memory-mapped files, an auxiliary symbol table file
7019 @file{@var{filename}.syms} may be available for @var{filename}. If it
7020 is, @value{GDBN} will map in the symbol table from
7021 @file{@var{filename}.syms}, starting up more quickly. See the
7022 descriptions of the options @samp{-mapped} and @samp{-readnow} (available
7023 on the command line, and with the commands @code{file}, @code{symbol-file},
7024 or @code{add-symbol-file}), for more information.
7027 @code{file} with no argument makes @value{GDBN} discard any information it
7028 has on both executable file and the symbol table.
7030 @item exec-file @r{[} @var{filename} @r{]}
7032 Specify that the program to be run (but not the symbol table) is found
7033 in @var{filename}. @value{GDBN} will search the environment variable @code{PATH}
7034 if necessary to locate your program. Omitting @var{filename} means to
7035 discard information on the executable file.
7037 @item symbol-file @r{[} @var{filename} @r{]}
7039 Read symbol table information from file @var{filename}. @code{PATH} is
7040 searched when necessary. Use the @code{file} command to get both symbol
7041 table and program to run from the same file.
7043 @code{symbol-file} with no argument clears out @value{GDBN} information on your
7044 program's symbol table.
7046 The @code{symbol-file} command causes @value{GDBN} to forget the contents of its
7047 convenience variables, the value history, and all breakpoints and
7048 auto-display expressions. This is because they may contain pointers to
7049 the internal data recording symbols and data types, which are part of
7050 the old symbol table data being discarded inside @value{GDBN}.
7052 @code{symbol-file} will not repeat if you press @key{RET} again after
7055 When @value{GDBN} is configured for a particular environment, it will
7056 understand debugging information in whatever format is the standard
7057 generated for that environment; you may use either a GNU compiler, or
7058 other compilers that adhere to the local conventions. Best results are
7059 usually obtained from GNU compilers; for example, using @code{@value{GCC}}
7060 you can generate debugging information for optimized code.
7062 On some kinds of object files, the @code{symbol-file} command does not
7063 normally read the symbol table in full right away. Instead, it scans
7064 the symbol table quickly to find which source files and which symbols
7065 are present. The details are read later, one source file at a time,
7068 The purpose of this two-stage reading strategy is to make @value{GDBN} start up
7069 faster. For the most part, it is invisible except for occasional
7070 pauses while the symbol table details for a particular source file are
7071 being read. (The @code{set verbose} command can turn these pauses
7072 into messages if desired. @xref{Messages/Warnings, ,Optional warnings
7075 When the symbol table is stored in COFF format, @code{symbol-file} does
7076 read the symbol table data in full right away. We have not implemented
7077 the two-stage strategy for COFF yet.
7079 @item symbol-file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
7080 @itemx file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
7082 @cindex reading symbols immediately
7083 @cindex symbols, reading immediately
7085 @cindex memory-mapped symbol file
7086 @cindex saving symbol table
7087 You can override the @value{GDBN} two-stage strategy for reading symbol
7088 tables by using the @samp{-readnow} option with any of the commands that
7089 load symbol table information, if you want to be sure @value{GDBN} has the
7090 entire symbol table available.
7093 If memory-mapped files are available on your system through the
7094 @code{mmap} system call, you can use another option, @samp{-mapped}, to
7095 cause @value{GDBN} to write the symbols for your program into a reusable
7096 file. Future @value{GDBN} debugging sessions will map in symbol information
7097 from this auxiliary symbol file (if the program has not changed), rather
7098 than spending time reading the symbol table from the executable
7099 program. Using the @samp{-mapped} option has the same effect as
7100 starting @value{GDBN} with the @samp{-mapped} command-line option.
7102 You can use both options together, to make sure the auxiliary symbol
7103 file has all the symbol information for your program.
7105 The auxiliary symbol file for a program called @var{myprog} is called
7106 @samp{@var{myprog}.syms}. Once this file exists (so long as it is newer
7107 than the corresponding executable), @value{GDBN} will always attempt to use
7108 it when you debug @var{myprog}; no special options or commands are
7111 The @file{.syms} file is specific to the host machine where you run
7112 @value{GDBN}. It holds an exact image of the internal @value{GDB}
7113 symbol table. It cannot be shared across multiple host platforms.
7115 @c FIXME: for now no mention of directories, since this seems to be in
7116 @c flux. 13mar1992 status is that in theory GDB would look either in
7117 @c current dir or in same dir as myprog; but issues like competing
7118 @c GDB's, or clutter in system dirs, mean that in practice right now
7119 @c only current dir is used. FFish says maybe a special GDB hierarchy
7120 @c (eg rooted in val of env var GDBSYMS) could exist for mappable symbol
7123 @item core-file @r{[} @var{filename} @r{]}
7126 Specify the whereabouts of a core dump file to be used as the ``contents
7127 of memory''. Traditionally, core files contain only some parts of the
7128 address space of the process that generated them; @value{GDBN} can access the
7129 executable file itself for other parts.
7131 @code{core-file} with no argument specifies that no core file is
7134 Note that the core file is ignored when your program is actually running
7135 under @value{GDBN}. So, if you have been running your program and you wish to
7136 debug a core file instead, you must kill the subprocess in which the
7137 program is running. To do this, use the @code{kill} command
7138 (@pxref{Kill Process, ,Killing the child process}).
7141 @item load @var{filename}
7144 Depending on what remote debugging facilities are configured into
7145 @value{GDBN}, the @code{load} command may be available. Where it exists, it
7146 is meant to make @var{filename} (an executable) available for debugging
7147 on the remote system---by downloading, or dynamic linking, for example.
7148 @code{load} also records the @var{filename} symbol table in @value{GDBN}, like
7149 the @code{add-symbol-file} command.
7151 If your @value{GDBN} does not have a @code{load} command, attempting to
7152 execute it gets the error message ``@code{You can't do that when your
7153 target is @dots{}}''
7157 On VxWorks, @code{load} will dynamically link @var{filename} on the
7158 current target system as well as adding its symbols in @value{GDBN}.
7162 @cindex download to Nindy-960
7163 With the Nindy interface to an Intel 960 board, @code{load} will
7164 download @var{filename} to the 960 as well as adding its symbols in
7169 @cindex download to H8/300
7170 @cindex H8/300 download
7171 When you select remote debugging to a Hitachi H8/300 board (@pxref{Hitachi
7172 H8/300 Remote,,@value{GDBN} and the Hitachi H8/300}), the
7173 @code{load} command downloads your program to the H8/300 and also opens
7174 it as the current executable target for @value{GDBN} on your host (like the
7175 @code{file} command).
7178 @code{load} will not repeat if you press @key{RET} again after using it.
7181 @item add-symbol-file @var{filename} @var{address}
7182 @itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
7183 @kindex add-symbol-file
7184 @cindex dynamic linking
7185 The @code{add-symbol-file} command reads additional symbol table information
7186 from the file @var{filename}. You would use this command when @var{filename}
7187 has been dynamically loaded (by some other means) into the program that
7188 is running. @var{address} should be the memory address at which the
7189 file has been loaded; @value{GDBN} cannot figure this out for itself.
7191 The symbol table of the file @var{filename} is added to the symbol table
7192 originally read with the @code{symbol-file} command. You can use the
7193 @code{add-symbol-file} command any number of times; the new symbol data thus
7194 read keeps adding to the old. To discard all old symbol data instead,
7195 use the @code{symbol-file} command.
7197 @code{add-symbol-file} will not repeat if you press @key{RET} after using it.
7199 You can use the @samp{-mapped} and @samp{-readnow} options just as with
7200 the @code{symbol-file} command, to change how @value{GDBN} manages the symbol
7201 table information for @var{filename}.
7208 @code{info files} and @code{info target} are synonymous; both print
7209 the current targets (@pxref{Targets, ,Specifying a Debugging Target}),
7210 including the names of the executable and core dump files currently in
7211 use by @value{GDBN}, and the files from which symbols were loaded. The command
7212 @code{help targets} lists all possible targets rather than current
7216 All file-specifying commands allow both absolute and relative file names
7217 as arguments. @value{GDBN} always converts the file name to an absolute path
7218 name and remembers it that way.
7221 @cindex shared libraries
7222 @value{GDBN} supports SunOS, SVR4, and IBM RS/6000 shared libraries.
7223 @value{GDBN} automatically loads symbol definitions from shared libraries
7224 when you use the @code{run} command, or when you examine a core file.
7225 (Before you issue the @code{run} command, @value{GDBN} will not understand
7226 references to a function in a shared library, however---unless you are
7227 debugging a core file).
7228 @c FIXME: next @value{GDBN} release should permit some refs to undef
7229 @c FIXME...symbols---eg in a break cmd---assuming they are from a shared lib
7233 @itemx info sharedlibrary
7234 @kindex info sharedlibrary
7236 Print the names of the shared libraries which are currently loaded.
7238 @item sharedlibrary @var{regex}
7239 @itemx share @var{regex}
7240 @kindex sharedlibrary
7242 This is an obsolescent command; you can use it to explicitly
7243 load shared object library symbols for files matching a UNIX regular
7244 expression, but as with files loaded automatically, it will only load
7245 shared libraries required by your program for a core file or after
7246 typing @code{run}. If @var{regex} is omitted all shared libraries
7247 required by your program are loaded.
7252 @section Errors reading symbol files
7254 While reading a symbol file, @value{GDBN} will occasionally encounter problems,
7255 such as symbol types it does not recognize, or known bugs in compiler
7256 output. By default, @value{GDBN} does not notify you of such problems, since
7257 they are relatively common and primarily of interest to people
7258 debugging compilers. If you are interested in seeing information
7259 about ill-constructed symbol tables, you can either ask @value{GDBN} to print
7260 only one message about each such type of problem, no matter how many
7261 times the problem occurs; or you can ask @value{GDBN} to print more messages,
7262 to see how many times the problems occur, with the @code{set
7263 complaints} command (@pxref{Messages/Warnings, ,Optional warnings and
7266 The messages currently printed, and their meanings, are:
7269 @item inner block not inside outer block in @var{symbol}
7271 The symbol information shows where symbol scopes begin and end
7272 (such as at the start of a function or a block of statements). This
7273 error indicates that an inner scope block is not fully contained
7274 in its outer scope blocks.
7276 @value{GDBN} circumvents the problem by treating the inner block as if it had
7277 the same scope as the outer block. In the error message, @var{symbol}
7278 may be shown as ``@code{(don't know)}'' if the outer block is not a
7281 @item block at @var{address} out of order
7283 The symbol information for symbol scope blocks should occur in
7284 order of increasing addresses. This error indicates that it does not
7287 @value{GDBN} does not circumvent this problem, and will have trouble
7288 locating symbols in the source file whose symbols it is reading. (You
7289 can often determine what source file is affected by specifying
7290 @code{set verbose on}. @xref{Messages/Warnings, ,Optional warnings and
7293 @item bad block start address patched
7295 The symbol information for a symbol scope block has a start address
7296 smaller than the address of the preceding source line. This is known
7297 to occur in the SunOS 4.1.1 (and earlier) C compiler.
7299 @value{GDBN} circumvents the problem by treating the symbol scope block as
7300 starting on the previous source line.
7302 @item bad string table offset in symbol @var{n}
7305 Symbol number @var{n} contains a pointer into the string table which is
7306 larger than the size of the string table.
7308 @value{GDBN} circumvents the problem by considering the symbol to have the
7309 name @code{foo}, which may cause other problems if many symbols end up
7312 @item unknown symbol type @code{0x@var{nn}}
7314 The symbol information contains new data types that @value{GDBN} does not yet
7315 know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood
7316 information, in hexadecimal.
7318 @value{GDBN} circumvents the error by ignoring this symbol information. This
7319 will usually allow your program to be debugged, though certain symbols
7320 will not be accessible. If you encounter such a problem and feel like
7321 debugging it, you can debug @code{@value{GDBP}} with itself, breakpoint on
7322 @code{complain}, then go up to the function @code{read_dbx_symtab} and
7323 examine @code{*bufp} to see the symbol.
7325 @item stub type has NULL name
7326 @value{GDBN} could not find the full definition for a struct or class.
7328 @item const/volatile indicator missing (ok if using g++ v1.x), got@dots{}
7330 The symbol information for a C++ member function is missing some
7331 information that recent versions of the compiler should have output
7334 @item info mismatch between compiler and debugger
7336 @value{GDBN} could not parse a type specification output by the compiler.
7340 @chapter Specifying a Debugging Target
7341 @cindex debugging target
7344 A @dfn{target} is the execution environment occupied by your program.
7346 Often, @value{GDBN} runs in the same host environment as your program; in
7347 that case, the debugging target is specified as a side effect when you
7348 use the @code{file} or @code{core} commands. When you need more
7349 flexibility---for example, running @value{GDBN} on a physically separate
7350 host, or controlling a standalone system over a serial port or a
7351 realtime system over a TCP/IP connection---you
7356 can use the @code{target} command to specify one of the target types
7357 configured for @value{GDBN} (@pxref{Target Commands, ,Commands for managing
7361 * Active Targets:: Active targets
7362 * Target Commands:: Commands for managing targets
7363 * Remote:: Remote debugging
7366 @node Active Targets
7367 @section Active targets
7368 @cindex stacking targets
7369 @cindex active targets
7370 @cindex multiple targets
7373 There are three classes of targets: processes, core files, and
7374 executable files. @value{GDBN} can work concurrently on up to three active
7375 targets, one in each class. This allows you to (for example) start a
7376 process and inspect its activity without abandoning your work on a core
7379 For example, if you execute @samp{gdb a.out}, then the executable file
7380 @code{a.out} is the only active target. If you designate a core file as
7381 well---presumably from a prior run that crashed and coredumped---then
7382 @value{GDBN} has two active targets and will use them in tandem, looking
7383 first in the corefile target, then in the executable file, to satisfy
7384 requests for memory addresses. (Typically, these two classes of target
7385 are complementary, since core files contain only a program's
7386 read-write memory---variables and so on---plus machine status, while
7387 executable files contain only the program text and initialized data.)
7390 When you type @code{run}, your executable file becomes an active process
7391 target as well. When a process target is active, all @value{GDBN} commands
7392 requesting memory addresses refer to that target; addresses in an
7396 executable file target are obscured while the process
7400 Use the @code{exec-file} command to select a
7401 new executable target (@pxref{Files, ,Commands to specify
7405 Use the @code{core-file} and @code{exec-file} commands to select a
7406 new core file or executable target (@pxref{Files, ,Commands to specify
7407 files}). To specify as a target a process that is already running, use
7408 the @code{attach} command (@pxref{Attach, ,Debugging an
7409 already-running process}).
7412 @node Target Commands
7413 @section Commands for managing targets
7416 @item target @var{type} @var{parameters}
7417 Connects the @value{GDBN} host environment to a target machine or process. A
7418 target is typically a protocol for talking to debugging facilities. You
7419 use the argument @var{type} to specify the type or protocol of the
7422 Further @var{parameters} are interpreted by the target protocol, but
7423 typically include things like device names or host names to connect
7424 with, process numbers, and baud rates.
7426 The @code{target} command will not repeat if you press @key{RET} again
7427 after executing the command.
7431 Displays the names of all targets available. To display targets
7432 currently selected, use either @code{info target} or @code{info files}
7433 (@pxref{Files, ,Commands to specify files}).
7435 @item help target @var{name}
7436 Describe a particular target, including any parameters necessary to
7440 Here are some common targets (available, or not, depending on the GDB
7444 @item target exec @var{program}
7446 An executable file. @samp{target exec @var{program}} is the same as
7447 @samp{exec-file @var{program}}.
7449 @item target core @var{filename}
7451 A core dump file. @samp{target core @var{filename}} is the same as
7452 @samp{core-file @var{filename}}.
7455 @item target remote @var{dev}
7456 @kindex target remote
7457 Remote serial target in GDB-specific protocol. The argument @var{dev}
7458 specifies what serial device to use for the connection (e.g.
7459 @file{/dev/ttya}). @xref{Remote, ,Remote debugging}.
7465 CPU simulator. @xref{Simulator,,Simulated CPU Target}.
7469 @item target udi @var{keyword}
7471 Remote AMD29K target, using the AMD UDI protocol. The @var{keyword}
7472 argument specifies which 29K board or simulator to use. @xref{UDI29K
7473 Remote,,@value{GDBN} and the UDI protocol for AMD29K}.
7475 @item target amd-eb @var{dev} @var{speed} @var{PROG}
7476 @kindex target amd-eb
7478 Remote PC-resident AMD EB29K board, attached over serial lines.
7479 @var{dev} is the serial device, as for @code{target remote};
7480 @var{speed} allows you to specify the linespeed; and @var{PROG} is the
7481 name of the program to be debugged, as it appears to DOS on the PC.
7482 @xref{EB29K Remote, ,@value{GDBN} with a remote EB29K}.
7488 A Hitachi H8/300 board, attached via serial line to your host. Use
7489 special commands @code{device} and @code{speed} to control the serial
7490 line and the communications speed used. @xref{Hitachi H8/300
7491 Remote,,@value{GDBN} and the Hitachi H8/300}.
7495 @item target nindy @var{devicename}
7496 @kindex target nindy
7497 An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is
7498 the name of the serial device to use for the connection, e.g.
7499 @file{/dev/ttya}. @xref{i960-Nindy Remote, ,@value{GDBN} with a remote i960 (Nindy)}.
7503 @item target st2000 @var{dev} @var{speed}
7504 @kindex target st2000
7505 A Tandem ST2000 phone switch, running Tandem's STDBUG protocol. @var{dev}
7506 is the name of the device attached to the ST2000 serial line;
7507 @var{speed} is the communication line speed. The arguments are not used
7508 if @value{GDBN} is configured to connect to the ST2000 using TCP or Telnet.
7509 @xref{ST2000 Remote,,@value{GDBN} with a Tandem ST2000}.
7513 @item target vxworks @var{machinename}
7514 @kindex target vxworks
7515 A VxWorks system, attached via TCP/IP. The argument @var{machinename}
7516 is the target system's machine name or IP address.
7517 @xref{VxWorks Remote, ,@value{GDBN} and VxWorks}.
7522 Different targets are available on different configurations of @value{GDBN}; your
7523 configuration may have more or fewer targets.
7527 @section Remote debugging
7528 @cindex remote debugging
7530 If you are trying to debug a program running on a machine that cannot run
7531 GDB in the usual way, it is often useful to use remote debugging. For
7532 example, you might use remote debugging on an operating system kernel, or on
7533 a small system which does not have a general purpose operating system
7534 powerful enough to run a full-featured debugger.
7536 Some configurations of GDB have special serial or TCP/IP interfaces
7537 to make this work with particular debugging targets. In addition,
7538 GDB comes with a generic serial protocol (specific to GDB, but
7539 not specific to any particular target system) which you can use if you
7540 write the remote stubs---the code that will run on the remote system to
7541 communicate with GDB.
7543 Other remote targets may be available in your
7544 configuration of GDB; use @code{help targets} to list them.
7547 @c Text on starting up GDB in various specific cases; it goes up front
7548 @c in manuals configured for any of those particular situations, here
7551 @c original, intended form of this menu (pre-unfolding):
7554 * Remote Serial:: @value{GDBN} remote serial protocol
7557 * i960-Nindy Remote:: @value{GDBN} with a remote i960 (Nindy)
7560 * UDI29K Remote:: @value{GDBN} and the UDI protocol for AMD29K
7561 * EB29K Remote:: @value{GDBN} with a remote EB29K
7564 * VxWorks Remote:: @value{GDBN} and VxWorks
7567 * ST2000 Remote:: @value{GDBN} with a Tandem ST2000
7570 * Hitachi H8/300 Remote:: @value{GDBN} and the Hitachi H8/300
7573 * Simulator:: Simulated CPU target
7579 @c add as configs require, while unfolding remains necessary.
7581 @c All target details:
7583 * Remote Serial:: @value{GDBN} remote serial protocol
7584 * i960-Nindy Remote:: @value{GDBN} with a remote i960 (Nindy)
7585 * UDI29K Remote:: @value{GDBN} and the UDI protocol for AMD29K
7586 * EB29K Remote:: @value{GDBN} with a remote EB29K
7587 * VxWorks Remote:: @value{GDBN} and VxWorks
7588 * ST2000 Remote:: @value{GDBN} with a Tandem ST2000
7589 * Hitachi H8/300 Remote:: @value{GDBN} and the Hitachi H8/300
7590 * Simulator:: Simulated CPUs
7593 @include gdbinv-s.texi
7596 @node Controlling GDB
7597 @chapter Controlling @value{GDBN}
7599 You can alter the way @value{GDBN} interacts with you by using
7600 the @code{set} command. For commands controlling how @value{GDBN} displays
7601 data, @pxref{Print Settings, ,Print settings}; other settings are described here.
7605 * Editing:: Command editing
7606 * History:: Command history
7607 * Screen Size:: Screen size
7609 * Messages/Warnings:: Optional warnings and messages
7616 @value{GDBN} indicates its readiness to read a command by printing a string
7617 called the @dfn{prompt}. This string is normally @samp{(@value{GDBP})}. You
7618 can change the prompt string with the @code{set prompt} command. For
7619 instance, when debugging @value{GDBN} with @value{GDBN}, it is useful to change
7620 the prompt in one of the @value{GDBN} sessions so that you can always tell which
7621 one you are talking to.
7624 @item set prompt @var{newprompt}
7626 Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth.
7629 Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
7633 @section Command editing
7635 @cindex command line editing
7637 @value{GDBN} reads its input commands via the @dfn{readline} interface. This
7638 GNU library provides consistent behavior for programs which provide a
7639 command line interface to the user. Advantages are @code{emacs}-style
7640 or @code{vi}-style inline editing of commands, @code{csh}-like history
7641 substitution, and a storage and recall of command history across
7644 You may control the behavior of command line editing in @value{GDBN} with the
7651 @itemx set editing on
7652 Enable command line editing (enabled by default).
7654 @item set editing off
7655 Disable command line editing.
7657 @kindex show editing
7659 Show whether command line editing is enabled.
7663 @section Command history
7665 @value{GDBN} can keep track of the commands you type during your
7666 debugging sessions, so that you can be certain of precisely what
7667 happened. Use these commands to manage the @value{GDBN} command
7671 @cindex history substitution
7672 @cindex history file
7673 @kindex set history filename
7674 @item set history filename @var{fname}
7675 Set the name of the @value{GDBN} command history file to @var{fname}. This is
7676 the file from which @value{GDBN} will read an initial command history
7677 list or to which it will write this list when it exits. This list is
7678 accessed through history expansion or through the history
7679 command editing characters listed below. This file defaults to the
7680 value of the environment variable @code{GDBHISTFILE}, or to
7681 @file{./.gdb_history} if this variable is not set.
7683 @cindex history save
7684 @kindex set history save
7685 @item set history save
7686 @itemx set history save on
7687 Record command history in a file, whose name may be specified with the
7688 @code{set history filename} command. By default, this option is disabled.
7690 @item set history save off
7691 Stop recording command history in a file.
7693 @cindex history size
7694 @kindex set history size
7695 @item set history size @var{size}
7696 Set the number of commands which @value{GDBN} will keep in its history list.
7697 This defaults to the value of the environment variable
7698 @code{HISTSIZE}, or to 256 if this variable is not set.
7701 @cindex history expansion
7702 History expansion assigns special meaning to the character @kbd{!}.
7703 @ifset have-readline-appendices
7704 @xref{Event Designators}.
7707 Since @kbd{!} is also the logical not operator in C, history expansion
7708 is off by default. If you decide to enable history expansion with the
7709 @code{set history expansion on} command, you may sometimes need to
7710 follow @kbd{!} (when it is used as logical not, in an expression) with
7711 a space or a tab to prevent it from being expanded. The readline
7712 history facilities will not attempt substitution on the strings
7713 @kbd{!=} and @kbd{!(}, even when history expansion is enabled.
7715 The commands to control history expansion are:
7719 @kindex set history expansion
7720 @item set history expansion on
7721 @itemx set history expansion
7722 Enable history expansion. History expansion is off by default.
7724 @item set history expansion off
7725 Disable history expansion.
7727 The readline code comes with more complete documentation of
7728 editing and history expansion features. Users unfamiliar with @code{emacs}
7729 or @code{vi} may wish to read it.
7730 @ifset have-readline-appendices
7731 @xref{Command Line Editing}.
7735 @kindex show history
7737 @itemx show history filename
7738 @itemx show history save
7739 @itemx show history size
7740 @itemx show history expansion
7741 These commands display the state of the @value{GDBN} history parameters.
7742 @code{show history} by itself displays all four states.
7747 @kindex show commands
7749 Display the last ten commands in the command history.
7751 @item show commands @var{n}
7752 Print ten commands centered on command number @var{n}.
7754 @item show commands +
7755 Print ten commands just after the commands last printed.
7759 @section Screen size
7760 @cindex size of screen
7761 @cindex pauses in output
7763 Certain commands to @value{GDBN} may produce large amounts of information
7764 output to the screen. To help you read all of it, @value{GDBN} pauses and
7765 asks you for input at the end of each page of output. Type @key{RET}
7766 when you want to continue the output. @value{GDBN} also uses the screen
7767 width setting to determine when to wrap lines of output. Depending on
7768 what is being printed, it tries to break the line at a readable place,
7769 rather than simply letting it overflow onto the following line.
7771 Normally @value{GDBN} knows the size of the screen from the termcap data base
7772 together with the value of the @code{TERM} environment variable and the
7773 @code{stty rows} and @code{stty cols} settings. If this is not correct,
7774 you can override it with the @code{set height} and @code{set
7778 @item set height @var{lpp}
7780 @itemx set width @var{cpl}
7786 These @code{set} commands specify a screen height of @var{lpp} lines and
7787 a screen width of @var{cpl} characters. The associated @code{show}
7788 commands display the current settings.
7790 If you specify a height of zero lines, @value{GDBN} will not pause during output
7791 no matter how long the output is. This is useful if output is to a file
7792 or to an editor buffer.
7797 @cindex number representation
7798 @cindex entering numbers
7800 You can always enter numbers in octal, decimal, or hexadecimal in @value{GDBN} by
7801 the usual conventions: octal numbers begin with @samp{0}, decimal
7802 numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}.
7803 Numbers that begin with none of these are, by default, entered in base
7804 10; likewise, the default display for numbers---when no particular
7805 format is specified---is base 10. You can change the default base for
7806 both input and output with the @code{set radix} command.
7810 @item set radix @var{base}
7811 Set the default base for numeric input and display. Supported choices
7812 for @var{base} are decimal 2, 8, 10, 16. @var{base} must itself be
7813 specified either unambiguously or using the current default radix; for
7824 will set the base to decimal. On the other hand, @samp{set radix 10}
7825 will leave the radix unchanged no matter what it was.
7829 Display the current default base for numeric input and display.
7832 @node Messages/Warnings
7833 @section Optional warnings and messages
7835 By default, @value{GDBN} is silent about its inner workings. If you are running
7836 on a slow machine, you may want to use the @code{set verbose} command.
7837 It will make @value{GDBN} tell you when it does a lengthy internal operation, so
7838 you will not think it has crashed.
7840 Currently, the messages controlled by @code{set verbose} are those
7841 which announce that the symbol table for a source file is being read;
7842 see @code{symbol-file} in @ref{Files, ,Commands to specify files}.
7846 @item set verbose on
7847 Enables @value{GDBN} output of certain informational messages.
7849 @item set verbose off
7850 Disables @value{GDBN} output of certain informational messages.
7852 @kindex show verbose
7854 Displays whether @code{set verbose} is on or off.
7857 By default, if @value{GDBN} encounters bugs in the symbol table of an object
7858 file, it is silent; but if you are debugging a compiler, you may find
7859 this information useful (@pxref{Symbol Errors, ,Errors reading symbol files}).
7862 @kindex set complaints
7863 @item set complaints @var{limit}
7864 Permits @value{GDBN} to output @var{limit} complaints about each type of unusual
7865 symbols before becoming silent about the problem. Set @var{limit} to
7866 zero to suppress all complaints; set it to a large number to prevent
7867 complaints from being suppressed.
7869 @kindex show complaints
7870 @item show complaints
7871 Displays how many symbol complaints @value{GDBN} is permitted to produce.
7874 By default, @value{GDBN} is cautious, and asks what sometimes seems to be a
7875 lot of stupid questions to confirm certain commands. For example, if
7876 you try to run a program which is already running:
7880 The program being debugged has been started already.
7881 Start it from the beginning? (y or n)
7884 If you are willing to unflinchingly face the consequences of your own
7885 commands, you can disable this ``feature'':
7890 @cindex confirmation
7891 @cindex stupid questions
7892 @item set confirm off
7893 Disables confirmation requests.
7895 @item set confirm on
7896 Enables confirmation requests (the default).
7899 @kindex show confirm
7900 Displays state of confirmation requests.
7903 @c FIXME this does not really belong here. But where *does* it belong?
7904 @cindex reloading symbols
7905 Some systems allow individual object files that make up your program to
7906 be replaced without stopping and restarting your program.
7908 For example, in VxWorks you can simply recompile a defective object file
7909 and keep on running.
7911 If you are running on one of these systems, you can allow @value{GDBN} to
7912 reload the symbols for automatically relinked modules:
7915 @kindex set symbol-reloading
7916 @item set symbol-reloading on
7917 Replace symbol definitions for the corresponding source file when an
7918 object file with a particular name is seen again.
7920 @item set symbol-reloading off
7921 Do not replace symbol definitions when re-encountering object files of
7922 the same name. This is the default state; if you are not running on a
7923 system that permits automatically relinking modules, you should leave
7924 @code{symbol-reloading} off, since otherwise @value{GDBN} may discard symbols
7925 when linking large programs, that may contain several modules (from
7926 different directories or libraries) with the same name.
7928 @item show symbol-reloading
7929 Show the current @code{on} or @code{off} setting.
7933 @chapter Canned Sequences of Commands
7935 Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint
7936 command lists}), @value{GDBN} provides two ways to store sequences of commands
7937 for execution as a unit: user-defined commands and command files.
7940 * Define:: User-defined commands
7941 * Hooks:: User-defined command hooks
7942 * Command Files:: Command files
7943 * Output:: Commands for controlled output
7947 @section User-defined commands
7949 @cindex user-defined command
7950 A @dfn{user-defined command} is a sequence of @value{GDBN} commands to which you
7951 assign a new name as a command. This is done with the @code{define}
7955 @item define @var{commandname}
7957 Define a command named @var{commandname}. If there is already a command
7958 by that name, you are asked to confirm that you want to redefine it.
7960 The definition of the command is made up of other @value{GDBN} command lines,
7961 which are given following the @code{define} command. The end of these
7962 commands is marked by a line containing @code{end}.
7964 @item document @var{commandname}
7966 Give documentation to the user-defined command @var{commandname}. The
7967 command @var{commandname} must already be defined. This command reads
7968 lines of documentation just as @code{define} reads the lines of the
7969 command definition, ending with @code{end}. After the @code{document}
7970 command is finished, @code{help} on command @var{commandname} will print
7971 the documentation you have specified.
7973 You may use the @code{document} command again to change the
7974 documentation of a command. Redefining the command with @code{define}
7975 does not change the documentation.
7977 @item help user-defined
7978 @kindex help user-defined
7979 List all user-defined commands, with the first line of the documentation
7983 @itemx show user @var{commandname}
7985 Display the @value{GDBN} commands used to define @var{commandname} (but not its
7986 documentation). If no @var{commandname} is given, display the
7987 definitions for all user-defined commands.
7990 User-defined commands do not take arguments. When they are executed, the
7991 commands of the definition are not printed. An error in any command
7992 stops execution of the user-defined command.
7994 Commands that would ask for confirmation if used interactively proceed
7995 without asking when used inside a user-defined command. Many @value{GDBN} commands
7996 that normally print messages to say what they are doing omit the messages
7997 when used in a user-defined command.
8000 @section User-defined command hooks
8001 @cindex command files
8003 You may define @emph{hooks}, which are a special kind of user-defined
8004 command. Whenever you run the command @samp{foo}, if the user-defined
8005 command @samp{hook-foo} exists, it is executed (with no arguments)
8006 before that command.
8008 In addition, a pseudo-command, @samp{stop} exists. Hooking this command
8009 will cause your hook to be executed every time execution stops in the
8010 inferior program, before breakpoint commands are run, displays are
8011 printed, or the stack frame is printed.
8013 For example, to cause @code{SIGALRM} signals to be ignored while
8014 single-stepping, but cause them to be resumed during normal execution,
8019 handle SIGALRM nopass
8026 define hook-continue
8031 Any single-word command in GDB can be hooked. Aliases for other commands
8032 cannot be hooked (you should hook the basic command name, e.g. @code{backtrace}
8033 rather than @code{bt}). If an error occurs during the execution of your
8034 hook, execution of GDB commands stops and you are returned to the GDB
8035 prompt (before the command that you actually typed had a chance to run).
8037 If you try to define a hook which does not match any known command, you
8038 will get a warning from the @code{define} command.
8041 @section Command files
8043 @cindex command files
8044 A command file for @value{GDBN} is a file of lines that are @value{GDBN} commands. Comments
8045 (lines starting with @kbd{#}) may also be included. An empty line in a
8046 command file does nothing; it does not mean to repeat the last command, as
8047 it would from the terminal.
8050 @cindex @file{@value{GDBINIT}}
8051 When you start @value{GDBN}, it automatically executes commands from its
8052 @dfn{init files}. These are files named @file{@value{GDBINIT}}. @value{GDBN} reads
8053 the init file (if any) in your home directory and then the init file
8054 (if any) in the current working directory. (The init files are not
8055 executed if you use the @samp{-nx} option; @pxref{Mode Options,
8056 ,Choosing modes}.) You can also request the execution of a command
8057 file with the @code{source} command:
8060 @item source @var{filename}
8062 Execute the command file @var{filename}.
8065 The lines in a command file are executed sequentially. They are not
8066 printed as they are executed. An error in any command terminates execution
8067 of the command file.
8069 Commands that would ask for confirmation if used interactively proceed
8070 without asking when used in a command file. Many @value{GDBN} commands that
8071 normally print messages to say what they are doing omit the messages
8072 when called from command files.
8075 @section Commands for controlled output
8077 During the execution of a command file or a user-defined command, normal
8078 @value{GDBN} output is suppressed; the only output that appears is what is
8079 explicitly printed by the commands in the definition. This section
8080 describes three commands useful for generating exactly the output you
8084 @item echo @var{text}
8086 @c I do not consider backslash-space a standard C escape sequence
8087 @c because it is not in ANSI.
8088 Print @var{text}. Nonprinting characters can be included in
8089 @var{text} using C escape sequences, such as @samp{\n} to print a
8090 newline. @strong{No newline will be printed unless you specify one.}
8091 In addition to the standard C escape sequences, a backslash followed
8092 by a space stands for a space. This is useful for displaying a
8093 string with spaces at the beginning or the end, since leading and
8094 trailing spaces are otherwise trimmed from all arguments.
8095 To print @samp{@w{ }and foo =@w{ }}, use the command
8096 @samp{echo \@w{ }and foo = \@w{ }}.
8098 A backslash at the end of @var{text} can be used, as in C, to continue
8099 the command onto subsequent lines. For example,
8102 echo This is some text\n\
8103 which is continued\n\
8104 onto several lines.\n
8107 produces the same output as
8110 echo This is some text\n
8111 echo which is continued\n
8112 echo onto several lines.\n
8115 @item output @var{expression}
8117 Print the value of @var{expression} and nothing but that value: no
8118 newlines, no @samp{$@var{nn} = }. The value is not entered in the
8119 value history either. @xref{Expressions, ,Expressions}, for more information on
8122 @item output/@var{fmt} @var{expression}
8123 Print the value of @var{expression} in format @var{fmt}. You can use
8124 the same formats as for @code{print}. @xref{Output Formats,,Output
8125 formats}, for more information.
8127 @item printf @var{string}, @var{expressions}@dots{}
8129 Print the values of the @var{expressions} under the control of
8130 @var{string}. The @var{expressions} are separated by commas and may
8131 be either numbers or pointers. Their values are printed as specified
8132 by @var{string}, exactly as if your program were to execute
8135 printf (@var{string}, @var{expressions}@dots{});
8138 For example, you can print two values in hex like this:
8141 printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
8144 The only backslash-escape sequences that you can use in the format
8145 string are the simple ones that consist of backslash followed by a
8151 @chapter Using @value{GDBN} under GNU Emacs
8154 A special interface allows you to use GNU Emacs to view (and
8155 edit) the source files for the program you are debugging with
8158 To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
8159 executable file you want to debug as an argument. This command starts
8160 @value{GDBN} as a subprocess of Emacs, with input and output through a newly
8161 created Emacs buffer.
8163 Using @value{GDBN} under Emacs is just like using @value{GDBN} normally except for two
8168 All ``terminal'' input and output goes through the Emacs buffer.
8171 This applies both to @value{GDBN} commands and their output, and to the input
8172 and output done by the program you are debugging.
8174 This is useful because it means that you can copy the text of previous
8175 commands and input them again; you can even use parts of the output
8178 All the facilities of Emacs' Shell mode are available for interacting
8179 with your program. In particular, you can send signals the usual
8180 way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a
8185 @value{GDBN} displays source code through Emacs.
8188 Each time @value{GDBN} displays a stack frame, Emacs automatically finds the
8189 source file for that frame and puts an arrow (@samp{=>}) at the
8190 left margin of the current line. Emacs uses a separate buffer for
8191 source display, and splits the screen to show both your @value{GDBN} session
8194 Explicit @value{GDBN} @code{list} or search commands still produce output as
8195 usual, but you probably will have no reason to use them.
8198 @emph{Warning:} If the directory where your program resides is not your
8199 current directory, it can be easy to confuse Emacs about the location of
8200 the source files, in which case the auxiliary display buffer will not
8201 appear to show your source. @value{GDBN} can find programs by searching your
8202 environment's @code{PATH} variable, so the @value{GDBN} input and output
8203 session will proceed normally; but Emacs does not get enough information
8204 back from @value{GDBN} to locate the source files in this situation. To
8205 avoid this problem, either start @value{GDBN} mode from the directory where
8206 your program resides, or specify a full path name when prompted for the
8207 @kbd{M-x gdb} argument.
8209 A similar confusion can result if you use the @value{GDBN} @code{file} command to
8210 switch to debugging a program in some other location, from an existing
8211 @value{GDBN} buffer in Emacs.
8214 By default, @kbd{M-x gdb} calls the program called @file{gdb}. If
8215 you need to call @value{GDBN} by a different name (for example, if you keep
8216 several configurations around, with different names) you can set the
8217 Emacs variable @code{gdb-command-name}; for example,
8220 (setq gdb-command-name "mygdb")
8224 (preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or
8225 in your @file{.emacs} file) will make Emacs call the program named
8226 ``@code{mygdb}'' instead.
8228 In the @value{GDBN} I/O buffer, you can use these special Emacs commands in
8229 addition to the standard Shell mode commands:
8233 Describe the features of Emacs' @value{GDBN} Mode.
8236 Execute to another source line, like the @value{GDBN} @code{step} command; also
8237 update the display window to show the current file and location.
8240 Execute to next source line in this function, skipping all function
8241 calls, like the @value{GDBN} @code{next} command. Then update the display window
8242 to show the current file and location.
8245 Execute one instruction, like the @value{GDBN} @code{stepi} command; update
8246 display window accordingly.
8249 Execute to next instruction, using the @value{GDBN} @code{nexti} command; update
8250 display window accordingly.
8253 Execute until exit from the selected stack frame, like the @value{GDBN}
8254 @code{finish} command.
8257 Continue execution of your program, like the @value{GDBN} @code{continue}
8260 @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}.
8263 Go up the number of frames indicated by the numeric argument
8264 (@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}),
8265 like the @value{GDBN} @code{up} command.
8267 @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-u}.
8270 Go down the number of frames indicated by the numeric argument, like the
8271 @value{GDBN} @code{down} command.
8273 @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-d}.
8276 Read the number where the cursor is positioned, and insert it at the end
8277 of the @value{GDBN} I/O buffer. For example, if you wish to disassemble code
8278 around an address that was displayed earlier, type @kbd{disassemble};
8279 then move the cursor to the address display, and pick up the
8280 argument for @code{disassemble} by typing @kbd{C-x &}.
8282 You can customize this further by defining elements of the list
8283 @code{gdb-print-command}; once it is defined, you can format or
8284 otherwise process numbers picked up by @kbd{C-x &} before they are
8285 inserted. A numeric argument to @kbd{C-x &} will both indicate that you
8286 wish special formatting, and act as an index to pick an element of the
8287 list. If the list element is a string, the number to be inserted is
8288 formatted using the Emacs function @code{format}; otherwise the number
8289 is passed as an argument to the corresponding list element.
8292 In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break})
8293 tells @value{GDBN} to set a breakpoint on the source line point is on.
8295 If you accidentally delete the source-display buffer, an easy way to get
8296 it back is to type the command @code{f} in the @value{GDBN} buffer, to
8297 request a frame display; when you run under Emacs, this will recreate
8298 the source buffer if necessary to show you the context of the current
8301 The source files displayed in Emacs are in ordinary Emacs buffers
8302 which are visiting the source files in the usual way. You can edit
8303 the files with these buffers if you wish; but keep in mind that @value{GDBN}
8304 communicates with Emacs in terms of line numbers. If you add or
8305 delete lines from the text, the line numbers that @value{GDBN} knows will cease
8306 to correspond properly with the code.
8308 @c The following dropped because Epoch is nonstandard. Reactivate
8309 @c if/when v19 does something similar. ---pesch@cygnus.com 19dec1990
8311 @kindex emacs epoch environment
8315 Version 18 of Emacs has a built-in window system called the @code{epoch}
8316 environment. Users of this environment can use a new command,
8317 @code{inspect} which performs identically to @code{print} except that
8318 each value is printed in its own window.
8324 @chapter Using @value{GDBN} with Energize
8327 The Energize Programming System is an integrated development environment
8328 that includes a point-and-click interface to many programming tools.
8329 When you use @value{GDBN} in this environment, you can use the standard
8330 Energize graphical interface to drive @value{GDBN}; you can also, if you
8331 choose, type @value{GDBN} commands as usual in a debugging window. Even if
8332 you use the graphical interface, the debugging window (which uses Emacs,
8333 and resembles the standard Emacs interface to @value{GDBN}) displays the
8334 equivalent commands, so that the history of your debugging session is
8337 When Energize starts up a @value{GDBN} session, it uses one of the
8338 command-line options @samp{-energize} or @samp{-cadillac} (``cadillac''
8339 is the name of the communications protocol used by the Energize system).
8340 This option makes @value{GDBN} run as one of the tools in the Energize Tool
8341 Set: it sends all output to the Energize kernel, and accept input from
8344 See the user manual for the Energize Programming System for
8345 information on how to use the Energize graphical interface and the other
8346 development tools that Energize integrates with @value{GDBN}.
8351 @chapter Reporting Bugs in @value{GDBN}
8352 @cindex bugs in @value{GDBN}
8353 @cindex reporting bugs in @value{GDBN}
8355 Your bug reports play an essential role in making @value{GDBN} reliable.
8357 Reporting a bug may help you by bringing a solution to your problem, or it
8358 may not. But in any case the principal function of a bug report is to help
8359 the entire community by making the next version of @value{GDBN} work better. Bug
8360 reports are your contribution to the maintenance of @value{GDBN}.
8362 In order for a bug report to serve its purpose, you must include the
8363 information that enables us to fix the bug.
8366 * Bug Criteria:: Have you found a bug?
8367 * Bug Reporting:: How to report bugs
8371 @section Have you found a bug?
8372 @cindex bug criteria
8374 If you are not sure whether you have found a bug, here are some guidelines:
8378 @cindex fatal signal
8380 If the debugger gets a fatal signal, for any input whatever, that is a
8381 @value{GDBN} bug. Reliable debuggers never crash.
8384 @cindex error on valid input
8385 If @value{GDBN} produces an error message for valid input, that is a bug.
8388 @cindex invalid input
8389 If @value{GDBN} does not produce an error message for invalid input,
8390 that is a bug. However, you should note that your idea of
8391 ``invalid input'' might be our idea of ``an extension'' or ``support
8392 for traditional practice''.
8395 If you are an experienced user of debugging tools, your suggestions
8396 for improvement of @value{GDBN} are welcome in any case.
8400 @section How to report bugs
8402 @cindex @value{GDBN} bugs, reporting
8404 A number of companies and individuals offer support for GNU products.
8405 If you obtained @value{GDBN} from a support organization, we recommend you
8406 contact that organization first.
8408 You can find contact information for many support companies and
8409 individuals in the file @file{etc/SERVICE} in the GNU Emacs
8412 In any event, we also recommend that you send bug reports for @value{GDBN} to one
8416 bug-gdb@@prep.ai.mit.edu
8417 @{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb
8420 @strong{Do not send bug reports to @samp{info-gdb}, or to
8421 @samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do not want to
8422 receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}.
8424 The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which
8425 serves as a repeater. The mailing list and the newsgroup carry exactly
8426 the same messages. Often people think of posting bug reports to the
8427 newsgroup instead of mailing them. This appears to work, but it has one
8428 problem which can be crucial: a newsgroup posting often lacks a mail
8429 path back to the sender. Thus, if we need to ask for more information,
8430 we may be unable to reach you. For this reason, it is better to send
8431 bug reports to the mailing list.
8433 As a last resort, send bug reports on paper to:
8437 Free Software Foundation
8442 The fundamental principle of reporting bugs usefully is this:
8443 @strong{report all the facts}. If you are not sure whether to state a
8444 fact or leave it out, state it!
8446 Often people omit facts because they think they know what causes the
8447 problem and assume that some details do not matter. Thus, you might
8448 assume that the name of the variable you use in an example does not matter.
8449 Well, probably it does not, but one cannot be sure. Perhaps the bug is a
8450 stray memory reference which happens to fetch from the location where that
8451 name is stored in memory; perhaps, if the name were different, the contents
8452 of that location would fool the debugger into doing the right thing despite
8453 the bug. Play it safe and give a specific, complete example. That is the
8454 easiest thing for you to do, and the most helpful.
8456 Keep in mind that the purpose of a bug report is to enable us to fix
8457 the bug if it is new to us. It is not as important as what happens if
8458 the bug is already known. Therefore, always write your bug reports on
8459 the assumption that the bug has not been reported previously.
8461 Sometimes people give a few sketchy facts and ask, ``Does this ring a
8462 bell?'' Those bug reports are useless, and we urge everyone to
8463 @emph{refuse to respond to them} except to chide the sender to report
8466 To enable us to fix the bug, you should include all these things:
8470 The version of @value{GDBN}. @value{GDBN} announces it if you start with no
8471 arguments; you can also print it at any time using @code{show version}.
8473 Without this, we will not know whether there is any point in looking for
8474 the bug in the current version of @value{GDBN}.
8477 The type of machine you are using, and the operating system name and
8481 What compiler (and its version) was used to compile @value{GDBN}---e.g.
8482 ``@value{GCC}--2.0''.
8485 What compiler (and its version) was used to compile the program you
8486 are debugging---e.g. ``@value{GCC}--2.0''.
8489 The command arguments you gave the compiler to compile your example and
8490 observe the bug. For example, did you use @samp{-O}? To guarantee
8491 you will not omit something important, list them all. A copy of the
8492 Makefile (or the output from make) is sufficient.
8494 If we were to try to guess the arguments, we would probably guess wrong
8495 and then we might not encounter the bug.
8498 A complete input script, and all necessary source files, that will
8502 A description of what behavior you observe that you believe is
8503 incorrect. For example, ``It gets a fatal signal.''
8505 Of course, if the bug is that @value{GDBN} gets a fatal signal, then we will
8506 certainly notice it. But if the bug is incorrect output, we might not
8507 notice unless it is glaringly wrong. We are human, after all. You
8508 might as well not give us a chance to make a mistake.
8510 Even if the problem you experience is a fatal signal, you should still
8511 say so explicitly. Suppose something strange is going on, such as,
8512 your copy of @value{GDBN} is out of synch, or you have encountered a
8513 bug in the C library on your system. (This has happened!) Your copy
8514 might crash and ours would not. If you told us to expect a crash,
8515 then when ours fails to crash, we would know that the bug was not
8516 happening for us. If you had not told us to expect a crash, then we
8517 would not be able to draw any conclusion from our observations.
8520 If you wish to suggest changes to the @value{GDBN} source, send us context
8521 diffs. If you even discuss something in the @value{GDBN} source, refer to
8522 it by context, not by line number.
8524 The line numbers in our development sources will not match those in your
8525 sources. Your line numbers would convey no useful information to us.
8528 Here are some things that are not necessary:
8532 A description of the envelope of the bug.
8534 Often people who encounter a bug spend a lot of time investigating
8535 which changes to the input file will make the bug go away and which
8536 changes will not affect it.
8538 This is often time consuming and not very useful, because the way we
8539 will find the bug is by running a single example under the debugger
8540 with breakpoints, not by pure deduction from a series of examples.
8541 We recommend that you save your time for something else.
8543 Of course, if you can find a simpler example to report @emph{instead}
8544 of the original one, that is a convenience for us. Errors in the
8545 output will be easier to spot, running under the debugger will take
8548 However, simplification is not vital; if you do not want to do this,
8549 report the bug anyway and send us the entire test case you used.
8552 A patch for the bug.
8554 A patch for the bug does help us if it is a good one. But do not omit
8555 the necessary information, such as the test case, on the assumption that
8556 a patch is all we need. We might see problems with your patch and decide
8557 to fix the problem another way, or we might not understand it at all.
8559 Sometimes with a program as complicated as @value{GDBN} it is very hard to
8560 construct an example that will make the program follow a certain path
8561 through the code. If you do not send us the example, we will not be able
8562 to construct one, so we will not be able to verify that the bug is fixed.
8564 And if we cannot understand what bug you are trying to fix, or why your
8565 patch should be an improvement, we will not install it. A test case will
8566 help us to understand.
8569 A guess about what the bug is or what it depends on.
8571 Such guesses are usually wrong. Even we cannot guess right about such
8572 things without first using the debugger to find the facts.
8575 @ifset have-readline-appendices
8576 @include rluser.texinfo
8577 @include inc-hist.texi
8581 @node Renamed Commands
8582 @appendix Renamed Commands
8584 The following commands were renamed in GDB 4, in order to make the
8585 command set as a whole more consistent and easier to use and remember:
8588 @kindex delete environment
8589 @kindex info copying
8590 @kindex info convenience
8591 @kindex info directories
8592 @kindex info editing
8593 @kindex info history
8594 @kindex info targets
8596 @kindex info version
8597 @kindex info warranty
8598 @kindex set addressprint
8599 @kindex set arrayprint
8600 @kindex set prettyprint
8601 @kindex set screen-height
8602 @kindex set screen-width
8603 @kindex set unionprint
8604 @kindex set vtblprint
8605 @kindex set demangle
8606 @kindex set asm-demangle
8607 @kindex set sevenbit-strings
8608 @kindex set array-max
8610 @kindex set history write
8611 @kindex show addressprint
8612 @kindex show arrayprint
8613 @kindex show prettyprint
8614 @kindex show screen-height
8615 @kindex show screen-width
8616 @kindex show unionprint
8617 @kindex show vtblprint
8618 @kindex show demangle
8619 @kindex show asm-demangle
8620 @kindex show sevenbit-strings
8621 @kindex show array-max
8622 @kindex show caution
8623 @kindex show history write
8628 @c END TEXI2ROFF-KILL
8630 OLD COMMAND NEW COMMAND
8632 --------------- -------------------------------
8633 @c END TEXI2ROFF-KILL
8634 add-syms add-symbol-file
8635 delete environment unset environment
8636 info convenience show convenience
8637 info copying show copying
8638 info directories show directories
8639 info editing show commands
8640 info history show values
8641 info targets help target
8642 info values show values
8643 info version show version
8644 info warranty show warranty
8645 set/show addressprint set/show print address
8646 set/show array-max set/show print elements
8647 set/show arrayprint set/show print array
8648 set/show asm-demangle set/show print asm-demangle
8649 set/show caution set/show confirm
8650 set/show demangle set/show print demangle
8651 set/show history write set/show history save
8652 set/show prettyprint set/show print pretty
8653 set/show screen-height set/show height
8654 set/show screen-width set/show width
8655 set/show sevenbit-strings set/show print sevenbit-strings
8656 set/show unionprint set/show print union
8657 set/show vtblprint set/show print vtbl
8659 unset [No longer an alias for delete]
8665 \vskip \parskip\vskip \baselineskip
8666 \halign{\tt #\hfil &\qquad#&\tt #\hfil\cr
8667 {\bf Old Command} &&{\bf New Command}\cr
8668 add-syms &&add-symbol-file\cr
8669 delete environment &&unset environment\cr
8670 info convenience &&show convenience\cr
8671 info copying &&show copying\cr
8672 info directories &&show directories \cr
8673 info editing &&show commands\cr
8674 info history &&show values\cr
8675 info targets &&help target\cr
8676 info values &&show values\cr
8677 info version &&show version\cr
8678 info warranty &&show warranty\cr
8679 set{\rm / }show addressprint &&set{\rm / }show print address\cr
8680 set{\rm / }show array-max &&set{\rm / }show print elements\cr
8681 set{\rm / }show arrayprint &&set{\rm / }show print array\cr
8682 set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr
8683 set{\rm / }show caution &&set{\rm / }show confirm\cr
8684 set{\rm / }show demangle &&set{\rm / }show print demangle\cr
8685 set{\rm / }show history write &&set{\rm / }show history save\cr
8686 set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr
8687 set{\rm / }show screen-height &&set{\rm / }show height\cr
8688 set{\rm / }show screen-width &&set{\rm / }show width\cr
8689 set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr
8690 set{\rm / }show unionprint &&set{\rm / }show print union\cr
8691 set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr
8693 unset &&\rm(No longer an alias for delete)\cr
8696 @c END TEXI2ROFF-KILL
8699 @ifclear PRECONFIGURED
8700 @node Formatting Documentation
8701 @appendix Formatting Documentation
8703 @cindex GDB reference card
8704 @cindex reference card
8705 The GDB 4 release includes an already-formatted reference card, ready
8706 for printing with PostScript or GhostScript, in the @file{gdb}
8707 subdirectory of the main source directory@footnote{In
8708 @file{gdb-@value{GDBVN}/gdb/refcard.ps} of the version @value{GDBVN}
8709 release.}. If you can use PostScript or GhostScript with your printer,
8710 you can print the reference card immediately with @file{refcard.ps}.
8712 The release also includes the source for the reference card. You
8713 can format it, using @TeX{}, by typing:
8719 The GDB reference card is designed to print in landscape mode on US
8720 ``letter'' size paper; that is, on a sheet 11 inches wide by 8.5 inches
8721 high. You will need to specify this form of printing as an option to
8722 your @sc{dvi} output program.
8724 @cindex documentation
8726 All the documentation for GDB comes as part of the machine-readable
8727 distribution. The documentation is written in Texinfo format, which is
8728 a documentation system that uses a single source file to produce both
8729 on-line information and a printed manual. You can use one of the Info
8730 formatting commands to create the on-line version of the documentation
8731 and @TeX{} (or @code{texi2roff}) to typeset the printed version.
8733 GDB includes an already formatted copy of the on-line Info version of
8734 this manual in the @file{gdb} subdirectory. The main Info file is
8735 @file{gdb-@var{version-number}/gdb/gdb.info}, and it refers to
8736 subordinate files matching @samp{gdb.info*} in the same directory. If
8737 necessary, you can print out these files, or read them with any editor;
8738 but they are easier to read using the @code{info} subsystem in GNU Emacs
8739 or the standalone @code{info} program, available as part of the GNU
8740 Texinfo distribution.
8742 If you want to format these Info files yourself, you need one of the
8743 Info formatting programs, such as @code{texinfo-format-buffer} or
8746 If you have @code{makeinfo} installed, and are in the top level GDB
8747 source directory (@file{gdb-@value{GDBVN}}, in the case of version @value{GDBVN}), you can
8748 make the Info file by typing:
8755 If you want to typeset and print copies of this manual, you need @TeX{},
8756 a program to print its @sc{dvi} output files, and @file{texinfo.tex}, the
8757 Texinfo definitions file.
8759 @TeX{} is a typesetting program; it does not print files directly, but
8760 produces output files called @sc{dvi} files. To print a typeset
8761 document, you need a program to print @sc{dvi} files. If your system
8762 has @TeX{} installed, chances are it has such a program. The precise
8763 command to use depends on your system; @kbd{lpr -d} is common; another
8764 (for PostScript devices) is @kbd{dvips}. The @sc{dvi} print command may
8765 require a file name without any extension or a @samp{.dvi} extension.
8767 @TeX{} also requires a macro definitions file called
8768 @file{texinfo.tex}. This file tells @TeX{} how to typeset a document
8769 written in Texinfo format. On its own, @TeX{} cannot read, much less
8770 typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB
8771 and is located in the @file{gdb-@var{version-number}/texinfo}
8774 If you have @TeX{} and a @sc{dvi} printer program installed, you can
8775 typeset and print this manual. First switch to the the @file{gdb}
8776 subdirectory of the main source directory (for example, to
8777 @file{gdb-@value{GDBVN}/gdb}) and then type:
8783 @node Installing GDB
8784 @appendix Installing GDB
8785 @cindex configuring GDB
8786 @cindex installation
8788 GDB comes with a @code{configure} script that automates the process
8789 of preparing GDB for installation; you can then use @code{make} to
8790 build the @code{gdb} program.
8792 @c irrelevant in info file; it's as current as the code it lives with.
8793 @footnote{If you have a more recent version of GDB than @value{GDBVN},
8794 look at the @file{README} file in the sources; we may have improved the
8795 installation procedures since publishing this manual.}
8798 The GDB distribution includes all the source code you need for GDB in
8799 a single directory, whose name is usually composed by appending the
8800 version number to @samp{gdb}.
8802 For example, the GDB version @value{GDBVN} distribution is in the
8803 @file{gdb-@value{GDBVN}} directory. That directory contains:
8806 @item gdb-@value{GDBVN}/configure @r{(and supporting files)}
8807 script for configuring GDB and all its supporting libraries.
8809 @item gdb-@value{GDBVN}/gdb
8810 the source specific to GDB itself
8812 @item gdb-@value{GDBVN}/bfd
8813 source for the Binary File Descriptor library
8815 @item gdb-@value{GDBVN}/include
8818 @item gdb-@value{GDBVN}/libiberty
8819 source for the @samp{-liberty} free software library
8821 @item gdb-@value{GDBVN}/opcodes
8822 source for the library of opcode tables and disassemblers
8824 @item gdb-@value{GDBVN}/readline
8825 source for the GNU command-line interface
8827 @item gdb-@value{GDBVN}/glob
8828 source for the GNU filename pattern-matching subroutine
8830 @item gdb-@value{GDBVN}/mmalloc
8831 source for the GNU memory-mapped malloc package
8834 The simplest way to configure and build GDB is to run @code{configure}
8835 from the @file{gdb-@var{version-number}} source directory, which in
8836 this example is the @file{gdb-@value{GDBVN}} directory.
8838 First switch to the @file{gdb-@var{version-number}} source directory
8839 if you are not already in it; then run @code{configure}. Pass the
8840 identifier for the platform on which GDB will run as an
8846 cd gdb-@value{GDBVN}
8847 ./configure @var{host}
8852 where @var{host} is an identifier such as @samp{sun4} or
8853 @samp{decstation}, that identifies the platform where GDB will run.
8855 Running @samp{configure @var{host}} followed by @code{make} builds the
8856 @file{bfd}, @file{readline}, @file{mmalloc}, and @file{libiberty}
8857 libraries, then @code{gdb} itself. The configured source files, and the
8858 binaries, are left in the corresponding source directories.
8860 @code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your
8861 system does not recognize this automatically when you run a different
8862 shell, you may need to run @code{sh} on it explicitly:
8865 sh configure @var{host}
8868 If you run @code{configure} from a directory that contains source
8869 directories for multiple libraries or programs, such as the
8870 @file{gdb-@value{GDBVN}} source directory for version @value{GDBVN}, @code{configure}
8871 creates configuration files for every directory level underneath (unless
8872 you tell it not to, with the @samp{--norecursion} option).
8874 You can run the @code{configure} script from any of the
8875 subordinate directories in the GDB distribution, if you only want to
8876 configure that subdirectory; but be sure to specify a path to it.
8878 For example, with version @value{GDBVN}, type the following to configure only
8879 the @code{bfd} subdirectory:
8883 cd gdb-@value{GDBVN}/bfd
8884 ../configure @var{host}
8888 You can install @code{@value{GDBP}} anywhere; it has no hardwired paths.
8889 However, you should make sure that the shell on your path (named by
8890 the @samp{SHELL} environment variable) is publicly readable. Remember
8891 that GDB uses the shell to start your program---some systems refuse to
8892 let GDB debug child processes whose programs are not readable.
8895 * Separate Objdir:: Compiling GDB in another directory
8896 * Config Names:: Specifying names for hosts and targets
8897 * configure Options:: Summary of options for configure
8900 @node Separate Objdir
8901 @section Compiling GDB in another directory
8903 If you want to run GDB versions for several host or target machines,
8904 you need a different @code{gdb} compiled for each combination of
8905 host and target. @code{configure} is designed to make this easy by
8906 allowing you to generate each configuration in a separate subdirectory,
8907 rather than in the source directory. If your @code{make} program
8908 handles the @samp{VPATH} feature (GNU @code{make} does), running
8909 @code{make} in each of these directories builds the @code{gdb}
8910 program specified there.
8912 To build @code{gdb} in a separate directory, run @code{configure}
8913 with the @samp{--srcdir} option to specify where to find the source.
8914 (You also need to specify a path to find @code{configure}
8915 itself from your working directory. If the path to @code{configure}
8916 would be the same as the argument to @samp{--srcdir}, you can leave out
8917 the @samp{--srcdir} option; it will be assumed.)
8919 For example, with version @value{GDBVN}, you can build GDB in a separate
8920 directory for a Sun 4 like this:
8924 cd gdb-@value{GDBVN}
8927 ../gdb-@value{GDBVN}/configure sun4
8932 When @code{configure} builds a configuration using a remote source
8933 directory, it creates a tree for the binaries with the same structure
8934 (and using the same names) as the tree under the source directory. In
8935 the example, you'd find the Sun 4 library @file{libiberty.a} in the
8936 directory @file{gdb-sun4/libiberty}, and GDB itself in
8937 @file{gdb-sun4/gdb}.
8939 One popular reason to build several GDB configurations in separate
8940 directories is to configure GDB for cross-compiling (where GDB
8941 runs on one machine---the host---while debugging programs that run on
8942 another machine---the target). You specify a cross-debugging target by
8943 giving the @samp{--target=@var{target}} option to @code{configure}.
8945 When you run @code{make} to build a program or library, you must run
8946 it in a configured directory---whatever directory you were in when you
8947 called @code{configure} (or one of its subdirectories).
8949 The @code{Makefile} that @code{configure} generates in each source
8950 directory also runs recursively. If you type @code{make} in a source
8951 directory such as @file{gdb-@value{GDBVN}} (or in a separate configured
8952 directory configured with @samp{--srcdir=@var{path}/gdb-@value{GDBVN}}), you
8953 will build all the required libraries, and then build GDB.
8955 When you have multiple hosts or targets configured in separate
8956 directories, you can run @code{make} on them in parallel (for example,
8957 if they are NFS-mounted on each of the hosts); they will not interfere
8961 @section Specifying names for hosts and targets
8963 The specifications used for hosts and targets in the @code{configure}
8964 script are based on a three-part naming scheme, but some short predefined
8965 aliases are also supported. The full naming scheme encodes three pieces
8966 of information in the following pattern:
8969 @var{architecture}-@var{vendor}-@var{os}
8972 For example, you can use the alias @code{sun4} as a @var{host} argument
8973 or in a @code{--target=@var{target}} option. The equivalent full name
8974 is @samp{sparc-sun-sunos4}.
8976 The @code{configure} script accompanying GDB does not provide
8977 any query facility to list all supported host and target names or
8978 aliases. @code{configure} calls the Bourne shell script
8979 @code{config.sub} to map abbreviations to full names; you can read the
8980 script, if you wish, or you can use it to test your guesses on
8981 abbreviations---for example:
8984 % sh config.sub sun4
8986 % sh config.sub sun3
8988 % sh config.sub decstation
8990 % sh config.sub hp300bsd
8992 % sh config.sub i386v
8994 % sh config.sub i786v
8995 Invalid configuration `i786v': machine `i786v' not recognized
8999 @code{config.sub} is also distributed in the GDB source
9000 directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}).
9002 @node configure Options
9003 @section @code{configure} options
9005 Here is a summary of the @code{configure} options and arguments that
9006 are most often useful for building @value{GDBN}. @code{configure} also has
9007 several other options not listed here. @inforef{What Configure
9008 Does,,configure.info}, for a full explanation of @code{configure}.
9009 @c FIXME: Would this be more, or less, useful as an xref (ref to printed
9010 @c manual in the printed manual, ref to info file only from the info file)?
9013 configure @r{[}--help@r{]}
9014 @r{[}--prefix=@var{dir}@r{]}
9015 @r{[}--srcdir=@var{path}@r{]}
9016 @r{[}--norecursion@r{]} @r{[}--rm@r{]}
9017 @r{[}--target=@var{target}@r{]} @var{host}
9021 You may introduce options with a single @samp{-} rather than
9022 @samp{--} if you prefer; but you may abbreviate option names if you use
9027 Display a quick summary of how to invoke @code{configure}.
9029 @item -prefix=@var{dir}
9030 Configure the source to install programs and files under directory
9033 @item --srcdir=@var{path}
9034 @strong{Warning: using this option requires GNU @code{make}, or another
9035 @code{make} that implements the @code{VPATH} feature.}@*
9036 Use this option to make configurations in directories separate from the
9037 GDB source directories. Among other things, you can use this to
9038 build (or maintain) several configurations simultaneously, in separate
9039 directories. @code{configure} writes configuration specific files in
9040 the current directory, but arranges for them to use the source in the
9041 directory @var{path}. @code{configure} will create directories under
9042 the working directory in parallel to the source directories below
9046 Configure only the directory level where @code{configure} is executed; do not
9047 propagate configuration to subdirectories.
9050 Remove the configuration that the other arguments specify.
9052 @c This does not work (yet if ever). FIXME.
9053 @c @item --parse=@var{lang} @dots{}
9054 @c Configure the GDB expression parser to parse the listed languages.
9055 @c @samp{all} configures GDB for all supported languages. To get a
9056 @c list of all supported languages, omit the argument. Without this
9057 @c option, GDB is configured to parse all supported languages.
9059 @item --target=@var{target}
9060 Configure GDB for cross-debugging programs running on the specified
9061 @var{target}. Without this option, GDB is configured to debug
9062 programs that run on the same machine (@var{host}) as GDB itself.
9064 There is no convenient way to generate a list of all available targets.
9066 @item @var{host} @dots{}
9067 Configure GDB to run on the specified @var{host}.
9069 There is no convenient way to generate a list of all available hosts.
9073 @code{configure} accepts other options, for compatibility with
9074 configuring other GNU tools recursively; but these are the only
9075 options that affect GDB or its supporting libraries.
9078 @ifclear AGGLOMERATION
9080 @unnumbered GNU GENERAL PUBLIC LICENSE
9081 @center Version 2, June 1991
9084 Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
9085 675 Mass Ave, Cambridge, MA 02139, USA
9087 Everyone is permitted to copy and distribute verbatim copies
9088 of this license document, but changing it is not allowed.
9091 @unnumberedsec Preamble
9093 The licenses for most software are designed to take away your
9094 freedom to share and change it. By contrast, the GNU General Public
9095 License is intended to guarantee your freedom to share and change free
9096 software---to make sure the software is free for all its users. This
9097 General Public License applies to most of the Free Software
9098 Foundation's software and to any other program whose authors commit to
9099 using it. (Some other Free Software Foundation software is covered by
9100 the GNU Library General Public License instead.) You can apply it to
9103 When we speak of free software, we are referring to freedom, not
9104 price. Our General Public Licenses are designed to make sure that you
9105 have the freedom to distribute copies of free software (and charge for
9106 this service if you wish), that you receive source code or can get it
9107 if you want it, that you can change the software or use pieces of it
9108 in new free programs; and that you know you can do these things.
9110 To protect your rights, we need to make restrictions that forbid
9111 anyone to deny you these rights or to ask you to surrender the rights.
9112 These restrictions translate to certain responsibilities for you if you
9113 distribute copies of the software, or if you modify it.
9115 For example, if you distribute copies of such a program, whether
9116 gratis or for a fee, you must give the recipients all the rights that
9117 you have. You must make sure that they, too, receive or can get the
9118 source code. And you must show them these terms so they know their
9121 We protect your rights with two steps: (1) copyright the software, and
9122 (2) offer you this license which gives you legal permission to copy,
9123 distribute and/or modify the software.
9125 Also, for each author's protection and ours, we want to make certain
9126 that everyone understands that there is no warranty for this free
9127 software. If the software is modified by someone else and passed on, we
9128 want its recipients to know that what they have is not the original, so
9129 that any problems introduced by others will not reflect on the original
9130 authors' reputations.
9132 Finally, any free program is threatened constantly by software
9133 patents. We wish to avoid the danger that redistributors of a free
9134 program will individually obtain patent licenses, in effect making the
9135 program proprietary. To prevent this, we have made it clear that any
9136 patent must be licensed for everyone's free use or not licensed at all.
9138 The precise terms and conditions for copying, distribution and
9139 modification follow.
9142 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
9145 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
9150 This License applies to any program or other work which contains
9151 a notice placed by the copyright holder saying it may be distributed
9152 under the terms of this General Public License. The ``Program'', below,
9153 refers to any such program or work, and a ``work based on the Program''
9154 means either the Program or any derivative work under copyright law:
9155 that is to say, a work containing the Program or a portion of it,
9156 either verbatim or with modifications and/or translated into another
9157 language. (Hereinafter, translation is included without limitation in
9158 the term ``modification''.) Each licensee is addressed as ``you''.
9160 Activities other than copying, distribution and modification are not
9161 covered by this License; they are outside its scope. The act of
9162 running the Program is not restricted, and the output from the Program
9163 is covered only if its contents constitute a work based on the
9164 Program (independent of having been made by running the Program).
9165 Whether that is true depends on what the Program does.
9168 You may copy and distribute verbatim copies of the Program's
9169 source code as you receive it, in any medium, provided that you
9170 conspicuously and appropriately publish on each copy an appropriate
9171 copyright notice and disclaimer of warranty; keep intact all the
9172 notices that refer to this License and to the absence of any warranty;
9173 and give any other recipients of the Program a copy of this License
9174 along with the Program.
9176 You may charge a fee for the physical act of transferring a copy, and
9177 you may at your option offer warranty protection in exchange for a fee.
9180 You may modify your copy or copies of the Program or any portion
9181 of it, thus forming a work based on the Program, and copy and
9182 distribute such modifications or work under the terms of Section 1
9183 above, provided that you also meet all of these conditions:
9187 You must cause the modified files to carry prominent notices
9188 stating that you changed the files and the date of any change.
9191 You must cause any work that you distribute or publish, that in
9192 whole or in part contains or is derived from the Program or any
9193 part thereof, to be licensed as a whole at no charge to all third
9194 parties under the terms of this License.
9197 If the modified program normally reads commands interactively
9198 when run, you must cause it, when started running for such
9199 interactive use in the most ordinary way, to print or display an
9200 announcement including an appropriate copyright notice and a
9201 notice that there is no warranty (or else, saying that you provide
9202 a warranty) and that users may redistribute the program under
9203 these conditions, and telling the user how to view a copy of this
9204 License. (Exception: if the Program itself is interactive but
9205 does not normally print such an announcement, your work based on
9206 the Program is not required to print an announcement.)
9209 These requirements apply to the modified work as a whole. If
9210 identifiable sections of that work are not derived from the Program,
9211 and can be reasonably considered independent and separate works in
9212 themselves, then this License, and its terms, do not apply to those
9213 sections when you distribute them as separate works. But when you
9214 distribute the same sections as part of a whole which is a work based
9215 on the Program, the distribution of the whole must be on the terms of
9216 this License, whose permissions for other licensees extend to the
9217 entire whole, and thus to each and every part regardless of who wrote it.
9219 Thus, it is not the intent of this section to claim rights or contest
9220 your rights to work written entirely by you; rather, the intent is to
9221 exercise the right to control the distribution of derivative or
9222 collective works based on the Program.
9224 In addition, mere aggregation of another work not based on the Program
9225 with the Program (or with a work based on the Program) on a volume of
9226 a storage or distribution medium does not bring the other work under
9227 the scope of this License.
9230 You may copy and distribute the Program (or a work based on it,
9231 under Section 2) in object code or executable form under the terms of
9232 Sections 1 and 2 above provided that you also do one of the following:
9236 Accompany it with the complete corresponding machine-readable
9237 source code, which must be distributed under the terms of Sections
9238 1 and 2 above on a medium customarily used for software interchange; or,
9241 Accompany it with a written offer, valid for at least three
9242 years, to give any third party, for a charge no more than your
9243 cost of physically performing source distribution, a complete
9244 machine-readable copy of the corresponding source code, to be
9245 distributed under the terms of Sections 1 and 2 above on a medium
9246 customarily used for software interchange; or,
9249 Accompany it with the information you received as to the offer
9250 to distribute corresponding source code. (This alternative is
9251 allowed only for noncommercial distribution and only if you
9252 received the program in object code or executable form with such
9253 an offer, in accord with Subsection b above.)
9256 The source code for a work means the preferred form of the work for
9257 making modifications to it. For an executable work, complete source
9258 code means all the source code for all modules it contains, plus any
9259 associated interface definition files, plus the scripts used to
9260 control compilation and installation of the executable. However, as a
9261 special exception, the source code distributed need not include
9262 anything that is normally distributed (in either source or binary
9263 form) with the major components (compiler, kernel, and so on) of the
9264 operating system on which the executable runs, unless that component
9265 itself accompanies the executable.
9267 If distribution of executable or object code is made by offering
9268 access to copy from a designated place, then offering equivalent
9269 access to copy the source code from the same place counts as
9270 distribution of the source code, even though third parties are not
9271 compelled to copy the source along with the object code.
9274 You may not copy, modify, sublicense, or distribute the Program
9275 except as expressly provided under this License. Any attempt
9276 otherwise to copy, modify, sublicense or distribute the Program is
9277 void, and will automatically terminate your rights under this License.
9278 However, parties who have received copies, or rights, from you under
9279 this License will not have their licenses terminated so long as such
9280 parties remain in full compliance.
9283 You are not required to accept this License, since you have not
9284 signed it. However, nothing else grants you permission to modify or
9285 distribute the Program or its derivative works. These actions are
9286 prohibited by law if you do not accept this License. Therefore, by
9287 modifying or distributing the Program (or any work based on the
9288 Program), you indicate your acceptance of this License to do so, and
9289 all its terms and conditions for copying, distributing or modifying
9290 the Program or works based on it.
9293 Each time you redistribute the Program (or any work based on the
9294 Program), the recipient automatically receives a license from the
9295 original licensor to copy, distribute or modify the Program subject to
9296 these terms and conditions. You may not impose any further
9297 restrictions on the recipients' exercise of the rights granted herein.
9298 You are not responsible for enforcing compliance by third parties to
9302 If, as a consequence of a court judgment or allegation of patent
9303 infringement or for any other reason (not limited to patent issues),
9304 conditions are imposed on you (whether by court order, agreement or
9305 otherwise) that contradict the conditions of this License, they do not
9306 excuse you from the conditions of this License. If you cannot
9307 distribute so as to satisfy simultaneously your obligations under this
9308 License and any other pertinent obligations, then as a consequence you
9309 may not distribute the Program at all. For example, if a patent
9310 license would not permit royalty-free redistribution of the Program by
9311 all those who receive copies directly or indirectly through you, then
9312 the only way you could satisfy both it and this License would be to
9313 refrain entirely from distribution of the Program.
9315 If any portion of this section is held invalid or unenforceable under
9316 any particular circumstance, the balance of the section is intended to
9317 apply and the section as a whole is intended to apply in other
9320 It is not the purpose of this section to induce you to infringe any
9321 patents or other property right claims or to contest validity of any
9322 such claims; this section has the sole purpose of protecting the
9323 integrity of the free software distribution system, which is
9324 implemented by public license practices. Many people have made
9325 generous contributions to the wide range of software distributed
9326 through that system in reliance on consistent application of that
9327 system; it is up to the author/donor to decide if he or she is willing
9328 to distribute software through any other system and a licensee cannot
9331 This section is intended to make thoroughly clear what is believed to
9332 be a consequence of the rest of this License.
9335 If the distribution and/or use of the Program is restricted in
9336 certain countries either by patents or by copyrighted interfaces, the
9337 original copyright holder who places the Program under this License
9338 may add an explicit geographical distribution limitation excluding
9339 those countries, so that distribution is permitted only in or among
9340 countries not thus excluded. In such case, this License incorporates
9341 the limitation as if written in the body of this License.
9344 The Free Software Foundation may publish revised and/or new versions
9345 of the General Public License from time to time. Such new versions will
9346 be similar in spirit to the present version, but may differ in detail to
9347 address new problems or concerns.
9349 Each version is given a distinguishing version number. If the Program
9350 specifies a version number of this License which applies to it and ``any
9351 later version'', you have the option of following the terms and conditions
9352 either of that version or of any later version published by the Free
9353 Software Foundation. If the Program does not specify a version number of
9354 this License, you may choose any version ever published by the Free Software
9358 If you wish to incorporate parts of the Program into other free
9359 programs whose distribution conditions are different, write to the author
9360 to ask for permission. For software which is copyrighted by the Free
9361 Software Foundation, write to the Free Software Foundation; we sometimes
9362 make exceptions for this. Our decision will be guided by the two goals
9363 of preserving the free status of all derivatives of our free software and
9364 of promoting the sharing and reuse of software generally.
9367 @heading NO WARRANTY
9374 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
9375 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
9376 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
9377 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
9378 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9379 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
9380 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
9381 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
9382 REPAIR OR CORRECTION.
9385 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
9386 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
9387 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
9388 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
9389 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
9390 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
9391 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
9392 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
9393 POSSIBILITY OF SUCH DAMAGES.
9397 @heading END OF TERMS AND CONDITIONS
9400 @center END OF TERMS AND CONDITIONS
9404 @unnumberedsec Applying These Terms to Your New Programs
9406 If you develop a new program, and you want it to be of the greatest
9407 possible use to the public, the best way to achieve this is to make it
9408 free software which everyone can redistribute and change under these terms.
9410 To do so, attach the following notices to the program. It is safest
9411 to attach them to the start of each source file to most effectively
9412 convey the exclusion of warranty; and each file should have at least
9413 the ``copyright'' line and a pointer to where the full notice is found.
9416 @var{one line to give the program's name and an idea of what it does.}
9417 Copyright (C) 19@var{yy} @var{name of author}
9419 This program is free software; you can redistribute it and/or
9420 modify it under the terms of the GNU General Public License
9421 as published by the Free Software Foundation; either version 2
9422 of the License, or (at your option) any later version.
9424 This program is distributed in the hope that it will be useful,
9425 but WITHOUT ANY WARRANTY; without even the implied warranty of
9426 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9427 GNU General Public License for more details.
9429 You should have received a copy of the GNU General Public License
9430 along with this program; if not, write to the
9431 Free Software Foundation, Inc., 675 Mass Ave,
9432 Cambridge, MA 02139, USA.
9435 Also add information on how to contact you by electronic and paper mail.
9437 If the program is interactive, make it output a short notice like this
9438 when it starts in an interactive mode:
9441 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
9442 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
9443 type `show w'. This is free software, and you are welcome
9444 to redistribute it under certain conditions; type `show c'
9448 The hypothetical commands @samp{show w} and @samp{show c} should show
9449 the appropriate parts of the General Public License. Of course, the
9450 commands you use may be called something other than @samp{show w} and
9451 @samp{show c}; they could even be mouse-clicks or menu items---whatever
9454 You should also get your employer (if you work as a programmer) or your
9455 school, if any, to sign a ``copyright disclaimer'' for the program, if
9456 necessary. Here is a sample; alter the names:
9459 Yoyodyne, Inc., hereby disclaims all copyright
9460 interest in the program `Gnomovision'
9461 (which makes passes at compilers) written
9464 @var{signature of Ty Coon}, 1 April 1989
9465 Ty Coon, President of Vice
9468 This General Public License does not permit incorporating your program into
9469 proprietary programs. If your program is a subroutine library, you may
9470 consider it more useful to permit linking proprietary applications with the
9471 library. If this is what you want to do, use the GNU Library General
9472 Public License instead of this License.
9481 % I think something like @colophon should be in texinfo. In the
9483 \long\def\colophon{\hbox to0pt{}\vfill
9484 \centerline{The body of this manual is set in}
9485 \centerline{\fontname\tenrm,}
9486 \centerline{with headings in {\bf\fontname\tenbf}}
9487 \centerline{and examples in {\tt\fontname\tentt}.}
9488 \centerline{{\it\fontname\tenit\/},}
9489 \centerline{{\bf\fontname\tenbf}, and}
9490 \centerline{{\sl\fontname\tensl\/}}
9491 \centerline{are used for emphasis.}\vfill}
9493 % Blame: pesch@cygnus.com, 1991.