2 _dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc.
4 @setfilename _GDBP__.info
6 @c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly.
8 @c NOTE: this manual is marked up for preprocessing with a collection
9 @c of m4 macros called "pretex.m4". If you see <_if__> and <_fi__>
10 @c scattered around the source, you have the full source before
11 @c preprocessing; if you don't, you have the source configured for
12 @c _HOST__ architectures (and you can of course get the full source,
13 @c with all configurations, from wherever you got this).
16 THIS IS THE SOURCE PRIOR TO PREPROCESSING. The full source needs to
17 be run through m4 before either tex- or info- formatting: for example,
19 m4 pretex.m4 none.m4 m680x0.m4 gdb.texinfo >gdb-680x0.texinfo
21 will produce (assuming your path finds either GNU m4 >= 0.84, or SysV
22 m4; Berkeley won't do) a file suitable for formatting. See the text in
23 "pretex.m4" for a fuller explanation (and the macro definitions).
27 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
28 \xdef\manvers{\$Revision$} % For use in headers, footers too
32 @c FOR UPDATES LEADING TO THIS DRAFT, GDB CHANGELOG CONSULTED BETWEEN:
33 @c Thu Aug 22 14:05:47 1991 Stu Grossman (grossman at cygint.cygnus.com)
34 @c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint)
36 This file documents the GNU debugger _GDBN__.
38 Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
40 Permission is granted to make and distribute verbatim copies of
41 this manual provided the copyright notice and this permission notice
42 are preserved on all copies.
45 Permission is granted to process this file through TeX and print the
46 results, provided the printed document carries copying permission
47 notice identical to this one except for the removal of this paragraph
48 (this paragraph not being relevant to the printed manual).
51 Permission is granted to copy and distribute modified versions of this
52 manual under the conditions for verbatim copying, provided also that the
53 section entitled ``GNU General Public License'' is included exactly as
54 in the original, and provided that the entire resulting derived work is
55 distributed under the terms of a permission notice identical to this
58 Permission is granted to copy and distribute translations of this manual
59 into another language, under the above conditions for modified versions,
60 except that the section entitled ``GNU General Public License'' may be
61 included in a translation approved by the Free Software Foundation
62 instead of in the original English.
65 @setchapternewpage odd
67 @settitle Using _GDBN__ (v4.0)
70 @settitle Using _GDBN__ v4.0 (_HOST__)
77 @subtitle{A Guide to the GNU Source-Level Debugger}
79 @subtitle{On _HOST__ Systems}
82 @c Maybe crank this up to "Fourth Edition" when released at FSF
83 @c @subtitle Third Edition---_GDBN__ version 4.0
84 @subtitle _GDBN__ version 4.0
86 @author{Richard M. Stallman@qquad @hfill Free Software Foundation}
87 @author{Roland H. Pesch@qquad @hfill Cygnus Support}
91 \hfill rms\@ai.mit.edu, pesch\@cygnus.com\par
92 \hfill {\it Using _GDBN__}, \manvers\par
93 \hfill \TeX{}info \texinfoversion\par
97 @vskip 0pt plus 1filll
98 Copyright @copyright{} 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
100 Permission is granted to make and distribute verbatim copies of
101 this manual provided the copyright notice and this permission notice
102 are preserved on all copies.
104 Permission is granted to copy and distribute modified versions of this
105 manual under the conditions for verbatim copying, provided also that the
106 section entitled ``GNU General Public License'' is included exactly as
107 in the original, and provided that the entire resulting derived work is
108 distributed under the terms of a permission notice identical to this
111 Permission is granted to copy and distribute translations of this manual
112 into another language, under the above conditions for modified versions,
113 except that the section entitled ``GNU General Public License'' may be
114 included in a translation approved by the Free Software Foundation
115 instead of in the original English.
119 @node Top, Summary, (dir), (dir)
121 This file describes version 4.0 of GDB, the GNU symbolic debugger.
125 * Summary:: Summary of _GDBN__
126 * New Features:: New Features in _GDBN__ version 4.0
127 * Sample Session:: A Sample _GDBN__ Session
128 * Invocation:: Getting In and Out of _GDBN__
129 * Commands:: _GDBN__ Commands
130 * Running:: Running Programs Under _GDBN__
131 * Stopping:: Stopping and Continuing
132 * Stack:: Examining the Stack
133 * Source:: Examining Source Files
134 * Data:: Examining Data
135 * Languages:: Using _GDBN__ with Different Languages
136 * Symbols:: Examining the Symbol Table
137 * Altering:: Altering Execution
138 * _GDBN__ Files:: _GDBN__'s Files
139 * Targets:: Specifying a Debugging Target
140 * Controlling _GDBN__:: Controlling _GDBN__
141 * Sequences:: Canned Sequences of Commands
142 * Emacs:: Using _GDBN__ under GNU Emacs
143 * _GDBN__ Bugs:: Reporting Bugs in _GDBN__
145 * Installing _GDBN__:: Installing _GDBN__
146 * Copying:: GNU GENERAL PUBLIC LICENSE
149 --- The Detailed Node Listing ---
153 * Free Software:: Free Software
154 * Contributors:: Contributors to _GDBN__
156 Getting In and Out of _GDBN__
158 * Starting _GDBN__:: Starting _GDBN__
159 * Leaving _GDBN__:: Leaving _GDBN__
160 * Shell Commands:: Shell Commands
164 * File Options:: Choosing Files
165 * Mode Options:: Choosing Modes
169 * Command Syntax:: Command Syntax
170 * Help:: Getting Help
172 Running Programs Under _GDBN__
174 * Compilation:: Compiling for Debugging
175 * Starting:: Starting your Program
176 * Arguments:: Your Program's Arguments
177 * Environment:: Your Program's Environment
178 * Working Directory:: Your Program's Working Directory
179 * Input/Output:: Your Program's Input and Output
180 * Attach:: Debugging an Already-Running Process
181 * Kill Process:: Killing the Child Process
183 Stopping and Continuing
185 * Breakpoints:: Breakpoints, Watchpoints, and Exceptions
186 * Continuing and Stepping:: Resuming Execution
189 Breakpoints, Watchpoints, and Exceptions
191 * Set Breaks:: Setting Breakpoints
192 * Set Watchpoints:: Setting Watchpoints
193 * Exception Handling:: Breakpoints and Exceptions
194 * Delete Breaks:: Deleting Breakpoints
195 * Disabling:: Disabling Breakpoints
196 * Conditions:: Break Conditions
197 * Break Commands:: Breakpoint Command Lists
198 * Breakpoint Menus:: Breakpoint Menus
199 * Error in Breakpoints:: ``Cannot insert breakpoints''
203 * Frames:: Stack Frames
204 * Backtrace:: Backtraces
205 * Selection:: Selecting a Frame
206 * Frame Info:: Information on a Frame
208 Examining Source Files
210 * List:: Printing Source Lines
211 * Search:: Searching Source Files
212 * Source Path:: Specifying Source Directories
213 * Machine Code:: Source and Machine Code
217 * Expressions:: Expressions
218 * Variables:: Program Variables
219 * Arrays:: Artificial Arrays
220 * Output formats:: Output formats
221 * Memory:: Examining Memory
222 * Auto Display:: Automatic Display
223 * Print Settings:: Print Settings
224 * Value History:: Value History
225 * Convenience Vars:: Convenience Variables
226 * Registers:: Registers
227 * Floating Point Hardware:: Floating Point Hardware
229 Using GDB with Different Languages
231 * Setting:: Switching between source languages
232 * Show:: Displaying the language
233 * Checks:: Type and Range checks
234 * Support:: Supported languages
236 Switching between source languages
238 * Manually:: Setting the working language manually
239 * Automatically:: Having GDB infer the source language
241 Type and range Checking
243 * Type Checking:: An overview of type checking
244 * Range Checking:: An overview of range checking
249 * Modula-2:: Modula-2
253 * C Operators:: C and C++ Operators
254 * C Constants:: C and C++ Constants
255 * Cplusplus expressions:: C++ Expressions
256 * C Defaults:: Default settings for C and C++
257 * C Checks:: C and C++ Type and Range Checks
258 * Debugging C:: _GDBN__ and C
259 * Debugging C plus plus:: Special features for C++
263 * M2 Operators:: Built-in operators
264 * Builtin Func/Proc:: Built-in Functions and Procedures
265 * M2 Constants:: Modula-2 Constants
266 * M2 Defaults:: Default settings for Modula-2
267 * Deviations:: Deviations from standard Modula-2
268 * M2 Checks:: Modula-2 Type and Range Checks
269 * M2 Scope:: The scope operators @code{::} and @code{.}
270 * GDB/M2:: GDB and Modula-2
274 * Assignment:: Assignment to Variables
275 * Jumping:: Continuing at a Different Address
276 * Signaling:: Giving the Program a Signal
277 * Returning:: Returning from a Function
278 * Calling:: Calling your Program's Functions
282 * Files:: Commands to Specify Files
283 * Symbol Errors:: Errors Reading Symbol Files
285 Specifying a Debugging Target
287 * Active Targets:: Active Targets
288 * Target Commands:: Commands for Managing Targets
289 * Remote:: Remote Debugging
293 * i960-Nindy Remote:: _GDBN__ with a Remote i960 (Nindy)
294 * EB29K Remote:: _GDBN__ with a Remote EB29K
295 * VxWorks Remote:: _GDBN__ and VxWorks
297 _GDBN__ with a Remote i960 (Nindy)
299 * Nindy Startup:: Startup with Nindy
300 * Nindy Options:: Options for Nindy
301 * Nindy reset:: Nindy Reset Command
303 _GDBN__ with a Remote EB29K
305 * Comms (EB29K):: Communications Setup
306 * gdb-EB29K:: EB29K cross-debugging
307 * Remote Log:: Remote Log
311 * VxWorks connection:: Connecting to VxWorks
312 * VxWorks download:: VxWorks Download
313 * VxWorks attach:: Running Tasks
318 * Editing:: Command Editing
319 * History:: Command History
320 * Screen Size:: Screen Size
322 * Messages/Warnings:: Optional Warnings and Messages
324 Canned Sequences of Commands
326 * Define:: User-Defined Commands
327 * Command Files:: Command Files
328 * Output:: Commands for Controlled Output
330 Reporting Bugs in _GDBN__
332 * Bug Criteria:: Have You Found a Bug?
333 * Bug Reporting:: How to Report Bugs
337 * Subdirectories:: Configuration subdirectories
338 * Config Names:: Specifying names for hosts and targets
339 * configure Options:: Summary of options for configure
340 * Formatting Manual:: How to format and print GDB documentation
343 @node Summary, New Features, Top, Top
344 @unnumbered Summary of _GDBN__
346 The purpose of a debugger such as _GDBN__ is to allow you to see what is
347 going on ``inside'' another program while it executes---or what another
348 program was doing at the moment it crashed.
350 _GDBN__ can do four main kinds of things (plus other things in support of
351 these) to help you catch bugs in the act:
355 Start your program, specifying anything that might affect its behavior.
358 Make your program stop on specified conditions.
361 Examine what has happened, when your program has stopped.
364 Change things in your program, so you can experiment with correcting the
365 effects of one bug and go on to learn about another.
368 You can use _GDBN__ to debug programs written in C, C++, and Modula-2.
369 Fortran support will be added when a GNU Fortran compiler is ready.
372 * Free Software:: Free Software
373 * Contributors:: Contributors to GDB
376 @node Free Software, Contributors, Summary, Summary
377 @unnumberedsec Free Software
378 _GDBN__ is @dfn{free software}, protected by the GNU General Public License (GPL).
379 The GPL gives you the freedom to copy or adapt a licensed
380 program---but every person getting a copy also gets with it the
381 freedom to modify that copy (which means that they must get access to
382 the source code), and the freedom to distribute further copies.
383 Typical software companies use copyrights to limit your freedoms; the
384 Free Software Foundation uses the GPL to preserve these freedoms.
386 Fundamentally, the General Public License is a license which says that
387 you have these freedoms and that you can't take these freedoms away
390 @c FIXME: (passim) go through all xrefs, expanding to use text headings
391 For full details, @pxref{Copying}.
392 @node Contributors, , Free Software, Summary
393 @unnumberedsec Contributors to GDB
395 Richard Stallman was the original author of GDB, and of many other GNU
396 programs. Many others have contributed to its development. This
397 section attempts to credit major contributors. One of the virtues of
398 free software is that everyone is free to contribute to it; with
399 regret, we cannot actually acknowledge everyone here. The file
400 @file{ChangeLog} in the GDB distribution approximates a blow-by-blow
403 Changes much prior to version 2.0 are lost in the mists of time.
406 @emph{Plea:} Additions to this section are particularly welcome. If you
407 or your friends (or enemies; let's be evenhanded) have been unfairly
408 omitted from this list, we would like to add your names!
411 So that they may not regard their long labor as thankless, we
412 particularly thank those who shepherded GDB through major releases: John
413 Gilmore (releases 4.1, 4.0); Jim Kingdon (releases 3.9, 3.5, 3.4, 3.3);
414 and Randy Smith (releases 3.2, 3.1, 3.0). As major maintainer of GDB
415 for some period, each contributed significantly to the structure,
416 stability, and capabilities of the entire debugger.
418 Richard Stallman, assisted at various times by Pete TerMaat, Chris
419 Hanson, and Richard Mlynarik, handled releases through 2.8.
421 Michael Tiemann is the author of most of the GNU C++ support in GDB,
422 with significant additional contributions from Per Bothner. James
423 Clark wrote the GNU C++ demangler. Early work on C++ was by Peter
424 TerMaat (who also did much general update work leading to release 3.0).
426 GDB 4.0 uses the BFD subroutine library to examine multiple
427 object-file formats; BFD was a joint project of V. Gumby
428 Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
430 David Johnson wrote the original COFF support; Pace Willison did
431 the original support for encapsulated COFF.
433 Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
434 Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
435 support. Jean-Daniel Fekete contributed Sun 386i support. Chris
436 Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki
437 Hasei contributed Sony/News OS 3 support. David Johnson contributed
438 Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support.
439 Keith Packard contributed NS32K support. Doug Rabson contributed
440 Acorn Risc Machine support. Chris Smith contributed Convex support
441 (and Fortran debugging). Jonathan Stone contributed Pyramid support.
442 Michael Tiemann contributed SPARC support. Tim Tucker contributed
443 support for the Gould NP1 and Gould Powernode. Pace Willison
444 contributed Intel 386 support. Jay Vosburgh contributed Symmetry
447 Rich Schaefer helped with support of SunOS shared libraries.
449 Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about
450 several machine instruction sets.
452 Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
453 develop remote debugging. Intel Corporation and Wind River Systems
454 contributed remote debugging modules for their products.
456 Brian Fox is the author of the readline libraries providing
457 command-line editing and command history.
459 Andrew Beers of SUNY Buffalo wrote the language-switching code and
460 the Modula-2 support, and contributed the Languages chapter of this
463 @node New Features, Sample Session, Summary, Top
464 @unnumbered New Features since _GDBN__ version 3.5
468 Using the new command @code{target}, you can select at runtime whether
469 you are debugging local files, local processes, standalone systems over
470 a serial port, realtime systems over a TCP/IP connection, etc. The
471 command @code{load} can download programs into a remote system. Serial
472 stubs are available for Motorola 680x0 and Intel 80386 remote systems;
473 _GDBN__ also supports debugging realtime processes running under
474 VxWorks, using SunRPC Remote Procedure Calls over TCP/IP to talk to a
475 debugger stub on the target system. Internally, _GDBN__ now uses a
476 function vector to mediate access to different targets; if you need to
477 add your own support for a remote protocol, this makes it much easier.
480 _GDBN__ now sports watchpoints as well as breakpoints. You can use a
481 watchpoint to stop execution whenever the value of an expression
482 changes, without having to predict a particular place in your program
483 where this may happen.
486 Commands that issue wide output now insert newlines at places designed
487 to make the output more readable.
489 @item Object Code Formats
490 _GDBN__ uses a new library called the Binary File Descriptor (BFD)
491 Library to permit it to switch dynamically, without reconfiguration or
492 recompilation, between different object-file formats. Formats currently
493 supported are COFF, a.out, and the Intel 960 b.out; files may be read as
494 .o's, archive libraries, or core dumps. BFD is available as a
495 subroutine library so that other programs may take advantage of it, and
496 the other GNU binary utilities are being converted to use it.
498 @item Configuration and Ports
499 Compile-time configuration (to select a particular architecture and
500 operating system) is much easier. The script @code{configure} now
501 allows you to configure _GDBN__ as either a native debugger or a
502 cross-debugger. @xref{Installing _GDBN__} for details on how to
503 configure and on what architectures are now available.
506 The user interface to _GDBN__'s control variables has been simplified
507 and consolidated in two commands, @code{set} and @code{show}. Output
508 lines are now broken at readable places, rather than overflowing onto
509 the next line. You can suppress output of machine-level addresses,
510 displaying only source language information.
514 _GDBN__ now supports C++ multiple inheritance (if used with a GCC
515 version 2 compiler), and also has limited support for C++ exception
516 handling, with the commands @code{catch} and @code{info catch}: _GDBN__
517 can break when an exception is raised, before the stack is peeled back
518 to the exception handler's context.
521 _GDBN__ now has preliminary support for the GNU Modula-2 compiler,
522 currently under development at the State University of New York at
523 Buffalo. Coordinated development of both _GDBN__ and the GNU Modula-2
524 compiler will continue through the fall of 1991 and into 1992. Other
525 Modula-2 compilers are currently not supported, and attempting to debug
526 programs compiled with them will likely result in an error as the symbol
527 table of the executable is read in.
529 @item Command Rationalization
530 Many _GDBN__ commands have been renamed to make them easier to remember
531 and use. In particular, the subcommands of @code{info} and
532 @code{show}/@code{set} are grouped to make the former refer to the state
533 of your program, and the latter refer to the state of _GDBN__ itself.
534 @xref{Renamed Commands}, for details on what commands were renamed.
536 @item Shared Libraries
537 _GDBN__ 4.0 can debug programs and core files that use SunOS shared
538 libraries. You can load symbols from a shared library with the command
539 @code{sharedlibrary} (@pxref{Files}).
542 _GDBN__ 4.0 has a reference card; @xref{Formatting Manual} for
543 instructions on printing it.
545 @item Work in Progress
546 Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture
551 @node Sample Session, Invocation, New Features, Top
552 @chapter A Sample _GDBN__ Session
554 You can use this manual at your leisure to read all about _GDBN__.
555 However, a handful of commands are enough to get started using the
556 debugger. This chapter illustrates these commands.
559 In this sample session, we emphasize user input like this: @i{input},
560 to make it easier to pick out from the surrounding output.
563 @c FIXME: this example may not be appropriate for some configs, where
564 @c FIXME...primary interest is in remote use.
566 One of the preliminary versions of GNU @code{m4} (a generic macro
567 processor) exhibits the following bug: sometimes, when we change its
568 quote strings from the default, the commands used to capture one macro's
569 definition in another stop working. In the following short @code{m4}
570 session, we define a macro @code{foo} which expands to @code{0000}; we
571 then use the @code{m4} builtin @code{defn} to define @code{bar} as the
572 same thing. However, when we change the open quote string to
573 @code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same
574 procedure fails to define a new synonym @code{baz}:
583 @i{define(bar,defn(`foo'))}
587 @i{changequote(<QUOTE>,<UNQUOTE>)}
589 @i{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
592 m4: End of input: 0: fatal error: EOF in string
596 Let's use _GDBN__ to try to see what's going on.
600 Reading symbol data from m4...done.
605 _GDBN__ reads only enough symbol data to know where to find the rest
606 when needed; as a result, the first prompt comes up very quickly. We
607 then tell _GDBN__ to use a narrower display width than usual, so
608 that examples will fit in this manual.
611 (_GDBP__) @i{set width 70}
615 Let's see how the @code{m4} builtin @code{changequote} works.
616 Having looked at the source, we know the relevant subroutine is
617 @code{m4_changequote}, so we set a breakpoint there with _GDBN__'s
618 @code{break} command.
621 (_GDBP__) @i{break m4_changequote}
622 Breakpoint 1 at 0x62f4: file builtin.c, line 879.
626 Using the @code{run} command, we start @code{m4} running under _GDBN__
627 control; as long as control does not reach the @code{m4_changequote}
628 subroutine, the program runs as usual:
632 Starting program: /work/Editorial/gdb/gnu/m4/m4
640 To trigger the breakpoint, we call @code{changequote}. _GDBN__
641 suspends execution of @code{m4}, displaying information about the
642 context where it stops.
645 @i{changequote(<QUOTE>,<UNQUOTE>)}
647 Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) at builtin.c:879
648 879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
652 Now we use the command @code{n} (@code{next}) to advance execution to
653 the next line of the current function.
657 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1]) : nil,
661 @code{set_quotes} looks like a promising subroutine. We can go into it
662 by using the command @code{s} (@code{step}) instead of @code{next}.
663 @code{step} goes to the next line to be executed in @emph{any}
664 subroutine, so it steps into @code{set_quotes}.
668 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
670 530 if (lquote != def_lquote)
674 The summary display showing the subroutine where @code{m4} is now
675 suspended (and its arguments) is called a stack frame display. We can
676 use the @code{backtrace} command (which can also be spelled @code{bt}),
677 to see where we are in the stack: it displays a stack frame for each
682 #0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
684 #1 0x6344 in m4_changequote (argc=3, argv=0x33c70) at builtin.c:882
685 #2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
686 #3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
688 #4 0x79dc in expand_input () at macro.c:40
689 #5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
693 Let's step through a few more lines to see what happens. The first two
694 times, we can use @samp{s}; the next two times we use @code{n} to avoid
695 falling into the @code{xstrdup} subroutine.
698 0x3b5c 532 if (rquote != def_rquote)
700 0x3b80 535 lquote = (lq == nil || *lq == '\0') ? def_lquote :\
703 536 rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
706 538 len_lquote = strlen(rquote);
710 The last line displayed looks a little odd; let's examine the variables
711 @code{lquote} and @code{rquote} to see if they are in fact the new left
712 and right quotes we specified. We can use the command @code{p}
713 (@code{print}) to see their values.
716 (_GDBP__) @i{p lquote}
717 $1 = 0x35d40 "<QUOTE>"
718 (_GDBP__) @i{p rquote}
719 $2 = 0x35d50 "<UNQUOTE>"
723 @code{lquote} and @code{rquote} are indeed the new left and right quotes.
724 Let's look at some context; we can display ten lines of source
725 surrounding the current line, with the @code{l} (@code{list}) command.
731 535 lquote = (lq == nil || *lq == '\0') ? def_lquote : xstrdup\
733 536 rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
736 538 len_lquote = strlen(rquote);
737 539 len_rquote = strlen(lquote);
744 Let's step past the two lines that set @code{len_lquote} and
745 @code{len_rquote}, and then examine the values of those variables.
749 539 len_rquote = strlen(lquote);
752 (_GDBP__) @i{p len_lquote}
754 (_GDBP__) @i{p len_rquote}
759 That certainly looks wrong, assuming @code{len_lquote} and
760 @code{len_rquote} are meant to be the lengths of @code{lquote} and
761 @code{rquote} respectively. Let's try setting them to better values.
762 We can use the @code{p} command for this, since it'll print the value of
763 any expression---and that expression can include subroutine calls and
767 (_GDBP__) p len_lquote=strlen(lquote)
769 (_GDBP__) p len_rquote=strlen(rquote)
774 Let's see if that fixes the problem of using the new quotes with the
775 @code{m4} built-in @code{defn}. We can allow @code{m4} to continue
776 executing with the @code{c} (@code{continue}) command, and then try the
777 example that caused trouble initially:
783 @i{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
790 Success! The new quotes now work just as well as the default ones. The
791 problem seems to have been just the two typos defining the wrong
792 lengths. We'll let @code{m4} exit by giving it an EOF as input.
796 Program exited normally.
800 The message @samp{Program exited normally.} is from _GDBN__; it
801 indicates @code{m4} has finished executing. We can end our _GDBN__
802 session with the _GDBN__ @code{quit} command.
806 _1__@end smallexample
808 @node Invocation, Commands, Sample Session, Top
809 @chapter Getting In and Out of _GDBN__
812 * Starting _GDBN__:: Starting _GDBN__
813 * Leaving _GDBN__:: Leaving _GDBN__
814 * Shell Commands:: Shell Commands
817 @node Starting _GDBN__, Leaving _GDBN__, Invocation, Invocation
818 @section Starting _GDBN__
820 _GDBN__ is invoked with the shell command @code{_GDBP__}. Once started,
821 it reads commands from the terminal until you tell it to exit.
823 You can run @code{_GDBP__} with no arguments or options; but the most
824 usual way to start _GDBN__ is with one argument or two, specifying an
825 executable program as the argument:
830 You can also start with both an executable program and a core file specified:
835 You can, instead, specify a process ID as a second argument, if you want
836 to debug a running process:
841 would attach _GDBN__ to process @code{1234} (unless you also have a file
842 named @file{1234}; _GDBN__ does check for a core file first).
845 You can further control how _GDBN__ starts up by using command-line
846 options. _GDBN__ itself can remind you of the options available:
851 will display all available options and briefly describe their use
852 (@samp{_GDBP__ -h} is a shorter equivalent).
854 All options and command line arguments you give are processed
855 in sequential order. The order makes a difference when the
856 @samp{-x} option is used.
859 * File Options:: Choosing Files
860 * Mode Options:: Choosing Modes
862 _include__(gdbinv-m.m4)_dnl__
866 @node File Options, Mode Options, Starting _GDBN__, Starting _GDBN__
867 @subsection Choosing Files
869 As shown above, any arguments other than options specify an executable
870 file and core file; that is, the first argument encountered with no
871 associated option flag is equivalent to a @samp{-se} option, and the
872 second, if any, is equivalent to a @samp{-c} option. Many options have
873 both long and short forms; both are shown here. The long forms are also
874 recognized if you truncate them, so long as enough of the option is
875 present to be unambiguous. (If you prefer, you can flag option
876 arguments with @samp{+} rather than @samp{-}, though we illustrate the
877 more usual convention.)
880 @item -symbols=@var{file}
882 Read symbol table from file @var{file}.
884 @item -exec=@var{file}
886 Use file @var{file} as the executable file to execute when
887 appropriate, and for examining pure data in conjunction with a core
891 Read symbol table from file @var{file} and use it as the executable
894 @item -core=@var{file}
896 Use file @var{file} as a core dump to examine.
898 @item -command=@var{file}
900 Execute _GDBN__ commands from file @var{file}. @xref{Command Files}.
902 @item -directory=@var{directory}
903 @itemx -d @var{directory}
904 Add @var{directory} to the path to search for source files.
908 @node Mode Options, Mode Options, File Options, Starting _GDBN__
911 @node Mode Options, , File Options, Starting _GDBN__
913 @subsection Choosing Modes
918 Do not execute commands from any @file{_GDBINIT__} initialization files.
919 Normally, the commands in these files are executed after all the
920 command options and arguments have been processed. @xref{Command
925 ``Quiet''. Do not print the introductory and copyright messages. These
926 messages are also suppressed in batch mode, or if an executable file name is
927 specified on the _GDBN__ command line.
930 Run in batch mode. Exit with status @code{0} after processing all the command
931 files specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited).
932 Exit with nonzero status if an error occurs in executing the _GDBN__
933 commands in the command files.
935 Batch mode may be useful for running _GDBN__ as a filter, for example to
936 download and run a program on another computer; in order to make this
937 more useful, the message
939 Program exited normally.
942 (which is ordinarily issued whenever a program running under _GDBN__ control
943 terminates) is not issued when running in batch mode.
945 @item -cd=@var{directory}
946 Run _GDBN__ using @var{directory} as its working directory,
947 instead of the current directory.
951 Emacs sets this option when it runs _GDBN__ as a subprocess. It tells _GDBN__
952 to output the full file name and line number in a standard,
953 recognizable fashion each time a stack frame is displayed (which
954 includes each time the program stops). This recognizable format looks
955 like two @samp{\032} characters, followed by the file name, line number
956 and character position separated by colons, and a newline. The
957 Emacs-to-_GDBN__ interface program uses the two @samp{\032} characters as
958 a signal to display the source code for the frame.
961 Set the line speed (baud rate or bits per second) of any serial
962 interface used by _GDBN__ for remote debugging.
964 @item -tty=@var{device}
965 Run using @var{device} for your program's standard input and output.
966 @c FIXME: kingdon thinks there's more to -tty. Investigate.
970 _include__(gdbinv-s.m4)
973 @node Leaving _GDBN__, Shell Commands, Starting _GDBN__, Invocation
974 @section Leaving _GDBN__
975 @cindex exiting _GDBN__
980 To exit _GDBN__, use the @code{quit} command (abbreviated @code{q}), or type
981 an end-of-file character (usually @kbd{C-d}).
985 An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather
986 will terminate the action of any _GDBN__ command that is in progress and
987 return to _GDBN__ command level. It is safe to type the interrupt
988 character at any time because _GDBN__ does not allow it to take effect
989 until a time when it is safe.
991 If you've been using _GDBN__ to control an attached process or device,
992 you can release it with the @code{detach} command; @pxref{Attach}.
994 @node Shell Commands, , Leaving _GDBN__, Invocation
995 @section Shell Commands
996 If you need to execute occasional shell commands during your
997 debugging session, there's no need to leave or suspend _GDBN__; you can
998 just use the @code{shell} command.
1001 @item shell @var{command string}
1003 @cindex shell escape
1004 Directs _GDBN__ to invoke an inferior shell to execute @var{command
1005 string}. If it exists, the environment variable @code{SHELL} is used
1006 for the name of the shell to run. Otherwise _GDBN__ uses
1010 The utility @code{make} is often needed in development environments.
1011 You don't have to use the @code{shell} command for this purpose in _GDBN__:
1014 @item make @var{make-args}
1016 @cindex calling make
1017 Causes _GDBN__ to execute an inferior @code{make} program with the specified
1018 arguments. This is equivalent to @samp{shell make @var{make-args}}.
1021 @node Commands, Running, Invocation, Top
1022 @chapter _GDBN__ Commands
1025 * Command Syntax:: Command Syntax
1026 * Help:: Getting Help
1029 @node Command Syntax, Help, Commands, Commands
1030 @section Command Syntax
1031 A _GDBN__ command is a single line of input. There is no limit on how long
1032 it can be. It starts with a command name, which is followed by arguments
1033 whose meaning depends on the command name. For example, the command
1034 @code{step} accepts an argument which is the number of times to step,
1035 as in @samp{step 5}. You can also use the @code{step} command with
1036 no arguments. Some command names do not allow any arguments.
1038 @cindex abbreviation
1039 _GDBN__ command names may always be truncated if that abbreviation is
1040 unambiguous. Other possible command abbreviations are listed in the
1041 documentation for individual commands. In some cases, even ambiguous
1042 abbreviations are allowed; for example, @code{s} is specially defined as
1043 equivalent to @code{step} even though there are other commands whose
1044 names start with @code{s}. You can test abbreviations by using them as
1045 arguments to the @code{help} command.
1047 @cindex repeating commands
1049 A blank line as input to _GDBN__ (typing just @key{RET}) means to
1050 repeat the previous command. Certain commands (for example, @code{run})
1051 will not repeat this way; these are commands for which unintentional
1052 repetition might cause trouble and which you are unlikely to want to
1055 The @code{list} and @code{x} commands, when you repeat them with
1056 @key{RET}, construct new arguments rather than repeating
1057 exactly as typed. This permits easy scanning of source or memory.
1059 _GDBN__ can also use @key{RET} in another way: to partition lengthy
1060 output, in a way similar to the common utility @code{more}
1061 (@pxref{Screen Size}). Since it's easy to press one @key{RET} too many
1062 in this situation, _GDBN__ disables command repetition after any command
1063 that generates this sort of display.
1067 A line of input starting with @kbd{#} is a comment; it does nothing.
1068 This is useful mainly in command files (@xref{Command Files}).
1070 @node Help, , Command Syntax, Commands
1071 @section Getting Help
1072 @cindex online documentation
1074 You can always ask _GDBN__ itself for information on its commands, using the
1075 command @code{help}.
1081 You can use @code{help} (abbreviated @code{h}) with no arguments to
1082 display a short list of named classes of commands:
1085 List of classes of commands:
1087 running -- Running the program
1088 stack -- Examining the stack
1089 data -- Examining data
1090 breakpoints -- Making program stop at certain points
1091 files -- Specifying and examining files
1092 status -- Status inquiries
1093 support -- Support facilities
1094 user-defined -- User-defined commands
1095 aliases -- Aliases of other commands
1096 obscure -- Obscure features
1098 Type "help" followed by a class name for a list of commands in that class.
1099 Type "help" followed by command name for full documentation.
1100 Command name abbreviations are allowed if unambiguous.
1104 @item help @var{class}
1105 Using one of the general help classes as an argument, you can get a
1106 list of the individual commands in that class. For example, here is the
1107 help display for the class @code{status}:
1109 (_GDBP__) help status
1114 show -- Generic command for showing things set with "set"
1115 info -- Generic command for printing status
1117 Type "help" followed by command name for full documentation.
1118 Command name abbreviations are allowed if unambiguous.
1122 @item help @var{command}
1123 With a command name as @code{help} argument, _GDBN__ will display a
1124 short paragraph on how to use that command.
1127 In addition to @code{help}, you can use the _GDBN__ commands @code{info}
1128 and @code{show} to inquire about the state of your program, or the state
1129 of _GDBN__ itself. Each command supports many topics of inquiry; this
1130 manual introduces each of them in the appropriate context. The listings
1131 under @code{info} and under @code{show} in the Index point to
1132 all the sub-commands.
1133 @c FIXME: @pxref{Index} used to be here, but even though it shows up in
1134 @c FIXME...the 'aux' file with a pageno the xref can't find it.
1141 This command (abbreviated @code{i}) is for describing the state of your
1142 program; for example, it can list the arguments given to your program
1143 (@code{info args}), the registers currently in use (@code{info
1144 registers}), or the breakpoints you've set (@code{info breakpoints}).
1145 You can get a complete list of the @code{info} sub-commands with
1146 @w{@code{help info}}.
1150 In contrast, @code{show} is for describing the state of _GDBN__ itself.
1151 You can change most of the things you can @code{show}, by using the
1152 related command @code{set}; for example, you can control what number
1153 system is used for displays with @code{set radix}, or simply inquire
1154 which is currently in use with @code{show radix}.
1157 To display all the settable parameters and their current
1158 values, you can use @code{show} with no arguments; you may also use
1159 @code{info set}. Both commands produce the same display.
1160 @c FIXME: "info set" violates the rule that "info" is for state of
1161 @c FIXME...program. Ck w/ GNU: "info set" to be called something else,
1162 @c FIXME...or change desc of rule---eg "state of prog and debugging session"?
1166 Here are three miscellaneous @code{show} subcommands, all of which are
1167 exceptional in lacking corresponding @code{set} commands:
1170 @kindex show version
1171 @cindex version number
1173 Show what version of _GDBN__ is running. You should include this
1174 information in _GDBN__ bug-reports. If multiple versions of _GDBN__ are
1175 in use at your site, you may occasionally want to make sure what version
1176 of _GDBN__ you're running; as _GDBN__ evolves, new commands are
1177 introduced, and old ones may wither away. The version number is also
1178 announced when you start _GDBN__ with no arguments.
1180 @kindex show copying
1182 Display information about permission for copying _GDBN__.
1184 @kindex show warranty
1186 Display the GNU ``NO WARRANTY'' statement.
1189 @node Running, Stopping, Commands, Top
1190 @chapter Running Programs Under _GDBN__
1193 * Compilation:: Compiling for Debugging
1194 * Starting:: Starting your Program
1195 * Arguments:: Your Program's Arguments
1196 * Environment:: Your Program's Environment
1197 * Working Directory:: Your Program's Working Directory
1198 * Input/Output:: Your Program's Input and Output
1199 * Attach:: Debugging an Already-Running Process
1200 * Kill Process:: Killing the Child Process
1203 @node Compilation, Starting, Running, Running
1204 @section Compiling for Debugging
1206 In order to debug a program effectively, you need to generate
1207 debugging information when you compile it. This debugging information
1208 is stored in the object file; it describes the data type of each
1209 variable or function and the correspondence between source line numbers
1210 and addresses in the executable code.
1212 To request debugging information, specify the @samp{-g} option when you run
1215 Many C compilers are unable to handle the @samp{-g} and @samp{-O}
1216 options together. Using those compilers, you cannot generate optimized
1217 executables containing debugging information.
1219 The GNU C compiler supports @samp{-g} with or without @samp{-O}, making it
1220 possible to debug optimized code. We recommend that you @emph{always} use
1221 @samp{-g} whenever you compile a program. You may think the program is
1222 correct, but there's no sense in pushing your luck.
1224 Some things do not work as well with @samp{-g -O} as with just
1225 @samp{-g}, particularly on machines with instruction scheduling. If in
1226 doubt, recompile with @samp{-g} alone, and if this fixes the problem,
1227 please report it as a bug (including a test case!).
1229 Older versions of the GNU C compiler permitted a variant option
1230 @samp{-gg} for debugging information. _GDBN__ no longer supports this
1231 format; if your GNU C compiler has this option, do not use it.
1234 @comment As far as I know, there are no cases in which _GDBN__ will
1235 @comment produce strange output in this case. (but no promises).
1236 If your program includes archives made with the @code{ar} program, and
1237 if the object files used as input to @code{ar} were compiled without the
1238 @samp{-g} option and have names longer than 15 characters, _GDBN__ will get
1239 confused reading the program's symbol table. No error message will be
1240 given, but _GDBN__ may behave strangely. The reason for this problem is a
1241 deficiency in the Unix archive file format, which cannot represent file
1242 names longer than 15 characters.
1244 To avoid this problem, compile the archive members with the @samp{-g}
1245 option or use shorter file names. Alternatively, use a version of GNU
1246 @code{ar} dated more recently than August 1989.
1250 @node Starting, Arguments, Compilation, Running
1251 @section Starting your Program
1258 Use the @code{run} command to start your program under _GDBN__. You
1259 must first specify the program name
1263 with an argument to _GDBN__
1264 (@pxref{Invocation}), or using the @code{file} or @code{exec-file}
1265 command (@pxref{Files}).
1269 On targets that support processes, @code{run} creates an inferior
1270 process and makes that process run your program. On other targets,
1271 @code{run} jumps to the start of the program.
1273 The execution of a program is affected by certain information it
1274 receives from its superior. _GDBN__ provides ways to specify this
1275 information, which you must do @i{before} starting the program. (You
1276 can change it after starting the program, but such changes will only affect
1277 the program the next time you start it.) This information may be
1278 divided into four categories:
1281 @item The @i{arguments.}
1282 You specify the arguments to give your program as the arguments of the
1283 @code{run} command. If a shell is available on your target, the shell
1284 is used to pass the arguments, so that you may use normal conventions
1285 (such as wildcard expansion or variable substitution) in
1286 describing the arguments. In Unix systems, you can control which shell
1287 is used with the @code{SHELL} environment variable. @xref{Arguments}.@refill
1289 @item The @i{environment.}
1290 Your program normally inherits its environment from _GDBN__, but you can
1291 use the _GDBN__ commands @code{set environment} and @code{unset
1292 environment} to change parts of the environment that will be given to
1293 the program. @xref{Environment}.@refill
1295 @item The @i{working directory.}
1296 Your program inherits its working directory from _GDBN__. You can set
1297 _GDBN__'s working directory with the @code{cd} command in _GDBN__.
1298 @xref{Working Directory}.
1300 @item The @i{standard input and output.}
1301 Your program normally uses the same device for standard input and
1302 standard output as _GDBN__ is using. You can redirect input and output
1303 in the @code{run} command line, or you can use the @code{tty} command to
1304 set a different device for your program.
1305 @xref{Input/Output}.
1308 @emph{Warning:} While input and output redirection work, you can't use
1309 pipes to pass the output of the program you're debugging to another
1310 program; if you attempt this, _GDBN__ is likely to wind up debugging the
1314 When you issue the @code{run} command, your program begins to execute
1315 immediately. @xref{Stopping}, for discussion of how to arrange for your
1316 program to stop. Once your program has been started by the @code{run}
1317 command (and then stopped), you may evaluate expressions that involve
1318 calls to functions in the inferior, using the @code{print} or
1319 @code{call} commands. @xref{Data}.
1321 If the modification time of your symbol file has changed since the last
1322 time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and re-read
1323 it. In this process, it tries to retain your current breakpoints.
1325 @node Arguments, Environment, Starting, Running
1326 @section Your Program's Arguments
1328 @cindex arguments (to your program)
1329 The arguments to your program can be specified by the arguments of the
1330 @code{run} command. They are passed to a shell, which expands wildcard
1331 characters and performs redirection of I/O, and thence to the program.
1332 _GDBN__ uses the shell indicated by your environment variable
1333 @code{SHELL} if it exists; otherwise, _GDBN__ uses @code{/bin/sh}.
1335 @code{run} with no arguments uses the same arguments used by the previous
1336 @code{run}, or those set by the @code{set args} command.
1341 Specify the arguments to be used the next time your program is run. If
1342 @code{set args} has no arguments, @code{run} will execute your program
1343 with no arguments. Once you have run your program with arguments,
1344 using @code{set args} before the next @code{run} is the only way to run
1345 it again without arguments.
1349 Show the arguments to give your program when it is started.
1352 @node Environment, Working Directory, Arguments, Running
1353 @section Your Program's Environment
1355 @cindex environment (of your program)
1356 The @dfn{environment} consists of a set of environment variables and
1357 their values. Environment variables conventionally record such things as
1358 your user name, your home directory, your terminal type, and your search
1359 path for programs to run. Usually you set up environment variables with
1360 the shell and they are inherited by all the other programs you run. When
1361 debugging, it can be useful to try running the program with a modified
1362 environment without having to start _GDBN__ over again.
1365 @item path @var{directory}
1367 Add @var{directory} to the front of the @code{PATH} environment variable
1368 (the search path for executables), for both _GDBN__ and your program.
1369 You may specify several directory names, separated by @samp{:} or
1370 whitespace. If @var{directory} is already in the path, it is moved to
1371 the front, so it will be searched sooner.
1373 You can use the string @samp{$cwd} to refer to whatever is the current
1374 working directory at the time _GDBN__ searches the path. If you use
1375 @samp{.} instead, it refers to the directory where you executed the
1376 @code{path} command. _GDBN__ fills in the current path where needed in
1377 the @var{directory} argument, before adding it to the search path.
1378 @c 'path' is explicitly nonrepeatable, but RMS points out it's silly to
1379 @c document that, since repeating it would be a no-op.
1383 Display the list of search paths for executables (the @code{PATH}
1384 environment variable).
1386 @item show environment @r{[}@var{varname}@r{]}
1387 @kindex show environment
1388 Print the value of environment variable @var{varname} to be given to
1389 your program when it starts. If you don't supply @var{varname},
1390 print the names and values of all environment variables to be given to
1391 your program. You can abbreviate @code{environment} as @code{env}.
1393 @item set environment @var{varname} @r{[}=@r{]} @var{value}
1394 @kindex set environment
1395 Sets environment variable @var{varname} to @var{value}. The value
1396 changes for your program only, not for _GDBN__ itself. @var{value} may
1397 be any string; the values of environment variables are just strings, and
1398 any interpretation is supplied by your program itself. The @var{value}
1399 parameter is optional; if it is eliminated, the variable is set to a
1401 @c "any string" here doesn't include leading, trailing
1402 @c blanks. Gnu asks: does anyone care?
1404 For example, this command:
1411 tells a Unix program, when subsequently run, that its user is named
1412 @samp{foo}. (The spaces around @samp{=} are used for clarity here; they
1413 are not actually required.)
1415 @item unset environment @var{varname}
1416 @kindex unset environment
1417 Remove variable @var{varname} from the environment to be passed to your
1418 program. This is different from @samp{set env @var{varname} =};
1419 @code{unset environment} removes the variable from the environment,
1420 rather than assigning it an empty value.
1423 @node Working Directory, Input/Output, Environment, Running
1424 @section Your Program's Working Directory
1426 @cindex working directory (of your program)
1427 Each time you start your program with @code{run}, it inherits its
1428 working directory from the current working directory of _GDBN__. _GDBN__'s
1429 working directory is initially whatever it inherited from its parent
1430 process (typically the shell), but you can specify a new working
1431 directory in _GDBN__ with the @code{cd} command.
1433 The _GDBN__ working directory also serves as a default for the commands
1434 that specify files for _GDBN__ to operate on. @xref{Files}.
1437 @item cd @var{directory}
1439 Set _GDBN__'s working directory to @var{directory}.
1443 Print _GDBN__'s working directory.
1446 @node Input/Output, Attach, Working Directory, Running
1447 @section Your Program's Input and Output
1452 By default, the program you run under _GDBN__ does input and output to
1453 the same terminal that _GDBN__ uses. _GDBN__ switches the terminal to
1454 its own terminal modes to interact with you, but it records the terminal
1455 modes your program was using and switches back to them when you continue
1456 running your program.
1460 @kindex info terminal
1461 Displays _GDBN__'s recorded information about the terminal modes your
1465 You can redirect the program's input and/or output using shell
1466 redirection with the @code{run} command. For example,
1473 starts the program, diverting its output to the file @file{outfile}.
1476 @cindex controlling terminal
1477 Another way to specify where the program should do input and output is
1478 with the @code{tty} command. This command accepts a file name as
1479 argument, and causes this file to be the default for future @code{run}
1480 commands. It also resets the controlling terminal for the child
1481 process, for future @code{run} commands. For example,
1488 directs that processes started with subsequent @code{run} commands
1489 default to do input and output on the terminal @file{/dev/ttyb} and have
1490 that as their controlling terminal.
1492 An explicit redirection in @code{run} overrides the @code{tty} command's
1493 effect on the input/output device, but not its effect on the controlling
1496 When you use the @code{tty} command or redirect input in the @code{run}
1497 command, only the input @emph{for your program} is affected. The input
1498 for _GDBN__ still comes from your terminal.
1500 @node Attach, Kill Process, Input/Output, Running
1501 @section Debugging an Already-Running Process
1506 @item attach @var{process-id}
1508 attaches to a running process---one that was started outside _GDBN__.
1509 (@code{info files} will show your active targets.) The command takes as
1510 argument a process ID. The usual way to find out the process-id of
1511 a Unix process is with the @code{ps} utility, or with the @samp{jobs -l}
1514 @code{attach} will not repeat if you press @key{RET} a second time after
1515 executing the command.
1518 To use @code{attach}, you must be debugging in an environment which
1519 supports processes. You must also have permission to send the process a
1520 signal, and it must have the same effective user ID as the _GDBN__
1523 When using @code{attach}, you should first use the @code{file} command
1524 to specify the program running in the process and load its symbol table.
1527 The first thing _GDBN__ does after arranging to debug the specified
1528 process is to stop it. You can examine and modify an attached process
1529 with all the _GDBN__ commands that are ordinarily available when you start
1530 processes with @code{run}. You can insert breakpoints; you can step and
1531 continue; you can modify storage. If you would rather the process
1532 continue running, you may use the @code{continue} command after
1533 attaching _GDBN__ to the process.
1538 When you have finished debugging the attached process, you can use the
1539 @code{detach} command to release it from _GDBN__'s control. Detaching
1540 the process continues its execution. After the @code{detach} command,
1541 that process and _GDBN__ become completely independent once more, and you
1542 are ready to @code{attach} another process or start one with @code{run}.
1543 @code{detach} will not repeat if you press @key{RET} again after
1544 executing the command.
1547 If you exit _GDBN__ or use the @code{run} command while you have an attached
1548 process, you kill that process. By default, you will be asked for
1549 confirmation if you try to do either of these things; you can control
1550 whether or not you need to confirm by using the @code{set confirm} command
1551 (@pxref{Messages/Warnings}).
1553 @node Kill Process, , Attach, Running
1555 @section Killing the Child Process
1560 Kill the child process in which your program is running under _GDBN__.
1563 This command is useful if you wish to debug a core dump instead of a
1564 running process. _GDBN__ ignores any core dump file while your program
1568 On some operating systems, a program can't be executed outside _GDBN__
1569 while you have breakpoints set on it inside _GDBN__. You can use the
1570 @code{kill} command in this situation to permit running the program
1571 outside the debugger.
1573 The @code{kill} command is also useful if you wish to recompile and
1574 relink the program, since on many systems it is impossible to modify an
1575 executable file while it is running in a process. In this case, when you
1576 next type @code{run}, _GDBN__ will notice that the file has changed, and
1577 will re-read the symbol table (while trying to preserve your current
1578 breakpoint settings).
1580 @node Stopping, Stack, Running, Top
1581 @chapter Stopping and Continuing
1583 The principal purpose of using a debugger is so that you can stop your
1584 program before it terminates; or so that, if the program runs into
1585 trouble, you can investigate and find out why.
1587 Inside _GDBN__, your program may stop for any of several reasons, such
1588 as a signal, a breakpoint, or reaching a new line after a _GDBN__
1589 command such as @code{step}. You may then examine and change
1590 variables, set new breakpoints or remove old ones, and then continue
1591 execution. Usually, the messages shown by _GDBN__ provide ample
1592 explanation of the status of your program---but you can also explicitly
1593 request this information at any time.
1597 @kindex info program
1598 Display information about the status of your program: whether it is
1599 running or not, what process it is, and why it stopped.
1603 * Breakpoints:: Breakpoints, Watchpoints, and Exceptions
1604 * Continuing and Stepping:: Resuming Execution
1608 @node Breakpoints, Continuing and Stepping, Stopping, Stopping
1609 @section Breakpoints, Watchpoints, and Exceptions
1612 A @dfn{breakpoint} makes your program stop whenever a certain point in
1613 the program is reached. For each breakpoint, you can add various
1614 conditions to control in finer detail whether the program will stop.
1615 You can set breakpoints with the @code{break} command and its variants
1616 (@pxref{Set Breaks}), to specify the place where the program should stop
1617 by line number, function name or exact address in the program. In
1618 languages with exception handling (such as GNU C++), you can also set
1619 breakpoints where an exception is raised (@pxref{Exception Handling}).
1622 A @dfn{watchpoint} is a special breakpoint that stops your program when
1623 the value of an expression changes. You must use a different command to
1624 set watchpoints (@pxref{Set Watchpoints}), but aside from that, you can
1625 manage a watchpoint like any other breakpoint: you enable, disable, and
1626 delete both breakpoints and watchpoints using the same commands.
1628 Each breakpoint or watchpoint is assigned a number when it is created;
1629 these numbers are successive integers starting with one. In many of the
1630 commands for controlling various features of breakpoints you use the
1631 breakpoint number to say which breakpoint you want to change. Each
1632 breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has
1633 no effect on the program until you enable it again.
1636 * Set Breaks:: Setting Breakpoints
1637 * Set Watchpoints:: Setting Watchpoints
1638 * Exception Handling:: Breakpoints and Exceptions
1639 * Delete Breaks:: Deleting Breakpoints
1640 * Disabling:: Disabling Breakpoints
1641 * Conditions:: Break Conditions
1642 * Break Commands:: Breakpoint Command Lists
1643 * Breakpoint Menus:: Breakpoint Menus
1644 * Error in Breakpoints::
1647 @node Set Breaks, Set Watchpoints, Breakpoints, Breakpoints
1648 @subsection Setting Breakpoints
1652 Breakpoints are set with the @code{break} command (abbreviated @code{b}).
1654 You have several ways to say where the breakpoint should go.
1657 @item break @var{function}
1658 Set a breakpoint at entry to function @var{function}. When using source
1659 languages that permit overloading of symbols, such as C++,
1660 @var{function} may refer to more than one possible place to break.
1661 @xref{Breakpoint Menus}, for a discussion of that situation.
1663 @item break +@var{offset}
1664 @itemx break -@var{offset}
1665 Set a breakpoint some number of lines forward or back from the position
1666 at which execution stopped in the currently selected frame.
1668 @item break @var{linenum}
1669 Set a breakpoint at line @var{linenum} in the current source file.
1670 That file is the last file whose source text was printed. This
1671 breakpoint will stop the program just before it executes any of the
1674 @item break @var{filename}:@var{linenum}
1675 Set a breakpoint at line @var{linenum} in source file @var{filename}.
1677 @item break @var{filename}:@var{function}
1678 Set a breakpoint at entry to function @var{function} found in file
1679 @var{filename}. Specifying a file name as well as a function name is
1680 superfluous except when multiple files contain similarly named
1683 @item break *@var{address}
1684 Set a breakpoint at address @var{address}. You can use this to set
1685 breakpoints in parts of the program which do not have debugging
1686 information or source files.
1689 When called without any arguments, @code{break} sets a breakpoint at the
1690 next instruction to be executed in the selected stack frame
1691 (@pxref{Stack}). In any selected frame but the innermost, this will
1692 cause the program to stop as soon as control returns to that frame.
1693 This is similar to the effect of a @code{finish} command in the frame
1694 inside the selected frame---except that @code{finish} doesn't leave an
1695 active breakpoint. If you use @code{break} without an argument in the
1696 innermost frame, _GDBN__ will stop the next time it reaches the current
1697 location; this may be useful inside loops.
1699 _GDBN__ normally ignores breakpoints when it resumes execution, until at
1700 least one instruction has been executed. If it did not do this, you
1701 would be unable to proceed past a breakpoint without first disabling the
1702 breakpoint. This rule applies whether or not the breakpoint already
1703 existed when the program stopped.
1705 @item break @dots{} if @var{cond}
1706 Set a breakpoint with condition @var{cond}; evaluate the expression
1707 @var{cond} each time the breakpoint is reached, and stop only if the
1708 value is nonzero---that is, if @var{cond} evaluates as true.
1709 @samp{@dots{}} stands for one of the possible arguments described above
1710 (or no argument) specifying where to break. @xref{Conditions}, for more
1711 information on breakpoint conditions.
1713 @item tbreak @var{args}
1715 Set a breakpoint enabled only for one stop. @var{args} are the
1716 same as for the @code{break} command, and the breakpoint is set in the same
1717 way, but the breakpoint is automatically disabled the first time it
1718 is hit. @xref{Disabling}.
1720 @item rbreak @var{regex}
1722 @cindex regular expression
1723 Set breakpoints on all functions matching the regular expression
1724 @var{regex}. This command
1725 sets an unconditional breakpoint on all matches, printing a list of all
1726 breakpoints it set. Once these breakpoints are set, they are treated
1727 just like the breakpoints set with the @code{break} command. They can
1728 be deleted, disabled, made conditional, etc., in the standard ways.
1730 When debugging C++ programs, @code{rbreak} is useful for setting
1731 breakpoints on overloaded functions that are not members of any special
1734 @kindex info breakpoints
1736 @item info breakpoints @r{[}@var{n}@r{]}
1737 @item info break @r{[}@var{n}@r{]}
1738 Print a list of all breakpoints (but not watchpoints) set and not
1739 deleted, showing their numbers, where in the program they are, and any
1740 special features in use for them. Disabled breakpoints are included in
1741 the list, but marked as disabled. @code{info break} with a breakpoint
1742 number @var{n} as argument lists only that breakpoint. The convenience
1743 variable @code{$_} and the default examining-address for the @code{x}
1744 command are set to the address of the last breakpoint listed
1745 (@pxref{Memory}). The equivalent command for watchpoints is @code{info
1748 _GDBN__ allows you to set any number of breakpoints at the same place in the
1749 program. There is nothing silly or meaningless about this. When the
1750 breakpoints are conditional, this is even useful (@pxref{Conditions}).
1752 @node Set Watchpoints, Exception Handling, Set Breaks, Breakpoints
1753 @subsection Setting Watchpoints
1754 @cindex setting watchpoints
1755 You can use a watchpoint to stop execution whenever the value of an
1756 expression changes, without having to predict a particular place
1757 where this may happen.
1759 Watchpoints currently execute two orders of magnitude more slowly than
1760 other breakpoints, but this can well be worth it to catch errors where
1761 you have no clue what part of your program is the culprit. Some
1762 processors provide special hardware to support watchpoint evaluation; future
1763 releases of _GDBN__ will use such hardware if it is available.
1767 @item watch @var{expr}
1768 Set a watchpoint for an expression.
1770 @kindex info watchpoints
1771 @item info watchpoints
1772 This command prints a list of watchpoints; it is otherwise similar to
1776 @node Exception Handling, Delete Breaks, Set Watchpoints, Breakpoints
1777 @subsection Breakpoints and Exceptions
1778 @cindex exception handlers
1780 Some languages, such as GNU C++, implement exception handling. You can
1781 use _GDBN__ to examine what caused the program to raise an exception,
1782 and to list the exceptions the program is prepared to handle at a
1783 given point in time.
1786 @item catch @var{exceptions}
1788 You can set breakpoints at active exception handlers by using the
1789 @code{catch} command. @var{exceptions} is a list of names of exceptions
1793 You can use @code{info catch} to list active exception handlers;
1796 There are currently some limitations to exception handling in _GDBN__.
1797 These will be corrected in a future release.
1801 If you call a function interactively, _GDBN__ normally returns
1802 control to you when the function has finished executing. If the call
1803 raises an exception, however, the call may bypass the mechanism that
1804 returns control to the user and cause the program to simply continue
1805 running until it hits a breakpoint, catches a signal that _GDBN__ is
1806 listening for, or exits.
1808 You cannot raise an exception interactively.
1810 You cannot interactively install an exception handler.
1813 @cindex raise exceptions
1814 Sometimes @code{catch} is not the best way to debug exception handling:
1815 if you need to know exactly where an exception is raised, it's better to
1816 stop @emph{before} the exception handler is called, since that way you
1817 can see the stack before any unwinding takes place. If you set a
1818 breakpoint in an exception handler instead, it may not be easy to find
1819 out where the exception was raised.
1821 To stop just before an exception handler is called, you need some
1822 knowledge of the implementation. In the case of GNU C++, exceptions are
1823 raised by calling a library function named @code{__raise_exception}
1824 which has the following ANSI C interface:
1827 /* @var{addr} is where the exception identifier is stored.
1828 ID is the exception identifier. */
1829 void __raise_exception (void **@var{addr}, void *@var{id});
1833 To make the debugger catch all exceptions before any stack
1834 unwinding takes place, set a breakpoint on @code{__raise_exception}
1835 (@pxref{Breakpoints}).
1837 With a conditional breakpoint (@xref{Conditions}) that depends on the
1838 value of @var{id}, you can stop your program when a specific exception
1839 is raised. You can use multiple conditional breakpoints to stop the
1840 program when any of a number of exceptions are raised.
1842 @node Delete Breaks, Disabling, Exception Handling, Breakpoints
1843 @subsection Deleting Breakpoints
1845 @cindex clearing breakpoints, watchpoints
1846 @cindex deleting breakpoints, watchpoints
1847 It is often necessary to eliminate a breakpoint or watchpoint once it
1848 has done its job and you no longer want the program to stop there. This
1849 is called @dfn{deleting} the breakpoint. A breakpoint that has been
1850 deleted no longer exists; it is forgotten.
1852 With the @code{clear} command you can delete breakpoints according to
1853 where they are in the program. With the @code{delete} command you can
1854 delete individual breakpoints or watchpoints by specifying their
1857 It is not necessary to delete a breakpoint to proceed past it. _GDBN__
1858 automatically ignores breakpoints on the first instruction to be executed
1859 when you continue execution without changing the execution address.
1864 Delete any breakpoints at the next instruction to be executed in the
1865 selected stack frame (@pxref{Selection}). When the innermost frame
1866 is selected, this is a good way to delete a breakpoint that the program
1869 @item clear @var{function}
1870 @itemx clear @var{filename}:@var{function}
1871 Delete any breakpoints set at entry to the function @var{function}.
1873 @item clear @var{linenum}
1874 @itemx clear @var{filename}:@var{linenum}
1875 Delete any breakpoints set at or within the code of the specified line.
1877 @item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
1878 @cindex delete breakpoints
1881 Delete the breakpoints or watchpoints of the numbers specified as
1882 arguments. If no argument is specified, delete all breakpoints (_GDBN__
1883 asks confirmation, unless you've @code{set confirm off}). You
1884 can abbreviate this command as @code{d}.
1887 @node Disabling, Conditions, Delete Breaks, Breakpoints
1888 @subsection Disabling Breakpoints
1890 @cindex disabled breakpoints
1891 @cindex enabled breakpoints
1892 Rather than deleting a breakpoint or watchpoint, you might prefer to
1893 @dfn{disable} it. This makes the breakpoint inoperative as if it had
1894 been deleted, but remembers the information on the breakpoint so that
1895 you can @dfn{enable} it again later.
1897 You disable and enable breakpoints and watchpoints with the
1898 @code{enable} and @code{disable} commands, optionally specifying one or
1899 more breakpoint numbers as arguments. Use @code{info break} or
1900 @code{info watch} to print a list of breakpoints or watchpoints if you
1901 don't know which numbers to use.
1903 A breakpoint or watchpoint can have any of four different states of
1908 Enabled. The breakpoint will stop the program. A breakpoint set
1909 with the @code{break} command starts out in this state.
1911 Disabled. The breakpoint has no effect on the program.
1913 Enabled once. The breakpoint will stop the program, but
1914 when it does so it will become disabled. A breakpoint set
1915 with the @code{tbreak} command starts out in this state.
1917 Enabled for deletion. The breakpoint will stop the program, but
1918 immediately after it does so it will be deleted permanently.
1921 You can use the following commands to enable or disable breakpoints and
1925 @item disable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
1926 @kindex disable breakpoints
1929 Disable the specified breakpoints---or all breakpoints, if none are
1930 listed. A disabled breakpoint has no effect but is not forgotten. All
1931 options such as ignore-counts, conditions and commands are remembered in
1932 case the breakpoint is enabled again later. You may abbreviate
1933 @code{disable} as @code{dis}.
1935 @item enable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
1936 @kindex enable breakpoints
1938 Enable the specified breakpoints (or all defined breakpoints). They
1939 become effective once again in stopping the program.
1941 @item enable @r{[}breakpoints@r{]} once @var{bnums}@dots{}
1942 Enable the specified breakpoints temporarily. Each will be disabled
1943 again the next time it stops the program.
1945 @item enable @r{[}breakpoints@r{]} delete @var{bnums}@dots{}
1946 Enable the specified breakpoints to work once and then die. Each of
1947 the breakpoints will be deleted the next time it stops the program.
1950 Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks}),
1951 breakpoints that you set are initially enabled; subsequently, they become
1952 disabled or enabled only when you use one of the commands above. (The
1953 command @code{until} can set and delete a breakpoint of its own, but it
1954 will not change the state of your other breakpoints;
1955 @pxref{Continuing and Stepping}.)
1957 @node Conditions, Break Commands, Disabling, Breakpoints
1958 @subsection Break Conditions
1959 @cindex conditional breakpoints
1960 @cindex breakpoint conditions
1962 The simplest sort of breakpoint breaks every time the program reaches a
1963 specified place. You can also specify a @dfn{condition} for a
1964 breakpoint. A condition is just a Boolean expression in your
1965 programming language. (@xref{Expressions}). A breakpoint with a condition
1966 evaluates the expression each time the program reaches it, and the
1967 program stops only if the condition is @emph{true}.
1969 This is the converse of using assertions for program validation; in that
1970 situation, you want to stop when the assertion is violated---that is,
1971 when the condition is false. In C, if you want to test an assertion expressed
1972 by the condition @var{assert}, you should set the condition
1973 @samp{! @var{assert}} on the appropriate breakpoint.
1975 Conditions are also accepted for watchpoints; you may not need them,
1976 since a watchpoint is inspecting the value of an expression anyhow---but
1977 it might be simpler, say, to just set a watchpoint on a variable name,
1978 and specify a condition that tests whether the new value is an interesting
1981 Break conditions ca have side effects, and may even call functions in
1982 your program. This can be useful, for example, to activate functions
1983 that log program progress, or to use your own print functions to format
1984 special data structures. The effects are completely predictable unless
1985 there is another enabled breakpoint at the same address. (In that
1986 case, _GDBN__ might see the other breakpoint first and stop the program
1987 without checking the condition of this one.) Note that breakpoint
1988 commands are usually more convenient and flexible for the purpose of
1989 performing side effects when a breakpoint is reached (@pxref{Break
1992 Break conditions can be specified when a breakpoint is set, by using
1993 @samp{if} in the arguments to the @code{break} command. @xref{Set Breaks}.
1994 They can also be changed at any time with the @code{condition} command.
1995 The @code{watch} command doesn't recognize the @code{if} keyword;
1996 @code{condition} is the only way to impose a further condition on a
2000 @item condition @var{bnum} @var{expression}
2002 Specify @var{expression} as the break condition for breakpoint or
2003 watchpoint number @var{bnum}. From now on, this breakpoint will stop
2004 the program only if the value of @var{expression} is true (nonzero, in
2005 C). When you use @code{condition}, _GDBN__ checks @var{expression}
2006 immediately for syntactic correctness, and to determine whether symbols
2007 in it have referents in the context of your breakpoint. _GDBN__ does
2008 not actually evaluate @var{expression} at the time the @code{condition}
2009 command is given, however. @xref{Expressions}.
2011 @item condition @var{bnum}
2012 Remove the condition from breakpoint number @var{bnum}. It becomes
2013 an ordinary unconditional breakpoint.
2016 @cindex ignore count (of breakpoint)
2017 A special case of a breakpoint condition is to stop only when the
2018 breakpoint has been reached a certain number of times. This is so
2019 useful that there is a special way to do it, using the @dfn{ignore
2020 count} of the breakpoint. Every breakpoint has an ignore count, which
2021 is an integer. Most of the time, the ignore count is zero, and
2022 therefore has no effect. But if the program reaches a breakpoint whose
2023 ignore count is positive, then instead of stopping, it just decrements
2024 the ignore count by one and continues. As a result, if the ignore count
2025 value is @var{n}, the breakpoint will not stop the next @var{n} times it
2029 @item ignore @var{bnum} @var{count}
2031 Set the ignore count of breakpoint number @var{bnum} to @var{count}.
2032 The next @var{count} times the breakpoint is reached, your program's
2033 execution will not stop; other than to decrement the ignore count, _GDBN__
2036 To make the breakpoint stop the next time it is reached, specify
2039 @item continue @var{count}
2040 @itemx c @var{count}
2041 @itemx fg @var{count}
2042 @kindex continue @var{count}
2043 Continue execution of the program, setting the ignore count of the
2044 breakpoint that the program stopped at to @var{count} minus one.
2045 Thus, the program will not stop at this breakpoint until the
2046 @var{count}'th time it is reached.
2048 An argument to this command is meaningful only when the program stopped
2049 due to a breakpoint. At other times, the argument to @code{continue} is
2052 The synonym @code{fg} is provided purely for convenience, and has
2053 exactly the same behavior as other forms of the command.
2056 If a breakpoint has a positive ignore count and a condition, the condition
2057 is not checked. Once the ignore count reaches zero, the condition will
2060 You could achieve the effect of the ignore count with a
2061 condition such as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience
2062 variable that is decremented each time. @xref{Convenience Vars}.
2064 @node Break Commands, Breakpoint Menus, Conditions, Breakpoints
2065 @subsection Breakpoint Command Lists
2067 @cindex breakpoint commands
2068 You can give any breakpoint (or watchpoint) a series of commands to
2069 execute when the program stops due to that breakpoint. For example, you
2070 might want to print the values of certain expressions, or enable other
2074 @item commands @r{[}@var{bnum}@r{]}
2075 @itemx @dots{} @var{command-list} @dots{}
2079 Specify a list of commands for breakpoint number @var{bnum}. The commands
2080 themselves appear on the following lines. Type a line containing just
2081 @code{end} to terminate the commands.
2083 To remove all commands from a breakpoint, type @code{commands} followed
2084 immediately by @code{end}; that is, give no commands.
2086 With no @var{bnum} argument, @code{commands} refers to the last
2087 breakpoint or watchpoint set (not to the breakpoint most recently
2091 Pressing @key{RET} as a means of repeating the last _GDBN__ command is
2092 disabled within a @var{command-list}.
2094 You can use breakpoint commands to start the program up again. Simply
2095 use the @code{continue} command, or @code{step}, or any other command
2096 that resumes execution. Subsequent commands in the command list are
2100 If the first command specified is @code{silent}, the usual message about
2101 stopping at a breakpoint is not printed. This may be desirable for
2102 breakpoints that are to print a specific message and then continue.
2103 If the remaining commands too print nothing, you will see no sign that
2104 the breakpoint was reached at all. @code{silent} is meaningful only
2105 at the beginning of a breakpoint command list.
2107 The commands @code{echo} and @code{output} that allow you to print precisely
2108 controlled output are often useful in silent breakpoints. @xref{Output}.
2110 For example, here is how you could use breakpoint commands to print the
2111 value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
2124 One application for breakpoint commands is to compensate for one bug so
2125 you can test for another. Put a breakpoint just after the erroneous line
2126 of code, give it a condition to detect the case in which something
2127 erroneous has been done, and give it commands to assign correct values
2128 to any variables that need them. End with the @code{continue} command
2129 so that the program does not stop, and start with the @code{silent}
2130 command so that no output is produced. Here is an example:
2142 One deficiency in the operation of automatically continuing breakpoints
2143 under Unix appears when your program uses raw mode for the terminal.
2144 _GDBN__ switches back to its own terminal modes (not raw) before executing
2145 commands, and then must switch back to raw mode when your program is
2146 continued. This causes any pending terminal input to be lost.
2147 @c FIXME: revisit below when GNU sys avail.
2148 @c In the GNU system, this will be fixed by changing the behavior of
2151 Under Unix, you can get around this problem by writing actions into
2152 the breakpoint condition rather than in commands. For example
2155 condition 5 (x = y + 4), 0
2159 specifies a condition expression (@xref{Expressions}) that will change
2160 @code{x} as needed, then always have the value zero so the program will
2161 not stop. No input is lost here, because _GDBN__ evaluates break
2162 conditions without changing the terminal modes. When you want to have
2163 nontrivial conditions for performing the side effects, the operators
2164 @samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful.
2166 @node Breakpoint Menus, Error in Breakpoints, Break Commands, Breakpoints
2167 @subsection Breakpoint Menus
2169 @cindex symbol overloading
2171 Some programming languages (notably C++) permit a single function name
2172 to be defined several times, for application in different contexts.
2173 This is called @dfn{overloading}. When a function name is overloaded,
2174 @samp{break @var{function}} is not enough to tell _GDBN__ where you
2175 want a breakpoint. _GDBN__ offers you a menu of numbered choices for
2176 different possible breakpoints, and waits for your selection with the
2177 prompt @samp{>}. The first two options are always @samp{[0] cancel}
2178 and @samp{[1] all}. Typing @kbd{1} sets a breakpoint at each
2179 definition of @var{function}, and typing @kbd{0} aborts the
2180 @code{break} command without setting any new breakpoints.
2182 For example, the following session excerpt shows an attempt to set a
2183 breakpoint at the overloaded symbol @code{String::after}.
2184 We choose three particular definitions of that function name:
2187 (_GDBP__) b String::after
2190 [2] file:String.cc; line number:867
2191 [3] file:String.cc; line number:860
2192 [4] file:String.cc; line number:875
2193 [5] file:String.cc; line number:853
2194 [6] file:String.cc; line number:846
2195 [7] file:String.cc; line number:735
2197 Breakpoint 1 at 0xb26c: file String.cc, line 867.
2198 Breakpoint 2 at 0xb344: file String.cc, line 875.
2199 Breakpoint 3 at 0xafcc: file String.cc, line 846.
2200 Multiple breakpoints were set.
2201 Use the "delete" command to delete unwanted breakpoints.
2206 @node Error in Breakpoints, , Breakpoint Menus, Breakpoints
2207 @subsection ``Cannot Insert Breakpoints''
2209 @c FIXME: "cannot insert breakpoints" error, v unclear.
2210 @c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91
2211 Under some operating systems, breakpoints cannot be used in a program if
2212 any other process is running that program. In this situation,
2213 attempting to run or continue a program with a breakpoint causes _GDBN__
2214 to stop the other process.
2216 When this happens, you have three ways to proceed:
2220 Remove or disable the breakpoints, then continue.
2223 Suspend _GDBN__, and copy the file containing the program to a new name.
2224 Resume _GDBN__ and use the @code{exec-file} command to specify that _GDBN__
2225 should run the program under that name. Then start the program again.
2227 @c FIXME: RMS commented here "Show example". Maybe when someone
2228 @c explains the first FIXME: in this section...
2231 Relink the program so that the text segment is nonsharable, using the
2232 linker option @samp{-N}. The operating system limitation may not apply
2233 to nonsharable executables.
2236 @node Continuing and Stepping, Signals, Breakpoints, Stopping
2237 @section Continuing and Stepping
2241 @cindex resuming execution
2242 @dfn{Continuing} means resuming program execution until your program
2243 completes normally. In contrast, @dfn{stepping} means resuming program
2244 execution for a very limited time: one line of source code, or one
2245 machine instruction. Either when continuing or when stepping, the
2246 program may stop even sooner, due to a breakpoint or to a signal. (If
2247 due to a signal, you may want to use @code{handle}, or use @samp{signal
2248 0} to resume execution; @pxref{Signals}.)
2251 @item continue @r{[}@var{ignore-count}@r{]}
2253 Resume program execution, at the address where the program last stopped;
2254 any breakpoints set at that address are bypassed. The optional argument
2255 @var{ignore-count} allows you to specify a further number of times to
2256 ignore a breakpoint at this location; its effect is like that of
2257 @code{ignore} (@pxref{Conditions}).
2259 To resume execution at a different place, you can use @code{return}
2260 (@pxref{Returning}) to go back to the calling function; or @code{jump}
2261 (@pxref{Jumping}) to go to an arbitrary location in your program.
2265 A typical technique for using stepping is to set a breakpoint
2266 (@pxref{Breakpoints}) at the beginning of the function or the section of
2267 the program in which a problem is believed to lie, run the program until
2268 it stops at that breakpoint, and then step through the suspect area,
2269 examining the variables that are interesting, until you see the problem
2276 Continue running the program until control reaches a different source
2277 line, then stop it and return control to _GDBN__. This command is
2278 abbreviated @code{s}.
2281 @emph{Warning:} If you use the @code{step} command while control is
2282 within a function that was compiled without debugging information,
2283 execution will proceed until control reaches another function.
2286 @item step @var{count}
2287 Continue running as in @code{step}, but do so @var{count} times. If a
2288 breakpoint is reached or a signal not related to stepping occurs before
2289 @var{count} steps, stepping stops right away.
2291 @item next @r{[}@var{count}@r{]}
2294 Continue to the next source line in the current (innermost) stack frame.
2295 Similar to @code{step}, but any function calls appearing within the line
2296 of code are executed without stopping. Execution stops when control
2297 reaches a different line of code at the stack level which was executing
2298 when the @code{next} command was given. This command is abbreviated
2301 An argument @var{count} is a repeat count, as for @code{step}.
2303 @code{next} within a function that lacks debugging information acts like
2304 @code{step}, but any function calls appearing within the code of the
2305 function are executed without stopping.
2309 Continue running until just after function in the selected stack frame
2310 returns. Print the returned value (if any).
2312 Contrast this with the @code{return} command (@pxref{Returning}).
2318 Continue running until a source line past the current line, in the
2319 current stack frame, is reached. This command is used to avoid single
2320 stepping through a loop more than once. It is like the @code{next}
2321 command, except that when @code{until} encounters a jump, it
2322 automatically continues execution until the program counter is greater
2323 than the address of the jump.
2325 This means that when you reach the end of a loop after single stepping
2326 though it, @code{until} will cause the program to continue execution
2327 until the loop is exited. In contrast, a @code{next} command at the end
2328 of a loop will simply step back to the beginning of the loop, which
2329 would force you to step through the next iteration.
2331 @code{until} always stops the program if it attempts to exit the current
2334 @code{until} may produce somewhat counterintuitive results if the order
2335 of machine code does not match the order of the source lines. For
2336 example, in the following excerpt from a debugging session, the @code{f}
2337 (@code{frame}) command shows that execution is stopped at line
2338 @code{206}; yet when we use @code{until}, we get to line @code{195}:
2342 #0 main (argc=4, argv=0xf7fffae8) at m4.c:206
2345 195 for ( ; argc > 0; NEXTARG) @{
2348 This happened because, for execution efficiency, the compiler had
2349 generated code for the loop closure test at the end, rather than the
2350 start, of the loop---even though the test in a C @code{for}-loop is
2351 written before the body of the loop. The @code{until} command appeared
2352 to step back to the beginning of the loop when it advanced to this
2353 expression; however, it has not really gone to an earlier
2354 statement---not in terms of the actual machine code.
2356 @code{until} with no argument works by means of single
2357 instruction stepping, and hence is slower than @code{until} with an
2360 @item until @var{location}
2361 @item u @var{location}
2362 Continue running the program until either the specified location is
2363 reached, or the current stack frame returns. @var{location}
2364 is any of the forms of argument acceptable to @code{break} (@pxref{Set
2365 Breaks}). This form of the command uses breakpoints, and hence is
2366 quicker than @code{until} without an argument.
2372 Execute one machine instruction, then stop and return to the debugger.
2374 It is often useful to do @samp{display/i $pc} when stepping by machine
2375 instructions. This will cause the next instruction to be executed to
2376 be displayed automatically at each stop. @xref{Auto Display}.
2378 An argument is a repeat count, as in @code{step}.
2384 Execute one machine instruction, but if it is a function call,
2385 proceed until the function returns.
2387 An argument is a repeat count, as in @code{next}.
2391 @node Signals, , Continuing and Stepping, Stopping
2395 A signal is an asynchronous event that can happen in a program. The
2396 operating system defines the possible kinds of signals, and gives each
2397 kind a name and a number. For example, in Unix @code{SIGINT} is the
2398 signal a program gets when you type an interrupt (often @kbd{C-c});
2399 @code{SIGSEGV} is the signal a program gets from referencing a place in
2400 memory far away from all the areas in use; @code{SIGALRM} occurs when
2401 the alarm clock timer goes off (which happens only if the program has
2402 requested an alarm).
2404 @cindex fatal signals
2405 Some signals, including @code{SIGALRM}, are a normal part of the
2406 functioning of the program. Others, such as @code{SIGSEGV}, indicate
2407 errors; these signals are @dfn{fatal} (kill the program immediately) if the
2408 program has not specified in advance some other way to handle the signal.
2409 @code{SIGINT} does not indicate an error in the program, but it is normally
2410 fatal so it can carry out the purpose of the interrupt: to kill the program.
2412 _GDBN__ has the ability to detect any occurrence of a signal in the program
2413 running under _GDBN__'s control. You can tell _GDBN__ in advance what to do for
2414 each kind of signal.
2416 @cindex handling signals
2417 Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM}
2418 (so as not to interfere with their role in the functioning of the program)
2419 but to stop the program immediately whenever an error signal happens.
2420 You can change these settings with the @code{handle} command.
2424 @kindex info signals
2425 Print a table of all the kinds of signals and how _GDBN__ has been told to
2426 handle each one. You can use this to see the signal numbers of all
2427 the defined types of signals.
2429 @item handle @var{signal} @var{keywords}@dots{}
2431 Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the
2432 number of a signal or its name (with or without the @samp{SIG} at the
2433 beginning). The @var{keywords} say what change to make.
2437 The keywords allowed by the @code{handle} command can be abbreviated.
2438 Their full names are:
2442 _GDBN__ should not stop the program when this signal happens. It may
2443 still print a message telling you that the signal has come in.
2446 _GDBN__ should stop the program when this signal happens. This implies
2447 the @code{print} keyword as well.
2450 _GDBN__ should print a message when this signal happens.
2453 _GDBN__ should not mention the occurrence of the signal at all. This
2454 implies the @code{nostop} keyword as well.
2457 _GDBN__ should allow the program to see this signal; the program will be
2458 able to handle the signal, or may be terminated if the signal is fatal
2462 _GDBN__ should not allow the program to see this signal.
2466 When a signal has been set to stop the program, the program cannot see the
2467 signal until you continue. It will see the signal then, if @code{pass} is
2468 in effect for the signal in question @i{at that time}. In other words,
2469 after _GDBN__ reports a signal, you can use the @code{handle} command with
2470 @code{pass} or @code{nopass} to control whether that signal will be seen by
2471 the program when you later continue it.
2473 You can also use the @code{signal} command to prevent the program from
2474 seeing a signal, or cause it to see a signal it normally would not see,
2475 or to give it any signal at any time. For example, if the program stopped
2476 due to some sort of memory reference error, you might store correct
2477 values into the erroneous variables and continue, hoping to see more
2478 execution; but the program would probably terminate immediately as
2479 a result of the fatal signal once it sees the signal. To prevent this,
2480 you can continue with @samp{signal 0}. @xref{Signaling}.
2482 @node Stack, Source, Stopping, Top
2483 @chapter Examining the Stack
2485 When your program has stopped, the first thing you need to know is where it
2486 stopped and how it got there.
2489 Each time your program performs a function call, the information about
2490 where in the program the call was made from is saved in a block of data
2491 called a @dfn{stack frame}. The frame also contains the arguments of the
2492 call and the local variables of the function that was called. All the
2493 stack frames are allocated in a region of memory called the @dfn{call
2496 When your program stops, the _GDBN__ commands for examining the stack allow you
2497 to see all of this information.
2499 @cindex selected frame
2500 One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands
2501 refer implicitly to the selected frame. In particular, whenever you ask
2502 _GDBN__ for the value of a variable in the program, the value is found in the
2503 selected frame. There are special _GDBN__ commands to select whichever frame
2504 you are interested in.
2506 When the program stops, _GDBN__ automatically selects the currently executing
2507 frame and describes it briefly as the @code{frame} command does
2508 (@pxref{Frame Info, Info}).
2511 * Frames:: Stack Frames
2512 * Backtrace:: Backtraces
2513 * Selection:: Selecting a Frame
2514 * Frame Info:: Information on a Frame
2517 @node Frames, Backtrace, Stack, Stack
2518 @section Stack Frames
2522 The call stack is divided up into contiguous pieces called @dfn{stack
2523 frames}, or @dfn{frames} for short; each frame is the data associated
2524 with one call to one function. The frame contains the arguments given
2525 to the function, the function's local variables, and the address at
2526 which the function is executing.
2528 @cindex initial frame
2529 @cindex outermost frame
2530 @cindex innermost frame
2531 When your program is started, the stack has only one frame, that of the
2532 function @code{main}. This is called the @dfn{initial} frame or the
2533 @dfn{outermost} frame. Each time a function is called, a new frame is
2534 made. Each time a function returns, the frame for that function invocation
2535 is eliminated. If a function is recursive, there can be many frames for
2536 the same function. The frame for the function in which execution is
2537 actually occurring is called the @dfn{innermost} frame. This is the most
2538 recently created of all the stack frames that still exist.
2540 @cindex frame pointer
2541 Inside your program, stack frames are identified by their addresses. A
2542 stack frame consists of many bytes, each of which has its own address; each
2543 kind of computer has a convention for choosing one of those bytes whose
2544 address serves as the address of the frame. Usually this address is kept
2545 in a register called the @dfn{frame pointer register} while execution is
2546 going on in that frame.
2548 @cindex frame number
2549 _GDBN__ assigns numbers to all existing stack frames, starting with
2550 zero for the innermost frame, one for the frame that called it,
2551 and so on upward. These numbers do not really exist in your program;
2552 they are assigned by _GDBN__ to give you a way of designating stack
2553 frames in _GDBN__ commands.
2555 @cindex frameless execution
2556 Some compilers allow functions to be compiled so that they operate
2557 without stack frames. (For example, the @code{_GCC__} option
2558 @samp{-fomit-frame-pointer} will generate functions without a frame.)
2559 This is occasionally done with heavily used library functions to save
2560 the frame setup time. _GDBN__ has limited facilities for dealing with
2561 these function invocations. If the innermost function invocation has no
2562 stack frame, _GDBN__ will nevertheless regard it as though it had a
2563 separate frame, which is numbered zero as usual, allowing correct
2564 tracing of the function call chain. However, _GDBN__ has no provision
2565 for frameless functions elsewhere in the stack.
2567 @node Backtrace, Selection, Frames, Stack
2570 A backtrace is a summary of how the program got where it is. It shows one
2571 line per frame, for many frames, starting with the currently executing
2572 frame (frame zero), followed by its caller (frame one), and on up the
2580 Print a backtrace of the entire stack: one line per frame for all
2581 frames in the stack.
2583 You can stop the backtrace at any time by typing the system interrupt
2584 character, normally @kbd{C-c}.
2586 @item backtrace @var{n}
2588 Similar, but print only the innermost @var{n} frames.
2590 @item backtrace -@var{n}
2592 Similar, but print only the outermost @var{n} frames.
2598 The names @code{where} and @code{info stack} (abbreviated @code{info s})
2599 are additional aliases for @code{backtrace}.
2601 Each line in the backtrace shows the frame number and the function name.
2602 The program counter value is also shown---unless you use @code{set
2603 print address off}. The backtrace also shows the source file name and
2604 line number, as well as the arguments to the function. The program
2605 counter value is omitted if it is at the beginning of the code for that
2608 Here is an example of a backtrace. It was made with the command
2609 @samp{bt 3}, so it shows the innermost three frames.
2613 #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) at builtin.c:993
2614 #1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
2615 #2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
2617 (More stack frames follow...)
2622 The display for frame zero doesn't begin with a program counter
2623 value, indicating that the program has stopped at the beginning of the
2624 code for line @code{993} of @code{builtin.c}.
2626 @node Selection, Frame Info, Backtrace, Stack
2627 @section Selecting a Frame
2629 Most commands for examining the stack and other data in the program work on
2630 whichever stack frame is selected at the moment. Here are the commands for
2631 selecting a stack frame; all of them finish by printing a brief description
2632 of the stack frame just selected.
2639 Select frame number @var{n}. Recall that frame zero is the innermost
2640 (currently executing) frame, frame one is the frame that called the
2641 innermost one, and so on. The highest-numbered frame is @code{main}'s
2644 @item frame @var{addr}
2646 Select the frame at address @var{addr}. This is useful mainly if the
2647 chaining of stack frames has been damaged by a bug, making it
2648 impossible for _GDBN__ to assign numbers properly to all frames. In
2649 addition, this can be useful when the program has multiple stacks and
2650 switches between them.
2653 On the SPARC architecture, @code{frame} needs two addresses to
2654 select an arbitrary frame: a frame pointer and a stack pointer.
2655 @c note to future updaters: this is conditioned on a flag
2656 @c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used
2657 @c by SPARC, hence the specific attribution. Generalize or list all
2658 @c possibilities if more supported machines start doing this.
2663 Move @var{n} frames up the stack. For positive numbers @var{n}, this
2664 advances toward the outermost frame, to higher frame numbers, to frames
2665 that have existed longer. @var{n} defaults to one.
2670 Move @var{n} frames down the stack. For positive numbers @var{n}, this
2671 advances toward the innermost frame, to lower frame numbers, to frames
2672 that were created more recently. @var{n} defaults to one. You may
2673 abbreviate @code{down} as @code{do}.
2676 All of these commands end by printing two lines of output describing the
2677 frame. The first line shows the frame number, the function name, the
2678 arguments, and the source file and line number of execution in that
2679 frame. The second line shows the text of that source line. For
2684 #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) at env.c:10
2685 10 read_input_file (argv[i]);
2688 After such a printout, the @code{list} command with no arguments will print
2689 ten lines centered on the point of execution in the frame. @xref{List}.
2692 @item up-silently @var{n}
2693 @itemx down-silently @var{n}
2694 @kindex down-silently
2696 These two commands are variants of @code{up} and @code{down},
2697 respectively; they differ in that they do their work silently, without
2698 causing display of the new frame. They are intended primarily for use
2699 in _GDBN__ command scripts, where the output might be unnecessary and
2704 @node Frame Info, , Selection, Stack
2705 @section Information About a Frame
2707 There are several other commands to print information about the selected
2713 When used without any argument, this command does not change which frame
2714 is selected, but prints a brief description of the currently
2715 selected stack frame. It can be abbreviated @code{f}. With an
2716 argument, this command is used to select a stack frame (@pxref{Selection}).
2722 This command prints a verbose description of the selected stack frame,
2723 including the address of the frame, the addresses of the next frame down
2724 (called by this frame) and the next frame up (caller of this frame), the
2725 language that the source code corresponding to this frame was written in,
2726 the address of the frame's arguments, the program counter saved in it
2727 (the address of execution in the caller frame), and which registers
2728 were saved in the frame. The verbose description is useful when
2729 something has gone wrong that has made the stack format fail to fit
2730 the usual conventions.
2732 @item info frame @var{addr}
2733 @itemx info f @var{addr}
2734 Print a verbose description of the frame at address @var{addr},
2735 without selecting that frame. The selected frame remains unchanged by
2740 Print the arguments of the selected frame, each on a separate line.
2744 Print the local variables of the selected frame, each on a separate
2745 line. These are all variables declared static or automatic within all
2746 program blocks that execution in this frame is currently inside of.
2750 @cindex catch exceptions
2751 @cindex exception handlers
2752 Print a list of all the exception handlers that are active in the
2753 current stack frame at the current point of execution. To see other
2754 exception handlers, visit the associated frame (using the @code{up},
2755 @code{down}, or @code{frame} commands); then type @code{info catch}.
2756 @xref{Exception Handling}.
2759 @node Source, Data, Stack, Top
2760 @chapter Examining Source Files
2762 _GDBN__ can print parts of your program's source, since the debugging
2763 information recorded in your program tells _GDBN__ what source files
2764 were used to built it. When your program stops, _GDBN__ spontaneously
2765 prints the line where it stopped. Likewise, when you select a stack
2766 frame (@pxref{Selection}), _GDBN__ prints the line where execution in
2767 that frame has stopped. You can print other portions of source files by
2770 If you use _GDBN__ through its GNU Emacs interface, you may prefer to
2771 use Emacs facilities to view source; @pxref{Emacs}.
2774 * List:: Printing Source Lines
2775 * Search:: Searching Source Files
2776 * Source Path:: Specifying Source Directories
2777 * Machine Code:: Source and Machine Code
2780 @node List, Search, Source, Source
2781 @section Printing Source Lines
2785 To print lines from a source file, use the @code{list} command
2786 (abbreviated @code{l}). There are several ways to specify what part
2787 of the file you want to print.
2789 Here are the forms of the @code{list} command most commonly used:
2792 @item list @var{linenum}
2793 Print ten lines centered around line number @var{linenum} in the
2794 current source file.
2796 @item list @var{function}
2797 Print ten lines centered around the beginning of function
2801 Print ten more lines. If the last lines printed were printed with a
2802 @code{list} command, this prints ten lines following the last lines
2803 printed; however, if the last line printed was a solitary line printed
2804 as part of displaying a stack frame (@pxref{Stack}), this prints ten
2805 lines centered around that line.
2808 Print ten lines just before the lines last printed.
2811 Repeating a @code{list} command with @key{RET} discards the argument,
2812 so it is equivalent to typing just @code{list}. This is more useful
2813 than listing the same lines again. An exception is made for an
2814 argument of @samp{-}; that argument is preserved in repetition so that
2815 each repetition moves up in the source file.
2818 In general, the @code{list} command expects you to supply zero, one or two
2819 @dfn{linespecs}. Linespecs specify source lines; there are several ways
2820 of writing them but the effect is always to specify some source line.
2821 Here is a complete description of the possible arguments for @code{list}:
2824 @item list @var{linespec}
2825 Print ten lines centered around the line specified by @var{linespec}.
2827 @item list @var{first},@var{last}
2828 Print lines from @var{first} to @var{last}. Both arguments are
2831 @item list ,@var{last}
2832 Print ten lines ending with @var{last}.
2834 @item list @var{first},
2835 Print ten lines starting with @var{first}.
2838 Print ten lines just after the lines last printed.
2841 Print ten lines just before the lines last printed.
2844 As described in the preceding table.
2847 Here are the ways of specifying a single source line---all the
2852 Specifies line @var{number} of the current source file.
2853 When a @code{list} command has two linespecs, this refers to
2854 the same source file as the first linespec.
2857 Specifies the line @var{offset} lines after the last line printed.
2858 When used as the second linespec in a @code{list} command that has
2859 two, this specifies the line @var{offset} lines down from the
2863 Specifies the line @var{offset} lines before the last line printed.
2865 @item @var{filename}:@var{number}
2866 Specifies line @var{number} in the source file @var{filename}.
2868 @item @var{function}
2869 @c FIXME: "of the open-brace" is C-centric. When we add other langs...
2870 Specifies the line of the open-brace that begins the body of the
2871 function @var{function}.
2873 @item @var{filename}:@var{function}
2874 Specifies the line of the open-brace that begins the body of the
2875 function @var{function} in the file @var{filename}. You only need the
2876 file name with a function name to avoid ambiguity when there are
2877 identically named functions in different source files.
2879 @item *@var{address}
2880 Specifies the line containing the program address @var{address}.
2881 @var{address} may be any expression.
2884 @node Search, Source Path, List, Source
2885 @section Searching Source Files
2887 @kindex reverse-search
2889 There are two commands for searching through the current source file for a
2893 @item forward-search @var{regexp}
2894 @itemx search @var{regexp}
2896 @kindex forward-search
2897 The command @samp{forward-search @var{regexp}} checks each line, starting
2898 with the one following the last line listed, for a match for @var{regexp}.
2899 It lists the line that is found. You can abbreviate the command name
2900 as @code{fo}. The synonym @samp{search @var{regexp}} is also supported.
2902 @item reverse-search @var{regexp}
2903 The command @samp{reverse-search @var{regexp}} checks each line, starting
2904 with the one before the last line listed and going backward, for a match
2905 for @var{regexp}. It lists the line that is found. You can abbreviate
2906 this command as @code{rev}.
2909 @node Source Path, Machine Code, Search, Source
2910 @section Specifying Source Directories
2913 @cindex directories for source files
2914 Executable programs sometimes do not record the directories of the source
2915 files from which they were compiled, just the names. Even when they do,
2916 the directories could be moved between the compilation and your debugging
2917 session. _GDBN__ has a list of directories to search for source files;
2918 this is called the @dfn{source path}. Each time _GDBN__ wants a source file,
2919 it tries all the directories in the list, in the order they are present
2920 in the list, until it finds a file with the desired name. Note that
2921 the executable search path is @emph{not} used for this purpose. Neither is
2922 the current working directory, unless it happens to be in the source
2925 If _GDBN__ can't find a source file in the source path, and the object
2926 program records a directory, _GDBN__ tries that directory too. If the
2927 source path is empty, and there is no record of the compilation
2928 directory, _GDBN__ will, as a last resort, look in the current
2931 Whenever you reset or rearrange the source path, _GDBN__ will clear out
2932 any information it has cached about where source files are found, where
2933 each line is in the file, etc.
2936 When you start _GDBN__, its source path is empty.
2937 To add other directories, use the @code{directory} command.
2940 @item directory @var{dirname} @dots{}
2941 Add directory @var{dirname} to the front of the source path. Several
2942 directory names may be given to this command, separated by @samp{:} or
2943 whitespace. You may specify a directory that is already in the source
2944 path; this moves it forward, so it will be searched sooner.
2946 You can use the string @samp{$cdir} to refer to the compilation
2947 directory (if one is recorded), and @samp{$cwd} to refer to the current
2948 working directory. @samp{$cwd} is not the same as @samp{.}---the former
2949 tracks the current working directory as it changes during your _GDBN__
2950 session, while the latter is immediately expanded to the current
2951 directory at the time you add an entry to the source path.
2954 Reset the source path to empty again. This requires confirmation.
2956 @c RET-repeat for @code{directory} is explicitly disabled, but since
2957 @c repeating it would be a no-op we don't say that. (thanks to RMS)
2959 @item show directories
2960 @kindex show directories
2961 Print the source path: show which directories it contains.
2964 If your source path is cluttered with directories that are no longer of
2965 interest, _GDBN__ may sometimes cause confusion by finding the wrong
2966 versions of source. You can correct the situation as follows:
2970 Use @code{directory} with no argument to reset the source path to empty.
2973 Use @code{directory} with suitable arguments to reinstall the
2974 directories you want in the source path. You can add all the
2975 directories in one command.
2978 @node Machine Code, , Source Path, Source
2979 @section Source and Machine Code
2980 You can use the command @code{info line} to map source lines to program
2981 addresses (and viceversa), and the command @code{disassemble} to display
2982 a range of addresses as machine instructions.
2985 @item info line @var{linespec}
2987 Print the starting and ending addresses of the compiled code for
2988 source line @var{linespec}. You can specify source lines in any of the
2989 ways understood by the @code{list} command (@pxref{List}).
2992 For example, we can use @code{info line} to inquire on where the object
2993 code for the first line of function @code{m4_changequote} lies:
2995 (_GDBP__) info line m4_changecom
2996 Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
3000 We can also inquire (using @code{*@var{addr}} as the form for
3001 @var{linespec}) what source line covers a particular address:
3003 (_GDBP__) info line *0x63ff
3004 Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
3008 After @code{info line}, the default address for the @code{x}
3009 command is changed to the starting address of the line, so that
3010 @samp{x/i} is sufficient to begin examining the machine code
3011 (@pxref{Memory}). Also, this address is saved as the value of the
3012 convenience variable @code{$_} (@pxref{Convenience Vars}).
3017 This specialized command is provided to dump a range of memory as
3018 machine instructions. The default memory range is the function
3019 surrounding the program counter of the selected frame. A single
3020 argument to this command is a program counter value; the function
3021 surrounding this value will be dumped. Two arguments (separated by one
3022 or more spaces) specify a range of addresses (first inclusive, second
3023 exclusive) to be dumped.
3026 We can use @code{disassemble} to inspect the object code
3027 range shown in the last @code{info line} example:
3030 (_GDBP__) disas 0x63e4 0x6404
3031 Dump of assembler code from 0x63e4 to 0x6404:
3032 0x63e4 <builtin_init+5340>: ble 0x63f8 <builtin_init+5360>
3033 0x63e8 <builtin_init+5344>: sethi %hi(0x4c00), %o0
3034 0x63ec <builtin_init+5348>: ld [%i1+4], %o0
3035 0x63f0 <builtin_init+5352>: b 0x63fc <builtin_init+5364>
3036 0x63f4 <builtin_init+5356>: ld [%o0+4], %o0
3037 0x63f8 <builtin_init+5360>: or %o0, 0x1a4, %o0
3038 0x63fc <builtin_init+5364>: call 0x9288 <path_search>
3039 0x6400 <builtin_init+5368>: nop
3040 End of assembler dump.
3045 @node Data, Languages, Source, Top
3046 @chapter Examining Data
3048 @cindex printing data
3049 @cindex examining data
3052 @c "inspect" isn't quite a synonym if you're using Epoch, which we don't
3053 @c document because it's nonstandard... Under Epoch it displays in a
3054 @c different window or something like that.
3055 The usual way to examine data in your program is with the @code{print}
3056 command (abbreviated @code{p}), or its synonym @code{inspect}. It
3057 evaluates and prints the value of an expression of the language your
3058 program is written in (@pxref{Languages}). You type
3065 where @var{exp} is an expression (in the source language), and
3066 the value of @var{exp} is printed in a format appropriate to its data
3069 A more low-level way of examining data is with the @code{x} command.
3070 It examines data in memory at a specified address and prints it in a
3071 specified format. @xref{Memory}.
3073 If you're interested in information about types, or about how the fields
3074 of a struct or class are declared, use the @code{ptype @var{exp}}
3075 command rather than @code{print}. @xref{Symbols}.
3078 * Expressions:: Expressions
3079 * Variables:: Program Variables
3080 * Arrays:: Artificial Arrays
3081 * Output formats:: Output formats
3082 * Memory:: Examining Memory
3083 * Auto Display:: Automatic Display
3084 * Print Settings:: Print Settings
3085 * Value History:: Value History
3086 * Convenience Vars:: Convenience Variables
3087 * Registers:: Registers
3088 * Floating Point Hardware:: Floating Point Hardware
3091 @node Expressions, Variables, Data, Data
3092 @section Expressions
3095 @code{print} and many other _GDBN__ commands accept an expression and
3096 compute its value. Any kind of constant, variable or operator defined
3097 by the programming language you are using is legal in an expression in
3098 _GDBN__. This includes conditional expressions, function calls, casts
3099 and string constants. It unfortunately does not include symbols defined
3100 by preprocessor @code{#define} commands.
3102 Because C is so widespread, most of the expressions shown in examples in
3103 this manual are in C. @xref{Languages,, Using _GDBN__ with Different
3104 Languages}, for information on how to use expressions in other
3107 In this section, we discuss operators that you can use in _GDBN__
3108 expressions regardless of your programming language.
3110 Casts are supported in all languages, not just in C, because it is so
3111 useful to cast a number into a pointer so as to examine a structure
3112 at that address in memory.
3113 @c FIXME: casts supported---Mod2 true?
3115 _GDBN__ supports these operators in addition to those of programming
3120 @samp{@@} is a binary operator for treating parts of memory as arrays.
3121 @xref{Arrays}, for more information.
3124 @samp{::} allows you to specify a variable in terms of the file or
3125 function where it is defined. @xref{Variables}.
3127 @item @{@var{type}@} @var{addr}
3128 Refers to an object of type @var{type} stored at address @var{addr} in
3129 memory. @var{addr} may be any expression whose value is an integer or
3130 pointer (but parentheses are required around binary operators, just as in
3131 a cast). This construct is allowed regardless of what kind of data is
3132 normally supposed to reside at @var{addr}.@refill
3135 @node Variables, Arrays, Expressions, Data
3136 @section Program Variables
3138 The most common kind of expression to use is the name of a variable
3141 Variables in expressions are understood in the selected stack frame
3142 (@pxref{Selection}); they must either be global (or static) or be visible
3143 according to the scope rules of the programming language from the point of
3144 execution in that frame. This means that in the function
3159 the variable @code{a} is usable whenever the program is executing
3160 within the function @code{foo}, but the variable @code{b} is visible
3161 only while the program is executing inside the block in which @code{b}
3164 @cindex variable name conflict
3165 There is an exception: you can refer to a variable or function whose
3166 scope is a single source file even if the current execution point is not
3167 in this file. But it is possible to have more than one such variable or
3168 function with the same name (in different source files). If that happens,
3169 referring to that name has unpredictable effects. If you wish, you can
3170 specify a variable in a particular file, using the colon-colon notation:
3175 @var{file}::@var{variable}
3179 Here @var{file} is the name of the source file whose variable you want.
3181 @cindex C++ scope resolution
3182 This use of @samp{::} is very rarely in conflict with the very similar
3183 use of the same notation in C++. _GDBN__ also supports use of the C++
3184 scope resolution operator in _GDBN__ expressions.
3186 @cindex wrong values
3187 @cindex variable values, wrong
3189 @emph{Warning:} Occasionally, a local variable may appear to have the
3190 wrong value at certain points in a function---just after entry to the
3191 function, and just before exit. You may see this problem when you're
3192 stepping by machine instructions. This is because on most machines, it
3193 takes more than one instruction to set up a stack frame (including local
3194 variable definitions); if you're stepping by machine instructions,
3195 variables may appear to have the wrong values until the stack frame is
3196 completely built. On function exit, it usually also takes more than one
3197 machine instruction to destroy a stack frame; after you begin stepping
3198 through that group of instructions, local variable definitions may be
3202 @node Arrays, Output formats, Variables, Data
3203 @section Artificial Arrays
3205 @cindex artificial array
3207 It is often useful to print out several successive objects of the
3208 same type in memory; a section of an array, or an array of
3209 dynamically determined size for which only a pointer exists in the
3212 This can be done by constructing an @dfn{artificial array} with the
3213 binary operator @samp{@@}. The left operand of @samp{@@} should be
3214 the first element of the desired array, as an individual object.
3215 The right operand should be the desired length of the array. The result is
3216 an array value whose elements are all of the type of the left argument.
3217 The first element is actually the left argument; the second element
3218 comes from bytes of memory immediately following those that hold the
3219 first element, and so on. Here is an example. If a program says
3222 int *array = (int *) malloc (len * sizeof (int));
3226 you can print the contents of @code{array} with
3232 The left operand of @samp{@@} must reside in memory. Array values made
3233 with @samp{@@} in this way behave just like other arrays in terms of
3234 subscripting, and are coerced to pointers when used in expressions.
3235 Artificial arrays most often appear in expressions via the value history
3236 (@pxref{Value History}), after printing one out.)
3238 Sometimes the artificial array mechanism isn't quite enough; in
3239 moderately complex data structures, the elements of interest may not
3240 actually be adjacent---for example, if you're interested in the values
3241 of pointers in an array. One useful work-around in this situation is to
3242 use a convenience variable (@pxref{Convenience Vars}) as a counter in an
3243 expression that prints the first interesting value, and then repeat that
3244 expression via @key{RET}. For instance, suppose you have an array
3245 @code{dtab} of pointers to structures, and you're interested in the
3246 values of a field @code{fv} in each structure. Here's an example of
3247 what you might type:
3256 @node Output formats, Memory, Arrays, Data
3257 @section Output formats
3259 @cindex formatted output
3260 @cindex output formats
3261 By default, _GDBN__ prints a value according to its data type. Sometimes
3262 this is not what you want. For example, you might want to print a number
3263 in hex, or a pointer in decimal. Or you might want to view data in memory
3264 at a certain address as a character string or as an instruction. To do
3265 these things, specify an @dfn{output format} when you print a value.
3267 The simplest use of output formats is to say how to print a value
3268 already computed. This is done by starting the arguments of the
3269 @code{print} command with a slash and a format letter. The format
3270 letters supported are:
3274 Regard the bits of the value as an integer, and print the integer in
3278 Print as integer in signed decimal.
3281 Print as integer in unsigned decimal.
3284 Print as integer in octal.
3287 Print as integer in binary. The letter @samp{t} stands for ``two''.
3290 Print as an address, both absolute in hex and as an offset from the
3291 nearest preceding symbol. This format can be used to discover where (in
3292 what function) an unknown address is located:
3294 (_GDBP__) p/a 0x54320
3295 _0__$3 = 0x54320 <_initialize_vx+396>_1__
3300 Regard as an integer and print it as a character constant.
3303 Regard the bits of the value as a floating point number and print
3304 using typical floating point syntax.
3307 For example, to print the program counter in hex (@pxref{Registers}), type
3314 Note that no space is required before the slash; this is because command
3315 names in _GDBN__ cannot contain a slash.
3317 To reprint the last value in the value history with a different format,
3318 you can use the @code{print} command with just a format and no
3319 expression. For example, @samp{p/x} reprints the last value in hex.
3321 @node Memory, Auto Display, Output formats, Data
3322 @section Examining Memory
3324 @cindex examining memory
3327 @item x/@var{nfu} @var{expr}
3328 The command @code{x} (for `examine') can be used to examine memory
3329 without being constrained by your program's data types. You can specify
3330 the unit size @var{u} of memory to inspect, and a repeat count @var{n} of how
3331 many of those units to display. @code{x} understands the formats
3332 @var{f} used by @code{print}; two additional formats, @samp{s} (string)
3333 and @samp{i} (machine instruction) can be used without specifying a unit
3337 For example, @samp{x/3uh 0x54320} is a request to display three halfwords
3338 (@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}),
3339 starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four
3340 words (@samp{w}) of memory above the stack pointer (here, @samp{$sp};
3341 @pxref{Registers}) in hexadecimal (@samp{x}).
3343 Since the letters indicating unit sizes are all distinct from the
3344 letters specifying output formats, you don't have to remember whether
3345 unit size or format comes first; either order will work. The output
3346 specifications @samp{4xw} and @samp{4wx} mean exactly the same thing.
3348 After the format specification, you supply an expression for the address
3349 where _GDBN__ is to begin reading from memory. The expression need not
3350 have a pointer value (though it may); it is always interpreted as an
3351 integer address of a byte of memory. @xref{Expressions} for more
3352 information on expressions.
3354 These are the memory units @var{u} you can specify with the @code{x}
3359 Examine individual bytes.
3362 Examine halfwords (two bytes each).
3365 Examine words (four bytes each).
3368 Many assemblers and cpu designers still use `word' for a 16-bit quantity,
3369 as a holdover from specific predecessor machines of the 1970's that really
3370 did use two-byte words. But more generally the term `word' has always
3371 referred to the size of quantity that a machine normally operates on and
3372 stores in its registers. This is 32 bits for all the machines that _GDBN__
3376 Examine giant words (8 bytes).
3379 You can combine these unit specifications with any of the formats
3380 described for @code{print}. @xref{Output formats}.
3382 @code{x} has two additional output specifications which derive the unit
3383 size from the data inspected:
3387 Print a null-terminated string of characters. Any explicitly specified
3388 unit size is ignored; instead, the unit is however many bytes it takes
3389 to reach a null character (including the null character).
3392 Print a machine instruction in assembler syntax (or nearly). Any
3393 specified unit size is ignored; the number of bytes in an instruction
3394 varies depending on the type of machine, the opcode and the addressing
3395 modes used. The command @code{disassemble} gives an alternative way of
3396 inspecting machine instructions. @xref{Machine Code}.
3399 If you omit either the format @var{f} or the unit size @var{u}, @code{x}
3400 will use the same one that was used last. If you don't use any letters
3401 or digits after the slash, you can omit the slash as well.
3403 You can also omit the address to examine. Then the address used is just
3404 after the last unit examined. This is why string and instruction
3405 formats actually compute a unit-size based on the data: so that the next
3406 string or instruction examined will start in the right place.
3408 When the @code{print} command shows a value that resides in memory,
3409 @code{print} also sets the default address for the @code{x} command.
3410 @code{info line} also sets the default for @code{x}, to the address of
3411 the start of the machine code for the specified line (@pxref{Machine
3412 Code}), and @code{info breakpoints} sets it to the address of the last
3413 breakpoint listed (@pxref{Set Breaks}).
3415 When you use @key{RET} to repeat an @code{x} command, the address
3416 specified previously (if any) is ignored, so that the repeated command
3417 examines the successive locations in memory rather than the same ones.
3419 You can examine several consecutive units of memory with one command by
3420 writing a repeat-count after the slash (before the format letters, if
3421 any). Omitting the repeat count @var{n} displays one unit of the
3422 appropriate size. The repeat count must be a decimal integer. It has
3423 the same effect as repeating the @code{x} command @var{n} times except
3424 that the output may be more compact, with several units per line. For
3432 prints ten instructions starting with the one to be executed next in the
3433 selected frame. After doing this, you could print a further seven
3441 ---where the format and address are allowed to default.
3445 The addresses and contents printed by the @code{x} command are not put
3446 in the value history because there is often too much of them and they
3447 would get in the way. Instead, _GDBN__ makes these values available for
3448 subsequent use in expressions as values of the convenience variables
3449 @code{$_} and @code{$__}. After an @code{x} command, the last address
3450 examined is available for use in expressions in the convenience variable
3451 @code{$_}. The contents of that address, as examined, are available in
3452 the convenience variable @code{$__}.
3454 If the @code{x} command has a repeat count, the address and contents saved
3455 are from the last memory unit printed; this is not the same as the last
3456 address printed if several units were printed on the last line of output.
3458 @node Auto Display, Print Settings, Memory, Data
3459 @section Automatic Display
3460 @cindex automatic display
3461 @cindex display of expressions
3463 If you find that you want to print the value of an expression frequently
3464 (to see how it changes), you might want to add it to the @dfn{automatic
3465 display list} so that _GDBN__ will print its value each time the program stops.
3466 Each expression added to the list is given a number to identify it;
3467 to remove an expression from the list, you specify that number.
3468 The automatic display looks like this:
3472 3: bar[5] = (struct hack *) 0x3804
3476 showing item numbers, expressions and their current values. As with
3477 displays you request manually using @code{x} or @code{print}, you can
3478 specify the output format you prefer; in fact, @code{display} decides
3479 whether to use @code{print} or @code{x} depending on how elaborate your
3480 format specification is---it uses @code{x} if you specify a unit size,
3481 or one of the two formats (@samp{i} and @samp{s}) that are only
3482 supported by @code{x}; otherwise it uses @code{print}.
3485 @item display @var{exp}
3487 Add the expression @var{exp} to the list of expressions to display
3488 each time the program stops. @xref{Expressions}.
3490 @code{display} will not repeat if you press @key{RET} again after using it.
3492 @item display/@var{fmt} @var{exp}
3493 For @var{fmt} specifying only a display format and not a size or
3494 count, add the expression @var{exp} to the auto-display list but
3495 arranges to display it each time in the specified format @var{fmt}.
3496 @xref{Output formats}.
3498 @item display/@var{fmt} @var{addr}
3499 For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
3500 number of units, add the expression @var{addr} as a memory address to
3501 be examined each time the program stops. Examining means in effect
3502 doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory}.
3505 For example, @samp{display/i $pc} can be helpful, to see the machine
3506 instruction about to be executed each time execution stops (@samp{$pc}
3507 is a common name for the program counter; @pxref{Registers}).
3510 @item undisplay @var{dnums}@dots{}
3511 @itemx delete display @var{dnums}@dots{}
3512 @kindex delete display
3514 Remove item numbers @var{dnums} from the list of expressions to display.
3516 @code{undisplay} will not repeat if you press @key{RET} after using it.
3517 (Otherwise you would just get the error @samp{No display number @dots{}}.)
3519 @item disable display @var{dnums}@dots{}
3520 @kindex disable display
3521 Disable the display of item numbers @var{dnums}. A disabled display
3522 item is not printed automatically, but is not forgotten. It may be
3523 enabled again later.
3525 @item enable display @var{dnums}@dots{}
3526 @kindex enable display
3527 Enable display of item numbers @var{dnums}. It becomes effective once
3528 again in auto display of its expression, until you specify otherwise.
3531 Display the current values of the expressions on the list, just as is
3532 done when the program stops.
3535 @kindex info display
3536 Print the list of expressions previously set up to display
3537 automatically, each one with its item number, but without showing the
3538 values. This includes disabled expressions, which are marked as such.
3539 It also includes expressions which would not be displayed right now
3540 because they refer to automatic variables not currently available.
3543 If a display expression refers to local variables, then it does not make
3544 sense outside the lexical context for which it was set up. Such an
3545 expression is disabled when execution enters a context where one of its
3546 variables is not defined. For example, if you give the command
3547 @code{display last_char} while inside a function with an argument
3548 @code{last_char}, then this argument will be displayed while the program
3549 continues to stop inside that function. When it stops elsewhere---where
3550 there is no variable @code{last_char}---display is disabled. The next time
3551 your program stops where @code{last_char} is meaningful, you can enable the
3552 display expression once again.
3554 @node Print Settings, Value History, Auto Display, Data
3555 @section Print Settings
3557 @cindex format options
3558 @cindex print settings
3559 _GDBN__ provides the following ways to control how arrays, structures,
3560 and symbols are printed.
3563 These settings are useful for debugging programs in any language:
3566 @item set print address
3567 @item set print address on
3568 @kindex set print address
3569 _GDBN__ will print memory addresses showing the location of stack
3570 traces, structure values, pointer values, breakpoints, and so forth,
3571 even when it also displays the contents of those addresses. The default
3572 is on. For example, this is what a stack frame display looks like, with
3573 @code{set print address on}:
3576 #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
3578 530 if (lquote != def_lquote)
3581 @item set print address off
3582 Do not print addresses when displaying their contents. For example,
3583 this is the same stack frame displayed with @code{set print address off}:
3585 (_GDBP__) set print addr off
3587 #0 set_quotes (lq="<<", rq=">>") at input.c:530
3588 530 if (lquote != def_lquote)
3591 @item show print address
3592 @kindex show print address
3593 Show whether or not addresses are to be printed.
3595 @item set print array
3596 @itemx set print array on
3597 @kindex set print array
3598 _GDBN__ will pretty print arrays. This format is more convenient to read,
3599 but uses more space. The default is off.
3601 @item set print array off.
3602 Return to compressed format for arrays.
3604 @item show print array
3605 @kindex show print array
3606 Show whether compressed or pretty format is selected for displaying
3609 @item set print elements @var{number-of-elements}
3610 @kindex set print elements
3611 If _GDBN__ is printing a large array, it will stop printing after it has
3612 printed the number of elements set by the @code{set print elements} command.
3613 This limit also applies to the display of strings.
3615 @item show print elements
3616 @kindex show print elements
3617 Display the number of elements of a large array that _GDBN__ will print
3618 before losing patience.
3620 @item set print pretty on
3621 @kindex set print pretty
3622 Cause _GDBN__ to print structures in an indented format with one member per
3636 @item set print pretty off
3637 Cause _GDBN__ to print structures in a compact format, like this:
3640 $1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \
3645 This is the default format.
3647 @item show print pretty
3648 @kindex show print pretty
3649 Show which format _GDBN__ will use to print structures.
3651 @item set print sevenbit-strings on
3652 Print using only seven-bit characters; if this option is set,
3653 _GDBN__ will display any eight-bit characters (in strings or character
3654 values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is
3655 displayed as @code{\341}.
3657 @item set print sevenbit-strings off
3658 Print using either seven-bit or eight-bit characters, as required. This
3661 @item show print sevenbit-strings
3662 Show whether or not _GDBN__ will print only seven-bit characters.
3664 @item set print union on
3665 @kindex set print union
3666 Tell _GDBN__ to print unions which are contained in structures. This is the
3669 @item set print union off
3670 Tell _GDBN__ not to print unions which are contained in structures.
3672 @item show print union
3673 @kindex show print union
3674 Ask _GDBN__ whether or not it will print unions which are contained in
3677 For example, given the declarations
3680 typedef enum @{Tree, Bug@} Species;
3681 typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
3682 typedef enum @{Caterpillar, Cocoon, Butterfly@} Bug_forms;
3692 struct thing foo = @{Tree, @{Acorn@}@};
3696 with @code{set print union on} in effect @samp{p foo} would print
3699 $1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
3703 and with @code{set print union off} in effect it would print
3706 $1 = @{it = Tree, form = @{...@}@}
3711 These settings are of interest when debugging C++ programs:
3714 @item set print demangle
3715 @itemx set print demangle on
3716 @kindex set print demangle
3717 Print C++ names in their source form rather than in the mangled form
3718 in which they are passed to the assembler and linker for type-safe linkage.
3721 @item show print demangle
3722 @kindex show print demangle
3723 Show whether C++ names will be printed in mangled or demangled form.
3725 @item set print asm-demangle
3726 @itemx set print asm-demangle on
3727 @kindex set print asm-demangle
3728 Print C++ names in their source form rather than their mangled form, even
3729 in assembler code printouts such as instruction disassemblies.
3732 @item show print asm-demangle
3733 @kindex show print asm-demangle
3734 Show whether C++ names in assembly listings will be printed in mangled
3737 @item set print object
3738 @itemx set print object on
3739 @kindex set print object
3740 When displaying a pointer to an object, identify the @emph{actual}
3741 (derived) type of the object rather than the @emph{declared} type, using
3742 the virtual function table.
3744 @item set print object off
3745 Display only the declared type of objects, without reference to the
3746 virtual function table. This is the default setting.
3748 @item show print object
3749 @kindex show print object
3750 Show whether actual, or declared, object types will be displayed.
3752 @item set print vtbl
3753 @itemx set print vtbl on
3754 @kindex set print vtbl
3755 Pretty print C++ virtual function tables. The default is off.
3757 @item set print vtbl off
3758 Do not pretty print C++ virtual function tables.
3760 @item show print vtbl
3761 @kindex show print vtbl
3762 Show whether C++ virtual function tables are pretty printed, or not.
3766 @node Value History, Convenience Vars, Print Settings, Data
3767 @section Value History
3769 @cindex value history
3770 Values printed by the @code{print} command are saved in _GDBN__'s @dfn{value
3771 history} so that you can refer to them in other expressions. Values are
3772 kept until the symbol table is re-read or discarded (for example with
3773 the @code{file} or @code{symbol-file} commands). When the symbol table
3774 changes, the value history is discarded, since the values may contain
3775 pointers back to the types defined in the symbol table.
3779 @cindex history number
3780 The values printed are given @dfn{history numbers} for you to refer to them
3781 by. These are successive integers starting with one. @code{print} shows you
3782 the history number assigned to a value by printing @samp{$@var{num} = }
3783 before the value; here @var{num} is the history number.
3785 To refer to any previous value, use @samp{$} followed by the value's
3786 history number. The way @code{print} labels its output is designed to
3787 remind you of this. Just @code{$} refers to the most recent value in
3788 the history, and @code{$$} refers to the value before that.
3789 @code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
3790 is the value just prior to @code{$$}, @code{$$1} is equivalent to
3791 @code{$$}, and @code{$$0} is equivalent to @code{$}.
3793 For example, suppose you have just printed a pointer to a structure and
3794 want to see the contents of the structure. It suffices to type
3800 If you have a chain of structures where the component @code{next} points
3801 to the next one, you can print the contents of the next one with this:
3808 You can print successive links in the chain by repeating this
3809 command---which you can do by just typing @key{RET}.
3811 Note that the history records values, not expressions. If the value of
3812 @code{x} is 4 and you type these commands:
3820 then the value recorded in the value history by the @code{print} command
3821 remains 4 even though the value of @code{x} has changed.
3826 Print the last ten values in the value history, with their item numbers.
3827 This is like @samp{p@ $$9} repeated ten times, except that @code{show
3828 values} does not change the history.
3830 @item show values @var{n}
3831 Print ten history values centered on history item number @var{n}.
3834 Print ten history values just after the values last printed. If no more
3835 values are available, produces no display.
3838 Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the
3839 same effect as @samp{show values +}.
3841 @node Convenience Vars, Registers, Value History, Data
3842 @section Convenience Variables
3844 @cindex convenience variables
3845 _GDBN__ provides @dfn{convenience variables} that you can use within
3846 _GDBN__ to hold on to a value and refer to it later. These variables
3847 exist entirely within _GDBN__; they are not part of your program, and
3848 setting a convenience variable has no direct effect on further execution
3849 of your program. That's why you can use them freely.
3851 Convenience variables are prefixed with @samp{$}. Any name preceded by
3852 @samp{$} can be used for a convenience variable, unless it is one of
3853 the predefined machine-specific register names (@pxref{Registers}).
3854 (Value history references, in contrast, are @emph{numbers} preceded
3855 by @samp{$}. @xref{Value History}.)
3857 You can save a value in a convenience variable with an assignment
3858 expression, just as you would set a variable in your program. Example:
3861 set $foo = *object_ptr
3865 would save in @code{$foo} the value contained in the object pointed to by
3868 Using a convenience variable for the first time creates it; but its value
3869 is @code{void} until you assign a new value. You can alter the value with
3870 another assignment at any time.
3872 Convenience variables have no fixed types. You can assign a convenience
3873 variable any type of value, including structures and arrays, even if
3874 that variable already has a value of a different type. The convenience
3875 variable, when used as an expression, has the type of its current value.
3878 @item show convenience
3879 @kindex show convenience
3880 Print a list of convenience variables used so far, and their values.
3881 Abbreviated @code{show con}.
3884 One of the ways to use a convenience variable is as a counter to be
3885 incremented or a pointer to be advanced. For example, to print
3886 a field from successive elements of an array of structures:
3890 print bar[$i++]->contents
3891 @i{@dots{} repeat that command by typing @key{RET}.}
3894 Some convenience variables are created automatically by _GDBN__ and given
3895 values likely to be useful.
3899 The variable @code{$_} is automatically set by the @code{x} command to
3900 the last address examined (@pxref{Memory}). Other commands which
3901 provide a default address for @code{x} to examine also set @code{$_}
3902 to that address; these commands include @code{info line} and @code{info
3903 breakpoint}. @code{$_}'s type is @code{void *} except when set by the
3904 @code{x} command, in which case it is a pointer to the type of @code{$__}.
3907 The variable @code{$__} is automatically set by the @code{x} command
3908 to the value found in the last address examined. Its type is chosen
3909 to match the format in which the data was printed.
3912 @node Registers, Floating Point Hardware, Convenience Vars, Data
3916 You can refer to machine register contents, in expressions, as variables
3917 with names starting with @samp{$}. The names of registers are different
3918 for each machine; use @code{info registers} to see the names used on
3922 @item info registers
3923 @kindex info registers
3924 Print the names and values of all registers except floating-point
3925 registers (in the selected stack frame).
3927 @item info all-registers
3928 @kindex info all-registers
3929 @cindex floating point registers
3930 Print the names and values of all registers, including floating-point
3933 @item info registers @var{regname}
3934 Print the relativized value of register @var{regname}. @var{regname}
3935 may be any register name valid on the machine you are using, with
3936 or without the initial @samp{$}.
3939 The register names @code{$pc} and @code{$sp} are used on most machines
3940 for the program counter register and the stack pointer. For example,
3941 you could print the program counter in hex with
3947 or print the instruction to be executed next with
3953 or add four to the stack pointer with
3959 The last is a way of removing one word from the stack, on machines where
3960 stacks grow downward in memory (most machines, nowadays). This assumes
3961 that the innermost stack frame is selected; setting @code{$sp} is
3962 not allowed when other stack frames are selected. (To pop entire frames
3963 off the stack, regardless of machine architecture, use @code{return};
3966 Often @code{$fp} is used for a register that contains a pointer to the
3967 current stack frame, and @code{$ps} is sometimes used for a register
3968 that contains the processor status. These standard register names may
3969 be available on your machine even though the @code{info registers}
3970 command shows other names. For example, on the SPARC, @code{info
3971 registers} displays the processor status register as @code{$psr} but you
3972 can also refer to it as @code{$ps}.
3974 _GDBN__ always considers the contents of an ordinary register as an
3975 integer when the register is examined in this way. Some machines have
3976 special registers which can hold nothing but floating point; these
3977 registers are considered to have floating point values. There is no way
3978 to refer to the contents of an ordinary register as floating point value
3979 (although you can @emph{print} it as a floating point value with
3980 @samp{print/f $@var{regname}}).
3982 Some registers have distinct ``raw'' and ``virtual'' data formats. This
3983 means that the data format in which the register contents are saved by
3984 the operating system is not the same one that your program normally
3985 sees. For example, the registers of the 68881 floating point
3986 coprocessor are always saved in ``extended'' (raw) format, but all C
3987 programs expect to work with ``double'' (virtual) format. In such
3988 cases, _GDBN__ normally works with the virtual format only (the format that
3989 makes sense for your program), but the @code{info registers} command
3990 prints the data in both formats.
3992 Normally, register values are relative to the selected stack frame
3993 (@pxref{Selection}). This means that you get the value that the
3994 register would contain if all stack frames farther in were exited and
3995 their saved registers restored. In order to see the true contents of
3996 hardware registers, you must select the innermost frame (with
3999 However, _GDBN__ must deduce where registers are saved, from the machine
4000 code generated by your compiler. If some registers are not saved, or if
4001 _GDBN__ is unable to locate the saved registers, the selected stack
4002 frame will make no difference.
4004 @node Floating Point Hardware, , Registers, Data
4005 @section Floating Point Hardware
4006 @cindex floating point
4007 Depending on the host machine architecture, _GDBN__ may be able to give
4008 you more information about the status of the floating point hardware.
4013 If available, provides hardware-dependent information about the floating
4014 point unit. The exact contents and layout vary depending on the
4015 floating point chip.
4017 @c FIXME: this is a cop-out. Try to get examples, explanations. Only
4018 @c FIXME...supported currently on arm's and 386's. Mark properly with
4019 @c FIXME... m4 macros to isolate general statements from hardware-dep,
4020 @c FIXME... at that point.
4022 @node Languages, Symbols, Data, Top
4023 @chapter Using _GDBN__ with Different Languages
4026 Although programming languages generally have common aspects, they are
4027 rarely expressed in the same manner. For instance, in ANSI C,
4028 dereferencing a pointer @code{p} is accomplished by @code{*p}, but in
4029 Modula-2, it is accomplished by @code{p^}. Values can also be
4030 represented (and displayed) differently. Hex numbers in C are written
4031 like @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}.
4033 @cindex working language
4034 Language-specific information is built into _GDBN__ for some languages,
4035 allowing you to express operations like the above in the program's
4036 native language, and allowing _GDBN__ to output values in a manner
4037 consistent with the syntax of the program's native language. The
4038 language you use to build expressions, called the @dfn{working
4039 language}, can be selected manually, or _GDBN__ can set it
4043 * Setting:: Switching between source languages
4044 * Show:: Displaying the language
4045 * Checks:: Type and Range checks
4046 * Support:: Supported languages
4049 @node Setting, Show, Languages, Languages
4050 @section Switching between source languages
4052 There are two ways to control the working language---either have _GDBN__
4053 set it automatically, or select it manually yourself. You can use the
4054 @code{set language} command for either purpose. On startup, _GDBN__
4055 defaults to setting the language automatically.
4058 * Manually:: Setting the working language manually
4059 * Automatically:: Having _GDBN__ infer the source language
4062 @node Manually, Automatically, Setting, Setting
4063 @subsection Setting the working language
4065 @kindex set language
4066 To set the language, issue the command @samp{set language @var{lang}},
4067 where @var{lang} is the name of a language, such as @code{c} or
4068 @code{m2}, or the extension of a filename written in that language, such
4069 as @file{.c} or @file{.mod}. For a list of the supported
4070 languages, type @samp{set language}.
4072 Setting the language manually prevents _GDBN__ from updating the working
4073 language automatically. This can lead to confusion if you try
4074 to debug a program when the working language is not the same as the
4075 source language, when an expression is acceptable to both
4076 languages---but means different things. For instance, if the current
4077 source file were written in C, and _GDBN__ was parsing Modula-2, a
4085 might not have the effect you intended. In C, this means to add
4086 @code{b} and @code{c} and place the result in @code{a}. The result
4087 printed would be the value of @code{a}. In Modula-2, this means to compare
4088 @code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value.
4090 If you allow _GDBN__ to set the language automatically, then
4091 you can count on expressions evaluating the same way in your debugging
4092 session and in your program.
4094 @node Automatically, , Manually, Setting
4095 @subsection Having _GDBN__ infer the source language
4097 To have _GDBN__ set the working language automatically, use @samp{set
4098 language local} or @samp{set language auto}. _GDBN__ then infers the
4099 language that a program was written in by looking at the name of its
4100 source files, and examining their extensions:
4104 Modula-2 source file
4108 C or C++ source file.
4111 This information is recorded for each function or procedure in a source
4112 file. When your program stops in a frame (usually by encountering a
4113 breakpoint), _GDBN__ sets the working language to the language recorded
4114 for the function in that frame. If the language for a frame is unknown
4115 (that is, if the function or block corresponding to the frame was
4116 defined in a source file that does not have a recognized extension), the
4117 current working language is not changed, and _GDBN__ issues a warning.
4119 This may not seem necessary for most programs, which are written
4120 entirely in one source language. However, program modules and libraries
4121 written in one source language can be used by a main program written in
4122 a different source language. Using @samp{set language auto} in this
4123 case frees you from having to set the working language manually.
4125 @node Show, Checks, Setting, Languages
4126 @section Displaying the language
4128 The following commands will help you find out which language is the
4129 working language, and also what language source files were written in.
4131 @kindex show language
4136 Display the current working language. This is the
4137 language you can use with commands such as @code{print} to
4138 build and compute expressions that may involve variables in the program.
4141 Among the other information listed here (@pxref{Frame Info,,Information
4142 about a Frame}) is the source language for this frame. This is the
4143 language that will become the working language if you ever use an
4144 identifier that is in this frame.
4147 Among the other information listed here (@pxref{Symbols,,Examining the
4148 Symbol Table}) is the source language of this source file.
4152 @node Checks, Support, Show, Languages
4153 @section Type and range Checking
4156 @emph{Warning:} In this release, the _GDBN__ commands for type and range
4157 checking are included, but they do not yet have any effect. This
4158 section documents the intended facilities.
4160 @c FIXME remove warning when type/range code added
4162 Some languages are designed to guard you against making seemingly common
4163 errors through a series of compile- and run-time checks. These include
4164 checking the type of arguments to functions and operators, and making
4165 sure mathematical overflows are caught at run time. Checks such as
4166 these help to ensure a program's correctness once it has been compiled
4167 by eliminating type mismatches, and providing active checks for range
4168 errors when the program is running.
4170 _GDBN__ can check for conditions like the above if you wish.
4171 Although _GDBN__ will not check the statements in your program, it
4172 can check expressions entered directly into _GDBN__ for evaluation via
4173 the @code{print} command, for example. As with the working language,
4174 _GDBN__ can also decide whether or not to check automatically based on
4175 the source language of the program being debugged.
4176 @xref{Support,,Supported Languages}, for the default settings
4177 of supported languages.
4180 * Type Checking:: An overview of type checking
4181 * Range Checking:: An overview of range checking
4184 @cindex type checking
4185 @cindex checks, type
4186 @node Type Checking, Range Checking, Checks, Checks
4187 @subsection An overview of type checking
4189 Some languages, such as Modula-2, are strongly typed, meaning that the
4190 arguments to operators and functions have to be of the correct type,
4191 otherwise an error occurs. These checks prevent type mismatch
4192 errors from ever causing any run-time problems. For example,
4199 The second example fails because the @code{CARDINAL} 1 is not
4200 type-compatible with the @code{REAL} 2.3.
4202 For expressions you use in _GDBN__ commands, you can tell the _GDBN__
4203 type checker to skip checking; to treat any mismatches as errors and
4204 abandon the expression; or only issue warnings when type mismatches
4205 occur, but evaluate the expression anyway. When you choose the last of
4206 these, _GDBN__ evaluates expressions like the second example above, but
4207 also issues a warning.
4209 Even though you may turn type checking off, other type-based reasons may
4210 prevent _GDBN__ from evaluating an expression. For instance, _GDBN__ does not
4211 know how to add an @code{int} and a @code{struct foo}. These particular
4212 type errors have nothing to do with the language in use, and usually
4213 arise from expressions, such as the one described above, which make
4214 little sense to evaluate anyway.
4216 Each language defines to what degree it is strict about type. For
4217 instance, both Modula-2 and C require the arguments to arithmetical
4218 operators to be numbers. In C, enumerated types and pointers can be
4219 represented as numbers, so that they are valid arguments to mathematical
4220 operators. @xref{Support,,Supported Languages}, for futher
4221 details on specific languages.
4223 _GDBN__ provides some additional commands for controlling the type checker:
4226 @kindex set check type
4227 @kindex show check type
4229 @item set check type auto
4230 Set type checking on or off based on the current working language.
4231 @xref{Support,,Supported Languages}, for the default settings for
4234 @item set check type on
4235 @itemx set check type off
4236 Set type checking on or off, overriding the default setting for the
4237 current working language. Issue a warning if the setting does not
4238 match the language's default. If any type mismatches occur in
4239 evaluating an expression while typechecking is on, _GDBN__ prints a
4240 message and aborts evaluation of the expression.
4242 @item set check type warn
4243 Cause the type checker to issue warnings, but to always attempt to
4244 evaluate the expression. Evaluating the expression may still
4245 be impossible for other reasons. For example, _GDBN__ cannot add
4246 numbers and structures.
4249 Show the current setting of the type checker, and whether or not _GDBN__ is
4250 setting it automatically.
4253 @cindex range checking
4254 @cindex checks, range
4255 @node Range Checking, , Type Checking, Checks
4256 @subsection An overview of Range Checking
4258 In some languages (such as Modula-2), it is an error to exceed the
4259 bounds of a type; this is enforced with run-time checks. Such range
4260 checking is meant to ensure program correctness by making sure
4261 computations do not overflow, or indices on an array element access do
4262 not exceed the bounds of the array.
4264 For expressions you use in _GDBN__ commands, you can tell _GDBN__ to
4265 ignore range errors; to always treat them as errors and abandon the
4266 expression; or to issue warnings when a range error occurs but evaluate
4267 the expression anyway.
4269 A range error can result from numerical overflow, from exceeding an
4270 array index bound, or when you type in a constant that is not a member
4271 of any type. Some languages, however, do not treat overflows as an
4272 error. In many implementations of C, mathematical overflow causes the
4273 result to ``wrap around'' to lower values---for example, if @var{m} is
4274 the largest integer value, and @var{s} is the smallest, then
4276 @var{m} + 1 @result{} @var{s}
4279 This, too, is specific to individual languages, and in some cases
4280 specific to individual compilers or machines. @xref{Support,,
4281 Supported Languages}, for further details on specific languages.
4283 _GDBN__ provides some additional commands for controlling the range checker:
4286 @kindex set check range
4287 @kindex show check range
4289 @item set check range auto
4290 Set range checking on or off based on the current working language.
4291 @xref{Support,,Supported Languages}, for the default settings for
4294 @item set check range on
4295 @itemx set check range off
4296 Set range checking on or off, overriding the default setting for the
4297 current working language. A warning is issued if the setting does not
4298 match the language's default. If a range error occurs, then a message
4299 is printed and evaluation of the expression is aborted.
4301 @item set check range warn
4302 Output messages when the _GDBN__ range checker detects a range error,
4303 but attempt to evaluate the expression anyway. Evaluating the
4304 expression may still be impossible for other reasons, such as accessing
4305 memory that the process does not own (a typical example from many UNIX
4309 Show the current setting of the range checker, and whether or not it is
4310 being set automatically by _GDBN__.
4313 @node Support, , Checks, Languages
4314 @section Supported Languages
4316 _GDBN__ 4.0 supports C, C++, and Modula-2. The syntax for C and C++ is
4317 so closely related that _GDBN__ does not distinguish the two. Some
4318 _GDBN__ features may be used in expressions regardless of the language
4319 you use: the _GDBN__ @code{@@} and @code{::} operators, and the
4320 @samp{@{type@}addr} construct (@pxref{Expressions}) can be used with the constructs of
4321 any of the supported languages.
4323 The following sections detail to what degree each of these
4324 source languages is supported by _GDBN__. These sections are
4325 not meant to be language tutorials or references, but serve only as a
4326 reference guide to what the _GDBN__ expression parser will accept, and
4327 what input and output formats should look like for different languages.
4328 There are many good books written on each of these languages; please
4329 look to these for a language reference or tutorial.
4333 * Modula-2:: Modula-2
4336 @node C, Modula-2, Support, Support
4337 @subsection C and C++
4340 @cindex expressions in C or C++
4341 Since C and C++ are so closely related, _GDBN__ does not distinguish
4342 between them when interpreting the expressions recognized in _GDBN__
4348 The C++ debugging facilities are jointly implemented by the GNU C++
4349 compiler and _GDBN__. Therefore, to debug your C++ code effectively,
4350 you must compile your C++ programs with the GNU C++ compiler,
4355 * C Operators:: C and C++ Operators
4356 * C Constants:: C and C++ Constants
4357 * Cplusplus expressions:: C++ Expressions
4358 * C Defaults:: Default settings for C and C++
4359 * C Checks:: C and C++ Type and Range Checks
4360 * Debugging C:: _GDBN__ and C
4361 * Debugging C plus plus:: Special features for C++
4364 @cindex C and C++ operators
4365 @node C Operators, C Constants, C, C
4366 @subsubsection C and C++ Operators
4368 Operators must be defined on values of specific types. For instance,
4369 @code{+} is defined on numbers, but not on structures. Operators are
4370 often defined on groups of types. For the purposes of C and C++, the
4371 following definitions hold:
4375 @emph{Integral types} include @code{int} with any of its storage-class
4376 specifiers, @code{char}, and @code{enum}s.
4379 @emph{Floating-point types} include @code{float} and @code{double}.
4382 @emph{Pointer types} include all types defined as @code{(@var{type}
4386 @emph{Scalar types} include all of the above.
4391 The following operators are supported. They are listed here
4392 in order of increasing precedence:
4397 The comma or sequencing operator. Expressions in a comma-separated list
4398 are evaluated from left to right, with the result of the entire
4399 expression being the last expression evaluated.
4402 Assignment. The value of an assignment expression is the value
4403 assigned. Defined on scalar types.
4406 Used in an expression of the form @var{a} @var{op}@code{=} @var{b}, and
4407 translated to @var{a} @code{=} @var{a op b}. @var{op}@code{=} and
4408 @code{=} have the same precendence. @var{op} is any one of the
4409 operators @code{|}, @code{^}, @code{&}, @code{<<}, @code{>>}, @code{+},
4410 @code{-}, @code{*}, @code{/}, @code{%}.
4413 The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought
4414 of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an
4418 Logical OR. Defined on integral types.
4421 Logical AND. Defined on integral types.
4424 Bitwise OR. Defined on integral types.
4427 Bitwise exclusive-OR. Defined on integral types.
4430 Bitwise AND. Defined on integral types.
4433 Equality and inequality. Defined on scalar types. The value of these
4434 expressions is 0 for false and non-zero for true.
4436 @item <@r{, }>@r{, }<=@r{, }>=
4437 Less than, greater than, less than or equal, greater than or equal.
4438 Defined on scalar types. The value of these expressions is 0 for false
4439 and non-zero for true.
4442 left shift, and right shift. Defined on integral types.
4445 The _GDBN__ ``artificial array'' operator (@pxref{Expressions}).
4448 Addition and subtraction. Defined on integral types, floating-point types and
4451 @item *@r{, }/@r{, }%
4452 Multiplication, division, and modulus. Multiplication and division are
4453 defined on integral and floating-point types. Modulus is defined on
4457 Increment and decrement. When appearing before a variable, the
4458 operation is performed before the variable is used in an expression;
4459 when appearing after it, the variable's value is used before the
4460 operation takes place.
4463 Pointer dereferencing. Defined on pointer types. Same precedence as
4467 Address operator. Defined on variables. Same precedence as @code{++}.
4470 Negative. Defined on integral and floating-point types. Same
4471 precedence as @code{++}.
4474 Logical negation. Defined on integral types. Same precedence as
4478 Bitwise complement operator. Defined on integral types. Same precedence as
4482 Structure member, and pointer-to-structure member. For convenience,
4483 _GDBN__ regards the two as equivalent, choosing whether to dereference a
4484 pointer based on the stored type information.
4485 Defined on @code{struct}s and @code{union}s.
4488 Array indexing. @code{@var{a}[@var{i}]} is defined as
4489 @code{*(@var{a}+@var{i})}. Same precedence as @code{->}.
4492 Function parameter list. Same precedence as @code{->}.
4495 C++ scope resolution operator. Defined on
4496 @code{struct}, @code{union}, and @code{class} types.
4499 The _GDBN__ scope operator (@pxref{Expressions}). Same precedence as
4500 @code{::}, above. _1__
4503 @cindex C and C++ constants
4504 @node C Constants, Cplusplus expressions, C Operators, C
4505 @subsubsection C and C++ Constants
4507 _GDBN__ allows you to express the constants of C and C++ in the
4513 Integer constants are a sequence of digits. Octal constants are
4514 specified by a leading @samp{0} (ie. zero), and hexadecimal constants by
4515 a leading @samp{0x} or @samp{0X}. Constants may also end with an
4516 @samp{l}, specifying that the constant should be treated as a
4520 Floating point constants are a sequence of digits, followed by a decimal
4521 point, followed by a sequence of digits, and optionally followed by an
4522 exponent. An exponent is of the form:
4523 @samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another
4524 sequence of digits. The @samp{+} is optional for positive exponents.
4527 Enumerated constants consist of enumerated identifiers, or their
4528 integral equivalents.
4531 Character constants are a single character surrounded by single quotes
4532 (@code{'}), or a number---the ordinal value of the corresponding character
4533 (usually its @sc{ASCII} value). Within quotes, the single character may
4534 be represented by a letter or by @dfn{escape sequences}, which are of
4535 the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation
4536 of the character's ordinal value; or of the form @samp{\@var{x}}, where
4537 @samp{@var{x}} is a predefined special character---for example,
4538 @samp{\n} for newline.
4541 String constants are a sequence of character constants surrounded
4542 by double quotes (@code{"}).
4545 Pointer constants are an integral value.
4550 @node Cplusplus expressions, C Defaults, C Constants, C
4551 @subsubsection C++ Expressions
4553 @cindex expressions in C++
4554 _GDBN__'s expression handling has the following extensions to
4555 interpret a significant subset of C++ expressions:
4559 @cindex member functions
4561 Member function calls are allowed; you can use expressions like
4563 count = aml->GetOriginal(x, y)
4567 @cindex namespace in C++
4569 While a member function is active (in the selected stack frame), your
4570 expressions have the same namespace available as the member function;
4571 that is, _GDBN__ allows implicit references to the class instance
4572 pointer @code{this} following the same rules as C++.
4574 @cindex call overloaded functions
4575 @cindex type conversions in C++
4577 You can call overloaded functions; _GDBN__ will resolve the function
4578 call to the right definition, with one restriction---you must use
4579 arguments of the type required by the function that you want to call.
4580 _GDBN__ will not perform conversions requiring constructors or
4581 user-defined type operators.
4583 @cindex reference declarations
4585 _GDBN__ understands variables declared as C++ references; you can use them in
4586 expressions just as you do in C++ source---they are automatically
4589 In the parameter list shown when _GDBN__ displays a frame, the values of
4590 reference variables are not displayed (unlike other variables); this
4591 avoids clutter, since references are often used for large structures.
4592 The @emph{address} of a reference variable is always shown, unless
4593 you've specified @samp{set print address off}.
4597 _GDBN__ supports the C++ name resolution operator @code{::}---your
4598 expressions can use it just as expressions in your program do. Since
4599 one scope may be defined in another, you can use @code{::} repeatedly if
4600 necessary, for example in an expression like
4601 @samp{@var{scope1}::@var{scope2}::@var{name}}. _GDBN__ also allows
4602 resolving name scope by reference to source files, in both C and C++
4603 debugging; @pxref{Variables}.
4608 @node C Defaults, C Checks, Cplusplus expressions, C
4609 @subsubsection C and C++ Defaults
4610 @cindex C and C++ defaults
4612 If you allow _GDBN__ to set type and range checking automatically, they
4613 both default to @code{off} whenever the working language changes to
4614 C/C++. This happens regardless of whether you, or _GDBN__,
4615 selected the working language.
4617 If you allow _GDBN__ to set the language automatically, it sets the
4618 working language to C/C++ on entering code compiled from a source file
4619 whose name ends with @file{.c} or @file{.cc}.
4620 @xref{Automatically,,Having _GDBN__ infer the source language}, for
4623 @node C Checks, Debugging C, C Defaults, C
4624 @subsubsection C and C++ Type and Range Checks
4625 @cindex C and C++ checks
4628 @emph{Warning:} in this release, _GDBN__ does not yet perform type or
4631 @c FIXME remove warning when type/range checks added
4633 By default, when _GDBN__ parses C or C++ expressions, type checking
4634 is not used. However, if you turn type checking on, _GDBN__ will
4635 consider two variables type equivalent if:
4639 The two variables are structured and have the same structure, union, or
4643 Two two variables have the same type name, or types that have been
4644 declared equivalent through @code{typedef}.
4647 @c leaving this out because neither J Gilmore nor R Pesch understand it.
4650 The two @code{struct}, @code{union}, or @code{enum} variables are
4651 declared in the same declaration. (Note: this may not be true for all C
4657 Range checking, if turned on, is done on mathematical operations. Array
4658 indices are not checked, since they are often used to index a pointer
4659 that is not itself an array.
4661 @node Debugging C, Debugging C plus plus, C Checks, C
4662 @subsubsection _GDBN__ and C
4664 The @code{set print union} and @code{show print union} commands apply to
4665 the @code{union} type. When set to @samp{on}, any @code{union} that is
4666 inside a @code{struct} or @code{class} will also be printed.
4667 Otherwise, it will appear as @samp{@{...@}}.
4669 The @code{@@} operator aids in the debugging of dynamic arrays, formed
4670 with pointers and a memory allocation function. (@pxref{Expressions})
4672 @node Debugging C plus plus, , Debugging C, C
4673 @subsubsection _GDBN__ Commands for C++
4675 @cindex commands for C++
4676 Some _GDBN__ commands are particularly useful with C++, and some are
4677 designed specifically for use with C++. Here is a summary:
4680 @cindex break in overloaded functions
4681 @item @r{breakpoint menus}
4682 When you want a breakpoint in a function whose name is overloaded,
4683 _GDBN__'s breakpoint menus help you specify which function definition
4684 you want. @xref{Breakpoint Menus}.
4686 @cindex overloading in C++
4687 @item rbreak @var{regex}
4688 Setting breakpoints using regular expressions is helpful for setting
4689 breakpoints on overloaded functions that are not members of any special
4693 @cindex C++ exception handling
4694 @item catch @var{exceptions}
4696 Debug C++ exception handling using these commands. @xref{Exception Handling}.
4699 @item ptype @var{typename}
4700 Print inheritance relationships as well as other information for type
4704 @cindex C++ symbol display
4705 @item set print demangle
4706 @itemx show print demangle
4707 @itemx set print asm-demangle
4708 @itemx show print asm-demangle
4709 Control whether C++ symbols display in their source form, both when
4710 displaying code as C++ source and when displaying disassemblies.
4711 @xref{Print Settings}.
4713 @item set print object
4714 @itemx show print object
4715 Choose whether to print derived (actual) or declared types of objects.
4716 @xref{Print Settings}.
4718 @item set print vtbl
4719 @itemx show print vtbl
4720 Control the format for printing virtual function tables.
4721 @xref{Print Settings}.
4726 @node Modula-2, , C, Support
4727 @subsection Modula-2
4730 The extensions made to _GDBN__ to support Modula-2 support output
4731 from the GNU Modula-2 compiler (which is currently being developed).
4732 Other Modula-2 compilers are not currently supported, and attempting to
4733 debug executables produced by them will most likely result in an error
4734 as _GDBN__ reads in the executable's symbol table.
4736 @cindex expressions in Modula-2
4738 * M2 Operators:: Built-in operators
4739 * Builtin Func/Proc:: Built-in Functions and Procedures
4740 * M2 Constants:: Modula-2 Constants
4741 * M2 Defaults:: Default settings for Modula-2
4742 * Deviations:: Deviations from standard Modula-2
4743 * M2 Checks:: Modula-2 Type and Range Checks
4744 * M2 Scope:: The scope operators @code{::} and @code{.}
4745 * GDB/M2:: _GDBN__ and Modula-2
4748 @node M2 Operators, Builtin Func/Proc, Modula-2, Modula-2
4749 @subsubsection Operators
4750 @cindex Modula-2 operators
4752 Operators must be defined on values of specific types. For instance,
4753 @code{+} is defined on numbers, but not on structures. Operators are
4754 often defined on groups of types. For the purposes of Modula-2, the
4755 following definitions hold:
4760 @emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and
4764 @emph{Character types} consist of @code{CHAR} and its subranges.
4767 @emph{Floating-point types} consist of @code{REAL}.
4770 @emph{Pointer types} consist of anything declared as @code{POINTER TO
4774 @emph{Scalar types} consist of all of the above.
4777 @emph{Set types} consist of @code{SET}s and @code{BITSET}s.
4780 @emph{Boolean types} consist of @code{BOOLEAN}.
4785 The following operators are supported, and appear in order of
4786 increasing precedence:
4791 Function argument or array index separator.
4794 Assignment. The value of @var{var} @code{:=} @var{value} is
4798 Less than, greater than on integral, floating-point, or enumerated
4802 Less than, greater than, less than or equal to, greater than or equal to
4803 on integral, floating-point and enumerated types, or set inclusion on
4804 set types. Same precedence as @code{<}.
4806 @item =@r{, }<>@r{, }#
4807 Equality and two ways of expressing inequality, valid on scalar types.
4808 Same precedence as @code{<}. In _GDBN__ scripts, only @code{<>} is
4809 available for inequality, since @code{#} conflicts with the script
4813 Set membership. Defined on set types and the types of their members.
4814 Same precedence as @code{<}.
4817 Boolean disjunction. Defined on boolean types.
4820 Boolean conjuction. Defined on boolean types.
4823 The _GDBN__ ``artificial array'' operator (@pxref{Expressions}).
4826 Addition and subtraction on integral and floating-point types, or union
4827 and difference on set types.
4830 Multiplication on integral and floating-point types, or set intersection
4834 Division on floating-point types, or symmetric set difference on set
4835 types. Same precedence as @code{*}.
4838 Integer division and remainder. Defined on integral types. Same
4839 precedence as @code{*}.
4842 Negative. Defined on @code{INTEGER}s and @code{REAL}s.
4845 Pointer dereferencing. Defined on pointer types.
4848 Boolean negation. Defined on boolean types. Same precedence as
4852 @code{RECORD} field selector. Defined on @code{RECORD}s. Same
4853 precedence as @code{^}.
4856 Array indexing. Defined on @code{ARRAY}s. Same precedence as @code{^}.
4859 Procedure argument list. Defined on @code{PROCEDURE}s. Same precedence
4863 _GDBN__ and Modula-2 scope operators.
4868 @emph{Warning:} Sets and their operations are not yet supported, so _GDBN__
4869 will treat the use of the operator @code{IN}, or the use of operators
4870 @code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#},
4871 @code{<=}, and @code{>=} on sets as an error.
4875 @cindex Modula-2 builtins
4876 @node Builtin Func/Proc, M2 Constants, M2 Operators, Modula-2
4877 @subsubsection Built-in Functions and Procedures
4879 Modula-2 also makes available several built-in procedures and functions.
4880 In describing these, the following metavariables are used:
4885 represents an @code{ARRAY} variable.
4888 represents a @code{CHAR} constant or variable.
4891 represents a variable or constant of integral type.
4894 represents an identifier that belongs to a set. Generally used in the
4895 same function with the metavariable @var{s}. The type of @var{s} should
4896 be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}.
4899 represents a variable or constant of integral or floating-point type.
4902 represents a variable or constant of floating-point type.
4908 represents a variable.
4911 represents a variable or constant of one of many types. See the
4912 explanation of the function for details.
4916 All Modula-2 built-in procedures also return a result, described below.
4920 Returns the absolute value of @var{n}.
4923 If @var{c} is a lower case letter, it returns its upper case
4924 equivalent, otherwise it returns its argument
4927 Returns the character whose ordinal value is @var{i}.
4930 Decrements the value in the variable @var{v}. Returns the new value.
4932 @item DEC(@var{v},@var{i})
4933 Decrements the value in the variable @var{v} by @var{i}. Returns the
4936 @item EXCL(@var{m},@var{s})
4937 Removes the element @var{m} from the set @var{s}. Returns the new
4940 @item FLOAT(@var{i})
4941 Returns the floating point equivalent of the integer @var{i}.
4944 Returns the index of the last member of @var{a}.
4947 Increments the value in the variable @var{v}. Returns the new value.
4949 @item INC(@var{v},@var{i})
4950 Increments the value in the variable @var{v} by @var{i}. Returns the
4953 @item INCL(@var{m},@var{s})
4954 Adds the element @var{m} to the set @var{s} if it is not already
4955 there. Returns the new set.
4958 Returns the maximum value of the type @var{t}.
4961 Returns the minimum value of the type @var{t}.
4964 Returns boolean TRUE if @var{i} is an odd number.
4967 Returns the ordinal value of its argument. For example, the ordinal
4968 value of a character is its ASCII value (on machines supporting the
4969 ASCII character set). @var{x} must be of an ordered type, which include
4970 integral, character and enumerated types.
4973 Returns the size of its argument. @var{x} can be a variable or a type.
4975 @item TRUNC(@var{r})
4976 Returns the integral part of @var{r}.
4978 @item VAL(@var{t},@var{i})
4979 Returns the member of the type @var{t} whose ordinal value is @var{i}.
4983 @emph{Warning:} Sets and their operations are not yet supported, so
4984 _GDBN__ will treat the use of procedures @code{INCL} and @code{EXCL} as
4988 @cindex Modula-2 constants
4989 @node M2 Constants, M2 Defaults, Builtin Func/Proc, Modula-2
4990 @subsubsection Constants
4992 _GDBN__ allows you to express the constants of Modula-2 in the following
4998 Integer constants are simply a sequence of digits. When used in an
4999 expression, a constant is interpreted to be type-compatible with the
5000 rest of the expression. Hexadecimal integers are specified by a
5001 trailing @samp{H}, and octal integers by a trailing @samp{B}.
5004 Floating point constants appear as a sequence of digits, followed by a
5005 decimal point and another sequence of digits. An optional exponent can
5006 then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where
5007 @samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the
5008 digits of the floating point constant must be valid decimal (base 10)
5012 Character constants consist of a single character enclosed by a pair of
5013 like quotes, either single (@code{'}) or double (@code{"}). They may
5014 also be expressed by their ordinal value (their ASCII value, usually)
5015 followed by a @samp{C}.
5018 String constants consist of a sequence of characters enclosed by a pair
5019 of like quotes, either single (@code{'}) or double (@code{"}). Escape
5020 sequences in the style of C are also allowed. @xref{C Constants}, for a
5021 brief explanation of escape sequences.
5024 Enumerated constants consist of an enumerated identifier.
5027 Boolean constants consist of the identifiers @code{TRUE} and
5031 Pointer constants consist of integral values only.
5034 Set constants are not yet supported.
5038 @node M2 Defaults, Deviations, M2 Constants, Modula-2
5039 @subsubsection Modula-2 Defaults
5040 @cindex Modula-2 defaults
5042 If type and range checking are set automatically by _GDBN__, they
5043 both default to @code{on} whenever the working language changes to
5044 Modula-2. This happens regardless of whether you, or _GDBN__,
5045 selected the working language.
5047 If you allow _GDBN__ to set the language automatically, then entering
5048 code compiled from a file whose name ends with @file{.mod} will set the
5049 working language to Modula-2. @xref{Automatically,,Having _GDBN__ set
5050 the language automatically}, for further details.
5052 @node Deviations, M2 Checks, M2 Defaults, Modula-2
5053 @subsubsection Deviations from Standard Modula-2
5054 @cindex Modula-2, deviations from
5056 A few changes have been made to make Modula-2 programs easier to debug.
5057 This is done primarily via loosening its type strictness:
5061 Unlike in standard Modula-2, pointer constants can be formed by
5062 integers. This allows you to modify pointer variables during
5063 debugging. (In standard Modula-2, the actual address contained in a
5064 pointer variable is hidden from you; it can only be modified
5065 through direct assignment to another pointer variable or expression that
5066 returned a pointer.)
5069 C escape sequences can be used in strings and characters to represent
5070 non-printable characters. _GDBN__ will print out strings with these
5071 escape sequences embedded. Single non-printable characters are
5072 printed using the @samp{CHR(@var{nnn})} format.
5075 The assignment operator (@code{:=}) returns the value of its right-hand
5079 All builtin procedures both modify @emph{and} return their argument.
5083 @node M2 Checks, M2 Scope, Deviations, Modula-2
5084 @subsubsection Modula-2 Type and Range Checks
5085 @cindex Modula-2 checks
5088 @emph{Warning:} in this release, _GDBN__ does not yet perform type or
5091 @c FIXME remove warning when type/range checks added
5093 _GDBN__ considers two Modula-2 variables type equivalent if:
5097 They are of types that have been declared equivalent via a @code{TYPE
5098 @var{t1} = @var{t2}} statement
5101 They have been declared on the same line. (Note: This is true of the
5102 GNU Modula-2 compiler, but it may not be true of other compilers.)
5106 As long as type checking is enabled, any attempt to combine variables
5107 whose types are not equivalent is an error.
5109 Range checking is done on all mathematical operations, assignment, array
5110 index bounds, and all builtin functions and procedures.
5112 @node M2 Scope, GDB/M2, M2 Checks, Modula-2
5113 @subsubsection The scope operators @code{::} and @code{.}
5118 There are a few subtle differences between the Modula-2 scope operator
5119 (@code{.}) and the _GDBN__ scope operator (@code{::}). The two have
5124 @var{module} . @var{id}
5125 @var{scope} :: @var{id}
5130 where @var{scope} is the name of a module or a procedure,
5131 @var{module} the name of a module, and @var{id} is any delcared
5132 identifier within the program, except another module.
5134 Using the @code{::} operator makes _GDBN__ search the scope
5135 specified by @var{scope} for the identifier @var{id}. If it is not
5136 found in the specified scope, then _GDBN__ will search all scopes
5137 enclosing the one specified by @var{scope}.
5139 Using the @code{.} operator makes _GDBN__ search the current scope for
5140 the identifier specified by @var{id} that was imported from the
5141 definition module specified by @var{module}. With this operator, it is
5142 an error if the identifier @var{id} was not imported from definition
5143 module @var{module}, or if @var{id} is not an identifier in
5146 @node GDB/M2, , M2 Scope, Modula-2
5147 @subsubsection _GDBN__ and Modula-2
5149 Some _GDBN__ commands have little use when debugging Modula-2 programs.
5150 Five subcommands of @code{set print} and @code{show print} apply
5151 specifically to C and C++: @samp{vtbl}, @samp{demangle},
5152 @samp{asm-demangle}, @samp{object}, and @samp{union}. The first four
5153 apply to C++, and the last to C's @code{union} type, which has no direct
5154 analogue in Modula-2.
5156 The @code{@@} operator (@pxref{Expressions}), while available
5157 while using any language, is not useful with Modula-2. Its
5158 intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be
5159 created in Modula-2 as they can in C or C++. However, because an
5160 address can be specified by an integral constant, the construct
5161 @samp{@{@var{type}@}@var{adrexp}} is still useful. (@pxref{Expressions})
5164 @cindex @code{#} in Modula-2
5165 In _GDBN__ scripts, the Modula-2 inequality operator @code{#} is
5166 interpreted as the beginning of a comment. Use @code{<>} instead.
5170 @node Symbols, Altering, Languages, Top
5171 @chapter Examining the Symbol Table
5173 The commands described in this section allow you to inquire about the
5174 symbols (names of variables, functions and types) defined in your
5175 program. This information is inherent in the text of your program and
5176 does not change as the program executes. _GDBN__ finds it in your
5177 program's symbol table, in the file indicated when you started _GDBN__
5178 (@pxref{File Options}), or by one of the file-management commands
5182 @item info address @var{symbol}
5183 @kindex info address
5184 Describe where the data for @var{symbol} is stored. For a register
5185 variable, this says which register it is kept in. For a non-register
5186 local variable, this prints the stack-frame offset at which the variable
5189 Note the contrast with @samp{print &@var{symbol}}, which does not work
5190 at all for a register variables, and for a stack local variable prints
5191 the exact address of the current instantiation of the variable.
5193 @item whatis @var{exp}
5195 Print the data type of expression @var{exp}. @var{exp} is not
5196 actually evaluated, and any side-effecting operations (such as
5197 assignments or function calls) inside it do not take place.
5201 Print the data type of @code{$}, the last value in the value history.
5203 @item ptype @var{typename}
5205 Print a description of data type @var{typename}. @var{typename} may be
5206 the name of a type, or for C code it may have the form
5207 @samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or
5208 @samp{enum @var{enum-tag}}.@refill
5210 @item ptype @var{exp}
5211 Print a description of the type of expression @var{exp}. @code{ptype}
5212 differs from @code{whatis} by printing a detailed description, instead of just
5213 the name of the type. For example, if your program declares a variable
5216 struct complex @{double real; double imag;@} v;
5219 compare the output of the two commands:
5222 type = struct complex
5224 type = struct complex @{
5230 @item info types @var{regexp}
5233 Print a brief description of all types whose name matches @var{regexp}
5234 (or all types in your program, if you supply no argument). Each
5235 complete typename is matched as though it were a complete line; thus,
5236 @samp{i type value} gives information on all types in your program whose
5237 name includes the string @code{value}, but @samp{i type ^value$} gives
5238 information only on types whose complete name is @code{value}.
5240 This command differs from @code{ptype} in two ways: first, like
5241 @code{whatis}, it does not print a detailed description; second, it
5242 lists all source files where a type is defined.
5246 Show the name of the current source file---that is, the source file for
5247 the function containing the current point of execution---and the language
5251 @kindex info sources
5252 Print the names of all source files in the program for which there is
5253 debugging information, organized into two lists: files whose symbols
5254 have already been read, and files whose symbols will be read when needed.
5256 @item info functions
5257 @kindex info functions
5258 Print the names and data types of all defined functions.
5260 @item info functions @var{regexp}
5261 Print the names and data types of all defined functions
5262 whose names contain a match for regular expression @var{regexp}.
5263 Thus, @samp{info fun step} finds all functions whose names
5264 include @code{step}; @samp{info fun ^step} finds those whose names
5265 start with @code{step}.
5267 @item info variables
5268 @kindex info variables
5269 Print the names and data types of all variables that are declared
5270 outside of functions (i.e., excluding local variables).
5272 @item info variables @var{regexp}
5273 Print the names and data types of all variables (except for local
5274 variables) whose names contain a match for regular expression
5279 This was never implemented.
5281 @itemx info methods @var{regexp}
5282 @kindex info methods
5283 The @code{info methods} command permits the user to examine all defined
5284 methods within C++ program, or (with the @var{regexp} argument) a
5285 specific set of methods found in the various C++ classes. Many
5286 C++ classes provide a large number of methods. Thus, the output
5287 from the @code{ptype} command can be overwhelming and hard to use. The
5288 @code{info-methods} command filters the methods, printing only those
5289 which match the regular-expression @var{regexp}.
5292 @item printsyms @var{filename}
5294 Write a dump of debugging symbol data into the file
5295 @var{filename}. Only symbols with debugging data are included. _GDBN__
5296 includes all the symbols it already knows about: that is, @var{filename}
5297 reflects symbols for only those files whose symbols _GDBN__ has read.
5298 You can find out which files these are using the command @code{info
5299 files}. The description of @code{symbol-file} describes how _GDBN__
5300 reads symbols; both commands are described under @ref{Files}.
5303 @node Altering, _GDBN__ Files, Symbols, Top
5304 @chapter Altering Execution
5306 Once you think you have found an error in the program, you might want to
5307 find out for certain whether correcting the apparent error would lead to
5308 correct results in the rest of the run. You can find the answer by
5309 experiment, using the _GDBN__ features for altering execution of the
5312 For example, you can store new values into variables or memory
5313 locations, give the program a signal, restart it at a different address,
5314 or even return prematurely from a function to its caller.
5317 * Assignment:: Assignment to Variables
5318 * Jumping:: Continuing at a Different Address
5319 * Signaling:: Giving the Program a Signal
5320 * Returning:: Returning from a Function
5321 * Calling:: Calling your Program's Functions
5324 @node Assignment, Jumping, Altering, Altering
5325 @section Assignment to Variables
5328 @cindex setting variables
5329 To alter the value of a variable, evaluate an assignment expression.
5330 @xref{Expressions}. For example,
5337 would store the value 4 into the variable @code{x}, and then print the
5338 value of the assignment expression (which is 4). @xref{Languages}, for
5339 more information on operators in supported languages.
5341 @kindex set variable
5342 @cindex variables, setting
5343 If you are not interested in seeing the value of the assignment, use the
5344 @code{set} command instead of the @code{print} command. @code{set} is
5345 really the same as @code{print} except that the expression's value is not
5346 printed and is not put in the value history (@pxref{Value History}). The
5347 expression is evaluated only for its effects.
5349 If the beginning of the argument string of the @code{set} command
5350 appears identical to a @code{set} subcommand, use the @code{set
5351 variable} command instead of just @code{set}. This command is identical
5352 to @code{set} except for its lack of subcommands. For example, a
5353 program might well have a variable @code{width}---which leads to
5354 an error if we try to set a new value with just @samp{set width=13}, as
5355 we might if @code{set width} didn't happen to be a _GDBN__ command:
5357 (_GDBP__) whatis width
5361 (_GDBP__) set width=47
5362 Invalid syntax in expression.
5365 The invalid expression, of course, is @samp{=47}. What we can do in
5366 order to actually set our program's variable @code{width} is
5368 (_GDBP__) set var width=47
5371 _GDBN__ allows more implicit conversions in assignments than C does; you can
5372 freely store an integer value into a pointer variable or vice versa, and
5373 any structure can be converted to any other structure that is the same
5375 @comment FIXME: how do structs align/pad in these conversions?
5376 @comment /pesch@cygnus.com 18dec1990
5378 To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
5379 construct to generate a value of specified type at a specified address
5380 (@pxref{Expressions}). For example, @code{@{int@}0x83040} refers
5381 to memory location @code{0x83040} as an integer (which implies a certain size
5382 and representation in memory), and
5385 set @{int@}0x83040 = 4
5389 stores the value 4 into that memory location.
5391 @node Jumping, Signaling, Assignment, Altering
5392 @section Continuing at a Different Address
5394 Ordinarily, when you continue the program, you do so at the place where
5395 it stopped, with the @code{continue} command. You can instead continue at
5396 an address of your own choosing, with the following commands:
5399 @item jump @var{linespec}
5401 Resume execution at line @var{linespec}. Execution will stop
5402 immediately if there is a breakpoint there. @xref{List} for a
5403 description of the different forms of @var{linespec}.
5405 The @code{jump} command does not change the current stack frame, or
5406 the stack pointer, or the contents of any memory location or any
5407 register other than the program counter. If line @var{linespec} is in
5408 a different function from the one currently executing, the results may
5409 be bizarre if the two functions expect different patterns of arguments or
5410 of local variables. For this reason, the @code{jump} command requests
5411 confirmation if the specified line is not in the function currently
5412 executing. However, even bizarre results are predictable if you are
5413 well acquainted with the machine-language code of the program.
5415 @item jump *@var{address}
5416 Resume execution at the instruction at address @var{address}.
5419 You can get much the same effect as the @code{jump} command by storing a
5420 new value into the register @code{$pc}. The difference is that this
5421 does not start the program running; it only changes the address where it
5422 @emph{will} run when it is continued. For example,
5429 causes the next @code{continue} command or stepping command to execute at
5430 address 0x485, rather than at the address where the program stopped.
5431 @xref{Continuing and Stepping}.
5433 The most common occasion to use the @code{jump} command is to back up,
5434 perhaps with more breakpoints set, over a portion of a program that has
5435 already executed, in order to examine its execution in more detail.
5437 @node Signaling, Returning, Jumping, Altering
5439 @section Giving the Program a Signal
5442 @item signal @var{signalnum}
5444 Resume execution where the program stopped, but give it immediately the
5445 signal number @var{signalnum}.
5447 Alternatively, if @var{signalnum} is zero, continue execution without
5448 giving a signal. This is useful when the program stopped on account of
5449 a signal and would ordinary see the signal when resumed with the
5450 @code{continue} command; @samp{signal 0} causes it to resume without a
5453 @code{signal} does not repeat when you press @key{RET} a second time
5454 after executing the command.
5458 @node Returning, Calling, Signaling, Altering
5459 @section Returning from a Function
5463 @itemx return @var{expression}
5464 @cindex returning from a function
5466 You can cancel execution of a function call with the @code{return}
5467 command. If you give an
5468 @var{expression} argument, its value is used as the function's return
5472 When you use @code{return}, _GDBN__ discards the selected stack frame
5473 (and all frames within it). You can think of this as making the
5474 discarded frame return prematurely. If you wish to specify a value to
5475 be returned, give that value as the argument to @code{return}.
5477 This pops the selected stack frame (@pxref{Selection}), and any other
5478 frames inside of it, leaving its caller as the innermost remaining
5479 frame. That frame becomes selected. The specified value is stored in
5480 the registers used for returning values of functions.
5482 The @code{return} command does not resume execution; it leaves the
5483 program stopped in the state that would exist if the function had just
5484 returned. In contrast, the @code{finish} command (@pxref{Continuing and
5485 Stepping}) resumes execution until the selected stack frame returns
5488 @node Calling, , Returning, Altering
5489 @section Calling your Program's Functions
5491 @cindex calling functions
5494 @item call @var{expr}
5495 Evaluate the expression @var{expr} without displaying @code{void}
5499 You can use this variant of the @code{print} command if you want to
5500 execute a function from your program, but without cluttering the output
5501 with @code{void} returned values. The result is printed and saved in
5502 the value history, if it is not void.
5504 @node _GDBN__ Files, Targets, Altering, Top
5505 @chapter _GDBN__'s Files
5508 * Files:: Commands to Specify Files
5509 * Symbol Errors:: Errors Reading Symbol Files
5512 @node Files, Symbol Errors, _GDBN__ Files, _GDBN__ Files
5513 @section Commands to Specify Files
5514 @cindex core dump file
5515 @cindex symbol table
5516 _GDBN__ needs to know the file name of the program to be debugged, both in
5517 order to read its symbol table and in order to start the program. To
5518 debug a core dump of a previous run, _GDBN__ must be told the file name of
5521 The usual way to specify the executable and core dump file names is with
5522 the command arguments given when you start _GDBN__, as discussed in
5525 Occasionally it is necessary to change to a different file during a
5526 _GDBN__ session. Or you may run _GDBN__ and forget to specify the files you
5527 want to use. In these situations the _GDBN__ commands to specify new files
5531 @item file @var{filename}
5532 @cindex executable file
5534 Use @var{filename} as the program to be debugged. It is read for its
5535 symbols and for the contents of pure memory. It is also the program
5536 executed when you use the @code{run} command. If you do not specify a
5537 directory and the file is not found in _GDBN__'s working directory,
5539 _GDBN__ uses the environment variable @code{PATH} as a list of
5540 directories to search, just as the shell does when looking for a program
5541 to run. You can change the value of this variable, for both _GDBN__ and
5542 your program, using the @code{path} command.
5544 @code{file} with no argument makes _GDBN__ discard any information it
5545 has on both executable file and the symbol table.
5547 @item exec-file @var{filename}
5549 Specify that the program to be run (but not the symbol table) is found
5550 in @var{filename}. _GDBN__ will search the environment variable @code{PATH}
5551 if necessary to locate the program.
5553 @item symbol-file @var{filename}
5555 Read symbol table information from file @var{filename}. @code{PATH} is
5556 searched when necessary. Use the @code{file} command to get both symbol
5557 table and program to run from the same file.
5559 @code{symbol-file} with no argument clears out _GDBN__'s information on your
5560 program's symbol table.
5562 The @code{symbol-file} command causes _GDBN__ to forget the contents of its
5563 convenience variables, the value history, and all breakpoints and
5564 auto-display expressions. This is because they may contain pointers to
5565 the internal data recording symbols and data types, which are part of
5566 the old symbol table data being discarded inside _GDBN__.
5568 @code{symbol-file} will not repeat if you press @key{RET} again after
5571 On some kinds of object files, the @code{symbol-file} command does not
5572 actually read the symbol table in full right away. Instead, it scans
5573 the symbol table quickly to find which source files and which symbols
5574 are present. The details are read later, one source file at a time,
5575 when they are needed.
5577 The purpose of this two-stage reading strategy is to make _GDBN__ start up
5578 faster. For the most part, it is invisible except for occasional pauses
5579 while the symbol table details for a particular source file are being
5580 read. (The @code{set verbose} command can turn these pauses into
5581 messages if desired. @xref{Messages/Warnings}).
5583 When the symbol table is stored in COFF format, @code{symbol-file} does
5584 read the symbol table data in full right away. We haven't implemented
5585 the two-stage strategy for COFF yet.
5587 When _GDBN__ is configured for a particular environment, it will
5588 understand debugging information in whatever format is the standard
5589 generated for that environment; you may use either a GNU compiler, or
5590 other compilers that adhere to the local conventions. Best results are
5591 usually obtained from GNU compilers; for example, using @code{_GCC__}
5592 you can generate debugging information for optimized code.
5594 @item core-file @var{filename}
5595 @itemx core @var{filename}
5598 Specify the whereabouts of a core dump file to be used as the ``contents
5599 of memory''. Traditionally, core files contain only some parts of the
5600 address space of the process that generated them; _GDBN__ can access the
5601 executable file itself for other parts.
5603 @code{core-file} with no argument specifies that no core file is
5606 Note that the core file is ignored when your program is actually running
5607 under _GDBN__. So, if you have been running the program and you wish to
5608 debug a core file instead, you must kill the subprocess in which the
5609 program is running. To do this, use the @code{kill} command
5610 (@pxref{Kill Process}).
5612 @item load @var{filename}
5615 Depending on what remote debugging facilities are configured into
5616 _GDBN__, the @code{load} command may be available. Where it exists, it
5617 is meant to make @var{filename} (an executable) available for debugging
5618 on the remote system---by downloading, or dynamic linking, for example.
5619 @code{load} also records @var{filename}'s symbol table in _GDBN__, like
5620 the @code{add-symbol-file} command.
5622 If @code{load} is not available on your _GDBN__, attempting to execute
5623 it gets the error message ``@code{You can't do that when your target is
5628 On VxWorks, @code{load} will dynamically link @var{filename} on the
5629 current target system as well as adding its symbols in _GDBN__.
5633 @cindex download to Nindy-960
5634 With the Nindy interface to an Intel 960 board, @code{load} will
5635 download @var{filename} to the 960 as well as adding its symbols in
5639 @code{load} will not repeat if you press @key{RET} again after using it.
5641 @item add-symbol-file @var{filename} @var{address}
5642 @kindex add-symbol-file
5643 @cindex dynamic linking
5644 The @code{add-symbol-file} command reads additional symbol table information
5645 from the file @var{filename}. You would use this command when @var{filename}
5646 has been dynamically loaded (by some other means) into the program that
5647 is running. @var{address} should be the memory address at which the
5648 file has been loaded; _GDBN__ cannot figure this out for itself.
5650 The symbol table of the file @var{filename} is added to the symbol table
5651 originally read with the @code{symbol-file} command. You can use the
5652 @code{add-symbol-file} command any number of times; the new symbol data thus
5653 read keeps adding to the old. To discard all old symbol data instead,
5654 use the @code{symbol-file} command.
5656 @code{add-symbol-file} will not repeat if you press @key{RET} after using it.
5662 @code{info files} and @code{info target} are synonymous; both print the
5663 current targets (@pxref{Targets}), including the names of the executable
5664 and core dump files currently in use by _GDBN__, and the files from
5665 which symbols were loaded. The command @code{help targets} lists all
5666 possible targets rather than current ones.
5670 All file-specifying commands allow both absolute and relative file names
5671 as arguments. _GDBN__ always converts the file name to an absolute path
5672 name and remembers it that way.
5674 @kindex sharedlibrary
5676 @cindex shared libraries
5678 _GDBN__ supports the SunOS shared library format. Symbols from a shared
5679 library cannot be referenced before the shared library has been linked
5680 with the program. (That is to say, until after you type @code{run} and
5681 the function @code{main} has been entered; or when examining core
5682 files.) Once the shared library has been linked in, you can use the
5686 @item sharedlibrary @var{regex}
5687 @itemx share @var{regex}
5688 Load shared object library symbols for files matching a UNIX regular
5692 @itemx sharedlibrary
5693 Load symbols for all shared libraries.
5696 @itemx info sharedlibrary
5697 @kindex info sharedlibrary
5699 Print the names of the shared libraries which you have loaded with the
5700 @code{sharedlibrary} command.
5703 @code{sharedlibrary} does not repeat automatically when you press
5704 @key{RET} after using it once.
5706 @node Symbol Errors, , Files, _GDBN__ Files
5707 @section Errors Reading Symbol Files
5708 While reading a symbol file, _GDBN__ will occasionally encounter
5709 problems, such as symbol types it does not recognize, or known bugs in
5710 compiler output. By default, _GDBN__ does not notify you of such
5711 problems, since they're relatively common and primarily of interest to
5712 people debugging compilers. If you are interested in seeing information
5713 about ill-constructed symbol tables, you can either ask _GDBN__ to print
5714 only one message about each such type of problem, no matter how many
5715 times the problem occurs; or you can ask _GDBN__ to print more messages,
5716 to see how many times the problems occur, with the @code{set complaints}
5717 command (@xref{Messages/Warnings}).
5719 The messages currently printed, and their meanings, are:
5722 @item inner block not inside outer block in @var{symbol}
5724 The symbol information shows where symbol scopes begin and end
5725 (such as at the start of a function or a block of statements). This
5726 error indicates that an inner scope block is not fully contained
5727 in its outer scope blocks.
5729 _GDBN__ circumvents the problem by treating the inner block as if it had
5730 the same scope as the outer block. In the error message, @var{symbol}
5731 may be shown as ``@code{(don't know)}'' if the outer block is not a
5734 @item block at @var{address} out of order
5736 The symbol information for symbol scope blocks should occur in
5737 order of increasing addresses. This error indicates that it does not
5740 _GDBN__ does not circumvent this problem, and will have trouble locating
5741 symbols in the source file whose symbols being read. (You can often
5742 determine what source file is affected by specifying @code{set verbose
5743 on}. @xref{Messages/Warnings}.)
5745 @item bad block start address patched
5747 The symbol information for a symbol scope block has a start address
5748 smaller than the address of the preceding source line. This is known
5749 to occur in the SunOS 4.1.1 (and earlier) C compiler.
5751 _GDBN__ circumvents the problem by treating the symbol scope block as
5752 starting on the previous source line.
5754 @item bad string table offset in symbol @var{n}
5757 Symbol number @var{n} contains a pointer into the string table which is
5758 larger than the size of the string table.
5760 _GDBN__ circumvents the problem by considering the symbol to have the
5761 name @code{foo}, which may cause other problems if many symbols end up
5764 @item unknown symbol type @code{0x@var{nn}}
5766 The symbol information contains new data types that _GDBN__ does not yet
5767 know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood
5768 information, in hexadecimal.
5770 _GDBN__ circumvents the error by ignoring this symbol information. This
5771 will usually allow the program to be debugged, though certain symbols
5772 will not be accessible. If you encounter such a problem and feel like
5773 debugging it, you can debug @code{_GDBP__} with itself, breakpoint on
5774 @code{complain}, then go up to the function @code{read_dbx_symtab} and
5775 examine @code{*bufp} to see the symbol.
5777 @item stub type has NULL name
5778 _GDBN__ could not find the full definition for a struct or class.
5781 @c this is #if 0'd in dbxread.c as of (at least!) 17 may 1991
5782 @item const/volatile indicator missing, got '@var{X}'
5784 The symbol information for a C++ member function is missing some
5785 information that the compiler should have output for it.
5788 @item C++ type mismatch between compiler and debugger
5790 _GDBN__ could not parse a type specification output by the compiler
5791 for some C++ object.
5795 @node Targets, Controlling _GDBN__, _GDBN__ Files, Top
5796 @chapter Specifying a Debugging Target
5797 @cindex debugging target
5799 A @dfn{target} is an interface between the debugger and a particular
5800 kind of file or process.
5802 Often, you will be able to run _GDBN__ in the same host environment as the
5803 program you are debugging; in that case, the debugging target can just be
5804 specified as a side effect of the @code{file} or @code{core} commands.
5805 When you need more flexibility---for example, running _GDBN__ on a
5806 physically separate host, controlling standalone systems over a
5807 serial port, or realtime systems over a TCP/IP connection---you can use
5808 the @code{target} command.
5811 * Active Targets:: Active Targets
5812 * Target Commands:: Commands for Managing Targets
5813 * Remote:: Remote Debugging
5816 @node Active Targets, Target Commands, Targets, Targets
5817 @section Active Targets
5818 @cindex stacking targets
5819 @cindex active targets
5820 @cindex multiple targets
5822 Targets are managed in three @dfn{strata} that correspond to different
5823 classes of target: processes, core files, and executable files. This
5824 allows you to (for example) start a process and inspect its activity
5825 without abandoning your work on a core file.
5827 More than one target can potentially respond to a request. In
5828 particular, when you access memory _GDBN__ will examine the three strata of
5829 targets until it finds a target that can handle that particular address.
5830 Strata are always examined in a fixed order: first a process if there is
5831 one, then a core file if there is one, and finally an executable file if
5832 there is one of those.
5834 When you specify a new target in a given stratum, it replaces any target
5835 previously in that stratum.
5837 To get rid of a target without replacing it, use the @code{detach}
5838 command. The related command @code{attach} provides you with a way of
5839 choosing a particular running process as a new target. @xref{Attach}.
5841 @node Target Commands, Remote, Active Targets, Targets
5842 @section Commands for Managing Targets
5845 @item target @var{type} @var{parameters}
5846 Connects the _GDBN__ host environment to a target machine or process. A
5847 target is typically a protocol for talking to debugging facilities. You
5848 use the argument @var{type} to specify the type or protocol of the
5851 Further @var{parameters} are interpreted by the target protocol, but
5852 typically include things like device names or host names to connect
5853 with, process numbers, and baud rates.
5855 The @code{target} command will not repeat if you press @key{RET} again
5856 after executing the command.
5860 Displays the names of all targets available. To display targets
5861 currently selected, use either @code{info target} or @code{info files}
5864 @item help target @var{name}
5865 Describe a particular target, including any parameters necessary to
5869 Here are some common targets (available, or not, depending on the _GDBN__
5873 @item target exec @var{prog}
5875 An executable file. @samp{target exec @var{prog}} is the same as
5876 @samp{exec-file @var{prog}}.
5878 @item target core @var{filename}
5880 A core dump file. @samp{target core @var{filename}} is the same as
5881 @samp{core-file @var{filename}}.
5883 @item target remote @var{dev}
5884 @kindex target remote
5885 Remote serial target in _GDBN__-specific protocol. The argument @var{dev}
5886 specifies what serial device to use for the connection (e.g.
5887 @file{/dev/ttya}). @xref{Remote}.
5890 @item target amd-eb @var{dev} @var{speed} @var{PROG}
5891 @kindex target amd-eb
5893 Remote PC-resident AMD EB29K board, attached over serial lines.
5894 @var{dev} is the serial device, as for @code{target remote};
5895 @var{speed} allows you to specify the linespeed; and @var{PROG} is the
5896 name of the program to be debugged, as it appears to DOS on the PC.
5897 @xref{EB29K Remote}.
5901 @item target nindy @var{devicename}
5902 @kindex target nindy
5903 An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is
5904 the name of the serial device to use for the connection, e.g.
5905 @file{/dev/ttya}. @xref{i960-Nindy Remote}.
5909 @item target vxworks @var{machinename}
5910 @kindex target vxworks
5911 A VxWorks system, attached via TCP/IP. The argument @var{machinename}
5912 is the target system's machine name or IP address.
5913 @xref{VxWorks Remote}.
5918 Different targets are available on different configurations of _GDBN__; your
5919 configuration may have more or fewer targets.
5922 @node Remote, , Target Commands, Targets
5923 @section Remote Debugging
5924 @cindex remote debugging
5928 _include__(gdbinv-m.m4)<>_dnl__
5932 If you are trying to debug a program running on a machine that can't run
5933 _GDBN__ in the usual way, it is often useful to use remote debugging. For
5934 example, you might use remote debugging on an operating system kernel, or on
5935 a small system which does not have a general purpose operating system
5936 powerful enough to run a full-featured debugger.
5938 Some configurations of _GDBN__ have special serial or TCP/IP interfaces
5939 to make this work with particular debugging targets. In addition,
5940 _GDBN__ comes with a generic serial protocol (specific to _GDBN__, but
5941 not specific to any particular target system) which you can use if you
5942 write the remote stubs---the code that will run on the remote system to
5943 communicate with _GDBN__.
5945 To use the _GDBN__ remote serial protocol, the program to be debugged on
5946 the remote machine needs to contain a debugging stub which talks to
5947 _GDBN__ over the serial line. Several working remote stubs are
5948 distributed with _GDBN__; see the @file{README} file in the _GDBN__
5949 distribution for more information.
5951 For details of this communication protocol, see the comments in the
5952 _GDBN__ source file @file{remote.c}.
5954 To start remote debugging, first run _GDBN__ and specify as an executable file
5955 the program that is running in the remote machine. This tells _GDBN__ how
5956 to find the program's symbols and the contents of its pure text. Then
5957 establish communication using the @code{target remote} command with a device
5958 name as an argument. For example:
5961 target remote /dev/ttyb
5965 if the serial line is connected to the device named @file{/dev/ttyb}. This
5966 will stop the remote machine if it is not already stopped.
5968 Now you can use all the usual commands to examine and change data and to
5969 step and continue the remote program.
5971 To resume the remote program and stop debugging it, use the @code{detach}
5974 Other remote targets may be available in your
5975 configuration of _GDBN__; use @code{help targets} to list them.
5978 @c Text on starting up GDB in various specific cases; it goes up front
5979 @c in manuals configured for any of those particular situations, here
5981 _include__(gdbinv-s.m4)
5984 @node Controlling _GDBN__, Sequences, Targets, Top
5985 @chapter Controlling _GDBN__
5987 You can alter many aspects of _GDBN__'s interaction with you by using
5988 the @code{set} command. For commands controlling how _GDBN__ displays
5989 data, @pxref{Print Settings}; other settings are described here.
5993 * Editing:: Command Editing
5994 * History:: Command History
5995 * Screen Size:: Screen Size
5997 * Messages/Warnings:: Optional Warnings and Messages
6000 @node Prompt, Editing, Controlling _GDBN__, Controlling _GDBN__
6003 _GDBN__ indicates its readiness to read a command by printing a string
6004 called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You
6005 can change the prompt string with the @code{set prompt} command. For
6006 instance, when debugging _GDBN__ with _GDBN__, it is useful to change
6007 the prompt in one of the _GDBN__<>s so that you can always tell which
6008 one you are talking to.
6011 @item set prompt @var{newprompt}
6013 Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth.
6016 Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
6019 @node Editing, History, Prompt, Controlling _GDBN__
6020 @section Command Editing
6022 @cindex command line editing
6023 _GDBN__ reads its input commands via the @dfn{readline} interface. This
6024 GNU library provides consistent behavior for programs which provide a
6025 command line interface to the user. Advantages are @code{emacs}-style
6026 or @code{vi}-style inline editing of commands, @code{csh}-like history
6027 substitution, and a storage and recall of command history across
6030 You may control the behavior of command line editing in _GDBN__ with the
6037 @itemx set editing on
6038 Enable command line editing (enabled by default).
6040 @item set editing off
6041 Disable command line editing.
6043 @kindex show editing
6045 Show whether command line editing is enabled.
6048 @node History, Screen Size, Editing, Controlling _GDBN__
6049 @section Command History
6051 @cindex history substitution
6052 @cindex history file
6053 @kindex set history filename
6054 @item set history filename @var{fname}
6055 Set the name of the _GDBN__ command history file to @var{fname}. This is
6056 the file from which _GDBN__ will read an initial command history
6057 list or to which it will write this list when it exits. This list is
6058 accessed through history expansion or through the history
6059 command editing characters listed below. This file defaults to the
6060 value of the environment variable @code{GDBHISTFILE}, or to
6061 @file{./.gdb_history} if this variable is not set.
6063 @cindex history save
6064 @kindex set history save
6065 @item set history save
6066 @itemx set history save on
6067 Record command history in a file, whose name may be specified with the
6068 @code{set history filename} command. By default, this option is disabled.
6070 @item set history save off
6071 Stop recording command history in a file.
6073 @cindex history size
6074 @kindex set history size
6075 @item set history size @var{size}
6076 Set the number of commands which _GDBN__ will keep in its history list.
6077 This defaults to the value of the environment variable
6078 @code{HISTSIZE}, or to 256 if this variable is not set.
6081 @cindex history expansion
6082 History expansion assigns special meaning to the character @kbd{!}.
6084 (@xref{Event Designators}.)
6086 Since @kbd{!} is also the logical not operator in C, history expansion
6087 is off by default. If you decide to enable history expansion with the
6088 @code{set history expansion on} command, you may sometimes need to
6089 follow @kbd{!} (when it is used as logical not, in an expression) with
6090 a space or a tab to prevent it from being expanded. The readline
6091 history facilities will not attempt substitution on the strings
6092 @kbd{!=} and @kbd{!(}, even when history expansion is enabled.
6094 The commands to control history expansion are:
6098 @kindex set history expansion
6099 @item set history expansion on
6100 @itemx set history expansion
6101 Enable history expansion. History expansion is off by default.
6103 @item set history expansion off
6104 Disable history expansion.
6106 The readline code comes with more complete documentation of
6107 editing and history expansion features. Users unfamiliar with @code{emacs}
6108 or @code{vi} may wish to read it.
6110 @xref{Command Line Editing}.
6114 @kindex show history
6116 @itemx show history filename
6117 @itemx show history save
6118 @itemx show history size
6119 @itemx show history expansion
6120 These commands display the state of the _GDBN__ history parameters.
6121 @code{show history} by itself displays all four states.
6127 @kindex show commands
6129 Display the last ten commands in the command history.
6131 @item show commands @var{n}
6132 Print ten commands centered on command number @var{n}.
6134 @item show commands +
6135 Print ten commands just after the commands last printed.
6139 @node Screen Size, Numbers, History, Controlling _GDBN__
6140 @section Screen Size
6141 @cindex size of screen
6142 @cindex pauses in output
6143 Certain commands to _GDBN__ may produce large amounts of information
6144 output to the screen. To help you read all of it, _GDBN__ pauses and
6145 asks you for input at the end of each page of output. Type @key{RET}
6146 when you want to continue the output. _GDBN__ also uses the screen
6147 width setting to determine when to wrap lines of output. Depending on
6148 what is being printed, it tries to break the line at a readable place,
6149 rather than simply letting it overflow onto the following line.
6151 Normally _GDBN__ knows the size of the screen from the termcap data base
6152 together with the value of the @code{TERM} environment variable and the
6153 @code{stty rows} and @code{stty cols} settings. If this is not correct,
6154 you can override it with the @code{set height} and @code{set
6158 @item set height @var{lpp}
6160 @itemx set width @var{cpl}
6166 These @code{set} commands specify a screen height of @var{lpp} lines and
6167 a screen width of @var{cpl} characters. The associated @code{show}
6168 commands display the current settings.
6170 If you specify a height of zero lines, _GDBN__ will not pause during output
6171 no matter how long the output is. This is useful if output is to a file
6172 or to an editor buffer.
6175 @node Numbers, Messages/Warnings, Screen Size, Controlling _GDBN__
6177 @cindex number representation
6178 @cindex entering numbers
6179 You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by
6180 the usual conventions: octal numbers begin with @samp{0}, decimal
6181 numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}.
6182 Numbers that begin with none of these are, by default, entered in base
6183 10; likewise, the default display for numbers---when no particular
6184 format is specified---is base 10. You can change the default base for
6185 both input and output with the @code{set radix} command.
6189 @item set radix @var{base}
6190 Set the default base for numeric input and display. Supported choices
6191 for @var{base} are decimal 2, 8, 10, 16. @var{base} must itself be
6192 specified either unambiguously or using the current default radix; for
6203 will set the base to decimal. On the other hand, @samp{set radix 10}
6204 will leave the radix unchanged no matter what it was.
6208 Display the current default base for numeric input and display.
6212 @node Messages/Warnings, , Numbers, Controlling _GDBN__
6213 @section Optional Warnings and Messages
6214 By default, _GDBN__ is silent about its inner workings. If you are running
6215 on a slow machine, you may want to use the @code{set verbose} command.
6216 It will make _GDBN__ tell you when it does a lengthy internal operation, so
6217 you won't think it has crashed.
6219 Currently, the messages controlled by @code{set verbose} are those which
6220 announce that the symbol table for a source file is being read
6221 (@pxref{Files}, in the description of the command
6222 @code{symbol-file}).
6223 @c The following is the right way to do it, but emacs 18.55 doesn't support
6224 @c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo
6227 see @code{symbol-file} in @ref{Files}).
6232 @item set verbose on
6233 Enables _GDBN__'s output of certain informational messages.
6235 @item set verbose off
6236 Disables _GDBN__'s output of certain informational messages.
6238 @kindex show verbose
6240 Displays whether @code{set verbose} is on or off.
6243 By default, if _GDBN__ encounters bugs in the symbol table of an object
6244 file, it is silent; but if you are debugging a compiler, you may find
6245 this information useful (@pxref{Symbol Errors}).
6248 @kindex set complaints
6249 @item set complaints @var{limit}
6250 Permits _GDBN__ to output @var{limit} complaints about each type of unusual
6251 symbols before becoming silent about the problem. Set @var{limit} to
6252 zero to suppress all complaints; set it to a large number to prevent
6253 complaints from being suppressed.
6255 @kindex show complaints
6256 @item show complaints
6257 Displays how many symbol complaints _GDBN__ is permitted to produce.
6260 By default, _GDBN__ is cautious, and asks what sometimes seem to be a
6261 lot of stupid questions to confirm certain commands. For example, if
6262 you try to run a program which is already running:
6265 The program being debugged has been started already.
6266 Start it from the beginning? (y or n)
6269 If you're willing to unflinchingly face the consequences of your own
6270 commands, you can disable this ``feature'':
6275 @cindex confirmation
6276 @cindex stupid questions
6277 @item set confirm off
6278 Disables confirmation requests.
6280 @item set confirm on
6281 Enables confirmation requests (the default).
6284 @kindex show confirm
6285 Displays state of confirmation requests.
6288 @c FIXME this doesn't really belong here. But where *does* it belong?
6289 @cindex reloading symbols
6290 Some systems allow individual object files that make up your program to
6291 be replaced without stopping and restarting your program.
6293 For example, in VxWorks you can simply recompile a defective object file
6294 and keep on running.
6296 If you're running on one of these systems, you can allow _GDBN__ to
6297 reload the symbols for automatically relinked modules:@refill
6299 @kindex set symbol-reloading
6300 @item set symbol-reloading on
6301 Replace symbol definitions for the corresponding source file when an
6302 object file with a particular name is seen again.
6304 @item set symbol-reloading off
6305 Don't replace symbol definitions when re-encountering object files of
6306 the same name. This is the default state; if you're not running on a
6307 system that permits automatically relinking modules, you should leave
6308 @code{symbol-reloading} off, since otherwise _GDBN__ may discard symbols
6309 when linking large programs, that may contain several modules (from
6310 different directories or libraries) with the same name.
6312 @item show symbol-reloading
6313 Show the current @code{on} or @code{off} setting.
6316 @node Sequences, Emacs, Controlling _GDBN__, Top
6317 @chapter Canned Sequences of Commands
6319 Aside from breakpoint commands (@pxref{Break Commands}), _GDBN__ provides two
6320 ways to store sequences of commands for execution as a unit:
6321 user-defined commands and command files.
6324 * Define:: User-Defined Commands
6325 * Command Files:: Command Files
6326 * Output:: Commands for Controlled Output
6329 @node Define, Command Files, Sequences, Sequences
6330 @section User-Defined Commands
6332 @cindex user-defined command
6333 A @dfn{user-defined command} is a sequence of _GDBN__ commands to which you
6334 assign a new name as a command. This is done with the @code{define}
6338 @item define @var{commandname}
6340 Define a command named @var{commandname}. If there is already a command
6341 by that name, you are asked to confirm that you want to redefine it.
6343 The definition of the command is made up of other _GDBN__ command lines,
6344 which are given following the @code{define} command. The end of these
6345 commands is marked by a line containing @code{end}.
6347 @item document @var{commandname}
6349 Give documentation to the user-defined command @var{commandname}. The
6350 command @var{commandname} must already be defined. This command reads
6351 lines of documentation just as @code{define} reads the lines of the
6352 command definition, ending with @code{end}. After the @code{document}
6353 command is finished, @code{help} on command @var{commandname} will print
6354 the documentation you have specified.
6356 You may use the @code{document} command again to change the
6357 documentation of a command. Redefining the command with @code{define}
6358 does not change the documentation.
6360 @item help user-defined
6361 @kindex help user-defined
6362 List all user-defined commands, with the first line of the documentation
6366 @itemx info user @var{commandname}
6368 Display the _GDBN__ commands used to define @var{commandname} (but not its
6369 documentation). If no @var{commandname} is given, display the
6370 definitions for all user-defined commands.
6373 User-defined commands do not take arguments. When they are executed, the
6374 commands of the definition are not printed. An error in any command
6375 stops execution of the user-defined command.
6377 Commands that would ask for confirmation if used interactively proceed
6378 without asking when used inside a user-defined command. Many _GDBN__ commands
6379 that normally print messages to say what they are doing omit the messages
6380 when used in a user-defined command.
6382 @node Command Files, Output, Define, Sequences
6383 @section Command Files
6385 @cindex command files
6386 A command file for _GDBN__ is a file of lines that are _GDBN__ commands. Comments
6387 (lines starting with @kbd{#}) may also be included. An empty line in a
6388 command file does nothing; it does not mean to repeat the last command, as
6389 it would from the terminal.
6392 @cindex @file{_GDBINIT__}
6393 When you start _GDBN__, it automatically executes commands from its
6394 @dfn{init files}. These are files named @file{_GDBINIT__}. _GDBN__
6395 reads the init file (if any) in your home directory and then the init
6396 file (if any) in the current working directory. (The init files are not
6397 executed if you use the @samp{-nx} option; @pxref{Mode Options}.) You
6398 can also request the execution of a command file with the @code{source}
6402 @item source @var{filename}
6404 Execute the command file @var{filename}.
6407 The lines in a command file are executed sequentially. They are not
6408 printed as they are executed. An error in any command terminates execution
6409 of the command file.
6411 Commands that would ask for confirmation if used interactively proceed
6412 without asking when used in a command file. Many _GDBN__ commands that
6413 normally print messages to say what they are doing omit the messages
6414 when called from command files.
6416 @node Output, , Command Files, Sequences
6417 @section Commands for Controlled Output
6419 During the execution of a command file or a user-defined command, normal
6420 _GDBN__ output is suppressed; the only output that appears is what is
6421 explicitly printed by the commands in the definition. This section
6422 describes three commands useful for generating exactly the output you
6426 @item echo @var{text}
6428 @c I don't consider backslash-space a standard C escape sequence
6429 @c because it's not in ANSI.
6430 Print @var{text}. Nonprinting characters can be included in @var{text}
6431 using C escape sequences, such as @samp{\n} to print a newline. @b{No
6432 newline will be printed unless you specify one.} In addition to the
6433 standard C escape sequences, a backslash followed by a space stands for a
6434 space. This is useful for outputting a string with spaces at the
6435 beginning or the end, since leading and trailing spaces are otherwise
6436 trimmed from all arguments. Thus, to print @samp{@ and foo =@ }, use the
6437 command @samp{echo \@ and foo = \@ }.
6438 @c FIXME: verify hard copy actually issues enspaces for '@ '! Will this
6441 A backslash at the end of @var{text} can be used, as in C, to continue
6442 the command onto subsequent lines. For example,
6445 echo This is some text\n\
6446 which is continued\n\
6447 onto several lines.\n
6450 produces the same output as
6453 echo This is some text\n
6454 echo which is continued\n
6455 echo onto several lines.\n
6458 @item output @var{expression}
6460 Print the value of @var{expression} and nothing but that value: no
6461 newlines, no @samp{$@var{nn} = }. The value is not entered in the
6462 value history either. @xref{Expressions} for more information on
6465 @item output/@var{fmt} @var{expression}
6466 Print the value of @var{expression} in format @var{fmt}. You can use
6467 the same formats as for @code{print}; @pxref{Output formats}, for more
6470 @item printf @var{string}, @var{expressions}@dots{}
6472 Print the values of the @var{expressions} under the control of
6473 @var{string}. The @var{expressions} are separated by commas and may
6474 be either numbers or pointers. Their values are printed as specified
6475 by @var{string}, exactly as if the program were to execute
6478 printf (@var{string}, @var{expressions}@dots{});
6481 For example, you can print two values in hex like this:
6484 printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
6487 The only backslash-escape sequences that you can use in the format
6488 string are the simple ones that consist of backslash followed by a
6492 @node Emacs, _GDBN__ Bugs, Sequences, Top
6493 @chapter Using _GDBN__ under GNU Emacs
6496 A special interface allows you to use GNU Emacs to view (and
6497 edit) the source files for the program you are debugging with
6500 To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
6501 executable file you want to debug as an argument. This command starts
6502 _GDBN__ as a subprocess of Emacs, with input and output through a newly
6503 created Emacs buffer.
6505 Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two
6510 All ``terminal'' input and output goes through the Emacs buffer.
6513 This applies both to _GDBN__ commands and their output, and to the input
6514 and output done by the program you are debugging.
6516 This is useful because it means that you can copy the text of previous
6517 commands and input them again; you can even use parts of the output
6520 All the facilities of Emacs' Shell mode are available for interacting
6521 with your program. In particular, you can send signals the usual
6522 way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a
6527 _GDBN__ displays source code through Emacs.
6530 Each time _GDBN__ displays a stack frame, Emacs automatically finds the
6531 source file for that frame and puts an arrow (_0__@samp{=>}_1__) at the
6532 left margin of the current line. Emacs uses a separate buffer for
6533 source display, and splits the window to show both your _GDBN__ session
6536 Explicit _GDBN__ @code{list} or search commands still produce output as
6537 usual, but you probably will have no reason to use them.
6540 @emph{Warning:} If the directory where your program resides is not your
6541 current directory, it can be easy to confuse Emacs about the location of
6542 the source files, in which case the auxiliary display buffer will not
6543 appear to show your source. _GDBN__ can find programs by searching your
6544 environment's @code{PATH} variable, so the _GDBN__ input and output
6545 session will proceed normally; but Emacs doesn't get enough information
6546 back from _GDBN__ to locate the source files in this situation. To
6547 avoid this problem, either start _GDBN__ mode from the directory where
6548 your program resides, or specify a full path name when prompted for the
6549 @kbd{M-x gdb} argument.
6551 A similar confusion can result if you use the _GDBN__ @code{file} command to
6552 switch to debugging a program in some other location, from an existing
6553 _GDBN__ buffer in Emacs.
6556 By default, @kbd{M-x gdb} calls the program called @file{gdb}. If
6557 you need to call _GDBN__ by a different name (for example, if you keep
6558 several configurations around, with different names) you can set the
6559 Emacs variable @code{gdb-command-name}; for example,
6561 (setq gdb-command-name "mygdb")
6564 (preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or
6565 in your @file{.emacs} file) will make Emacs call the program named
6566 ``@code{mygdb}'' instead.
6568 In the _GDBN__ I/O buffer, you can use these special Emacs commands in
6569 addition to the standard Shell mode commands:
6573 Describe the features of Emacs' _GDBN__ Mode.
6576 Execute to another source line, like the _GDBN__ @code{step} command; also
6577 update the display window to show the current file and location.
6580 Execute to next source line in this function, skipping all function
6581 calls, like the _GDBN__ @code{next} command. Then update the display window
6582 to show the current file and location.
6585 Execute one instruction, like the _GDBN__ @code{stepi} command; update
6586 display window accordingly.
6589 Execute to next instruction, using the _GDBN__ @code{nexti} command; update
6590 display window accordingly.
6593 Execute until exit from the selected stack frame, like the _GDBN__
6594 @code{finish} command.
6597 Continue execution of the program, like the _GDBN__ @code{continue}
6598 command. @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}.
6601 Go up the number of frames indicated by the numeric argument
6602 (@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}),
6603 like the _GDBN__ @code{up} command. @emph{Warning:} In Emacs v19, this
6604 command is @kbd{C-c C-u}.@refill
6607 Go down the number of frames indicated by the numeric argument, like the
6608 _GDBN__ @code{down} command. @emph{Warning:} In Emacs v19, this command
6612 Read the number where the cursor is positioned, and insert it at the end
6613 of the _GDBN__ I/O buffer. For example, if you wish to disassemble code
6614 around an address that was displayed earlier, type @kbd{disassemble};
6615 then move the cursor to the address display, and pick up the
6616 argument for @code{disassemble} by typing @kbd{C-x &}.
6618 You can customize this further on the fly by defining elements of the list
6619 @code{gdb-print-command}; once it is defined, you can format or
6620 otherwise process numbers picked up by @kbd{C-x &} before they are
6621 inserted. A numeric argument to @kbd{C-x &} will both indicate that you
6622 wish special formatting, and act as an index to pick an element of the
6623 list. If the list element is a string, the number to be inserted is
6624 formatted using the Emacs function @code{format}; otherwise the number
6625 is passed as an argument to the corresponding list element.
6629 In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break})
6630 tells _GDBN__ to set a breakpoint on the source line point is on.
6632 If you accidentally delete the source-display buffer, an easy way to get
6633 it back is to type the command @code{f} in the _GDBN__ buffer, to
6634 request a frame display; when you run under Emacs, this will recreate
6635 the source buffer if necessary to show you the context of the current
6638 The source files displayed in Emacs are in ordinary Emacs buffers
6639 which are visiting the source files in the usual way. You can edit
6640 the files with these buffers if you wish; but keep in mind that _GDBN__
6641 communicates with Emacs in terms of line numbers. If you add or
6642 delete lines from the text, the line numbers that _GDBN__ knows will cease
6643 to correspond properly to the code.
6645 @c The following dropped because Epoch is nonstandard. Reactivate
6646 @c if/when v19 does something similar. ---pesch@cygnus.com 19dec1990
6648 @kindex emacs epoch environment
6652 Version 18 of Emacs has a built-in window system called the @code{epoch}
6653 environment. Users of this environment can use a new command,
6654 @code{inspect} which performs identically to @code{print} except that
6655 each value is printed in its own window.
6658 @node _GDBN__ Bugs, Renamed Commands, Emacs, Top
6659 @chapter Reporting Bugs in _GDBN__
6660 @cindex Bugs in _GDBN__
6661 @cindex Reporting Bugs in _GDBN__
6663 Your bug reports play an essential role in making _GDBN__ reliable.
6665 Reporting a bug may help you by bringing a solution to your problem, or it
6666 may not. But in any case the principal function of a bug report is to help
6667 the entire community by making the next version of _GDBN__ work better. Bug
6668 reports are your contribution to the maintenance of _GDBN__.
6670 In order for a bug report to serve its purpose, you must include the
6671 information that enables us to fix the bug.
6674 * Bug Criteria:: Have You Found a Bug?
6675 * Bug Reporting:: How to Report Bugs
6678 @node Bug Criteria, Bug Reporting, _GDBN__ Bugs, _GDBN__ Bugs
6679 @section Have You Found a Bug?
6680 @cindex Bug Criteria
6682 If you are not sure whether you have found a bug, here are some guidelines:
6686 @cindex Fatal Signal
6688 If the debugger gets a fatal signal, for any input whatever, that is a
6689 _GDBN__ bug. Reliable debuggers never crash.
6692 @cindex error on Valid Input
6693 If _GDBN__ produces an error message for valid input, that is a bug.
6696 @cindex Invalid Input
6697 If _GDBN__ does not produce an error message for invalid input,
6698 that is a bug. However, you should note that your idea of
6699 ``invalid input'' might be our idea of ``an extension'' or ``support
6700 for traditional practice''.
6703 If you are an experienced user of debugging tools, your suggestions
6704 for improvement of _GDBN__ are welcome in any case.
6707 @node Bug Reporting, , Bug Criteria, _GDBN__ Bugs
6708 @section How to Report Bugs
6710 @cindex _GDBN__ Bugs, Reporting
6712 A number of companies and individuals offer support for GNU products.
6713 If you obtained _GDBN__ from a support organization, we recommend you
6714 contact that organization first.
6716 Contact information for many support companies and individuals is
6717 available in the file @file{etc/SERVICE} in the GNU Emacs distribution.
6719 In any event, we also recommend that you send bug reports for _GDBN__ to one
6723 bug-gdb@@prep.ai.mit.edu
6724 @{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb
6727 @strong{Do not send bug reports to @samp{info-gdb}, or to
6728 @samp{help-gdb}, or to any newsgroups.} Most users of _GDBN__ do not want to
6729 receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}.
6731 The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which
6732 serves as a repeater. The mailing list and the newsgroup carry exactly
6733 the same messages. Often people think of posting bug reports to the
6734 newsgroup instead of mailing them. This appears to work, but it has one
6735 problem which can be crucial: a newsgroup posting often lacks a mail
6736 path back to the sender. Thus, if we need to ask for more information,
6737 we may be unable to reach you. For this reason, it is better to send
6738 bug reports to the mailing list.
6740 As a last resort, send bug reports on paper to:
6744 Free Software Foundation
6749 The fundamental principle of reporting bugs usefully is this:
6750 @strong{report all the facts}. If you are not sure whether to state a
6751 fact or leave it out, state it!
6753 Often people omit facts because they think they know what causes the
6754 problem and assume that some details don't matter. Thus, you might
6755 assume that the name of the variable you use in an example does not matter.
6756 Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a
6757 stray memory reference which happens to fetch from the location where that
6758 name is stored in memory; perhaps, if the name were different, the contents
6759 of that location would fool the debugger into doing the right thing despite
6760 the bug. Play it safe and give a specific, complete example. That is the
6761 easiest thing for you to do, and the most helpful.
6763 Keep in mind that the purpose of a bug report is to enable us to fix
6764 the bug if it is new to us. It isn't as important what happens if
6765 the bug is already known. Therefore, always write your bug reports on
6766 the assumption that the bug has not been reported previously.
6768 Sometimes people give a few sketchy facts and ask, ``Does this ring a
6769 bell?'' Those bug reports are useless, and we urge everyone to
6770 @emph{refuse to respond to them} except to chide the sender to report
6773 To enable us to fix the bug, you should include all these things:
6777 The version of _GDBN__. _GDBN__ announces it if you start with no
6778 arguments; you can also print it at any time using @code{show version}.
6780 Without this, we won't know whether there is any point in looking for
6781 the bug in the current version of _GDBN__.
6784 A complete input script, and all necessary source files, that will
6788 What compiler (and its version) was used to compile _GDBN__---e.g.
6792 The command arguments you gave the compiler to compile your example and
6793 observe the bug. For example, did you use @samp{-O}? To guarantee
6794 you won't omit something important, list them all.
6796 If we were to try to guess the arguments, we would probably guess wrong
6797 and then we might not encounter the bug.
6800 The type of machine you are using, and the operating system name and
6804 A description of what behavior you observe that you believe is
6805 incorrect. For example, ``It gets a fatal signal.''
6807 Of course, if the bug is that _GDBN__ gets a fatal signal, then we will
6808 certainly notice it. But if the bug is incorrect output, we might not
6809 notice unless it is glaringly wrong. We are human, after all. You
6810 might as well not give us a chance to make a mistake.
6812 Even if the problem you experience is a fatal signal, you should still
6813 say so explicitly. Suppose something strange is going on, such as,
6814 your copy of _GDBN__ is out of synch, or you have encountered a
6815 bug in the C library on your system. (This has happened!) Your copy
6816 might crash and ours would not. If you told us to expect a crash,
6817 then when ours fails to crash, we would know that the bug was not
6818 happening for us. If you had not told us to expect a crash, then we
6819 would not be able to draw any conclusion from our observations.
6822 If you wish to suggest changes to the _GDBN__ source, send us context
6823 diffs. If you even discuss something in the _GDBN__ source, refer to
6824 it by context, not by line number.
6826 The line numbers in our development sources won't match those in your
6827 sources. Your line numbers would convey no useful information to us.
6831 Here are some things that are not necessary:
6835 A description of the envelope of the bug.
6837 Often people who encounter a bug spend a lot of time investigating
6838 which changes to the input file will make the bug go away and which
6839 changes will not affect it.
6841 This is often time consuming and not very useful, because the way we
6842 will find the bug is by running a single example under the debugger
6843 with breakpoints, not by pure deduction from a series of examples.
6844 We recommend that you save your time for something else.
6846 Of course, if you can find a simpler example to report @emph{instead}
6847 of the original one, that is a convenience for us. Errors in the
6848 output will be easier to spot, running under the debugger will take
6851 However, simplification is not vital; if you don't want to do this,
6852 report the bug anyway and send us the entire test case you used.
6855 A patch for the bug.
6857 A patch for the bug does help us if it is a good one. But don't omit
6858 the necessary information, such as the test case, on the assumption that
6859 a patch is all we need. We might see problems with your patch and decide
6860 to fix the problem another way, or we might not understand it at all.
6862 Sometimes with a program as complicated as _GDBN__ it is very hard to
6863 construct an example that will make the program follow a certain path
6864 through the code. If you don't send us the example, we won't be able
6865 to construct one, so we won't be able to verify that the bug is fixed.
6867 And if we can't understand what bug you are trying to fix, or why your
6868 patch should be an improvement, we won't install it. A test case will
6869 help us to understand.
6872 A guess about what the bug is or what it depends on.
6874 Such guesses are usually wrong. Even we can't guess right about such
6875 things without first using the debugger to find the facts.
6879 @include rdl-apps.texi
6882 @node Renamed Commands, Installing _GDBN__, _GDBN__ Bugs, Top
6883 @appendix Renamed Commands
6885 The following commands were renamed in _GDBN__ 4.0, in order to make the
6886 command set as a whole more consistent and easier to use and remember:
6889 @kindex delete environment
6890 @kindex info copying
6891 @kindex info convenience
6892 @kindex info directories
6893 @kindex info editing
6894 @kindex info history
6895 @kindex info targets
6897 @kindex info version
6898 @kindex info warranty
6899 @kindex set addressprint
6900 @kindex set arrayprint
6901 @kindex set prettyprint
6902 @kindex set screen-height
6903 @kindex set screen-width
6904 @kindex set unionprint
6905 @kindex set vtblprint
6906 @kindex set demangle
6907 @kindex set asm-demangle
6908 @kindex set sevenbit-strings
6909 @kindex set array-max
6911 @kindex set history write
6912 @kindex show addressprint
6913 @kindex show arrayprint
6914 @kindex show prettyprint
6915 @kindex show screen-height
6916 @kindex show screen-width
6917 @kindex show unionprint
6918 @kindex show vtblprint
6919 @kindex show demangle
6920 @kindex show asm-demangle
6921 @kindex show sevenbit-strings
6922 @kindex show array-max
6923 @kindex show caution
6924 @kindex show history write
6929 OLD COMMAND NEW COMMAND
6930 --------------- -------------------------------
6931 add-syms add-symbol-file
6932 delete environment unset environment
6933 info convenience show convenience
6934 info copying show copying
6935 info directories show directories
6936 info editing show commands
6937 info history show values
6938 info targets help target
6939 info values show values
6940 info version show version
6941 info warranty show warranty
6942 set/show addressprint set/show print address
6943 set/show array-max set/show print elements
6944 set/show arrayprint set/show print array
6945 set/show asm-demangle set/show print asm-demangle
6946 set/show caution set/show confirm
6947 set/show demangle set/show print demangle
6948 set/show history write set/show history save
6949 set/show prettyprint set/show print pretty
6950 set/show screen-height set/show height
6951 set/show screen-width set/show width
6952 set/show sevenbit-strings set/show print sevenbit-strings
6953 set/show unionprint set/show print union
6954 set/show vtblprint set/show print vtbl
6956 unset [No longer an alias for delete]
6961 \vskip \parskip\vskip \baselineskip
6962 \halign{\tt #\hfil &\qquad#&\tt #\hfil\cr
6963 {\bf Old Command} &&{\bf New Command}\cr
6964 add-syms &&add-symbol-file\cr
6965 delete environment &&unset environment\cr
6966 info convenience &&show convenience\cr
6967 info copying &&show copying\cr
6968 info directories &&show directories \cr
6969 info editing &&show commands\cr
6970 info history &&show values\cr
6971 info targets &&help target\cr
6972 info values &&show values\cr
6973 info version &&show version\cr
6974 info warranty &&show warranty\cr
6975 set{\rm / }show addressprint &&set{\rm / }show print address\cr
6976 set{\rm / }show array-max &&set{\rm / }show print elements\cr
6977 set{\rm / }show arrayprint &&set{\rm / }show print array\cr
6978 set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr
6979 set{\rm / }show caution &&set{\rm / }show confirm\cr
6980 set{\rm / }show demangle &&set{\rm / }show print demangle\cr
6981 set{\rm / }show history write &&set{\rm / }show history save\cr
6982 set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr
6983 set{\rm / }show screen-height &&set{\rm / }show height\cr
6984 set{\rm / }show screen-width &&set{\rm / }show width\cr
6985 set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr
6986 set{\rm / }show unionprint &&set{\rm / }show print union\cr
6987 set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr
6989 unset &&\rm(No longer an alias for delete)\cr
6993 @node Installing _GDBN__, Copying, Renamed Commands, Top
6994 @appendix Installing _GDBN__
6995 @cindex configuring _GDBN__
6996 @cindex installation
6998 _GDBN__ comes with a @code{configure} script that automates the process
6999 of preparing _GDBN__ for installation; you can then use @code{make} to
7000 build the @code{_GDBP__} program.
7002 The _GDBP__ distribution includes all the source code you need for
7003 _GDBP__ in a single directory @file{gdb-4.0}. That directory in turn
7007 @item gdb-4.0/configure
7008 Overall script for configuring _GDBN__ and all its supporting libraries.
7011 the source specific to _GDBN__ itself
7014 source for the Binary File Descriptor Library
7016 @item gdb-4.0/include
7019 @item gdb-4.0/libiberty
7020 source for the @samp{-liberty} free software library
7022 @item gdb-4.0/readline
7023 source for the GNU command-line interface
7026 Each of these directories has its own @code{configure} script, which are
7027 used by the overall @code{configure} script in @file{gdb-4.0}.
7029 It is most convenient to run @code{configure} from the @file{gdb-4.0}
7030 directory. The simplest way to configure and build _GDBN__ is the
7034 ./configure @var{host}
7038 where @var{host} is something like @samp{sun4} or @samp{decstation}, that
7039 identifies the platform where _GDBN__ will run. This builds the three
7040 libraries @file{bfd}, @file{readline}, and @file{libiberty}, then
7041 @code{gdb} itself. The configured source files, and the binaries, are
7042 left in the corresponding source directories.
7044 You can install @code{_GDBP__} anywhere; it has no hardwired paths. However,
7045 you should make sure that the shell on your path (named by the
7046 @samp{SHELL} environment variable) is publicly readable; some systems
7047 refuse to let _GDBN__ debug child processes whose programs are not
7048 readable, and _GDBN__ uses the shell to start your program.
7051 * Subdirectories:: Configuration subdirectories
7052 * Config Names:: Specifying names for hosts and targets
7053 * configure Options:: Summary of options for configure
7054 * Formatting Manual:: How to format and print _GDBN__ documentation
7058 @node Subdirectories, Config Names, Installing _GDBN__, Installing _GDBN__
7059 @section Configuration Subdirectories
7060 If you want to run _GDBN__ versions for several host or target machines,
7061 you'll need a different _GDBP__ compiled for each combination of host
7062 and target. @code{configure} is designed to make this easy by allowing
7063 you to generate each configuration in a separate subdirectory. If your
7064 @code{make} program handles the @samp{VPATH} feature (GNU @code{make}
7065 does), running @code{make} in each of these directories then builds the
7066 _GDBP__ program specified there.
7068 @code{configure} creates these subdirectories for you when you
7069 simultaneously specify several configurations; but it's a good habit
7070 even for a single configuration. You can specify the use of
7071 subdirectories using the @samp{+subdirs} option (abbreviated
7072 @samp{+sub}). For example, you can build _GDBN__ on a Sun 4 as follows:
7077 ./configure +sub sun4
7078 cd Host-sparc-sun-sunos4/Target-sparc-sun-sunos4
7083 When @code{configure} uses subdirectories to build programs or
7084 libraries, it creates nested directories
7085 @file{Host-@var{host}/Target-@var{target}}. (As you see in the example,
7086 the names used for @var{host} and @var{target} may be expanded from your
7087 @code{configure} argument; @pxref{Config Names}). @code{configure} uses
7088 these two directory levels because _GDBN__ can be configured for
7089 cross-compiling: _GDBN__ can run on one machine (the host) while
7090 debugging programs that run on another machine (the target). You
7091 specify cross-debugging targets by giving the
7092 @samp{+target=@var{target}} option to @code{configure}. Specifying only
7093 hosts still gives you two levels of subdirectory for each host, with the
7094 same configuration suffix on both; that is, if you give any number of
7095 hosts but no targets, _GDBN__ will be configured for native debugging on
7096 each host. On the other hand, whenever you specify both hosts and
7097 targets on the same command line, @code{configure} creates all
7098 combinations of the hosts and targets you list.@refill
7100 When you run @code{make} to build a program or library, you must run it
7101 in a configured directory. If you made a single configuration,
7102 without subdirectories, run @code{make} in the source directory.
7103 If you have @file{Host-@var{host}/Target-@var{target}} subdirectories,
7104 run @code{make} in those subdirectories.
7106 Each @code{configure} and @code{Makefile} under each source directory
7107 runs recursively, so that typing @code{make} in @file{gdb-4.0} (or in a
7108 @file{gdb-4.0/Host-@var{host}/Target-@var{target}} subdirectory)
7109 builds all the required libraries, then _GDBN__.@refill
7111 If you run @code{configure} from a directory (such as @file{gdb-4.0}) that
7112 contains source directories for multiple libraries or programs,
7113 @code{configure} creates the @file{Host-@var{host}/Target-@var{target}}
7114 subdirectories in each library or program's source directory. For
7118 configure sun4 +target=vxworks960
7121 creates the following directories:
7123 gdb-4.0/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks
7124 gdb-4.0/bfd/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks
7125 gdb-4.0/gdb/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks
7126 gdb-4.0/libiberty/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks
7127 gdb-4.0/readline/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks
7130 The @code{Makefile} in
7132 gdb-4.0/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks
7135 will @code{cd} to the appropriate lower-level directories, for example:
7137 gdb-4.0/bfd/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks
7140 building each in turn.
7142 When you have multiple hosts or targets configured, you can run
7143 @code{make} on them in parallel (for example, if they are NFS-mounted on
7144 each of the hosts); they will not interfere with each other.
7146 @node Config Names, configure Options, Subdirectories, Installing _GDBN__
7147 @section Specifying Names for Hosts and Targets
7149 The specifications used for hosts and targets in the @code{configure}
7150 script are based on a three-part naming scheme, but some short predefined
7151 aliases are also supported. The full naming scheme encodes three pieces
7152 of information in the following pattern:
7154 @var{architecture}-@var{vendor}-@var{os}
7157 For example, you can use the alias @code{sun4} as a @var{host} argument
7158 or in a @code{+target=}@var{target} option, but the full name of that
7159 configuration specifies that the architecture is @samp{sparc}, the
7160 vendor is @samp{sun}, and the operating system is @samp{sunos4}.
7163 @c I know this is ugly, but @group is useless except in examples now...
7164 @c (using texinfo 2.52 or so)
7168 The following table shows all the architectures, hosts, and OS prefixes
7169 that @code{configure} recognizes in _GDBN__ 4.0. Entries in the ``OS
7170 prefix'' column ending in a @samp{*} may be followed by a release number.
7175 ARCHITECTURE VENDOR OS prefix
7176 ------------+-------------+-------------
7179 alliant | aout | aout
7184 i860 | convergent | dynix*
7185 i960 | convex | esix*
7186 m68000 | dec | hpux*
7187 m68k | encore | isc*
7188 m88k | gould | mach*
7190 ns32k | ibm | nindy*
7191 pyramid | intel | none
7193 rtpc | little | sco*
7194 sparc | mips | sunos*
7195 tahoe | motorola | sysv*
7196 tron | ncr | ultrix*
7200 | sequent | vxworks*
7211 \vskip \parskip\vskip \baselineskip
7212 \halign{\hskip\parindent\tt #\hfil &\qquad#&\tt #\hfil &\qquad#&\tt #\hfil\cr
7213 {\bf Architecture} &&{\bf Vendor} &&{\bf OS prefix}\cr
7216 a29k &&altos &&aix*\cr
7217 alliant &&aout &&aout\cr
7218 arm &&apollo &&bout\cr
7221 i386 &&coff &&ctix*\cr
7222 i860 &&convergent &&dynix*\cr
7223 i960 &&convex &&esix*\cr
7224 m68000 &&dec &&hpux*\cr
7225 m68k &&encore &&isc*\cr
7226 m88k &&gould &&mach*\cr
7227 mips &&hp &&newsos*\cr
7228 ns32k &&ibm &&nindy*\cr
7229 pyramid &&intel &&none\cr
7230 rs6000 &&isi &&osf*\cr
7231 rtpc &&little &&sco*\cr
7232 sparc &&mips &&sunos*\cr
7233 tahoe &&motorola &&sysv*\cr
7234 tron &&ncr &&ultrix*\cr
7235 vax &&next &&unos*\cr
7238 &&sequent &&vxworks*\cr
7248 @emph{Warning:} Many combinations of architecture, vendor, and OS are
7252 The @code{configure} script accompanying _GDBN__ 4.0 does not provide
7253 any query facility to list all supported host and target names or
7254 aliases. @code{configure} calls the Bourne shell script
7255 @code{config.sub} to map abbreviations to full names; you can read the
7256 script, if you wish, or you can use it to test your guesses on
7257 abbreviations---for example:
7259 % sh config.sub sun4
7261 % sh config.sub sun3
7263 % sh config.sub decstation
7265 % sh config.sub hp300bsd
7267 % sh config.sub i386v
7269 % sh config.sub i486v
7270 *** No vendor: configuration `i486v' not recognized
7273 @node configure Options, Formatting Manual, Config Names, Installing _GDBN__
7274 @section @code{configure} Options
7276 Here is a summary of all the @code{configure} options and arguments that
7277 you might use for building _GDBN__:
7280 configure @r{[}+destdir=@var{dir}@r{]} @r{[}+subdirs@r{]} @r{[}+norecur@r{]} @r{[}+rm@r{]}
7281 @r{[}+target=@var{target}@dots{}@r{]} @var{host}@dots{}
7284 You may introduce options with the character @samp{-} rather than
7285 @samp{+} if you prefer; but you may abbreviate option names if you use
7289 @item +destdir=@var{dir}
7290 @var{dir} is an installation directory @emph{path prefix}. After you
7291 configure with this option, @code{make install} will install _GDBN__ as
7292 @file{@var{dir}/bin/_GDBP__}, and the libraries in @file{@var{dir}/lib}.
7293 If you specify @samp{+destdir=/usr/local}, for example, @code{make
7294 install} creates @file{/usr/local/bin/gdb}.@refill
7297 Write configuration specific files in subdirectories of the form
7299 Host-@var{host}/Target-@var{target}
7302 (and configure the @code{Makefile} to write binaries there too).
7303 Without this option, if you specify only one configuration for _GDBN__,
7304 @code{configure} will use the same directory for source, configured
7305 files, and binaries. This option is used automatically if you specify
7306 more than one @var{host} or more than one @samp{+target=@var{target}}
7307 option on the @code{configure} command line.
7310 Configure only the directory where @code{configure} is executed; do not
7311 propagate configuration to subdirectories.
7314 Remove the configuration that the other arguments specify.
7316 @item +parse=@var{lang} @dots{}
7317 Configure the _GDBN__ expression parser to parse the listed languages.
7318 @samp{all} configures _GDBN__ for all supported languages. To get a
7319 list of all supported languages, omit the argument. Without this
7320 option, _GDBN__ is configured to parse all supported languages.
7322 @item +target=@var{target} @dots{}
7323 Configure _GDBN__ for cross-debugging programs running on each specified
7324 @var{target}. You may specify as many @samp{+target} options as you
7325 wish. Without this option, _GDBN__ is configured to debug programs that
7326 run on the same machine (@var{host}) as _GDBN__ itself.
7328 There is no convenient way to generate a list of all available targets.
7330 @item @var{host} @dots{}
7331 Configure _GDBN__ to run on each specified @var{host}. You may specify as
7332 many host names as you wish.
7334 There is no convenient way to generate a list of all available hosts.
7338 @code{configure} accepts other options, for compatibility with
7339 configuring other GNU tools recursively; but these are the only
7340 options that affect _GDBN__ or its supporting libraries.
7342 @node Formatting Manual, , configure Options, Installing _GDBN__
7343 @section Formatting this Manual
7345 The _GDBN__ 4.0 release includes the Info version of this manual already
7346 formatted: the main Info file is @file{gdb-4.0/gdb/gdb.info}, and it
7347 refers to subordinate files matching @samp{gdb.info*} in the same
7350 If you want to make these Info files yourself from the _GDBN__ manual's
7351 source, you need the GNU @code{makeinfo} program. Once you have it, you
7358 to make the Info file.
7360 If you want to format and print copies of this manual, you need several
7364 @TeX{}, the public domain typesetting program written by Donald Knuth,
7365 must be installed on your system and available through your execution
7368 @file{gdb-4.0/texinfo}: @TeX{} macros defining the GNU
7369 Documentation Format.
7371 @emph{A @sc{dvi} output program.} @TeX{} doesn't actually make marks on
7372 paper; it produces output files called @sc{dvi} files. If your system
7373 has @TeX{} installed, chances are it has a program for printing out
7374 these files; one popular example is @code{dvips}, which can print
7375 @sc{dvi} files on PostScript printers.
7378 Once you have these things, you can type
7384 to format the text of this manual, and print it with the usual output
7385 method for @TeX{} @sc{dvi} files at your site.
7387 @cindex _GDBN__ reference card
7388 @cindex reference card
7389 You might also want hard copy of the _GDBN__ reference card. The
7390 _GDBN__ 4.0 release includes an already-formatted reference card, ready
7391 for printing on a PostScript printer, as @file{gdb-4.0/gdb/refcard.ps}.
7392 It uses the most common PostScript fonts: the Times family, Courier, and
7393 Symbol. If you have a PostScript printer you can print the reference
7394 card by just sending @file{refcard.ps} to the printer.
7396 If you have some other kind of printer, or want to print using Computer
7397 Modern fonts instead, you can still print the reference card if you have
7398 @TeX{}. Format the reference card by typing
7405 The _GDBN__ reference card is designed to print in landscape mode on US
7406 ``letter'' size paper; that is, on a sheet 11 inches wide by 8.5 inches
7407 high. You will need to specify this form of printing as an option to
7408 your @sc{dvi} output program.
7411 @node Copying, Index, Installing _GDBN__, Top
7412 @unnumbered GNU GENERAL PUBLIC LICENSE
7413 @center Version 2, June 1991
7416 Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
7417 675 Mass Ave, Cambridge, MA 02139, USA
7419 Everyone is permitted to copy and distribute verbatim copies
7420 of this license document, but changing it is not allowed.
7423 @unnumberedsec Preamble
7425 The licenses for most software are designed to take away your
7426 freedom to share and change it. By contrast, the GNU General Public
7427 License is intended to guarantee your freedom to share and change free
7428 software---to make sure the software is free for all its users. This
7429 General Public License applies to most of the Free Software
7430 Foundation's software and to any other program whose authors commit to
7431 using it. (Some other Free Software Foundation software is covered by
7432 the GNU Library General Public License instead.) You can apply it to
7435 When we speak of free software, we are referring to freedom, not
7436 price. Our General Public Licenses are designed to make sure that you
7437 have the freedom to distribute copies of free software (and charge for
7438 this service if you wish), that you receive source code or can get it
7439 if you want it, that you can change the software or use pieces of it
7440 in new free programs; and that you know you can do these things.
7442 To protect your rights, we need to make restrictions that forbid
7443 anyone to deny you these rights or to ask you to surrender the rights.
7444 These restrictions translate to certain responsibilities for you if you
7445 distribute copies of the software, or if you modify it.
7447 For example, if you distribute copies of such a program, whether
7448 gratis or for a fee, you must give the recipients all the rights that
7449 you have. You must make sure that they, too, receive or can get the
7450 source code. And you must show them these terms so they know their
7453 We protect your rights with two steps: (1) copyright the software, and
7454 (2) offer you this license which gives you legal permission to copy,
7455 distribute and/or modify the software.
7457 Also, for each author's protection and ours, we want to make certain
7458 that everyone understands that there is no warranty for this free
7459 software. If the software is modified by someone else and passed on, we
7460 want its recipients to know that what they have is not the original, so
7461 that any problems introduced by others will not reflect on the original
7462 authors' reputations.
7464 Finally, any free program is threatened constantly by software
7465 patents. We wish to avoid the danger that redistributors of a free
7466 program will individually obtain patent licenses, in effect making the
7467 program proprietary. To prevent this, we have made it clear that any
7468 patent must be licensed for everyone's free use or not licensed at all.
7470 The precise terms and conditions for copying, distribution and
7471 modification follow.
7474 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7477 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7482 This License applies to any program or other work which contains
7483 a notice placed by the copyright holder saying it may be distributed
7484 under the terms of this General Public License. The ``Program'', below,
7485 refers to any such program or work, and a ``work based on the Program''
7486 means either the Program or any derivative work under copyright law:
7487 that is to say, a work containing the Program or a portion of it,
7488 either verbatim or with modifications and/or translated into another
7489 language. (Hereinafter, translation is included without limitation in
7490 the term ``modification''.) Each licensee is addressed as ``you''.
7492 Activities other than copying, distribution and modification are not
7493 covered by this License; they are outside its scope. The act of
7494 running the Program is not restricted, and the output from the Program
7495 is covered only if its contents constitute a work based on the
7496 Program (independent of having been made by running the Program).
7497 Whether that is true depends on what the Program does.
7500 You may copy and distribute verbatim copies of the Program's
7501 source code as you receive it, in any medium, provided that you
7502 conspicuously and appropriately publish on each copy an appropriate
7503 copyright notice and disclaimer of warranty; keep intact all the
7504 notices that refer to this License and to the absence of any warranty;
7505 and give any other recipients of the Program a copy of this License
7506 along with the Program.
7508 You may charge a fee for the physical act of transferring a copy, and
7509 you may at your option offer warranty protection in exchange for a fee.
7512 You may modify your copy or copies of the Program or any portion
7513 of it, thus forming a work based on the Program, and copy and
7514 distribute such modifications or work under the terms of Section 1
7515 above, provided that you also meet all of these conditions:
7519 You must cause the modified files to carry prominent notices
7520 stating that you changed the files and the date of any change.
7523 You must cause any work that you distribute or publish, that in
7524 whole or in part contains or is derived from the Program or any
7525 part thereof, to be licensed as a whole at no charge to all third
7526 parties under the terms of this License.
7529 If the modified program normally reads commands interactively
7530 when run, you must cause it, when started running for such
7531 interactive use in the most ordinary way, to print or display an
7532 announcement including an appropriate copyright notice and a
7533 notice that there is no warranty (or else, saying that you provide
7534 a warranty) and that users may redistribute the program under
7535 these conditions, and telling the user how to view a copy of this
7536 License. (Exception: if the Program itself is interactive but
7537 does not normally print such an announcement, your work based on
7538 the Program is not required to print an announcement.)
7541 These requirements apply to the modified work as a whole. If
7542 identifiable sections of that work are not derived from the Program,
7543 and can be reasonably considered independent and separate works in
7544 themselves, then this License, and its terms, do not apply to those
7545 sections when you distribute them as separate works. But when you
7546 distribute the same sections as part of a whole which is a work based
7547 on the Program, the distribution of the whole must be on the terms of
7548 this License, whose permissions for other licensees extend to the
7549 entire whole, and thus to each and every part regardless of who wrote it.
7551 Thus, it is not the intent of this section to claim rights or contest
7552 your rights to work written entirely by you; rather, the intent is to
7553 exercise the right to control the distribution of derivative or
7554 collective works based on the Program.
7556 In addition, mere aggregation of another work not based on the Program
7557 with the Program (or with a work based on the Program) on a volume of
7558 a storage or distribution medium does not bring the other work under
7559 the scope of this License.
7562 You may copy and distribute the Program (or a work based on it,
7563 under Section 2) in object code or executable form under the terms of
7564 Sections 1 and 2 above provided that you also do one of the following:
7568 Accompany it with the complete corresponding machine-readable
7569 source code, which must be distributed under the terms of Sections
7570 1 and 2 above on a medium customarily used for software interchange; or,
7573 Accompany it with a written offer, valid for at least three
7574 years, to give any third party, for a charge no more than your
7575 cost of physically performing source distribution, a complete
7576 machine-readable copy of the corresponding source code, to be
7577 distributed under the terms of Sections 1 and 2 above on a medium
7578 customarily used for software interchange; or,
7581 Accompany it with the information you received as to the offer
7582 to distribute corresponding source code. (This alternative is
7583 allowed only for noncommercial distribution and only if you
7584 received the program in object code or executable form with such
7585 an offer, in accord with Subsection b above.)
7588 The source code for a work means the preferred form of the work for
7589 making modifications to it. For an executable work, complete source
7590 code means all the source code for all modules it contains, plus any
7591 associated interface definition files, plus the scripts used to
7592 control compilation and installation of the executable. However, as a
7593 special exception, the source code distributed need not include
7594 anything that is normally distributed (in either source or binary
7595 form) with the major components (compiler, kernel, and so on) of the
7596 operating system on which the executable runs, unless that component
7597 itself accompanies the executable.
7599 If distribution of executable or object code is made by offering
7600 access to copy from a designated place, then offering equivalent
7601 access to copy the source code from the same place counts as
7602 distribution of the source code, even though third parties are not
7603 compelled to copy the source along with the object code.
7606 You may not copy, modify, sublicense, or distribute the Program
7607 except as expressly provided under this License. Any attempt
7608 otherwise to copy, modify, sublicense or distribute the Program is
7609 void, and will automatically terminate your rights under this License.
7610 However, parties who have received copies, or rights, from you under
7611 this License will not have their licenses terminated so long as such
7612 parties remain in full compliance.
7615 You are not required to accept this License, since you have not
7616 signed it. However, nothing else grants you permission to modify or
7617 distribute the Program or its derivative works. These actions are
7618 prohibited by law if you do not accept this License. Therefore, by
7619 modifying or distributing the Program (or any work based on the
7620 Program), you indicate your acceptance of this License to do so, and
7621 all its terms and conditions for copying, distributing or modifying
7622 the Program or works based on it.
7625 Each time you redistribute the Program (or any work based on the
7626 Program), the recipient automatically receives a license from the
7627 original licensor to copy, distribute or modify the Program subject to
7628 these terms and conditions. You may not impose any further
7629 restrictions on the recipients' exercise of the rights granted herein.
7630 You are not responsible for enforcing compliance by third parties to
7634 If, as a consequence of a court judgment or allegation of patent
7635 infringement or for any other reason (not limited to patent issues),
7636 conditions are imposed on you (whether by court order, agreement or
7637 otherwise) that contradict the conditions of this License, they do not
7638 excuse you from the conditions of this License. If you cannot
7639 distribute so as to satisfy simultaneously your obligations under this
7640 License and any other pertinent obligations, then as a consequence you
7641 may not distribute the Program at all. For example, if a patent
7642 license would not permit royalty-free redistribution of the Program by
7643 all those who receive copies directly or indirectly through you, then
7644 the only way you could satisfy both it and this License would be to
7645 refrain entirely from distribution of the Program.
7647 If any portion of this section is held invalid or unenforceable under
7648 any particular circumstance, the balance of the section is intended to
7649 apply and the section as a whole is intended to apply in other
7652 It is not the purpose of this section to induce you to infringe any
7653 patents or other property right claims or to contest validity of any
7654 such claims; this section has the sole purpose of protecting the
7655 integrity of the free software distribution system, which is
7656 implemented by public license practices. Many people have made
7657 generous contributions to the wide range of software distributed
7658 through that system in reliance on consistent application of that
7659 system; it is up to the author/donor to decide if he or she is willing
7660 to distribute software through any other system and a licensee cannot
7663 This section is intended to make thoroughly clear what is believed to
7664 be a consequence of the rest of this License.
7667 If the distribution and/or use of the Program is restricted in
7668 certain countries either by patents or by copyrighted interfaces, the
7669 original copyright holder who places the Program under this License
7670 may add an explicit geographical distribution limitation excluding
7671 those countries, so that distribution is permitted only in or among
7672 countries not thus excluded. In such case, this License incorporates
7673 the limitation as if written in the body of this License.
7676 The Free Software Foundation may publish revised and/or new versions
7677 of the General Public License from time to time. Such new versions will
7678 be similar in spirit to the present version, but may differ in detail to
7679 address new problems or concerns.
7681 Each version is given a distinguishing version number. If the Program
7682 specifies a version number of this License which applies to it and ``any
7683 later version'', you have the option of following the terms and conditions
7684 either of that version or of any later version published by the Free
7685 Software Foundation. If the Program does not specify a version number of
7686 this License, you may choose any version ever published by the Free Software
7690 If you wish to incorporate parts of the Program into other free
7691 programs whose distribution conditions are different, write to the author
7692 to ask for permission. For software which is copyrighted by the Free
7693 Software Foundation, write to the Free Software Foundation; we sometimes
7694 make exceptions for this. Our decision will be guided by the two goals
7695 of preserving the free status of all derivatives of our free software and
7696 of promoting the sharing and reuse of software generally.
7699 @heading NO WARRANTY
7706 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
7707 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
7708 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
7709 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
7710 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
7711 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
7712 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
7713 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
7714 REPAIR OR CORRECTION.
7717 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
7718 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
7719 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
7720 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
7721 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
7722 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
7723 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
7724 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
7725 POSSIBILITY OF SUCH DAMAGES.
7729 @heading END OF TERMS AND CONDITIONS
7732 @center END OF TERMS AND CONDITIONS
7736 @unnumberedsec Applying These Terms to Your New Programs
7738 If you develop a new program, and you want it to be of the greatest
7739 possible use to the public, the best way to achieve this is to make it
7740 free software which everyone can redistribute and change under these terms.
7742 To do so, attach the following notices to the program. It is safest
7743 to attach them to the start of each source file to most effectively
7744 convey the exclusion of warranty; and each file should have at least
7745 the ``copyright'' line and a pointer to where the full notice is found.
7748 @var{one line to give the program's name and a brief idea of what it does.}
7749 Copyright (C) 19@var{yy} @var{name of author}
7751 This program is free software; you can redistribute it and/or modify
7752 it under the terms of the GNU General Public License as published by
7753 the Free Software Foundation; either version 2 of the License, or
7754 (at your option) any later version.
7756 This program is distributed in the hope that it will be useful,
7757 but WITHOUT ANY WARRANTY; without even the implied warranty of
7758 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7759 GNU General Public License for more details.
7761 You should have received a copy of the GNU General Public License
7762 along with this program; if not, write to the Free Software
7763 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7766 Also add information on how to contact you by electronic and paper mail.
7768 If the program is interactive, make it output a short notice like this
7769 when it starts in an interactive mode:
7772 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
7773 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
7774 This is free software, and you are welcome to redistribute it
7775 under certain conditions; type `show c' for details.
7778 The hypothetical commands @samp{show w} and @samp{show c} should show
7779 the appropriate parts of the General Public License. Of course, the
7780 commands you use may be called something other than @samp{show w} and
7781 @samp{show c}; they could even be mouse-clicks or menu items---whatever
7784 You should also get your employer (if you work as a programmer) or your
7785 school, if any, to sign a ``copyright disclaimer'' for the program, if
7786 necessary. Here is a sample; alter the names:
7789 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
7790 `Gnomovision' (which makes passes at compilers) written by James Hacker.
7792 @var{signature of Ty Coon}, 1 April 1989
7793 Ty Coon, President of Vice
7796 This General Public License does not permit incorporating your program into
7797 proprietary programs. If your program is a subroutine library, you may
7798 consider it more useful to permit linking proprietary applications with the
7799 library. If this is what you want to do, use the GNU Library General
7800 Public License instead of this License.
7803 @node Index, , Copying, Top
7809 % I think something like @colophon should be in texinfo. In the
7811 \long\def\colophon{\hbox to0pt{}\vfill
7812 \centerline{The body of this manual is set in}
7813 \centerline{\fontname\tenrm,}
7814 \centerline{with headings in {\bf\fontname\tenbf}}
7815 \centerline{and examples in {\tt\fontname\tentt}.}
7816 \centerline{{\it\fontname\tenit\/} and}
7817 \centerline{{\sl\fontname\tensl\/}}
7818 \centerline{are used for emphasis.}\vfill}
7820 % Blame: pesch@cygnus.com, 28mar91.