2 @setfilename _GDBP__.info
4 @c NOTE: this manual is marked up for preprocessing with a collection
5 @c of m4 macros called "pretex.m4". If you see <_if__> and <_fi__>
6 @c scattered around the source, you have the full source before
7 @c preprocessing; if you don't, you have the source configured for
8 @c _HOST__ architectures (and you can of course get the full source,
9 @c with all configurations, from wherever you got this).
12 THIS IS THE FULL SOURCE. The full source needs to be run through m4
13 before either tex- or info- formatting: for example,
15 m4 pretex.m4 none.m4 m680x0.m4 gdb.texinfo >gdb-680x0.texinfo
17 will produce (assuming your path finds either GNU or SysV m4; Berkeley
18 won't do) a file suitable for formatting. See the text in "pretex.m4"
19 for a fuller explanation (and the macro definitions).
20 To permit maximum flexibility, the full source also does not contain
21 any "info" markup that can be generated automatically; you should first
22 preprocess it as above, then run it through C-u texinfo-master-menu,
23 before actually info-formatting it.
27 @c FOR UPDATES LEADING TO THIS DRAFT, GDB CHANGELOG CONSULTED BETWEEN:
28 @c Tue Feb 26 01:47:07 1991 Cygnus John Gilmore (cygnus at yuba)
29 @c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint)
31 This file documents the GNU debugger _GDBN__.
33 Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
35 Permission is granted to make and distribute verbatim copies of
36 this manual provided the copyright notice and this permission notice
37 are preserved on all copies.
40 Permission is granted to process this file through Tex and print the
41 results, provided the printed document carries copying permission
42 notice identical to this one except for the removal of this paragraph
43 (this paragraph not being relevant to the printed manual).
46 Permission is granted to copy and distribute modified versions of this
47 manual under the conditions for verbatim copying, provided also that the
48 section entitled ``GNU General Public License'' is included exactly as
49 in the original, and provided that the entire resulting derived work is
50 distributed under the terms of a permission notice identical to this
53 Permission is granted to copy and distribute translations of this manual
54 into another language, under the above conditions for modified versions,
55 except that the section entitled ``GNU General Public License'' may be
56 included in a translation approved by the author instead of in the
60 @setchapternewpage odd
62 @settitle Using _GDBN__ (v4.0)
65 @settitle Using _GDBN__ v4.0 (_HOST__)
72 @subtitle{A Guide to the GNU Source-Level Debugger}
74 @subtitle{On _HOST__ Systems}
77 @c Maybe crank this up to "Fourth Edition" when released at FSF
78 @c @subtitle Third Edition---_GDBN__ version 4.0
79 @subtitle _GDBN__ version 4.0
80 @subtitle January 1991
81 @author{Richard M. Stallman}
82 @author{Roland H. Pesch (Cygnus Support)}
86 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
87 \xdef\manvers{\$Revision$} % For use in headers, footers too
89 \hfill Cygnus Support\par
90 \hfill {\it Using _GDBN__}, \manvers\par
91 \hfill \TeX{}info \texinfoversion\par
95 @vskip 0pt plus 1filll
96 Copyright @copyright{} 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
98 Permission is granted to make and distribute verbatim copies of
99 this manual provided the copyright notice and this permission notice
100 are preserved on all copies.
102 Permission is granted to copy and distribute modified versions of this
103 manual under the conditions for verbatim copying, provided also that the
104 section entitled ``GNU General Public License'' is included exactly as
105 in the original, and provided that the entire resulting derived work is
106 distributed under the terms of a permission notice identical to this
109 Permission is granted to copy and distribute translations of this manual
110 into another language, under the above conditions for modified versions,
111 except that the section entitled ``GNU General Public License'' may be
112 included in a translation approved by the author instead of in the
118 @unnumbered Summary of _GDBN__
120 The purpose of a debugger such as _GDBN__ is to allow you to see what is
121 going on ``inside'' another program while it executes---or what another
122 program was doing at the moment it crashed.
124 _GDBN__ can do four main kinds of things (plus other things in support of
125 these) to help you catch bugs in the act:
129 Start your program, specifying anything that might affect its behavior.
132 Make your program stop on specified conditions.
135 Examine what has happened, when your program has stopped.
138 Change things in your program, so you can experiment with correcting the
139 effects of one bug and go on to learn about another.
142 _GDBN__ can be used to debug programs written in C and C++. Pascal support
143 is being implemented, and Fortran support will be added when a GNU
144 Fortran compiler is ready.
146 @node Free Software,,,
147 @unnumberedsec Free Software
148 _GDBN__ is Free Software, protected by the GNU General Public License (GPL).
149 The GPL gives you the freedom to copy or adapt a licensed
150 program---but every person getting a copy also gets with it the
151 freedom to modify that copy (which means that they must get access to
152 the source code), and the freedom to distribute further copies.
153 Typical software companies use copyrights to limit your freedoms; the
154 Free Software Foundation uses the GPL to preserve these freedoms.
156 Fundamentally, the General Public License is a license which says that
157 you have these freedoms and that you can't take these freedoms away
160 For full details, @pxref{License}.
162 @node New Features,,,
163 @unnumbered New Features in _GDBN__ version 4.0
167 TARGETS: Using the new command @samp{target}, you can select at runtime
168 whether you are debugging local files, local processes, standalone
169 systems over the serial port, realtime systems over a TCP/IP
170 connection, etc. _GDBN__ now uses a function vector to mediate access to
171 all the different possible targets, making it much easier to add
172 support for new remote protocols.
175 WATCHPOINTS: _GDBN__ now sports watchpoints as well as breakpoints. You can
176 use a watchpoint to stop execution whenever the value of an expression
177 changes, without having to predict a particular place in the inferior
178 process where this may happen.
181 OBJECT CODE FORMATS: _GDBN__ uses a new scheme called Binary File
182 Descriptors (BFD) to permit it to switch dynamically, without
183 reconfiguration or recompilation, between different object-file
184 formats. Formats currently supported are COFF, a.out, and the new
185 Intel 960 b.out; files may be read as .o's, archive libraries, or core
186 dumps. BFD is available as a subroutine library so that other
187 programs may take advantage of it, and the other GNU binary utilities
188 are being converted to use it.
191 CONFIGURATION: You must still choose a particular machine architecture
192 and operating system for _GDBN__'s host and target systems when _GDBN__ is built.
193 The script @samp{config.gdb} now handles specification of separate host
194 and target configurations.
197 INTERACTION: _GDBN__ now uses the GNU readline interface to read its
198 input; this provides inline editing of commands, using the familiar
199 Emacs or @code{vi} keymaps, and command-history support. The user interface
200 to _GDBN__'s control variables has been simplified and consolidated in two
201 commands, @samp{set} and @samp{show}. Output lines are now broken at
202 readable places, rather than overflowing onto the next line.
205 SOURCE LANGUAGE: _GDBN__ now understands C++ source as well as C. Multiple
206 inheritance is supported when used with G++ 2.0. There is also limited
207 support for C++ exception handling: _GDBN__ can break when an exception is
208 raised, before the stack is peeled back to the exception handler's
209 context. You can suppress output of machine-level addresses,
210 displaying only source language information.
213 PORTS: _GDBN__ has been ported to the following new architectures:
214 AT&T 3b1, Acorn RISC machine, HP300 running HPUX, big- and little-
215 endian MIPS machines, Motorola 88k, Sun 386i, and Sun 3 running SunOS
216 4. In addition, the following are supported as targets only: AMD
217 29k, Intel 960, and Wind River's VxWorks.
220 SHARED LIBRARIES: _GDBN__ 4.0 supports SunOS shared libraries.
223 WORK IN PROGRESS: kernel debugging for BSD and Mach systems; Tahoe and
224 HPPA architecture support.
228 @node Sample Session,,,
229 @chapter A Sample _GDBN__ Session
231 You can use this manual at your leisure to read all about _GDBN__.
232 However, a handful of commands are enough to get started using the
233 debugger. This chapter illustrates these commands.
235 In this sample session, we emphasize user input like this: @var{input},
236 to make it easier to pick out from the surrounding output.
238 @c FIXME: this example may not be appropriate for some configs, where
239 @c FIXME...primary interest is in remote use.
240 We'll be using _GDBN__ to inspect GNU @code{m4} (a generic macro
244 $ @var{cd gm4/common}
247 Reading symbol data from m4...done.
248 (_GDBP__) set width 70
252 _GDBN__ only reads enough symbol data to know where to find the rest
253 when needed; as a result, the first prompt comes up very quickly. We
254 immediately told _GDBN__ to use a narrower display width than usual, so
255 that examples will fit in this manual.
258 (_GDBP__) @var{break m4_changequote}
259 Breakpoint 1 at 0x59d4: file builtin.c, line 812.
263 We've chosen to see how the @code{m4} builtin @samp{changequote} works.
264 Having looked at the source, we knew the relevant subroutine is
265 @samp{m4_changequote}. We've set a breakpoint there with _GDBN__'s
266 @code{break} command.
270 Starting program: /s1/gnu/src/gm4/common/m4
271 @var{`usual' quotes <not these>}
272 usual quotes <not these>
276 Using the @samp{run} command, we've started @code{m4} running under
277 _GDBN__ control; while we don't touch the @samp{m4_changequote}
278 subroutine, the program runs as usual---it filters standard input.
281 @var{changequote(<,>)}
283 Breakpoint 1, m4_changequote (argc=3, argv=0x2b958) at builtin.c:812
284 812 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
287 To trigger the breakpoint, we called @code{changequote}. _GDBN__
288 suspended execution of @code{m4}, displaying information about the
289 context where it stopped.
293 bad_argc (name=0xf851cfb4<Address 0xf851cfb4 out of bounds>, argc=3,
294 min=1, max=3) at builtin.c:230
295 230 if (min > 0 && argc < min) @{
298 We've used the command @samp{s} (@code{step}) to advance execution to
299 the next source line; since there was a subroutine call, we've stopped
300 in the first line of that subroutine, not in the next line of
301 @code{m4_changequote}.
303 The command @samp{next} would have taken us to the next line of
304 @code{m4_changequote}. To see where we are in the stack, we can use the
305 @samp{backtrace} command (which can also be spelled @samp{bt}).
309 #0 bad_argc (name=0xf851cfb4<Address 0xf851cfb4 out of bounds>,
310 argc=3, min=1, max=3) at builtin.c:230
311 #1 0x59ec in m4_changequote (argc=3, argv=0x2b958) at builtin.c:812
312 #2 0x6e38 in expand_macro (sym=0x2b060) at macro.c:242
313 #3 0x6840 in expand_token (obs=0x0, t=176224, td=0xf7fffb08)
315 #4 0x6794 in expand_input () at macro.c:40
316 #5 0x28dc in main (argc=0, argv=0xf7fffbf8) at m4.c:174
320 We'll tell _GDBN__ to finish execution of this subroutine, to get back
321 to @code{m4_changequote}.
324 (_GDBP__) @var{finish}
325 Run till exit from #0 bad_argc (name=0xf851cfb4<Address 0xf851cfb4 out
327 argc=3, min=1, max=3) at builtin.c:230
328 0x59ec in m4_changequote (argc=3, argv=0x2b958) at builtin.c:812
329 812 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
330 Value returned is $1 = false
334 We're still in the middle of the first line of @code{m4_changequote};
335 @samp{finish} just allowed the subroutine call to complete.
336 The display beginning ``@code{0x59ec in}@dots'', preceding the
337 display of line @code{812}, is a reminder of that situation from
340 Now that we're past the subroutine call, using the @code{step} command
341 again will get us to the next line of @code{m4_changequote}.
345 815 lquote = (argc >= 2) ? TOKEN_DATA_TEXT(argv[1])[0] : DEF_LQ
347 (_GDBP__) @var{whatis lquote}
349 (_GDBP__) @var{p lquote}
354 When we stepped to another line, @code{m4} was about to set a variable
355 @samp{lquote}; we inspected its type with @samp{whatis} and its value
356 with @samp{p} (the @samp{print} command). We can see some context by
357 displaying the surrounding source code, with the @samp{l} (@code{list})
362 810 token_data **argv;
364 812 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
367 815 lquote = (argc >= 2) ? TOKEN_DATA_TEXT(argv[1])[0] : DEF_LQ
369 816 rquote = (argc >= 3) ? TOKEN_DATA_TEXT(argv[2])[0] : DEF_RQ
375 816 rquote = (argc >= 3) ? TOKEN_DATA_TEXT(argv[2])[0] : DEF_RQ
379 (_GDBP__) @var{p lquote}
381 (_GDBP__) @var{p rquote}
386 We proceeded past another line with @samp{s}, and inspected the new
387 values of @code{m4}'s internal variables @code{rquote} and
390 Since we're done with our inspection of this subroutine, we'll tell
391 _GDBN__ to allow @code{m4} to continue running, with the @samp{c}
392 (@code{continue}) command:
398 @var{`usual' quotes <not these>}
399 `usual' quotes not these
401 Program exited normally.
405 _1__@end smallexample
408 Finally, when we ended the @code{m4} run, _GDBN__ told us
409 ``@code{Program exited normally.}'' We ended our _GDBN__ session with
410 the _GDBN__ @samp{quit} command.
414 @chapter Getting In and Out of _GDBN__
416 @node Starting _GDBN__,,,
417 @section Starting _GDBN__
419 _GDBN__ is invoked with the shell command @samp{_GDBP__}. Once started, it reads
420 commands from the terminal until you tell it to exit.
422 You can start by just calling @samp{_GDBP__} with no arguments or
423 options; but the most usual way to start _GDBN__ is with one argument or
424 two, specifying an executable program as the argument:
429 or you can start with both an executable program and a core file specified:
434 You can get more detailed control over how _GDBN__ starts up using some of
435 the command-line options.
437 All the options and command line arguments given are processed
438 in sequential order. The order makes a difference when the
439 @samp{-x} option is used.
441 @node File Options,,,
442 @subsection Choosing Files
444 As shown above, any arguments other than options specify an executable
445 file and core file; that is, the first argument encountered with no
446 associated option flag is equivalent to a @samp{-se} option, and the
447 second, if any, is equivalent to a @samp{-c} option.
451 Read symbol table from file @var{file}.
454 Use file @var{file} as the executable file to execute when
455 appropriate, and for examining pure data in conjunction with a core
459 Read symbol table from file @var{file} and use it as the executable
463 Use file @var{file} as a core dump to examine.
466 Execute _GDBN__ commands from file @var{file}. @xref{Command Files}.
468 @item -d @var{directory}
469 Add @var{directory} to the path to search for source files.
472 @node Mode Options,,,
473 @subsection Choosing Modes
477 Do not execute commands from the init files @file{_GDBINIT__}.
478 Normally, the commands in these files are executed after all the
479 command options and arguments have been processed. @xref{Command
483 ``Quiet''. Do not print the introductory and copyright messages. These
484 messages are also suppressed in batch mode, or if an executable file name is
485 specified on the _GDBN__ command line.
488 Run in batch mode. Exit with code @code{0} after processing all the command
489 files specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited).
490 Exit with nonzero status if an error occurs in executing the _GDBN__
491 commands in the command files.
493 Batch mode may be useful for running _GDBN__ as a filter, for example to
494 download and run a program on another computer; in order to make this
495 more useful, the message
497 Program exited normally.
500 (which is ordinarily issued whenever a program running under _GDBN__ control
501 terminates) is not issued when running in batch mode.
504 This option is used when Emacs runs _GDBN__ as a subprocess. It tells _GDBN__
505 to output the full file name and line number in a standard,
506 recognizable fashion each time a stack frame is displayed (which
507 includes each time the program stops). This recognizable format looks
508 like two @samp{\032} characters, followed by the file name, line number
509 and character position separated by colons, and a newline. The
510 Emacs-to-_GDBN__ interface program uses the two @samp{\032} characters as
511 a signal to display the source code for the frame.
514 Set the line speed (baud rate or bps) of any serial interface used by
515 _GDBN__ for remote debugging.
519 @node i960-Nindy Remote,,,
520 @subsection _GDBN__ with a Remote i960 (Nindy)
522 ``Nindy'' is the name of a ROM Monitor program for Intel 960 target
523 systems. When _GDBN__ is configured to control a remote Intel 960 using
524 Nindy, you can tell _GDBN__ how to connect to the 960 in several ways:
528 Through command line options specifying device, baud rate, and protocol;
531 By responding to a prompt on startup;
534 By using the @samp{target} command at any point during your _GDBN__ session.
537 @node Nindy Startup,,,
538 @subsubsection Startup with Nindy
540 The command-line options for Nindy are detailed below. If you simply
541 start @code{_GDBP__} without using options to specify a serial port, you are
542 prompted for it, @emph{before} you reach the ordinary _GDBN__ prompt:
544 Attach /dev/ttyNN -- specify NN, or "quit" to quit:
547 You can, if you choose, simply start up with no Nindy connection by
548 responding to the prompt with an empty line. If you do this, and later
549 wish to attach to Nindy, use @samp{target} (@pxref{Target Commands}).
551 @node Nindy Options,,,
552 @subsubsection Options for Nindy
554 These are the startup options for beginning your _GDBN__ session with a
555 Nindy-960 board attached:
559 Specify the serial port name of a serial interface to be used to connect
560 to the target system. This option is only available when _GDBN__ is
561 configured for the Intel 960 target architecture. You may specify
562 @var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a
563 device name in @samp{/dev} (e.g. @samp{-r ttya}), or simply the unique
564 suffix for a specific @code{tty} (e.g. @samp{-r a}).
567 (An uppercase letter ``O'', not a zero.) Specify that _GDBN__ should use
568 the ``old'' Nindy monitor protocol to connect to the target system.
569 This option is only available when _GDBN__ is configured for the Intel 960
573 @emph{Warning:} if you specify @samp{-O}, but are actually trying to
574 connect to a target system using the current protocol, the connection
575 will fail appearing to be a speed mismatch, and _GDBN__ will repeatedly
576 attempt to reconnect at several different line speeds. You can abort
577 this process with an interrupt.
581 Specify that _GDBN__ should first send a @samp{BREAK} signal to the target
582 system, in an attempt to reset it, before connecting to a Nindy target.
583 This option is only available when _GDBN__ is configured for the Intel 960
587 @emph{Warning:} Many target systems do not have the hardware that this
588 requires; it only works with a few boards.
593 The standard @samp{-b} option controls the line speed used on the serial
598 @node EB29K Remote,,,
599 @subsection _GDBN__ with a Remote EB29K
602 @cindex running 29K programs
605 To use _GDBN__ from a Unix system to run programs on AMD's EB29K
606 board in a PC, you must first connect a serial cable between the PC
607 and a serial port on the Unix system. In the following, we assume
608 you've hooked the cable between the PC's @samp{COM1} port and
609 @samp{/dev/ttya} on the Unix system.
611 @node Comms (EB29K),,,
612 @subsubsection Communications Setup
613 The next step is to set up the PC's port, by doing something like the
614 following in DOS on the PC:
616 C:\> MODE com1:9600,n,8,1,none
619 This example---run on an MS DOS 4.0 system---sets the PC port to 9600
620 bps, no parity, eight data bits, one stop bit, and no ``retry'' action;
621 you must match the communications parameters when establishing the Unix
622 end of the connection as well.
623 @c FIXME: Who knows what this "no retry action" crud from the DOS manual may
624 @c mean? It's optional; leave it out? ---pesch@cygnus.com, 25feb91
626 To give control of the PC to the Unix side of the serial line, type
627 the following at the DOS console:
632 (Later, if you wish to return control to the DOS console, you can use
633 the command @samp{CTTY con}---but you must send it over the device that
634 had control, in our example over the @samp{com1} serial line).
636 From the Unix host, use a communications program such as @code{tip} or
637 @code{cu} to communicate with the PC; for example,
639 cu -s 9600 -l /dev/ttya
642 The @code{cu} options shown specify, respectively, the linespeed and the
643 serial port to use. If you use @code{tip} instead, your command line
644 may look something like the following instead:
649 Your system may define a different name where our example uses
650 @samp{/dev/ttya} (the argument to @code{tip}). The communications
651 parameters, including what port to use, are associated with the
652 @code{tip} argument in the ``remote'' descriptions file---normally the
653 system table @file{/etc/remote}.
654 @c FIXME: What if anything needs doing to match the "n,8,1,none" part of
655 @c the DOS side's comms setup? cu can support -o (odd
656 @c parity), -e (even parity)---apparently no settings for no parity or
657 @c for character size. Taken from stty maybe...? John points out tip
658 @c can set these as internal variables, eg ~s parity=none; man stty
659 @c suggests that it *might* work to stty these options with stdin or
660 @c stdout redirected... ---pesch@cygnus.com, 25feb91
663 Using the @samp{tip} or @samp{cu} connection, change the DOS working
664 directory to the directory containing a copy of your 29K program, then
665 start the PC program @samp{EBMON} (an EB29K control program supplied
666 with your board by AMD). You should see an initial display from
667 @code{EBMON} similar to the one in our example, ending with the
668 @code{EBMON} prompt @samp{#}---
672 G:\> CD \usr\joe\work29k
674 G:\USR\JOE\WORK29K> EBMON
675 Am29000 PC Coprocessor Board Monitor, version 3.0-18
676 Copyright 1990 Advanced Micro Devices, Inc.
677 Written by Gibbons and Associates, Inc.
679 Enter '?' or 'H' for help
681 PC Coprocessor Type = EB29K
683 Memory Base = 0xd0000
685 Data Memory Size = 2048KB
686 Available I-RAM Range = 0x8000 to 0x1fffff
687 Available D-RAM Range = 0x80002000 to 0x801fffff
690 Register Stack Size = 0x800
691 Memory Stack Size = 0x1800
694 Am29027 Available = No
695 Byte Write Available = Yes
700 Then exit the @code{cu} or @code{tip} program (done in the example by
701 typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} will keep
702 running, ready for _GDBN__ to take over.
704 For this example, we've assumed what is probably the most convenient
705 way to make sure the same 29K program is on both the PC and the Unix
706 system: a PC/NFS connection that establishes ``drive @code{G:}'' on the
707 PC as a file system on the Unix host. If you don't have PC/NFS or
708 something similar connecting the two systems, you must arrange some
709 other way---perhaps floppy-disk transfer---of getting the 29K program
710 from the Unix system to the PC; _GDBN__ will @emph{not} download it over the
713 @node _GDBP__-EB29K,,,
714 @subsubsection EB29K cross-debugging
715 Finally, @code{cd} to the directory containing an image of your 29K
716 program on the Unix system, and start _GDBN__---specifying as argument the
717 name of your 29K program:
722 Now you can use the @code{target} command:
724 target amd-eb /dev/ttya 9600 MYFOO
726 @c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to
727 @c emphasize that this is the name as seen by DOS (since I think DOS is
728 @c single-minded about case of letters). ---pesch@cygnus.com, 25feb91
731 In this example, we've assumed your program is in a file called
732 @samp{myfoo}. Note that the filename given as the last argument to
733 @samp{target amd-eb} should be the name of the program as it appears to DOS.
734 In our example it is simply @samp{MYFOO}, but in general it can include
735 a DOS path, and depending on your transfer mechanism may not resemble
736 the name on the Unix side.
738 At this point, you can set any breakpoints you wish; when you're ready
739 to see your program run on the 29K board, use the _GDBN__ command
744 To stop debugging the remote program, use the _GDBN__ @samp{detach}
747 To return control of the PC to its console, use @code{tip} or @code{cu}
748 once again, after your _GDBN__ session has concluded, to attach to
749 @code{EBMON}. You can then type the command @samp{q} to shut down
750 @code{EBMON}, returning control to the DOS command-line interpreter.
751 Type @samp{CTTY con} to return command input to the main DOS console,
752 and type @samp{~.} to leave @code{tip} or @code{cu}.
755 @subsubsection Remote Log
757 @cindex log file for EB29K
758 The @samp{target amd-eb} command creates a file @file{eb.log} in the
759 current working directory, to help debug problems with the connection.
760 @file{eb.log} records all the output from @code{EBMON}, including echoes
761 of the commands sent to it. Running @samp{tail -f} on this file in
762 another window often helps to debug trouble with @code{EBMON}, or
763 unexpected events on the PC side of the connection.
767 @node VxWorks Remote,,,
768 @subsection _GDBN__ and VxWorks
769 _GDBN__ enables developers to spawn and debug tasks running on networked
770 VxWorks targets from a Unix host. Already-running tasks spawned from
771 the VxWorks shell can also be debugged. _GDBN__ uses code that runs on
772 both the UNIX host and on the VxWorks target. The program
773 @code{_GDBP__} is installed and executed on the UNIX host.
775 The remote debugging interface (RDB) routines are installed and executed
776 on the VxWorks target. These routines are included in the VxWorks library
777 @code{rdb.a} and are incorporated into the system image when source-level
778 debugging is enabled in the VxWorks configuration.
780 Defining @code{INCLUDE_RDB} in the VxWorks configuration file
781 @code{configAll.h} includes the RDB interface routines and spawns the
782 source debugging task @code{tRdbTask} when VxWorks is booted. For more
783 information on configuring and remaking VxWorks, @cite{VxWorks
786 Once you have included the RDB interface in your VxWorks system image
787 and set your Unix execution search path to find _GDBN__, you are ready
788 to run _GDBN__. From your UNIX host, type:
794 _GDBN__ will come up showing the prompt:
800 @node VxWorks connection,,,
801 @subsubsection Connecting to VxWorks
803 The _GDBN__ command @samp{target} lets you connect to a VxWorks target on the
804 network. To connect to a target whose host name is ``@code{tt}'', type:
807 (_GDBP__) target vxworks tt
810 _GDBN__ will display a message similar to the following:
813 Attaching remote machine across net... Success!
816 _GDBN__ will then attempt to read the symbol tables of any object
817 modules loaded into the VxWorks target since it was last booted.
818 _GDBN__ will locate the object files by searching the directories listed
819 in the source path (@pxref{Source Path}); if it fails to find an object
820 file, it will display a message such as:
823 prog.o: No such file or directory.
826 This will cause the @samp{target} command to abort. When this happens, you
827 should add the appropriate directory to the source path and execute the
828 @samp{target} command again.
830 @node VxWorks download,,,
831 @subsubsection Downloading to VxWorks
833 If you have connected to the VxWorks target and you want to debug an
834 object that has not yet been loaded, you can use the _GDBN__ @samp{load}
835 command to download a file from UNIX to VxWorks incrementally. The
836 object file given as an argument to the @samp{load} command is actually
837 opened twice: first by the VxWorks target in order to download the code,
838 then by _GDBN__ in order to read the symbol table. This can lead to
839 problems if the current working directories on the two systems differ.
840 It is simplest to set the working directory on both systems to the
841 directory in which the object file resides, and then to reference the
842 file by its name, without any path. Thus, to load a program
843 @samp{prog.o}, residing in @code{wherever/vw/demo/rdb}, on VxWorks type:
846 -> cd "wherever/vw/demo/rdb"
852 (_GDBP__) cd wherever/vw/demo/rdb
853 (_GDBP__) load prog.o
856 _GDBN__ will display a response similar to the following:
859 Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
862 You can also use the @samp{load} command to reload an object module
863 after editing and recompiling the corresponding source file. Note that
864 this will cause _GDBN__ to delete all currently-defined breakpoints,
865 auto-displays, and convenience variables, and to clear the value
866 history. (This is necessary in order to preserve the integrity of
867 debugger data structures that reference the target system's symbol
870 @node VxWorks attach,,,
871 @subsubsection Running Tasks
873 You can also attach to an existing task using the attach command as
877 (_GDBP__) attach @var{taskId}
880 where @var{taskId} is the VxWorks hexadecimal task ID. The task can be running
881 or suspended when you attach to it. If running, it will be suspended at
882 the time of attachment.
886 @node Stopping _GDBN__,,,
887 @section Stopping _GDBN__
888 @cindex exiting _GDBN__
890 To exit _GDBN__, use the @samp{quit} command (abbreviated @samp{q}), or type
891 an end-of-file character (usually @kbd{C-d}).
894 An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather
895 will terminate the action of any _GDBN__ command that is in progress and
896 return to _GDBN__ command level. It is safe to type the interrupt
897 character at any time because _GDBN__ does not allow it to take effect
898 until a time when it is safe.
900 If you've been using _GDBN__ to control an attached process or device,
901 you can release it with the @samp{detach} command; @pxref{Attach}.
903 @node Shell Commands,,,
904 @section Shell Commands
905 If you just need to execute occasional shell commands during your
906 debugging session, there's no need to stop or suspend _GDBN__; you can
907 just use the @samp{shell} command.
910 @item shell @var{command string}
913 Directs _GDBN__ to invoke an inferior shell to execute @var{command string}.
914 The environment variable @code{SHELL} is used if it exists, otherwise _GDBN__
918 The utility @samp{make} is often needed in development environments.
919 You don't have to use the @samp{shell} command for this purpose in _GDBN__:
925 Causes _GDBN__ to execute an inferior @code{make} program with the specified
926 arguments. This is equivalent to @samp{shell make @dots{}}.
930 @chapter _GDBN__ Commands
932 @node Command Syntax,,,
933 @section Command Syntax
934 A _GDBN__ command is a single line of input. There is no limit on how long
935 it can be. It starts with a command name, which is followed by arguments
936 whose meaning depends on the command name. For example, the command
937 @samp{step} accepts an argument which is the number of times to step,
938 as in @samp{step 5}. You can also use the @samp{step} command with
939 no arguments. Some command names do not allow any arguments.
942 _GDBN__ command names may always be truncated if that abbreviation is
943 unambiguous. Other possible command abbreviations are listed in the
944 documentation of the individual commands. Sometimes even ambiguous
945 abbreviations are allowed; for example, @samp{s} is specially defined as
946 equivalent to @samp{step} even though there are other commands whose
947 names start with @samp{s}.
949 @cindex repeating commands
950 A blank line as input to _GDBN__ means to repeat the previous command.
951 Certain commands will not repeat this way; these are commands for which
952 unintentional repetition might cause trouble and which you are unlikely
953 to want to repeat. Certain others (@samp{list} and @samp{x}) act
954 differently when repeated because that is more useful.
958 A line of input starting with @samp{#} is a comment; it does nothing.
959 This is useful mainly in command files (@xref{Command Files}).
962 @section Getting Help
963 @cindex online documentation
965 You can always ask _GDBN__ itself for information on its commands, using the
970 Used with no arguments, @samp{help} displays a short list of named
971 categories of commands:
974 List of classes of commands:
976 running -- Running the program
977 stack -- Examining the stack
978 data -- Examining data
979 breakpoints -- Making program stop at certain points
980 files -- Specifying and examining files
981 status -- Status inquiries
982 support -- Support facilities
983 user-defined -- User-defined commands
984 aliases -- Aliases of other commands
985 obscure -- Obscure features
987 Type "help" followed by a class name for a list of commands in that class.
988 Type "help" followed by command name for full documentation.
989 Command name abbreviations are allowed if unambiguous.
993 @item help @var{category}
994 Using one of the general help categories as an argument, you can get a
995 list of the individual commands in a category. For example, here is the
996 help display for category @samp{status}:
998 (_GDBP__) help status
1003 show -- Generic command for showing things set with "set"
1004 info -- Generic command for printing status
1006 Type "help" followed by command name for full documentation.
1007 Command name abbreviations are allowed if unambiguous.
1011 @item help @var{command}
1012 With a command name as @samp{help} argument, _GDBN__ will display a
1013 short paragraph on how to use that command.
1016 In addition to @samp{help}, you can use the _GDBN__ commands @samp{info}
1017 and @samp{show} to inquire about the state of your program, or the state
1018 of _GDBN__ itself. Both commands support many ``sub-commands'', or
1019 topics of inquiry; this manual introduces each of them in the
1020 appropriate context. The listings under ``@code{info}'' and under
1021 ``@code{show}'' in the Index point to all the sub-commands
1027 This command is for describing the state of your program; for example,
1028 it can list the arguments given to your program (@samp{info args}), the
1029 registers currently in use (@samp{info registers}), or the breakpoints
1030 you've set (@samp{info breakpoints}). You can get a complete list of
1031 the @code{info} sub-commands with @samp{help info}.
1035 In contrast, @samp{show} is for describing the state of _GDBN__ itself.
1036 You can change most of the things you can @code{show}, by using the
1037 related command @samp{set}; for example, you can control what number
1038 system is used for displays with @samp{set radix}, or simply inquire
1039 which possibility is currently in use with @samp{show radix}.
1042 To display all the settable parameters and their current
1043 values, you can use @samp{show} with no arguments; you may also use
1044 @samp{info set}. Both commands produce the same display.
1045 @c FIXME: "info set" violates the rule that "info" is for state of
1046 @c FIXME...program. Ck w/ GNU: "info set" to be called something else,
1047 @c FIXME...or change desc of rule---eg "state of prog and debugging session"?
1050 @kindex show version
1052 @c FIXME: chgd to "show version" from "info". Verify John doing same to GDBv4.
1053 This @samp{show} subcommand is one of those with no corresponding
1054 @samp{set} subcommand. As _GDBN__ evolves, new commands are introduced,
1055 and old ones may wither away. If multiple versions of _GDBN__ are in
1056 use at your site, it may occasionally be useful to make sure what
1057 version of _GDBN__ you're running. It is also useful to include this
1058 information in _GDBN__ bug-reports. _GDBN__ announces its version
1059 number if you start it with no arguments; but you can make it give this
1060 information on request, with the @samp{show version} command.
1065 @chapter Running Programs Under _GDBN__
1067 @node Compilation,,,
1068 @section Compiling for Debugging
1070 In order to debug a program effectively, you need to ask for debugging
1071 information when you compile it. This debugging information is stored
1072 in the object file; it describes the data type of each variable or
1073 function and the correspondence between source line numbers and
1074 addresses in the executable code.
1076 To request debugging information, specify the @samp{-g} option when you run
1079 The Unix C compiler is unable to handle the @samp{-g} and @samp{-O} options
1080 together. This means that you cannot ask for optimization if you ask for
1081 debugger information.
1083 The GNU C compiler supports @samp{-g} with or without @samp{-O}, making it
1084 possible to debug optimized code. We recommend that you @emph{always} use
1085 @samp{-g} whenever you compile a program. You may think the program is
1086 correct, but there's no sense in pushing your luck.
1088 Some things do not work as well with @samp{-g -O} as with just
1089 @samp{-g}, particularly on machines with instruction scheduling. If in
1090 doubt, recompile with @samp{-g} alone, and if this fixes the problem,
1091 please report it as a bug (including a test case---@pxref{_GDBN__ Bugs}).
1093 Older versions of the GNU C compiler permitted a variant option
1094 @samp{-gg} for debugging information. _GDBN__ no longer supports this
1095 format; if your GNU C compiler has this option, do not use it.
1098 @comment As far as I know, there are no cases in which _GDBN__ will
1099 @comment produce strange output in this case. (but no promises).
1100 If your program includes archives made with the @code{ar} program, and
1101 if the object files used as input to @code{ar} were compiled without the
1102 @samp{-g} option and have names longer than 15 characters, _GDBN__ will get
1103 confused reading the program's symbol table. No error message will be
1104 given, but _GDBN__ may behave strangely. The reason for this problem is a
1105 deficiency in the Unix archive file format, which cannot represent file
1106 names longer than 15 characters.
1108 To avoid this problem, compile the archive members with the @samp{-g}
1109 option or use shorter file names. Alternatively, use a version of GNU
1110 @code{ar} dated more recently than August 1989.
1115 @section Starting your Program
1119 To start your program under _GDBN__, use the @samp{run} command.
1121 Except on VxWorks, the
1126 program must already have been specified using the
1127 @samp{file} or @samp{exec-file} command, or with an argument to _GDBN__
1128 (@pxref{Files}).@refill
1130 On targets that support processes, @samp{run} creates an inferior
1131 process and makes that process run your program. On other targets,
1132 @samp{run} jumps to the location it has recorded for the start of the
1135 The execution of a program is affected by certain information it
1136 receives from its superior. _GDBN__ provides ways to specify this
1137 information, which you must do @i{before} starting the program. (You
1138 can change it after starting the program, but such changes do not affect
1139 the program unless you start it over again.) This information may be
1140 divided into four categories:
1143 @item The @i{arguments.}
1144 You specify the arguments to give your program as the arguments of the
1145 @samp{run} command. If a shell is available on your target, the shell
1146 is used to pass the arguments, so that you may use normal conventions
1147 (for example regular expression expansion or variable substitution) in
1148 describing the arguments. In Unix systems, you can control which shell
1149 is used with the @code{SHELL} environment variable.
1151 @item The @i{environment.}
1152 Your program normally inherits its environment from _GDBN__, but you can
1153 use the _GDBN__ commands @samp{set environment} and @samp{unset
1154 environment} to change parts of the environment that will be given to
1157 @item The @i{working directory.}
1158 Your program inherits its working directory from _GDBN__. You can set
1159 _GDBN__'s working directory with the @samp{cd} command in _GDBN__.
1161 @item The @i{standard input and output.}
1162 Your program normally uses the same device for standard input and
1163 standard output as _GDBN__ is using. You can redirect input and output
1164 in the @code{run} command line, or you can use the @samp{tty} command to
1165 set a different device for your program.
1168 When you issue the @samp{run} command, your program begins to execute
1169 immediately. @xref{Stopping}, for discussion of how to arrange for your
1172 Note that once your program has been started by the @samp{run} command,
1173 you may evaluate expressions that involve calls to functions in the
1174 inferior, using the @samp{print} or @samp{call} commands. @xref{Data}.
1176 If the modification time of your symbol file has changed since the last
1177 time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and re-read
1178 it. In this process, it tries to retain your current breakpoints.
1181 @section Your Program's Arguments
1183 @cindex arguments (to your program)
1184 The arguments to your program are specified by the arguments of the
1185 @samp{run} command. They are passed to a shell, which expands wildcard
1186 characters and performs redirection of I/O, and thence to the program.
1188 @samp{run} with no arguments uses the same arguments used by the previous
1194 The command @samp{set args} can be used to specify the arguments to be used
1195 the next time the program is run. If @samp{set args} has no arguments, it
1196 means to use no arguments the next time the program is run. If you have
1197 run your program with arguments and want to run it again with no arguments,
1198 this is the only way to do so.
1202 Show the arguments to give your program when it is started.
1205 @node Environment,,,
1206 @section Your Program's Environment
1208 @cindex environment (of your program)
1209 The @dfn{environment} consists of a set of @dfn{environment variables} and
1210 their values. Environment variables conventionally record such things as
1211 your user name, your home directory, your terminal type, and your search
1212 path for programs to run. Usually you set up environment variables with
1213 the shell and they are inherited by all the other programs you run. When
1214 debugging, it can be useful to try running the program with different
1215 environments without having to start the debugger over again.
1218 @item show environment @var{varname}
1219 @kindex show environment
1220 Print the value of environment variable @var{varname} to be given to
1221 your program when it is started.
1223 @item show environment
1224 Print the names and values of all environment variables to be given to
1225 your program when it is started.
1227 @item set environment @var{varname} @var{value}
1228 @itemx set environment @var{varname} = @var{value}
1229 @kindex set environment
1230 Sets environment variable @var{varname} to @var{value}, for your program
1231 only, not for _GDBN__ itself. @var{value} may be any string; the values of
1232 environment variables are just strings, and any interpretation is
1233 supplied by your program itself. The @var{value} parameter is optional;
1234 if it is eliminated, the variable is set to a null value.
1236 For example, this command:
1243 tells the program, when subsequently run, to assume it is being run
1244 on behalf of the user named @samp{foo}.
1246 @item unset environment @var{varname}
1247 @kindex unset environment
1248 Remove variable @var{varname} from the environment to be passed to your
1249 program. This is different from @samp{set env @var{varname}@ =};
1250 @samp{unset environment} removes the variable from the environment,
1251 rather than assigning it an empty value. This command can be
1252 abbreviated @samp{d e}.
1255 @node Working Directory,,,
1256 @section Your Program's Working Directory
1258 @cindex working directory (of your program)
1259 Each time you start your program with @samp{run}, it inherits its
1260 working directory from the current working directory of _GDBN__. _GDBN__'s
1261 working directory is initially whatever it inherited from its parent
1262 process (typically the shell), but you can specify a new working
1263 directory in _GDBN__ with the @samp{cd} command.
1265 The _GDBN__ working directory also serves as a default for the commands
1266 that specify files for _GDBN__ to operate on. @xref{Files}.
1269 @item cd @var{directory}
1271 Set _GDBN__'s working directory to @var{directory}.
1275 Print _GDBN__'s working directory.
1278 @node Input/Output,,,
1279 @section Your Program's Input and Output
1284 @cindex controlling terminal
1285 By default, the program you run under _GDBN__ does input and output to the same
1286 terminal that _GDBN__ uses.
1288 You can redirect the program's input and/or output using @samp{sh}-style
1289 redirection commands in the @samp{run} command. For example,
1296 starts the program, diverting its output to the file @file{outfile}.
1299 Another way to specify where the program should do input and output is
1300 with the @samp{tty} command. This command accepts a file name as
1301 argument, and causes this file to be the default for future @samp{run}
1302 commands. It also resets the controlling terminal for the child
1303 process, for future @samp{run} commands. For example,
1310 directs that processes started with subsequent @samp{run} commands
1311 default to do input and output on the terminal @file{/dev/ttyb} and have
1312 that as their controlling terminal.
1314 An explicit redirection in @samp{run} overrides the @samp{tty} command's
1315 effect on input/output redirection, but not its effect on the
1316 controlling terminal.
1318 When you use the @samp{tty} command or redirect input in the @samp{run}
1319 command, only the @emph{input for your program} is affected. The input
1320 for _GDBN__ still comes from your terminal.
1323 @section Debugging an Already-Running Process
1328 @item attach @var{process--id}
1329 This command attaches to a running process, if your currently selected
1330 target supports processes. (@samp{info files} will show your active
1331 targets). The command takes as argument a process ID.
1333 You specify a process ID to debug an already-running process that was
1334 started outside of _GDBN__. (The usual way to find out the process-id of
1335 a Unix process is with the @code{ps} utility, or with the @code{jobs -l}
1336 shell command.) In this case, you must have permission to send the
1337 process a signal, and it must have the same effective user ID as the
1341 When using @samp{attach}, you should first use the @samp{file} command
1342 to specify the program running in the process and load its symbol table.
1344 The first thing _GDBN__ does after arranging to debug the specified
1345 process is to stop it. You can examine and modify an attached process
1346 with all the _GDBN__ commands that ordinarily available when you start
1347 processes with @samp{run}. You can insert breakpoints; you can step and
1348 continue; you can modify storage. If you would rather the process
1349 continue running, you may use the @samp{continue} command after
1350 attaching _GDBN__ to the process.
1353 When you have finished debugging the attached process, you can use the
1354 @samp{detach} command to release it from _GDBN__'s control. Detaching
1355 the process continues its execution. After the @samp{detach} command,
1356 that process and _GDBN__ become completely independent once more, and you
1357 are ready to @samp{attach} another process or start one with @samp{run}.
1359 If you exit _GDBN__ or use the @samp{run} command while you have an attached
1360 process, you kill that process. By default, you will be asked for
1361 confirmation if you try to do either of these things; you can control
1362 whether or not this happens by using the @samp{set caution} command
1363 (@pxref{Messages/Warnings}).
1365 @node Kill Process,,,
1366 @section Killing the Child Process
1371 Kill the child process in which your program is running under _GDBN__.
1374 This command is useful if you wish to debug a core dump instead of a
1375 running process. _GDBN__ ignores any core dump file while your program
1378 On some operating systems, you can't execute your program in another
1379 process while breakpoints are active inside _GDBN__. You can use the
1380 @samp{kill} command in this situation to permit running the program
1381 outside the debugger.
1383 The @samp{kill} command is also useful if you wish to recompile and
1384 relink the program, since on many systems it is impossible to modify an
1385 executable file which is running in a process. In this case, when you
1386 next type @samp{run}, _GDBN__ will notice that the file has changed, and
1387 will re-read the symbol table (while trying to preserve your current
1388 breakpoint settings).
1391 @chapter Stopping and Continuing
1393 When you run a program normally, it runs until it terminates. The
1394 principal purpose of using a debugger is so that you can stop it before
1395 that point; or so that if the program runs into trouble you can
1396 investigate and find out why.
1398 @node Breakpoints,,,
1399 @section Breakpoints
1402 A @dfn{breakpoint} makes your program stop whenever a certain point in the
1403 program is reached. You set breakpoints explicitly with _GDBN__ commands,
1404 specifying the place where the program should stop by line number, function
1405 name or exact address in the program. You can add various other conditions
1406 to control whether the program will stop.
1408 Each breakpoint is assigned a number when it is created; these numbers are
1409 successive integers starting with 1. In many of the commands for controlling
1410 various features of breakpoints you use the breakpoint number to say which
1411 breakpoint you want to change. Each breakpoint may be @dfn{enabled} or
1412 @dfn{disabled}; if disabled, it has no effect on the program until you
1416 @subsection Setting Breakpoints
1420 Breakpoints are set with the @samp{break} command (abbreviated @samp{b}).
1422 You have several ways to say where the breakpoint should go.
1425 @item break @var{function}
1426 Set a breakpoint at entry to function @var{function}.
1428 @item break @var{+offset}
1429 @itemx break @var{-offset}
1430 Set a breakpoint some number of lines forward or back from the position
1431 at which execution stopped in the currently selected frame.
1433 @item break @var{linenum}
1434 Set a breakpoint at line @var{linenum} in the current source file.
1435 That file is the last file whose source text was printed. This
1436 breakpoint will stop the program just before it executes any of the
1439 @item break @var{filename}:@var{linenum}
1440 Set a breakpoint at line @var{linenum} in source file @var{filename}.
1442 @item break @var{filename}:@var{function}
1443 Set a breakpoint at entry to function @var{function} found in file
1444 @var{filename}. Specifying a file name as well as a function name is
1445 superfluous except when multiple files contain similarly named
1448 @item break *@var{address}
1449 Set a breakpoint at address @var{address}. You can use this to set
1450 breakpoints in parts of the program which do not have debugging
1451 information or source files.
1454 Set a breakpoint at the next instruction to be executed in the selected
1455 stack frame (@pxref{Stack}). In any selected frame but the innermost,
1456 this will cause the program to stop as soon as control returns to that
1457 frame. This is equivalent to a @samp{finish} command in the frame
1458 inside the selected frame. If this is done in the innermost frame, _GDBN__
1459 will stop the next time it reaches the current location; this may be
1460 useful inside of loops.
1462 _GDBN__ normally ignores breakpoints when it resumes execution, until at
1463 least one instruction has been executed. If it did not do this, you
1464 would be unable to proceed past a breakpoint without first disabling the
1465 breakpoint. This rule applies whether or not the breakpoint already
1466 existed when the program stopped.
1468 @item break @dots{} if @var{cond}
1469 Set a breakpoint with condition @var{cond}; evaluate the expression
1470 @var{cond} each time the breakpoint is reached, and stop only if the
1471 value is nonzero. @samp{@dots{}} stands for one of the possible
1472 arguments described above (or no argument) specifying where to break.
1473 @xref{Conditions}, for more information on breakpoint conditions.
1475 @item tbreak @var{args}
1477 Set a breakpoint enabled only for one stop. @var{args} are the
1478 same as in the @samp{break} command, and the breakpoint is set in the same
1479 way, but the breakpoint is automatically disabled the first time it
1480 is hit. @xref{Disabling}.
1482 @item rbreak @var{regex}
1484 Set a breakpoint on all functions matching @var{regex}. This is
1485 useful for setting breakpoints on overloaded functions that are not
1486 members of any special classes. This command sets an unconditional
1487 breakpoint on all matches, printing a list of all breakpoints it set.
1488 Once these breakpoints are set, they are treated just like the
1489 breakpoints set with the @samp{break} command. They can be deleted,
1490 disabled, made conditional, etc., in the standard ways.
1492 @kindex info breakpoints
1494 @item info breakpoints
1495 The command @samp{info breakpoints} prints a list of all breakpoints set
1496 and not deleted, showing their numbers, where in the program they are,
1497 and any special features in use for them. Disabled breakpoints are
1498 included in the list, but marked as disabled. @samp{info break} with a
1499 breakpoint number as argument lists only that breakpoint. The
1500 convenience variable @code{$_} and the default examining-address for the
1501 @samp{x} command are set to the address of the last breakpoint listed
1505 _GDBN__ allows you to set any number of breakpoints at the same place in the
1506 program. There is nothing silly or meaningless about this. When the
1507 breakpoints are conditional, this is even useful (@pxref{Conditions}).
1509 @node Set Watchpoints,,,
1510 @subsection Setting Watchpoints
1512 A @dfn{watchpoint} is a special breakpoint that stops your program when
1513 the value of an expression changes. You can use a watchpoint to stop
1514 execution whenever the value of an expression changes, without having to
1515 predict a particular place in the inferior process where this may
1516 happen. Aside from the different syntax in setting a watchpoint, it is
1517 managed exactly like any other breakpoint and is enabled, disabled, and
1518 deleted using exactly the same commands.
1520 Watchpoints currently execute two orders of magnitude more slowly than
1521 other breakpoints, but this can well be worth it to catch errors where
1522 you have no clue what part of your program is the culprit. Some
1523 processors provide special hardware to implement this feature; future
1524 releases of _GDBN__ will use such hardware if it is available.
1528 @item watch @var{expr}
1529 Set a watchpoint for an expression.
1533 This command prints a list of watchpoints.
1536 @node Exception Handling,,,
1537 @subsection Breakpoints and Exceptions
1538 @cindex exception handlers
1540 Some languages, such as GNU C++, implement exception handling. _GDBN__
1541 can be used to examine what caused the program to raise an exception
1542 and to list the exceptions the program is prepared to handle at a
1543 given point in time.
1546 @item catch @var{exceptions}
1549 Breakpoints can be set at active exception handlers by using the
1550 @samp{catch} command. @var{exceptions} is a list of names of exceptions
1554 You can use @samp{info catch} to list active exception handlers;
1557 There are currently some limitations to exception handling in _GDBN__.
1558 These will be corrected in a future release.
1562 If you call a function interactively, _GDBN__ will normally return
1563 control to you when the function has finished executing. If the call
1564 raises an exception, however, the call may bypass the mechanism that
1565 returns control to the user and cause the program to simply continue
1566 running until it hits a breakpoint, catches a signal that _GDBN__ is
1567 listening for, or exits.
1569 You cannot raise an exception interactively.
1571 You cannot interactively install an exception handler.
1574 @cindex raise exceptions
1575 Sometimes @samp{catch} is not the best way to debug exception handling:
1576 if you need to know exactly where an exception is raised, it's better to
1577 stop @emph{before} the exception handler is called, since that way you
1578 can see the stack before any unwinding takes place.
1580 To stop just before an exception handler is called, you need some
1581 knowledge of the implementation. In the case of GNU C++ exception are
1582 raised by calling a library function named @code{__raise_exception}
1583 which has the following ANSI C interface:
1586 /* ADDR is where the exception identifier is stored.
1587 ID is the exception identifier. */
1588 void __raise_exception (void **addr, void *id);
1592 To make the debugger catch all exceptions before any stack
1593 unwinding takes place, set a breakpoint on @code{__raise_exception}
1594 (@pxref{Breakpoints}). If you set a breakpoint in an exception handler
1595 instead, it may not be easy to find out where the exception was raised.
1597 With a conditional breakpoint (@xref{Conditions}) that depends on the
1598 value of @code{id}, you can cause the debugger to stop only when a
1599 specific exception is raised. Multiple conditional breakpoints can be
1600 used to stop the program when any of a number of exceptions are raised.
1602 @node Delete Breaks,,,
1603 @subsection Deleting Breakpoints
1605 @cindex clearing breakpoints, watchpoints
1606 @cindex deleting breakpoints, watchpoints
1607 It is often necessary to eliminate a breakpoint once it has done its job
1608 and you no longer want the program to stop there. This is called
1609 @dfn{deleting} the breakpoint. A breakpoint that has been deleted no
1610 longer exists in any sense; it is forgotten.
1612 With the @samp{clear} command you can delete breakpoints according to where
1613 they are in the program. With the @samp{delete} command you can delete
1614 individual breakpoints by specifying their breakpoint numbers.
1616 It is not necessary to delete a breakpoint to proceed past it. _GDBN__
1617 automatically ignores breakpoints on the first instruction to be executed
1618 when you continue execution without changing the execution address.
1623 Delete any breakpoints at the next instruction to be executed in the
1624 selected stack frame (@pxref{Selection}). When the innermost frame
1625 is selected, this is a good way to delete a breakpoint that the program
1628 @item clear @var{function}
1629 @itemx clear @var{filename}:@var{function}
1630 Delete any breakpoints set at entry to the function @var{function}.
1632 @item clear @var{linenum}
1633 @itemx clear @var{filename}:@var{linenum}
1634 Delete any breakpoints set at or within the code of the specified line.
1636 @item delete breakpoints @var{bnums}@dots{}
1637 @itemx delete @var{bnums}@dots{}
1639 @kindex delete breakpoints
1641 Delete the breakpoints of the numbers specified as arguments. If no
1642 argument is specified, delete all breakpoints.
1646 @subsection Disabling Breakpoints
1648 @cindex disabled breakpoints
1649 @cindex enabled breakpoints
1650 Rather than deleting a breakpoint, you might prefer to @dfn{disable} it.
1651 This makes the breakpoint inoperative as if it had been deleted, but
1652 remembers the information on the breakpoint so that you can @dfn{enable}
1655 You disable and enable breakpoints with the @samp{enable} and
1656 @samp{disable} commands, optionally specifying one or more breakpoint
1657 numbers as arguments. Use @samp{info break} to print a list of
1658 breakpoints if you don't know which breakpoint numbers to use.
1660 A breakpoint can have any of four different states of enablement:
1664 Enabled. The breakpoint will stop the program. A breakpoint made
1665 with the @samp{break} command starts out in this state.
1667 Disabled. The breakpoint has no effect on the program.
1669 Enabled once. The breakpoint will stop the program, but
1670 when it does so it will become disabled. A breakpoint made
1671 with the @samp{tbreak} command starts out in this state.
1673 Enabled for deletion. The breakpoint will stop the program, but
1674 immediately after it does so it will be deleted permanently.
1677 You can use the following commands to enable or disable a breakpoint:
1680 @item disable breakpoints @var{bnums}@dots{}
1681 @itemx disable @var{bnums}@dots{}
1683 @kindex disable breakpoints
1685 Disable the specified breakpoints---or all breakpoints, if none are
1686 listed. A disabled breakpoint has no effect but is not forgotten. All
1687 options such as ignore-counts, conditions and commands are remembered in
1688 case the breakpoint is enabled again later.
1690 @item enable breakpoints @var{bnums}@dots{}
1691 @itemx enable @var{bnums}@dots{}
1693 @kindex enable breakpoints
1695 Enable the specified breakpoints (or all defined breakpoints). They
1696 become effective once again in stopping the program, until you specify
1699 @item enable breakpoints once @var{bnums}@dots{}
1700 @itemx enable once @var{bnums}@dots{}
1701 Enable the specified breakpoints temporarily. Each will be disabled
1702 again the next time it stops the program (unless you have used one of
1703 these commands to specify a different state before that time comes).
1705 @item enable breakpoints delete @var{bnums}@dots{}
1706 @itemx enable delete @var{bnums}@dots{}
1707 Enable the specified breakpoints to work once and then die. Each of
1708 the breakpoints will be deleted the next time it stops the program
1709 (unless you have used one of these commands to specify a different
1710 state before that time comes).
1713 Save for a breakpoint set with @samp{tbreak} (@pxref{Set Breaks}),
1714 breakpoints that you set initially enabled; subsequently, they become
1715 disabled or enabled only when you use one of the commands above. (The
1716 command @samp{until} can set and delete a breakpoint of its own, but it
1717 will not change the state of your other breakpoints).
1720 @subsection Break Conditions
1721 @cindex conditional breakpoints
1722 @cindex breakpoint conditions
1724 The simplest sort of breakpoint breaks every time the program reaches a
1725 specified place. You can also specify a @dfn{condition} for a
1726 breakpoint. A condition is just a boolean expression in your
1727 programming language. (@xref{Expressions}). A breakpoint with a
1728 condition evaluates the expression each time the program reaches it, and
1729 the program stops only if the condition is true.
1731 Break conditions may have side effects, and may even call functions in your
1732 program. These may sound like strange things to do, but their effects are
1733 completely predictable unless there is another enabled breakpoint at the
1734 same address. (In that case, _GDBN__ might see the other breakpoint first and
1735 stop the program without checking the condition of this one.) Note that
1736 breakpoint commands are usually more convenient and flexible for the
1737 purpose of performing side effects when a breakpoint is reached
1738 (@pxref{Break Commands}).
1740 Break conditions can be specified when a breakpoint is set, by using
1741 @samp{if} in the arguments to the @samp{break} command. @xref{Set Breaks}.
1742 They can also be changed at any time with the @samp{condition} command:
1745 @item condition @var{bnum} @var{expression}
1747 Specify @var{expression} as the break condition for breakpoint number
1748 @var{bnum}. From now on, this breakpoint will stop the program only if
1749 the value of @var{expression} is true (nonzero, in C). @var{expression}
1750 is not evaluated at the time the @samp{condition} command is given.
1751 When you call @samp{condition}, the expression you specify is checked
1752 immediately for syntactic correctness, and to determine whether symbols
1753 in it have referents in the context of your breakpoint.
1756 @item condition @var{bnum}
1757 Remove the condition from breakpoint number @var{bnum}. It becomes
1758 an ordinary unconditional breakpoint.
1761 @cindex ignore count (of breakpoint)
1762 A special case of a breakpoint condition is to stop only when the
1763 breakpoint has been reached a certain number of times. This is so
1764 useful that there is a special way to do it, using the @dfn{ignore
1765 count} of the breakpoint. Every breakpoint has an ignore count, which
1766 is an integer. Most of the time, the ignore count is zero, and
1767 therefore has no effect. But if the program reaches a breakpoint whose
1768 ignore count is positive, then instead of stopping, it just decrements
1769 the ignore count by one and continues. As a result, if the ignore count
1770 value is @var{n}, the breakpoint will not stop the next @var{n} times it
1774 @item ignore @var{bnum} @var{count}
1776 Set the ignore count of breakpoint number @var{bnum} to @var{count}.
1777 The next @var{count} times the breakpoint is reached, your program's
1778 execution will not stop; other than to decrement the ignore count, _GDBN__
1781 To make the breakpoint stop the next time it is reached, specify
1784 @item continue @var{count}
1785 @itemx cont @var{count}
1786 @itemx c @var{count}
1787 @itemx fg @var{count}
1788 @kindex cont @var{count}
1789 @kindex continue @var{count}
1790 Continue execution of the program, setting the ignore count of the
1791 breakpoint that the program stopped at to @var{count} minus one.
1792 Thus, the program will not stop at this breakpoint until the
1793 @var{count}'th time it is reached.
1795 An argument to this command is meaningful only when the program stopped
1796 due to a breakpoint. At other times, the argument to @samp{cont} is
1799 The synonym @samp{fg} is provided purely for convenience, and has
1800 exactly the same behavior as other forms of the command.
1803 If a breakpoint has a positive ignore count and a condition, the condition
1804 is not checked. Once the ignore count reaches zero, the condition will
1807 Note that you could achieve the effect of the ignore count with a
1808 condition such as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience
1809 variable that is decremented each time. @xref{Convenience Vars}.
1811 @node Break Commands,,,
1812 @subsection Commands Executed on Breaking
1814 @cindex breakpoint commands
1815 You can give any breakpoint a series of commands to execute when the
1816 program stops due to that breakpoint. For example, you might want to
1817 print the values of certain expressions, or enable other breakpoints.
1820 @item commands @var{bnum}
1822 Specify a list of commands for breakpoint number @var{bnum}. The commands
1823 themselves appear on the following lines. Type a line containing just
1824 @samp{end} to terminate the commands.
1826 To remove all commands from a breakpoint, use the command
1827 @samp{commands} and follow it immediately by @samp{end}; that is, give
1830 With no arguments, @samp{commands} refers to the last breakpoint set
1831 (not to the breakpoint most recently encountered).
1834 You can use breakpoint commands to start the program up again. Simply
1835 use the @samp{cont} command, or @samp{step}, or any other command to
1836 resume execution. However, if you do this, any further commands in the
1837 same breakpoint's command list are ignored. When the program stops
1838 again, _GDBN__ will act according to the cause of that stop.
1841 If the first command specified is @samp{silent}, the usual message about
1842 stopping at a breakpoint is not printed. This may be desirable for
1843 breakpoints that are to print a specific message and then continue.
1844 If the remaining commands too print nothing, you will see no sign that
1845 the breakpoint was reached at all. @samp{silent} is not really a command;
1846 it is meaningful only at the beginning of the commands for a breakpoint.
1848 The commands @samp{echo} and @samp{output} that allow you to print precisely
1849 controlled output are often useful in silent breakpoints. @xref{Output}.
1851 For example, here is how you could use breakpoint commands to print the
1852 value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
1865 One application for breakpoint commands is to correct one bug so you can
1866 test another. Put a breakpoint just after the erroneous line of code, give
1867 it a condition to detect the case in which something erroneous has been
1868 done, and give it commands to assign correct values to any variables that
1869 need them. End with the @samp{cont} command so that the program does not
1870 stop, and start with the @samp{silent} command so that no output is
1871 produced. Here is an example:
1882 One deficiency in the operation of automatically continuing breakpoints
1883 under Unix appears when your program uses raw mode for the terminal.
1884 _GDBN__ switches back to its own terminal modes (not raw) before executing
1885 commands, and then must switch back to raw mode when your program is
1886 continued. This causes any pending terminal input to be lost.
1887 In the GNU system, this will be fixed by changing the behavior of
1890 Under Unix, when you have this problem, you might be able to get around
1891 it by putting your actions into the breakpoint condition instead of
1892 commands. For example
1895 condition 5 (x = y + 4), 0
1899 specifies a condition expression (@xref{Expressions}) that will change
1900 @code{x} as needed, then always have the value 0 so the program will not
1901 stop. Loss of input is avoided here because break conditions are
1902 evaluated without changing the terminal modes. When you want to have
1903 nontrivial conditions for performing the side effects, the operators
1904 @samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful.
1906 @node Error in Breakpoints,,,
1907 @subsection ``Cannot Insert Breakpoints''
1909 @c FIXME: "cannot insert breakpoints" error, v unclear.
1910 @c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91
1911 Under some operating systems, breakpoints cannot be used in a program if
1912 any other process is running that program. In this situation,
1913 attempting to run or continue a program with a breakpoint will cause _GDBN__
1914 to stop the other process.
1916 When this happens, you have three ways to proceed:
1920 Remove or disable the breakpoints, then continue.
1923 Suspend _GDBN__, and copy the file containing the program to a new name.
1924 Resume _GDBN__ and use the @samp{exec-file} command to specify that _GDBN__
1925 should run the program under that name. Then start the program again.
1928 Relink the program so that the text segment is nonsharable, using the
1929 linker option @samp{-N}. The operating system limitation may not apply
1930 to nonsharable executables.
1937 @dfn{Stepping} means setting your program in motion for a limited time, so
1938 that control will return automatically to _GDBN__ after one line of
1939 code or one machine instruction. Breakpoints are active during stepping
1940 and the program will stop for them even if it has not gone as far as the
1941 stepping command specifies.
1946 Continue running the program until control reaches a different source
1947 line, then stop it and return control to the debugger. This command is
1948 abbreviated @samp{s}.
1950 This command may be given when control is within a function for which
1951 there is no debugging information. In that case, execution will proceed
1952 until control reaches a different function, or is about to return from
1955 @item step @var{count}
1956 Continue running as in @samp{step}, but do so @var{count} times. If a
1957 breakpoint is reached or a signal not related to stepping occurs before
1958 @var{count} steps, stepping stops right away.
1962 Continue to the next source line in the current stack frame. Similar to
1963 @samp{step}, but any function calls appearing within the line of code
1964 are executed without stopping. Execution stops when control reaches a
1965 different line of code at the stack level which was executing when the
1966 @samp{next} command was given. This command is abbreviated @samp{n}.
1968 An argument is a repeat count, as in @samp{step}.
1970 @samp{next} within a function that lacks debugging information acts as does
1971 @samp{step}, but any function calls appearing within the code of the
1972 function are executed without stopping.
1976 Continue running until just after the selected stack frame returns (or
1977 until there is some other reason to stop, such as a fatal signal or a
1978 breakpoint). Print value returned by the selected stack frame (if any).
1980 Contrast this with the @samp{return} command (@pxref{Returning}).
1984 Continue running until a source line past the current line, in the
1985 current stack frame, is reached. This command is used to avoid single
1986 stepping through a loop more than once. It is like the @samp{next}
1987 command, except that when @samp{until} encounters a jump, it
1988 automatically continues execution until the program counter is greater
1989 than the address of the jump.
1991 This means that when you reach the end of a loop after single stepping
1992 though it, @samp{until} will cause the program to continue execution
1993 until the loop is exited. In contrast, a @samp{next} command at the end
1994 of a loop will simply step back to the beginning of the loop, which
1995 would force you to step through the next iteration.
1997 @samp{until} always stops the program if it attempts to exit the current
2000 @samp{until} may produce somewhat counterintuitive results if the order
2001 of the source lines does not match the actual order of execution. For
2002 example, in a typical C @code{for}-loop, the third expression in the
2003 @code{for}-statement (the loop-step expression) is executed after the
2004 statements in the body of the loop, but is written before them.
2005 Therefore, the @samp{until} command would appear to step back to the
2006 beginning of the loop when it advances to this expression. However, it
2007 has not really done so, not in terms of the actual machine code.
2009 @samp{until} with no argument works by means of single
2010 instruction stepping, and hence is slower than @samp{until} with an
2013 @item until @var{location}
2014 Continue running the program until either the specified location is
2015 reached, or the current (innermost) stack frame returns. @var{location}
2016 is any of the forms of argument acceptable to @samp{break} (@pxref{Set
2017 Breaks}). This form of the command uses breakpoints, and hence is
2018 quicker than @samp{until} without an argument.
2024 Execute one machine instruction, then stop and return to the debugger.
2026 It is often useful to do @samp{display/i $pc} when stepping by machine
2027 instructions. This will cause the next instruction to be executed to
2028 be displayed automatically at each stop. @xref{Auto Display}.
2030 An argument is a repeat count, as in @samp{step}.
2036 Execute one machine instruction, but if it is a function call,
2037 proceed until the function returns.
2039 An argument is a repeat count, as in @samp{next}.
2042 A typical technique for using stepping is to put a breakpoint
2043 (@pxref{Breakpoints}) at the beginning of the function or the section of
2044 the program in which a problem is believed to lie, run the program until
2045 it stops at that breakpoint, and then step through the suspect area,
2046 examining the variables that are interesting, until you see the problem
2049 The @samp{cont} command can be used after stepping to resume execution
2050 until the next breakpoint or signal.
2055 After your program stops, most likely you will want it to run some more if
2056 the bug you are looking for has not happened yet.
2063 Continue running the program at the place where it stopped.
2066 If the program stopped at a breakpoint, the place to continue running
2067 is the address of the breakpoint. You might expect that continuing would
2068 just stop at the same breakpoint immediately. In fact, @samp{cont}
2069 takes special care to prevent that from happening. You do not need
2070 to delete the breakpoint to proceed through it after stopping at it.
2071 You can, however, specify an ignore-count for the breakpoint that the
2072 program stopped at, by means of an argument to the @samp{cont} command.
2075 If the program stopped because of a signal other than @code{SIGINT} or
2076 @code{SIGTRAP}, continuing will cause the program to see that signal.
2077 You may not want this to happen. For example, if the program stopped
2078 due to some sort of memory reference error, you might store correct
2079 values into the erroneous variables and continue, hoping to see more
2080 execution; but the program would probably terminate immediately as
2081 a result of the fatal signal once it sees the signal. To prevent this,
2082 you can continue with @samp{signal 0}. @xref{Signaling}. You can
2083 also act in advance to control what signals your program will see, using
2084 the @samp{handle} command (@pxref{Signals}).
2090 A signal is an asynchronous event that can happen in a program. The
2091 operating system defines the possible kinds of signals, and gives each
2092 kind a name and a number. For example, in Unix @code{SIGINT} is the
2093 signal a program gets when you type @kbd{Ctrl-c}; @code{SIGSEGV} is the
2094 signal a program gets from referencing a place in memory far away from
2095 all the areas in use; @code{SIGALRM} occurs when the alarm clock timer
2096 goes off (which happens only if the program has requested an alarm).
2098 @cindex fatal signals
2099 Some signals, including @code{SIGALRM}, are a normal part of the
2100 functioning of the program. Others, such as @code{SIGSEGV}, indicate
2101 errors; these signals are @dfn{fatal} (kill the program immediately) if the
2102 program has not specified in advance some other way to handle the signal.
2103 @code{SIGINT} does not indicate an error in the program, but it is normally
2104 fatal so it can carry out the purpose of @kbd{Ctrl-c}: to kill the program.
2106 _GDBN__ has the ability to detect any occurrence of a signal in the program
2107 running under _GDBN__'s control. You can tell _GDBN__ in advance what to do for
2108 each kind of signal.
2110 @cindex handling signals
2111 Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM}
2112 (so as not to interfere with their role in the functioning of the program)
2113 but to stop the program immediately whenever an error signal happens.
2114 You can change these settings with the @samp{handle} command.
2119 Print a table of all the kinds of signals and how _GDBN__ has been told to
2120 handle each one. You can use this to see the signal numbers of all
2121 the defined types of signals.
2123 @item handle @var{signal} @var{keywords}@dots{}
2125 Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the
2126 number of a signal or its name (with or without the @samp{SIG} at the
2127 beginning). The @var{keywords} say what change to make.
2131 The keywords allowed by the @samp{handle} command can be abbreviated.
2132 Their full names are:
2136 _GDBN__ should not stop the program when this signal happens. It may
2137 still print a message telling you that the signal has come in.
2140 _GDBN__ should stop the program when this signal happens. This implies
2141 the @samp{print} keyword as well.
2144 _GDBN__ should print a message when this signal happens.
2147 _GDBN__ should not mention the occurrence of the signal at all. This
2148 implies the @samp{nostop} keyword as well.
2151 _GDBN__ should allow the program to see this signal; the program will be
2152 able to handle the signal, or may be terminated if the signal is fatal
2156 _GDBN__ should not allow the program to see this signal.
2160 When a signal has been set to stop the program, the program cannot see the
2161 signal until you continue. It will see the signal then, if @samp{pass} is
2162 in effect for the signal in question @i{at that time}. In other words,
2163 after _GDBN__ reports a signal, you can use the @samp{handle} command with
2164 @samp{pass} or @samp{nopass} to control whether that signal will be seen by
2165 the program when you later continue it.
2167 You can also use the @samp{signal} command to prevent the program from
2168 seeing a signal, or cause it to see a signal it normally would not see,
2169 or to give it any signal at any time. @xref{Signaling}.
2173 @chapter Examining the Stack
2175 When your program has stopped, the first thing you need to know is where it
2176 stopped and how it got there.
2179 Each time your program performs a function call, the information about
2180 where in the program the call was made from is saved in a block of data
2181 called a @dfn{stack frame}. The frame also contains the arguments of the
2182 call and the local variables of the function that was called. All the
2183 stack frames are allocated in a region of memory called the @dfn{call
2186 When your program stops, the _GDBN__ commands for examining the stack allow you
2187 to see all of this information.
2189 One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands
2190 refer implicitly to the selected frame. In particular, whenever you ask
2191 _GDBN__ for the value of a variable in the program, the value is found in the
2192 selected frame. There are special _GDBN__ commands to select whichever frame
2193 you are interested in.
2195 When the program stops, _GDBN__ automatically selects the currently executing
2196 frame and describes it briefly as the @samp{frame} command does
2197 (@pxref{Frame Info, Info}).
2200 @section Stack Frames
2204 The call stack is divided up into contiguous pieces called @dfn{stack
2205 frames}, or @dfn{frames} for short; each frame is the data associated
2206 with one call to one function. The frame contains the arguments given
2207 to the function, the function's local variables, and the address at
2208 which the function is executing.
2210 @cindex initial frame
2211 @cindex outermost frame
2212 @cindex innermost frame
2213 When your program is started, the stack has only one frame, that of the
2214 function @code{main}. This is called the @dfn{initial} frame or the
2215 @dfn{outermost} frame. Each time a function is called, a new frame is
2216 made. Each time a function returns, the frame for that function invocation
2217 is eliminated. If a function is recursive, there can be many frames for
2218 the same function. The frame for the function in which execution is
2219 actually occurring is called the @dfn{innermost} frame. This is the most
2220 recently created of all the stack frames that still exist.
2222 @cindex frame pointer
2223 Inside your program, stack frames are identified by their addresses. A
2224 stack frame consists of many bytes, each of which has its own address; each
2225 kind of computer has a convention for choosing one of those bytes whose
2226 address serves as the address of the frame. Usually this address is kept
2227 in a register called the @dfn{frame pointer register} while execution is
2228 going on in that frame.
2230 @cindex frame number
2231 _GDBN__ assigns numbers to all existing stack frames, starting with
2232 @code{0} for the innermost frame, @code{1} for the frame that called it,
2233 and so on upward. These numbers do not really exist in your program;
2234 they are assigned by _GDBN__ to give you a way of designating stack
2235 frames in _GDBN__ commands.
2237 @cindex selected frame
2238 Many _GDBN__ commands refer implicitly to one stack frame, called the
2239 @dfn{selected} stack frame. You can select any frame using one set of
2240 _GDBN__ commands, and then other commands will operate on that frame. When
2241 your program stops, _GDBN__ automatically selects the innermost frame.
2243 @cindex frameless execution
2244 Some compilers allow functions to be compiled so that they operate
2245 without stack frames. (For example, the _GCC__ option
2246 @samp{-fomit-frame-pointer} will generate functions without a frame.)
2247 This is occasionally done with heavily used library functions to save
2248 the frame setup time. _GDBN__ has limited facilities for dealing with
2249 these function invocations; if the innermost function invocation has no
2250 stack frame, _GDBN__ will give it a virtual stack frame of 0 and
2251 correctly allow tracing of the function call chain. Results are
2252 undefined if a function invocation besides the innermost one is
2258 A backtrace is a summary of how the program got where it is. It shows one
2259 line per frame, for many frames, starting with the currently executing
2260 frame (frame zero), followed by its caller (frame one), and on up the
2268 Print a backtrace of the entire stack: one line per frame for all
2269 frames in the stack.
2271 You can stop the backtrace at any time by typing the system interrupt
2272 character, normally @kbd{Control-C}.
2274 @item backtrace @var{n}
2276 Similar, but print only the innermost @var{n} frames.
2278 @item backtrace -@var{n}
2280 Similar, but print only the outermost @var{n} frames.
2285 The names @samp{where} and @samp{info stack} are additional aliases
2286 for @samp{backtrace}.
2288 Each line in the backtrace shows the frame number and the function
2289 name. The program counter value is also shown---unless you use
2290 @samp{set addressprint off}.
2292 If the function is in a source file whose symbol table data has been
2293 fully read, the backtrace shows the source file name and line number, as
2294 well as the arguments to the function. When the line number is shown,
2295 the program counter value is omitted if it is at the beginning of the
2296 code for that line number.
2298 Here is an example of a backtrace. It was made with the command
2299 @samp{bt 3}, so it shows the innermost three frames.
2302 #0 rtx_equal_p (x=(rtx) 0x8e58c, y=(rtx) 0x1086c4) \
2303 (/gp/rms/cc/rtlanal.c line 337)
2304 #1 0x246b0 in expand_call (...) (...)
2305 #2 0x21cfc in expand_expr (...) (...)
2306 (More stack frames follow...)
2310 _GDBN__ displayed the functions @code{expand_call} and @code{expand_expr}
2311 with place-holders in place of their argument values and line numbers,
2312 because each is in a file whose symbol details have not been fully read.
2313 Full detail is available for the function @code{rtx_equal_p}, which is
2314 in the file @file{rtlanal.c}. Its arguments, named @code{x} and
2315 @code{y}, are shown with their typed values.
2318 @section Selecting a Frame
2320 Most commands for examining the stack and other data in the program work on
2321 whichever stack frame is selected at the moment. Here are the commands for
2322 selecting a stack frame; all of them finish by printing a brief description
2323 of the stack frame just selected.
2328 Select frame number @var{n}. Recall that frame zero is the innermost
2329 (currently executing) frame, frame one is the frame that called the
2330 innermost one, and so on. The highest-numbered frame is @code{main}'s
2333 @item frame @var{addr}
2334 Select the frame at address @var{addr}. This is useful mainly if the
2335 chaining of stack frames has been damaged by a bug, making it
2336 impossible for _GDBN__ to assign numbers properly to all frames. In
2337 addition, this can be useful when the program has multiple stacks and
2338 switches between them.
2342 Move @var{n} frames up the stack. For positive numbers @var{n}, this
2343 advances toward the outermost frame, to higher frame numbers, to frames
2344 that have existed longer. @var{n} defaults to one.
2348 Move @var{n} frames down the stack. For positive numbers @var{n}, this
2349 advances toward the innermost frame, to lower frame numbers, to frames
2350 that were created more recently. @var{n} defaults to one.
2353 All of these commands end by printing some information on the frame that
2354 has been selected: the frame number, the function name, the arguments, the
2355 source file and line number of execution in that frame, and the text of
2356 that source line. For example:
2360 #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) at env.c:10
2361 10 read_input_file (argv[i]);
2364 After such a printout, the @samp{list} command with no arguments will print
2365 ten lines centered on the point of execution in the frame. @xref{List}.
2368 @item up-silently @var{n}
2369 @itemx down-silently @var{n}
2370 @kindex down-silently
2372 These two commands are variants of @samp{up} and @samp{down},
2373 respectively; they differ in that they do their work silently, without
2374 causing display of the new frame. They are intended primarily for use
2375 in _GDBN__ command scripts, where the output might be unnecessary and
2381 @section Information on a Frame
2383 There are several other commands to print information about the selected
2388 When used without any argument, this command does not change which frame
2389 is selected, but prints a brief description of the currently
2390 selected stack frame. It can be abbreviated @samp{f}. With an
2391 argument, this command is used to select a stack frame (@pxref{Selection}).
2395 This command prints a verbose description of the selected stack frame,
2396 including the address of the frame, the addresses of the next frame down
2397 (called by this frame) and the next frame up (caller of this frame),
2398 the address of the frame's arguments, the program counter saved in it
2399 (the address of execution in the caller frame), and which registers
2400 were saved in the frame. The verbose description is useful when
2401 something has gone wrong that has made the stack format fail to fit
2402 the usual conventions.
2404 @item info frame @var{addr}
2405 Print a verbose description of the frame at address @var{addr},
2406 without selecting that frame. The selected frame remains unchanged by
2411 Print the arguments of the selected frame, each on a separate line.
2415 Print the local variables of the selected frame, each on a separate
2416 line. These are all variables declared static or automatic within all
2417 program blocks that execution in this frame is currently inside of.
2421 @cindex catch exceptions
2422 @cindex exception handlers
2423 Print a list of all the exception handlers that are active in the
2424 current stack frame at the current point of execution. To see other
2425 exception handlers, visit the associated frame (using the @samp{up},
2426 @samp{down}, or @samp{frame} commands); then type @samp{info catch}.
2427 @xref{Exception Handling}.
2431 @chapter Examining Source Files
2433 _GDBN__ knows which source files your program was compiled from, and
2434 can print parts of their text. When your program stops, _GDBN__
2435 spontaneously prints the line it stopped in. Likewise, when you
2436 select a stack frame (@pxref{Selection}), _GDBN__ prints the line
2437 which execution in that frame has stopped in. You can also
2438 print parts of source files by explicit command.
2441 @section Printing Source Lines
2445 To print lines from a source file, use the @samp{list} command
2446 (abbreviated @samp{l}). There are several ways to specify what part
2447 of the file you want to print.
2449 Here are the forms of the @samp{list} command most commonly used:
2452 @item list @var{linenum}
2453 Print ten lines centered around line number @var{linenum} in the
2454 current source file.
2456 @item list @var{function}
2457 Print ten lines centered around the beginning of function
2461 Print ten more lines. If the last lines printed were printed with a
2462 @samp{list} command, this prints ten lines following the last lines
2463 printed; however, if the last line printed was a solitary line printed
2464 as part of displaying a stack frame (@pxref{Stack}), this prints ten
2465 lines centered around that line.
2468 Print ten lines just before the lines last printed.
2471 Repeating a @samp{list} command with @key{RET} discards the argument,
2472 so it is equivalent to typing just @samp{list}. This is more useful
2473 than listing the same lines again. An exception is made for an
2474 argument of @samp{-}; that argument is preserved in repetition so that
2475 each repetition moves up in the source file.
2478 In general, the @samp{list} command expects you to supply zero, one or two
2479 @dfn{linespecs}. Linespecs specify source lines; there are several ways
2480 of writing them but the effect is always to specify some source line.
2481 Here is a complete description of the possible arguments for @samp{list}:
2484 @item list @var{linespec}
2485 Print ten lines centered around the line specified by @var{linespec}.
2487 @item list @var{first},@var{last}
2488 Print lines from @var{first} to @var{last}. Both arguments are
2491 @item list ,@var{last}
2492 Print ten lines ending with @var{last}.
2494 @item list @var{first},
2495 Print ten lines starting with @var{first}.
2498 Print ten lines just after the lines last printed.
2501 Print ten lines just before the lines last printed.
2504 As described in the preceding table.
2507 Here are the ways of specifying a single source line---all the
2512 Specifies line @var{linenum} of the current source file.
2513 When a @samp{list} command has two linespecs, this refers to
2514 the same source file as the first linespec.
2517 Specifies the line @var{offset} lines after the last line printed.
2518 When used as the second linespec in a @samp{list} command that has
2519 two, this specifies the line @var{offset} lines down from the
2523 Specifies the line @var{offset} lines before the last line printed.
2525 @item @var{filename}:@var{linenum}
2526 Specifies line @var{linenum} in the source file @var{filename}.
2528 @item @var{function}
2529 Specifies the line of the open-brace that begins the body of the
2530 function @var{function}.
2532 @item @var{filename}:@var{function}
2533 Specifies the line of the open-brace that begins the body of the
2534 function @var{function} in the file @var{filename}. The file name is
2535 needed with a function name only for disambiguation of identically
2536 named functions in different source files.
2538 @item *@var{address}
2539 Specifies the line containing the program address @var{address}.
2540 @var{address} may be any expression.
2544 @section Searching Source Files
2547 @kindex forward-search
2548 @kindex reverse-search
2550 There are two commands for searching through the current source file for a
2553 The command @samp{forward-search @var{regexp}} checks each line, starting
2554 with the one following the last line listed, for a match for @var{regexp}.
2555 It lists the line that is found. You can abbreviate the command name
2556 as @samp{fo}. The synonym @samp{search @var{regexp}} is also supported.
2558 The command @samp{reverse-search @var{regexp}} checks each line, starting
2559 with the one before the last line listed and going backward, for a match
2560 for @var{regexp}. It lists the line that is found. You can abbreviate
2561 this command with as little as @samp{rev}.
2563 @node Source Path,,,
2564 @section Specifying Source Directories
2567 @cindex directories for source files
2568 Executable programs sometimes do not record the directories of the source
2569 files from which they were compiled, just the names. Even when they do,
2570 the directories could be moved between the compilation and your debugging
2571 session. _GDBN__ remembers a list of directories to search for source files;
2572 this is called the @dfn{source path}. Each time _GDBN__ wants a source file,
2573 it tries all the directories in the list, in the order they are present
2574 in the list, until it finds a file with the desired name. Note that
2575 the executable search path is @emph{not} used for this purpose. Neither is
2576 the current working directory, unless it happens to be in the source
2579 If it can't find a source file in the source path, and the object program
2580 records what directory it was compiled in, _GDBN__ tries that directory too.
2581 If the source path is empty, and there is no record of the compilation
2582 directory, _GDBN__ will, as a last resort, look in the current directory.
2584 Whenever you reset or rearrange the source path, _GDBN__ will clear out
2585 any information it has cached about where source files are found, where
2586 each line is in the file, etc.
2589 When you start _GDBN__, its source path is empty.
2590 To add other directories, use the @samp{directory} command.
2593 @item directory @var{dirnames...}
2594 Add directory @var{dirname} to the front of the source path. Several
2595 directory names may be given to this command, separated by whitespace or
2596 @samp{:}. If a name is already in the source path, it is moved to the
2597 front of the path, so it will be searched sooner.
2600 Reset the source path to empty again. This requires confirmation.
2602 @item info directories
2603 @kindex info directories
2604 Print the source path: show which directories it contains.
2607 If your source path is cluttered with directories that are no longer of
2608 interest, _GDBN__ may sometimes cause confusion by finding the wrong
2609 versions of source. You can correct the situation as follows:
2613 Use @samp{directory} with no argument to reset the source path to empty.
2616 Use @samp{directory} with suitable arguments to add any other
2617 directories you want in the source path. You can add all the directories
2621 @node Machine Code,,,
2622 @section Source and Machine Code
2623 You can use the command @samp{info line} to map source lines to program
2624 addresses, and the command @samp{disassemble} or its synonym
2625 @samp{disasm} to display a range of addresses as machine instructions.
2628 @item info line @var{linespec}
2630 Print the starting and ending addresses of the compiled code for
2631 source line @var{linespec}.
2634 The default examine address for the @samp{x} command is changed to the
2635 starting address of the line, so that @samp{x/i} is sufficient to
2636 begin examining the machine code (@pxref{Memory}). Also, this address
2637 is saved as the value of the convenience variable @code{$_}
2638 (@pxref{Convenience Vars}).
2644 This specialized command is provided to dump a range of memory as
2645 machine instructions. The default memory range is the function
2646 surrounding the program counter of the selected frame. A single
2647 argument to this command is a program counter value; the function
2648 surrounding this value will be dumped. Two arguments (separated by one
2649 or more spaces) specify a range of addresses (first inclusive, second
2650 exclusive) to be dumped. The two spellings, @samp{disasm} and
2651 @samp{disassemble}, are equivalent.
2655 @chapter Examining Data
2657 @cindex printing data
2658 @cindex examining data
2661 @c "inspect" isn't quite a synonym if you're using Epoch, which we don't
2662 @c document because it's nonstandard... Under Epoch it displays in a
2663 @c different window or something like that.
2664 The usual way to examine data in your program is with the @samp{print}
2665 command (abbreviated @samp{p}), or its synonym @samp{inspect}. It
2666 evaluates and prints the value of any valid expression of the language
2667 the program is written in (for now, C or C++). You type
2674 where @var{exp} is any valid expression (in the source language), and
2675 the value of @var{exp} is printed in a format appropriate to its data
2678 A more low-level way of examining data is with the @samp{x} command.
2679 It examines data in memory at a specified address and prints it in a
2682 @node Expressions,,,
2683 @section Expressions
2686 Many different _GDBN__ commands accept an expression and compute its value.
2687 Any kind of constant, variable or operator defined by the programming
2688 language you are using is legal in an expression in _GDBN__. This includes
2689 conditional expressions, function calls, casts and string constants. It
2690 unfortunately does not include symbols defined by preprocessor
2691 @code{#define} commands, or C++ expressions involving @samp{::}, the
2692 name resolution operator.
2693 @c FIXME: actually C++ a::b works except in obscure circumstances where it
2694 @c FIXME...can conflict with GDB's own name scope resolution.
2696 Casts are supported in all languages, not just in C, because it is so
2697 useful to cast a number into a pointer so as to examine a structure
2698 at that address in memory.
2700 _GDBN__ supports three kinds of operator in addition to those of programming
2705 @samp{@@} is a binary operator for treating parts of memory as arrays.
2706 @xref{Arrays}, for more information.
2709 @samp{::} allows you to specify a variable in terms of the file or
2710 function it is defined in. @xref{Variables}.
2712 @item @{@var{type}@} @var{addr}
2713 Refers to an object of type @var{type} stored at address @var{addr} in
2714 memory. @var{addr} may be any expression whose value is an integer or
2715 pointer (but parentheses are required around nonunary operators, just as in
2716 a cast). This construct is allowed regardless of what kind of data is
2717 officially supposed to reside at @var{addr}.@refill
2721 @section Program Variables
2723 The most common kind of expression to use is the name of a variable
2726 Variables in expressions are understood in the selected stack frame
2727 (@pxref{Selection}); they must either be global (or static) or be visible
2728 according to the scope rules of the programming language from the point of
2729 execution in that frame. This means that in the function
2744 the variable @code{a} is usable whenever the program is executing
2745 within the function @code{foo}, but the variable @code{b} is visible
2746 only while the program is executing inside the block in which @code{b}
2749 As a special exception, you can refer to a variable or function whose
2750 scope is a single source file even if the current execution point is not
2751 in this file. But it is possible to have more than one such variable or
2752 function with the same name (in different source files). In such a
2753 case, it is not defined which one you will get. If you wish, you can
2754 specify any one of them using the colon-colon construct:
2760 @var{block}::@var{variable}
2764 Here @var{block} is the name of the source file whose variable you want.
2766 @cindex name resolution (C++)
2767 Unfortunately, this use of @samp{::} conflicts with the very similar use
2768 of the same notation in C++; accordingly, _GDBN__ does not support use of
2769 the C++ name resolution operator in _GDBN__ expressions.
2772 @section Artificial Arrays
2774 @cindex artificial array
2776 It is often useful to print out several successive objects of the
2777 same type in memory; a section of an array, or an array of
2778 dynamically determined size for which only a pointer exists in the
2781 This can be done by constructing an @dfn{artificial array} with the
2782 binary operator @samp{@@}. The left operand of @samp{@@} should be
2783 the first element of the desired array, as an individual object.
2784 The right operand should be the length of the array. The result is
2785 an array value whose elements are all of the type of the left argument.
2786 The first element is actually the left argument; the second element
2787 comes from bytes of memory immediately following those that hold the
2788 first element, and so on. Here is an example. If a program says
2791 int *array = (int *) malloc (len * sizeof (int));
2795 you can print the contents of @code{array} with
2801 The left operand of @samp{@@} must reside in memory. Array values made
2802 with @samp{@@} in this way behave just like other arrays in terms of
2803 subscripting, and are coerced to pointers when used in expressions.
2804 (It would probably appear in an expression via the value history,
2805 after you had printed it out.)
2807 @node Output formats,,,
2808 @section Output formats
2810 @cindex formatted output
2811 @cindex output formats
2812 _GDBN__ normally prints all values according to their data types. Sometimes
2813 this is not what you want. For example, you might want to print a number
2814 in hex, or a pointer in decimal. Or you might want to view data in memory
2815 at a certain address as a character string or an instruction. To do
2816 these things, specify an @dfn{output format} when you print a value.
2818 The simplest use of output formats is to say how to print a value
2819 already computed. This is done by starting the arguments of the
2820 @samp{print} command with a slash and a format letter. The format
2821 letters supported are:
2825 Regard the bits of the value as an integer, and print the integer in
2829 Print as integer in signed decimal.
2832 Print as integer in unsigned decimal.
2835 Print as integer in octal.
2838 Print as an address, both absolute in hex and as an offset from the
2839 nearest preceding symbol. This format can be used to discover where (in
2840 what function) an unknown address is located:
2842 (_GDBP__) p/a 0x54320
2843 _0__$3 = 0x54320 <_initialize_vx+396>_1__
2848 Regard as an integer and print it as a character constant.
2851 Regard the bits of the value as a floating point number and print
2852 using typical floating point syntax.
2855 For example, to print the program counter in hex (@pxref{Registers}), type
2862 Note that no space is required before the slash; this is because command
2863 names in _GDBN__ cannot contain a slash.
2865 To reprint the last value in the value history with a different format,
2866 you can use the @samp{print} command with just a format and no
2867 expression. For example, @samp{p/x} reprints the last value in hex.
2870 @section Examining Memory
2872 @cindex examining memory
2876 The command @samp{x} (for `examine') can be used to examine memory
2877 without reference to the program's data types. The format in which you
2878 wish to examine memory is instead explicitly specified. The allowable
2879 formats are a superset of the formats described in the previous section.
2882 @samp{x} is followed by a slash and an output format specification,
2883 followed by an expression for an address. The expression need not have
2884 a pointer value (though it may); it is used as an integer, as the
2885 address of a byte of memory. @xref{Expressions} for more information on
2886 expressions. For example, @samp{x/4xw $sp} prints the four words of
2887 memory above the stack pointer in hexadecimal.
2889 The output format in this case specifies both how big a unit of memory
2890 to examine and how to print the contents of that unit. This is done
2891 with one or two of the following letters:
2893 These letters specify the size of unit to examine:
2897 Examine individual bytes.
2900 Examine halfwords (two bytes each).
2903 Examine words (four bytes each).
2906 Many assemblers and cpu designers still use `word' for a 16-bit quantity,
2907 as a holdover from specific predecessor machines of the 1970's that really
2908 did use two-byte words. But more generally the term `word' has always
2909 referred to the size of quantity that a machine normally operates on and
2910 stores in its registers. This is 32 bits for all the machines that _GDBN__
2914 Examine giant words (8 bytes).
2917 These letters specify the way to print the contents:
2921 Print as integers in unsigned hexadecimal.
2924 Print as integers in signed decimal.
2927 Print as integers in unsigned decimal.
2930 Print as integers in unsigned octal.
2933 Print as an address, both absolute in hex and then relative
2934 to a symbol defined as an address below it.
2937 Print as character constants.
2940 Print as floating point. This works only with sizes @samp{w} and
2944 These letters specify both the unit size and the output format:
2947 Print a null-terminated string of characters. Any explicitly specified
2948 unit size is ignored; instead, the unit is however many bytes it takes
2949 to reach a null character (including the null character).
2952 Print a machine instruction in assembler syntax (or nearly). Any
2953 specified unit size is ignored; the number of bytes in an instruction
2954 varies depending on the type of machine, the opcode and the addressing
2955 modes used. The command @samp{disassemble} gives an alternative way of
2956 inspecting machine instructions. @xref{Machine Code}.
2959 If either the manner of printing or the size of unit fails to be specified,
2960 the default is to use the same one that was used last. If you don't want
2961 to use any letters after the slash, you can omit the slash as well.
2963 You can also omit the address to examine. Then the address used is just
2964 after the last unit examined. This is why string and instruction
2965 formats actually compute a unit-size based on the data: so that the next
2966 string or instruction examined will start in the right place.
2968 When the @samp{print} command shows a value that resides in memory,
2969 @samp{print} also sets the default address for the @samp{x} command.
2970 @samp{info line} also sets the default for @samp{x}, to the address of
2971 the start of the machine code for the specified line (@pxref{Machine
2972 Code}), and @samp{info breakpoints} sets it to the address of the last
2973 breakpoint listed (@pxref{Set Breaks}).
2975 When you use @key{RET} to repeat an @samp{x} command, the address
2976 specified previously (if any) is ignored, so that the repeated command
2977 examines the successive locations in memory rather than the same ones.
2979 You can examine several consecutive units of memory with one command by
2980 writing a repeat-count after the slash (before the format letters, if any).
2981 The repeat count must be a decimal integer. It has the same effect as
2982 repeating the @samp{x} command that many times except that the output may
2983 be more compact with several units per line. For example,
2990 prints ten instructions starting with the one to be executed next in the
2991 selected frame. After doing this, you could print another seven following
2999 in which the format and address are allowed to default.
3003 The addresses and contents printed by the @samp{x} command are not put
3004 in the value history because there is often too much of them and they
3005 would get in the way. Instead, _GDBN__ makes these values available for
3006 subsequent use in expressions as values of the convenience variables
3007 @code{$_} and @code{$__}. After an @samp{x} command, the last address
3008 examined is available for use in expressions in the convenience variable
3009 @code{$_}. The contents of that address, as examined, are available in
3010 the convenience variable @code{$__}.
3012 If the @samp{x} command has a repeat count, the address and contents saved
3013 are from the last memory unit printed; this is not the same as the last
3014 address printed if several units were printed on the last line of output.
3016 @node Auto Display,,,
3017 @section Automatic Display
3018 @cindex automatic display
3019 @cindex display of expressions
3021 If you find that you want to print the value of an expression frequently
3022 (to see how it changes), you might want to add it to the @dfn{automatic
3023 display list} so that _GDBN__ will print its value each time the program stops.
3024 Each expression added to the list is given a number to identify it;
3025 to remove an expression from the list, you specify that number.
3026 The automatic display looks like this:
3030 3: bar[5] = (struct hack *) 0x3804
3034 showing item numbers, expressions and their current values.
3037 @item display @var{exp}
3039 Add the expression @var{exp} to the list of expressions to display
3040 each time the program stops. @xref{Expressions}.
3042 @item display/@var{fmt} @var{exp}
3043 For @var{fmt} specifying only a display format and not a size or
3044 count, add the expression @var{exp} to the auto-display list but
3045 arranges to display it each time in the specified format @var{fmt}.
3047 @item display/@var{fmt} @var{addr}
3048 For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
3049 number of units, add the expression @var{addr} as a memory address to
3050 be examined each time the program stops. Examining means in effect
3051 doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory}.
3054 For example, @samp{display/i $pc} can be helpful, to see the machine
3055 instruction about to be executed each time execution stops (@samp{$pc}
3056 is a common name for the program counter; @pxref{Registers}).
3059 @item undisplay @var{dnums}@dots{}
3060 @itemx delete display @var{dnums}@dots{}
3061 @kindex delete display
3063 Remove item numbers @var{dnums} from the list of expressions to display.
3065 @item disable display @var{dnums}@dots{}
3066 @kindex disable display
3067 Disable the display of item numbers @var{dnums}. A disabled display
3068 item is not printed automatically, but is not forgotten. It may be
3069 enabled again later.
3071 @item enable display @var{dnums}@dots{}
3072 @kindex enable display
3073 Enable display of item numbers @var{dnums}. It becomes effective once
3074 again in auto display of its expression, until you specify otherwise.
3077 Display the current values of the expressions on the list, just as is
3078 done when the program stops.
3081 @kindex info display
3082 Print the list of expressions previously set up to display
3083 automatically, each one with its item number, but without showing the
3084 values. This includes disabled expressions, which are marked as such.
3085 It also includes expressions which would not be displayed right now
3086 because they refer to automatic variables not currently available.
3089 If a display expression refers to local variables, then it does not make
3090 sense outside the lexical context for which it was set up. Such an
3091 expression is disabled when execution enters a context where one of its
3092 variables is not defined. For example, if you give the command
3093 @samp{display name} while inside a function with an argument
3094 @code{name}, then this argument will be displayed while the program
3095 continues to stop inside that function. When it stops elsewhere---where
3096 there is no variable @samp{name}---display is disabled. The next time
3097 your program stops where @samp{name} is meaningful, you can enable the
3098 display expression once again.
3100 @node Print Settings,,,
3101 @section Print Settings
3103 @cindex format options
3104 @cindex print settings
3105 _GDBN__ provides a few ways to control how arrays, structures, and symbols are
3109 @item set array-max @var{number-of-elements}
3110 @kindex set array-max
3111 If _GDBN__ is printing a large array, it will stop printing after it has
3112 printed the number of elements set by the @samp{set array-max} command.
3113 This limit also applies to the display of strings.
3115 @item show array-max
3116 @kindex show array-max
3117 Display the number of elements of a large array that _GDBN__ will print
3118 before losing patience.
3120 @item set arrayprint
3121 @itemx set arrayprint on
3122 @kindex set arrayprint
3123 _GDBN__ will pretty print arrays. This format is more convenient to read,
3124 but uses more space. The default is off.
3126 @item set arrayprint off.
3127 Return to compressed format for arrays.
3129 @item show arrayprint
3130 @kindex show arrayprint
3131 Show whether compressed or pretty format is selected for displaying
3135 @itemx set demangle on
3136 @kindex set demangle
3137 Print C++ names in their source form rather than in the mangled form
3138 in which they are passed to the assembler and linker for type-safe linkage.
3142 @kindex show demangle
3143 Show whether C++ names will be printed in mangled or demangled form.
3145 @item set asm-demangle
3146 @itemx set asm-demangle on
3147 @kindex set asm-demangle
3148 Print C++ names in their source form rather than their mangled form, even
3149 in assembler code printouts such as instruction disassemblies.
3152 @item show asm-demangle
3153 @kindex show asm-demangle
3154 Show whether C++ names in assembly listings will be printed in mangled
3158 @itemx set vtblprint on
3159 @kindex set vtblprint
3160 Pretty print C++ virtual function tables. The default is off.
3162 @item set vtblprint off
3163 Do not pretty print C++ virtual function tables.
3165 @item show vtblprint
3166 @kindex show vtblprint
3167 Show whether C++ virtual function tables are pretty printed, or not.
3169 @item set addressprint
3170 @item set addressprint on
3171 @kindex set addressprint
3172 _GDBN__ will print memory addresses in stack traces, structure values, pointer
3173 values, breakpoints, etc. The default is on.
3175 @item set addressprint off
3176 Do not print addresses.
3178 @item show addressprint
3179 @kindex show addressprint
3180 Show whether or not addresses are to be printed.
3182 @item set prettyprint on
3183 @kindex set prettyprint
3184 Cause _GDBN__ to print structures in an indented format with one member per
3198 @item set prettyprint off
3199 Cause _GDBN__ to print structures in a compact format, like this:
3202 $1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \
3207 This is the default format.
3209 @item show prettyprint
3210 @kindex show prettyprint
3211 Show which format _GDBN__ will use to print structures.
3213 @item set unionprint on
3214 @kindex set unionprint
3215 Tell _GDBN__ to print unions which are contained in structures. This is the
3218 @item set unionprint off
3219 Tell _GDBN__ not to print unions which are contained in structures.
3221 @item show unionprint
3222 @kindex show unionprint
3223 Ask _GDBN__ whether or not it will print unions which are contained in
3226 For example, given the declarations
3229 typedef enum @{Tree, Bug@} Species;
3230 typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
3231 typedef enum @{Caterpillar, Cocoon, Butterfly@} Bug_forms;
3241 struct thing foo = @{Tree, @{Acorn@}@};
3245 with @samp{set unionprint on} in effect @samp{p foo} would print
3248 $1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
3252 and with @samp{set unionprint off} in effect it would print
3255 $1 = @{it = Tree, form = @{...@}@}
3259 @node Value History,,,
3260 @section Value History
3262 @cindex value history
3263 Values printed by the @samp{print} command are saved in _GDBN__'s @dfn{value
3264 history} so that you can refer to them in other expressions. Values are
3265 kept until the symbol table is re-read or discarded (for example with
3266 the @samp{file} or @samp{symbol-file} commands). When the symbol table
3267 changes, the value history is discarded, since the values may contain
3268 pointers back to the types defined in the symbol table.
3272 @cindex history number
3273 The values printed are given @dfn{history numbers} for you to refer to them
3274 by. These are successive integers starting with 1. @samp{print} shows you
3275 the history number assigned to a value by printing @samp{$@var{num} = }
3276 before the value; here @var{num} is the history number.
3278 To refer to any previous value, use @samp{$} followed by the value's
3279 history number. The output printed by @samp{print} is designed to
3280 remind you of this. Just @code{$} refers to the most recent value in
3281 the history, and @code{$$} refers to the value before that.
3282 @code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
3283 is the value just prior to @code{$$}, @code{$$1} is equivalent to
3284 @code{$$}, and @code{$$0} is equivalent to @code{$}.
3286 For example, suppose you have just printed a pointer to a structure and
3287 want to see the contents of the structure. It suffices to type
3293 If you have a chain of structures where the component @samp{next} points
3294 to the next one, you can print the contents of the next one with this:
3301 You can print successive links in the chain by repeating this
3302 command---which you can do by just typing @key{RET}.
3304 Note that the history records values, not expressions. If the value of
3305 @code{x} is 4 and you type these commands:
3313 then the value recorded in the value history by the @samp{print} command
3314 remains 4 even though the value of @code{x} has changed.
3320 @kindex info history
3321 These two commands are synonymous. Either form will print the last ten
3322 values in the value history, with their item numbers. This is like
3323 @samp{p@ $$9} repeated ten times, except that @samp{info values} does
3324 not change the history.
3326 @item info values @var{n}
3327 Print ten history values centered on history item number @var{n}.
3330 Print ten history values just after the values last printed.
3333 @node Convenience Vars,,,
3334 @section Convenience Variables
3336 @cindex convenience variables
3337 _GDBN__ provides @dfn{convenience variables} that you can use within
3338 _GDBN__ to hold on to a value and refer to it later. These variables
3339 exist entirely within _GDBN__; they are not part of your program, and
3340 setting a convenience variable has no direct effect on further execution
3341 of your program. That's why you can use them freely.
3343 Convenience variables have names starting with @samp{$}. Any name starting
3344 with @samp{$} can be used for a convenience variable, unless it is one of
3345 the predefined machine-specific register names (@pxref{Registers}).
3347 You can save a value in a convenience variable with an assignment
3348 expression, just as you would set a variable in your program. Example:
3351 set $foo = *object_ptr
3355 would save in @code{$foo} the value contained in the object pointed to by
3358 Using a convenience variable for the first time creates it; but its value
3359 is @code{void} until you assign a new value. You can alter the value with
3360 another assignment at any time.
3362 Convenience variables have no fixed types. You can assign a convenience
3363 variable any type of value, including structures and arrays, even if
3364 that variable already has a value of a different type. The convenience
3365 variable, when used as an expression, has the type of its current value.
3368 @item info convenience
3369 @kindex info convenience
3370 Print a list of convenience variables used so far, and their values.
3371 Abbreviated @samp{i con}.
3374 One of the ways to use a convenience variable is as a counter to be
3375 incremented or a pointer to be advanced. For example, to print
3376 a field from successive elements of an array of structures:
3380 print bar[$i++]->contents
3381 @i{@dots{}repeat that command by typing @key{RET}.}
3384 Some convenience variables are created automatically by _GDBN__ and given
3385 values likely to be useful.
3389 The variable @code{$_} is automatically set by the @samp{x} command to
3390 the last address examined (@pxref{Memory}). Other commands which
3391 provide a default address for @samp{x} to examine also set @code{$_}
3392 to that address; these commands include @samp{info line} and @samp{info
3396 The variable @code{$__} is automatically set by the @samp{x} command
3397 to the value found in the last address examined.
3404 Machine register contents can be referred to in expressions as variables
3405 with names starting with @samp{$}. The names of registers are different
3406 for each machine; use @samp{info registers} to see the names used on
3407 your machine. The names @code{$pc} and @code{$sp} are used on most
3408 machines for the program counter register and the stack pointer. Often
3409 @code{$fp} is used for a register that contains a pointer to the current
3410 stack frame, and @code{$ps} is sometimes used for a register that
3411 contains the processor status. These standard register names may be
3412 available on your machine even though the @code{info registers} command
3413 shows other names. For example, on the SPARC, @code{info registers}
3414 displays the processor status register as @code{$psr} but you can also
3415 refer to it as @code{$ps}.
3417 _GDBN__ always considers the contents of an ordinary register as an
3418 integer when the register is examined in this way. Some machines have
3419 special registers which can hold nothing but floating point; these
3420 registers are considered to have floating point values. There is no way
3421 to refer to the contents of an ordinary register as floating point value
3422 (although you can @emph{print} it as a floating point value with
3423 @samp{print/f $@var{regname}}).
3425 Some registers have distinct ``raw'' and ``virtual'' data formats. This
3426 means that the data format in which the register contents are saved by
3427 the operating system is not the same one that your program normally
3428 sees. For example, the registers of the 68881 floating point
3429 coprocessor are always saved in ``extended'' (raw) format, but all C
3430 programs expect to work with ``double'' (virtual) format. In such
3431 cases, _GDBN__ normally works with the virtual format only (the format that
3432 makes sense for your program), but the @samp{info registers} command
3433 prints the data in both formats.
3435 Normally, register values are relative to the selected stack frame
3436 (@pxref{Selection}). This means that you get the value that the register
3437 would contain if all stack frames farther in were exited and their saved
3438 registers restored. In order to see the contents of hardware registers,
3439 you must select the innermost frame (with @samp{frame 0}).
3441 However, _GDBN__ must deduce where registers are saved, from the machine
3442 code generated by your compiler. If some registers are not saved, or if
3443 _GDBN__ is unable to locate the saved registers, the selected stack
3444 frame will make no difference.
3447 @item info registers
3448 @kindex info registers
3449 Print the names and relativized values of all registers.
3451 @item info registers @var{regname}
3452 Print the relativized value of register @var{regname}. @var{regname}
3453 may be any register name valid on the machine you are using, with
3454 or without the initial @samp{$}.
3457 For example, you could print the program counter in hex with
3464 or print the instruction to be executed next with
3471 or add four to the stack pointer with
3478 The last is a way of removing one word from the stack, on machines where
3479 stacks grow downward in memory (most machines, nowadays). This assumes
3480 that the innermost stack frame is selected. Setting @code{$sp} is
3481 not allowed when other stack frames are selected. (To pop entire frames
3482 off the stack, regardless of machine architecture, use @samp{return};
3486 @chapter Examining the Symbol Table
3488 The commands described in this section allow you to inquire about the
3489 symbols (names of variables, functions and types) defined in your
3490 program. This information is found by _GDBN__ in the symbol table loaded by
3491 the @samp{symbol-file} command; it is inherent in the text of your
3492 program and does not change as the program executes.
3495 @item info address @var{symbol}
3496 @kindex info address
3497 Describe where the data for @var{symbol} is stored. For a register
3498 variable, this says which register it is kept in. For a non-register
3499 local variable, this prints the stack-frame offset at which the variable
3502 Note the contrast with @samp{print &@var{symbol}}, which does not work
3503 at all for a register variables, and for a stack local variable prints
3504 the exact address of the current instantiation of the variable.
3506 @item whatis @var{exp}
3508 Print the data type of expression @var{exp}. @var{exp} is not
3509 actually evaluated, and any side-effecting operations (such as
3510 assignments or function calls) inside it do not take place.
3514 Print the data type of @code{$}, the last value in the value history.
3516 @item ptype @var{typename}
3518 Print a description of data type @var{typename}. @var{typename} may be
3519 the name of a type, or for C code it may have the form
3520 @samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or
3521 @samp{enum @var{enum-tag}}.@refill
3523 @item ptype @var{exp}
3524 Print a description of the type of expression @var{exp}. This is like
3525 @samp{whatis} except it prints a detailed description, instead of just
3526 the name of the type. For example, if the type of a variable is
3527 @samp{struct complex @{double real; double imag;@}}, @samp{whatis} will
3528 print @samp{struct complex} and @samp{ptype} will print @samp{struct
3529 complex @{double real; double imag;@}}
3532 @kindex info sources
3533 Print the names of all source files in the program for which there
3534 is debugging information.
3536 @item info functions
3537 @kindex info functions
3538 Print the names and data types of all defined functions.
3540 @item info functions @var{regexp}
3541 Print the names and data types of all defined functions
3542 whose names contain a match for regular expression @var{regexp}.
3543 Thus, @samp{info fun step} finds all functions whose names
3544 include @samp{step}; @samp{info fun ^step} finds those whose names
3545 start with @samp{step}.
3547 @item info variables
3548 @kindex info variables
3549 Print the names and data types of all variables that are declared
3550 outside of functions (i.e., excluding local variables).
3552 @item info variables @var{regexp}
3553 Print the names and data types of all variables (except for local
3554 variables) whose names contain a match for regular expression
3559 This was never implemented.
3561 @itemx info methods @var{regexp}
3562 @kindex info methods
3563 The @samp{info-methods} command permits the user to examine all defined
3564 methods within C++ program, or (with the @var{regexp} argument) a
3565 specific set of methods found in the various C++ classes. Many
3566 C++ classes provide a large number of methods. Thus, the output
3567 from the @samp{ptype} command can be overwhelming and hard to use. The
3568 @samp{info-methods} command filters the methods, printing only those
3569 which match the regular-expression @var{regexp}.
3572 @item printsyms @var{filename}
3574 Write a complete dump of the debugger's symbol data into the
3575 file @var{filename}.
3579 @chapter Altering Execution
3581 Once you think you have found an error in the program, you might want to
3582 find out for certain whether correcting the apparent error would lead to
3583 correct results in the rest of the run. You can find the answer by
3584 experiment, using the _GDBN__ features for altering execution of the
3587 For example, you can store new values into variables or memory
3588 locations, give the program a signal, restart it at a different address,
3589 or even return prematurely from a function to its caller.
3592 @section Assignment to Variables
3595 @cindex setting variables
3596 To alter the value of a variable, evaluate an assignment expression.
3597 @xref{Expressions}. For example,
3604 would store the value 4 into the variable @code{x}, and then print the
3605 value of the assignment expression (which is 4). All the assignment
3606 operators of C are supported, including the increment operators
3607 @samp{++} and @samp{--}, and combining assignments such as @samp{+=} and
3611 @kindex set variable
3612 @cindex variables, setting
3613 If you are not interested in seeing the value of the assignment, use the
3614 @samp{set} command instead of the @samp{print} command. @samp{set} is
3615 really the same as @samp{print} except that the expression's value is not
3616 printed and is not put in the value history (@pxref{Value History}). The
3617 expression is evaluated only for side effects.
3619 If the beginning of the argument string of the @samp{set} command
3620 appears identical to a @samp{set} subcommand, use the @samp{set
3621 variable} command instead of just @samp{set}. This command is identical
3622 to @samp{set} except for its lack of subcommands.
3624 _GDBN__ allows more implicit conversions in assignments than C does; you can
3625 freely store an integer value into a pointer variable or vice versa, and
3626 any structure can be converted to any other structure that is the same
3628 @comment FIXME: how do structs align/pad in these conversions?
3629 @comment /pesch@cygnus.com 18dec1990
3631 To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
3632 construct to generate a value of specified type at a specified address
3633 (@pxref{Expressions}). For example, @code{@{int@}0x83040} refers
3634 to memory location @code{0x83040} as an integer (which implies a certain size
3635 and representation in memory), and
3638 set @{int@}0x83040 = 4
3642 stores the value 4 into that memory location.
3645 @section Continuing at a Different Address
3647 Ordinarily, when you continue the program, you do so at the place where
3648 it stopped, with the @samp{cont} command. You can instead continue at
3649 an address of your own choosing, with the following commands:
3652 @item jump @var{linenum}
3654 Resume execution at line number @var{linenum}. Execution may stop
3655 immediately if there is a breakpoint there.
3657 The @samp{jump} command does not change the current stack frame, or
3658 the stack pointer, or the contents of any memory location or any
3659 register other than the program counter. If line @var{linenum} is in
3660 a different function from the one currently executing, the results may
3661 be bizarre if the two functions expect different patterns of arguments or
3662 of local variables. For this reason, the @samp{jump} command requests
3663 confirmation if the specified line is not in the function currently
3664 executing. However, even bizarre results are predictable based on
3665 careful study of the machine-language code of the program.
3667 @item jump *@var{address}
3668 Resume execution at the instruction at address @var{address}.
3671 You can get much the same effect as the @code{jump} command by storing a
3672 new value into the register @code{$pc}. The difference is that this
3673 does not start the program running; it only changes the address where it
3674 @emph{will} run when it is continued. For example,
3681 causes the next @samp{cont} command or stepping command to execute at
3682 address 0x485, rather than at the address where the program stopped.
3685 The most common occasion to use the @samp{jump} command is to back up,
3686 perhaps with more breakpoints set, over a portion of a program that has
3690 @section Giving the Program a Signal
3693 @item signal @var{signalnum}
3695 Resume execution where the program stopped, but give it immediately the
3696 signal number @var{signalnum}.
3698 Alternatively, if @var{signalnum} is zero, continue execution without
3699 giving a signal. This is useful when the program stopped on account of
3700 a signal and would ordinary see the signal when resumed with the
3701 @samp{cont} command; @samp{signal 0} causes it to resume without a
3706 @section Returning from a Function
3710 @cindex returning from a function
3712 You can cancel execution of a function call with the @samp{return}
3716 This command abandons execution of a function. When you use
3717 @code{return}, _GDBN__ discards the selected stack frame (and all frames
3718 within it). You can think of this as making the discarded frame return
3719 prematurely. If you wish to specify a value to be returned, give that
3720 value as the argument to @code{return}.
3722 This pops the selected stack frame (@pxref{Selection}), and any other
3723 frames inside of it, leaving its caller as the innermost remaining
3724 frame. That frame becomes selected. The specified value is stored in
3725 the registers used for returning values of functions.
3727 The @samp{return} command does not resume execution; it leaves the
3728 program stopped in the state that would exist if the function had just
3729 returned. In contrast, the @samp{finish} command (@pxref{Stepping})
3730 resumes execution until the selected stack frame returns naturally.
3733 @section Calling your Program's Functions
3735 @cindex calling functions
3738 @item call @var{expr}
3739 Evaluate the expression @var{expr} without displaying @code{void}
3743 You can use this variant of the @samp{print} command if you want to
3744 execute a function from your program, but without cluttering the output
3745 with @code{void} returned values. The result is printed and saved in
3746 the value history, if it is not void.
3749 @chapter _GDBN__'s Files
3751 @section Commands to Specify Files
3752 @cindex core dump file
3753 @cindex symbol table
3754 _GDBN__ needs to know the file name of the program to be debugged, both in
3755 order to read its symbol table and in order to start the program. To
3756 debug a core dump of a previous run, _GDBN__ must be told the file name of
3759 The usual way to specify the executable and core dump file names is with
3760 the command arguments given when you start _GDBN__, as discussed in
3763 Occasionally it is necessary to change to a different file during a
3764 _GDBN__ session. Or you may run _GDBN__ and forget to specify the files you
3765 want to use. In these situations the _GDBN__ commands to specify new files
3769 @item file @var{filename}
3770 @cindex executable file
3772 Use @var{filename} as the program to be debugged. It is read for its
3773 symbols and for the contents of pure memory. It is also the program
3774 executed when you use the @samp{run} command. If you do not specify a
3775 directory and the file is not found in _GDBN__'s working directory,
3776 _GDBN__ will use the environment variable @code{PATH} as a list of
3777 directories to search, just as the shell does when looking for a program
3780 @samp{file} with no argument makes _GDBN__ discard any information it
3781 has on both executable file and the symbol table.
3783 @item exec-file @var{filename}
3785 Specify that the program to be run (but not the symbol table) is found
3786 in @var{filename}. _GDBN__ will search the environment variable @code{PATH}
3787 if necessary to locate the program.
3789 @item symbol-file @var{filename}
3791 Read symbol table information from file @var{filename}. @code{PATH} is
3792 searched when necessary. Use the @samp{file} command to get both symbol
3793 table and program to run from the same file.
3795 @samp{symbol-file} with no argument clears out _GDBN__'s information on your
3796 program's symbol table.
3798 The @samp{symbol-file} command causes _GDBN__ to forget the contents of its
3799 convenience variables, the value history, and all breakpoints and
3800 auto-display expressions. This is because they may contain pointers to
3801 the internal data recording symbols and data types, which are part of
3802 the old symbol table data being discarded inside _GDBN__.
3804 On some kinds of object files, the @samp{symbol-file} command does not
3805 actually read the symbol table in full right away. Instead, it scans
3806 the symbol table quickly to find which source files and which symbols
3807 are present. The details are read later, one source file at a time,
3808 when they are needed.
3810 The purpose of this two-stage reading strategy is to make _GDBN__ start up
3811 faster. For the most part, it is invisible except for occasional pauses
3812 while the symbol table details for a particular source file are being
3813 read. (The @samp{set verbose} command can turn these pauses into
3814 messages if desired. @xref{Messages/Warnings}).
3816 When the symbol table is stored in COFF format, @samp{symbol-file} does
3817 read the symbol table data in full right away. We haven't implemented
3818 the two-stage strategy for COFF yet.
3820 When _GDBN__ is configured for a particular environment, it will understand
3821 debugging information in whatever format is the standard generated for
3822 that environment; you may use either the GNU compiler _GCC__, or other
3823 compilers that adhere to the local conventions. Best results are
3824 usually obtained from _GCC__; for example, using _GCC__ you can generate
3825 debugging information for optimized code.
3827 @item core-file @var{filename}
3828 @itemx core @var{filename}
3831 Specify the whereabouts of a core dump file to be used as the ``contents
3832 of memory''. Traditionally, core files contain only some parts of the
3833 address space of the process that generated them; _GDBN__ can access the
3834 executable file itself for other parts.
3836 @samp{core-file} with no argument specifies that no core file is
3839 Note that the core file is ignored when your program is actually running
3840 under _GDBN__. So, if you have been running the program and you wish to
3841 debug a core file instead, you must kill the subprocess in which the
3842 program is running. To do this, use the @samp{kill} command
3843 (@pxref{Kill Process}).
3845 @item load @var{filename}
3847 This command will dynamically link @var{filename} on the current target,
3848 performing any necessary downloads, then add @var{filename}'s symbol
3849 table in the same way as the @samp{add-syms} command.
3851 @item add-syms @var{filename} @var{address}
3853 @cindex dynamic linking
3854 The @samp{add-syms} command reads additional symbol table information
3855 from the file @var{filename}. You would use this command when that file
3856 has been dynamically loaded (by some other means) into the program that
3857 is running. @var{address} should be the memory address at which the
3858 file has been loaded; _GDBN__ cannot figure this out for itself.
3860 The symbol table of the file @var{filename} is added to the symbol table
3861 originally read with the @samp{symbol-file} command. You can use the
3862 @samp{add-syms} command any number of times; the new symbol data thus
3863 read keeps adding to the old. The @samp{symbol-file} command forgets
3864 all the symbol data _GDBN__ has read.
3870 @samp{info files} and @samp{info target} are synonymous; both print the
3871 current targets (@pxref{Targets}), including the names of the
3872 executable and core dump files currently in use by _GDBN__, and the files
3873 from which symbols were loaded.
3875 Beware: the similar command @samp{info targets} lists all possible
3876 targets rather than current ones.
3880 All file-specifying commands allow both absolute and relative file names
3881 as arguments. _GDBN__ always converts the file name to an absolute path
3882 name and remembers it that way.
3884 @kindex sharedlibrary
3886 @cindex shared libraries
3888 _GDBN__ supports the SunOS shared library format. Symbols from a shared
3889 library cannot be referenced before the shared library has been linked
3890 with the program. (That is to say, after you type @samp{run} and
3891 the function @code{main} has been entered; or when examining core
3892 files.) Once the shared library has been linked in, you can use the
3896 @item sharedlibrary @var{regex}
3897 @itemx share @var{regex}
3898 Load shared object library symbols for files matching a UNIX regular
3902 @itemx sharedlibrary
3903 Load symbols for all shared libraries.
3906 @itemx info sharedlibrary
3907 @kindex info sharedlibrary
3909 Print the names of the shared libraries which are currently loaded.
3912 @section Errors Reading Symbols
3913 While a symbol file is being read, _GDBN__ will occasionally encounter
3914 problems, such as symbol types it does not recognize, or known bugs in
3915 compiler output. By default, it prints one message about each such
3916 type of problem, no matter how many times the problem occurs. You can
3917 ask it to print more messages, to see how many times the problems occur,
3918 or can shut the messages off entirely, with the @samp{set
3919 complaints} command (@xref{Messages/Warnings}).
3921 The messages currently printed, and their meanings, are:
3924 @item inner block not inside outer block in @var{symbol}
3926 The symbol information shows where symbol scopes begin and end
3927 (such as at the start of a function or a block of statements). This
3928 error indicates that an inner scope block is not fully contained
3929 in its outer scope blocks. _GDBN__ circumvents the problem by treating
3930 the inner block as if it had the same scope as the outer block.
3931 @var{symbol} may be ``(don't know)'' if the outer block is not
3934 @item block at @var{address} out of order
3936 The symbol information for symbol scope blocks should occur in
3937 order of increasing addresses. This error indicates that it does not
3938 do so. _GDBN__ does not circumvent this problem, and will have trouble
3939 locating symbols in the source file whose symbols being read. (You
3940 can often determine what source file is affected by specifying
3941 @samp{set verbose on}. @xref{Messages/Warnings}.)
3943 @item bad block start address patched
3945 The symbol information for a symbol scope block has a start address
3946 smaller than the address of the preceding source line. This is known
3947 to occur in the SunOS 4.1.1 (and earlier) C compiler. _GDBN__ circumvents
3948 the problem by treating the symbol scope block as starting on the
3949 previous source line.
3951 @comment @item{encountered DBX-style class variable debugging information.
3952 @comment You seem to have compiled your program with "g++ -g0" instead of "g++ -g".
3953 @comment Therefore _GDBN__ will not know about your class variables}
3955 @comment This error indicates that the symbol information produced for a C++
3956 @comment program includes zero-size fields, which indicated static fields in
3957 @comment a previous release of the G++ compiler. This message is probably
3960 @item bad string table offset in symbol @var{n}
3963 Symbol number @var{n} contains a pointer into the string table which is
3964 larger than the size of the string table. _GDBN__ circumvents the problem
3965 by considering the symbol to have the name @code{foo}, which may cause
3966 other problems if many symbols end up with this name.
3968 @item unknown symbol type @code{0xNN}
3970 The symbol information contains new data types that _GDBN__ does not yet
3971 know how to read. @code{0xNN} is the symbol type of the misunderstood
3972 information, in hexadecimal. _GDBN__ circumvents the error by ignoring
3973 this symbol information. This will usually allow the program to be
3974 debugged, though certain symbols will not be accessible. If you
3975 encounter such a problem and feel like debugging it, you can debug _GDBP__
3976 with itself, breakpoint on "complain", then go "up" to
3977 read_dbx_symtab() and examine *bufp to see the symbol.
3979 @c @item stub type has NULL name
3981 @c FIXME, Mike Tiemann needs to write about what this means.
3983 @item const/volatile indicator missing, got 'X'
3985 The symbol information for a C++ type is missing some information that
3986 the compiler should have output for it.
3988 @item C++ type mismatch between compiler and debugger
3990 The debugger could not parse a type specification output by the compiler
3991 for some C++ object.
3996 @chapter Specifying a Debugging Target
3997 @cindex debugging target
3999 A @dfn{target} is an interface between the debugger and a particular
4000 kind of file or process.
4002 Often, you will be able to run _GDBN__ in the same host environment as the
4003 program you are debugging; in that case, the debugging target can just be
4004 specified as a side effect of the @samp{file} or @samp{core} commands.
4005 When you need more flexibility---for example, running _GDBN__ on a
4006 physically separate host, controlling standalone systems over a
4007 serial port, or realtime systems over a TCP/IP connection---you can use
4008 the @samp{target} command.
4010 @node Active Targets,,,
4011 @section Active Targets
4012 @cindex stacking targets
4013 @cindex active targets
4014 @cindex multiple targets
4016 Targets are managed in three @dfn{strata} that correspond to different
4017 classes of target: processes, core files, and executable files. This
4018 allows you to (for example) start a process and inspect its activity
4019 without abandoning your work on a core file.
4021 More than one target can potentially respond to a request. In
4022 particular, when you access memory _GDBN__ will walk down the three strata of
4023 targets until it finds a target that can handle that particular address.
4025 Strata are always examined in a fixed order: first a process if there is
4026 one, then a core file if there is one, and finally an executable file if
4027 there is one of those.
4029 When you specify a new target in a given stratum, it replaces any target
4030 previously in that stratum.
4032 To get rid of a target without replacing it, use the @samp{detach}
4033 command. The related command @samp{attach} provides you with a way of
4034 choosing a particular running process as a new target. @xref{Attach}.
4036 @node Target Commands,,,
4037 @section Commands for Managing Targets
4040 @item target @var{type} @var{parameters}
4041 Connects the _GDBN__ host environment to a target machine or process. A
4042 target is typically a protocol for talking to debugging facilities. You
4043 use the argument @var{type} to specify the type or protocol of the
4044 target machine; for example, @samp{target vxworks} for a TCP/IP link to
4047 Further @var{parameters} are interpreted by the target protocol, but
4048 typically include things like device names or host names to connect
4049 with, process numbers, and baud rates. Executing
4055 (without any parameters) will issue a message about what
4056 parameters are required for that target type.
4059 @kindex info targets
4060 Displays the names of all targets available. Beware: the similar
4061 command @samp{info target} displays targets currently in use rather than
4062 all available ones. @samp{info files} gives the same information as
4063 @samp{info target} (@pxref{Files}).
4066 Here are some common targets (available, or not, depending on _GDBN__
4070 @item target exec @var{prog}
4072 An executable file. @samp{target exec @var{prog}} is the same as
4073 @samp{exec-file @var{prog}}.
4075 @item target core @var{filename}
4077 A core dump file. @samp{target core @var{filename}} is the same as
4078 @samp{core-file @var{filename}}.
4080 @item target remote @var{dev}
4081 @kindex target remote
4082 Remote serial target in _GDBP__-specific protocol. The argument @var{dev}
4083 specifies what serial device to use for the connection (e.g.
4087 @item target amd-eb @var{dev} @var{speed} @var{PROG}
4088 @kindex target amd-eb
4090 Remote PC-resident AMD EB29K board, attached over serial lines.
4091 @var{dev} is the serial device, as for @samp{target remote};
4092 @samp{speed} allows you to specify the linespeed; and @var{PROG} is the
4093 name of the program to be debugged, as it appears to DOS on the PC.
4094 @xref{EB29K Remote}.
4098 @item target nindy @var{devicename}
4099 @kindex target nindy
4100 An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is
4101 the name of the serial device to use for the connection, e.g.
4106 @item target vxworks @var{machinename}
4107 @kindex target vxworks
4108 A VxWorks system, attached via TCP/IP. The argument @var{machinename}
4109 is the target system's machine name or IP address.
4115 Different targets are available on different configurations of _GDBN__; your
4116 configuration may have more or fewer targets.
4120 @section Remote Debugging
4121 @cindex remote debugging
4123 If you are trying to debug a program running on a machine that can't run
4124 _GDBN__ in the usual way, it is often useful to use remote debugging. For
4125 example, you might be debugging an operating system kernel, or debugging
4126 a small system which does not have a general purpose operating system
4127 powerful enough to run a full-featured debugger. Currently _GDBN__ supports
4128 remote debugging over a serial connection, and (using Sun RPC) over a
4131 The program to be debugged on the remote machine needs to contain a
4132 debugging device driver which talks to _GDBN__ over the serial line. The
4133 same version of _GDBN__ that is used ordinarily can be used for this.
4134 Several sample remote debugging drivers are distributed with _GDBN__; see
4135 the @file{README} file in the _GDBN__ distribution for more information.
4137 For details of the communication protocol, see the comments in the _GDBN__
4138 source file @file{remote.c}.
4140 To start remote debugging, first run _GDBN__ and specify as an executable file
4141 the program that is running in the remote machine. This tells _GDBN__ how
4142 to find the program's symbols and the contents of its pure text. Then
4143 establish communication using the @samp{target remote} command with a device
4144 name as an argument. For example:
4147 target remote /dev/ttyb
4151 if the serial line is connected to the device named @file{/dev/ttyb}. This
4152 will stop the remote machine if it is not already stopped.
4154 Now you can use all the usual commands to examine and change data and to
4155 step and continue the remote program.
4157 To resume the remote program and stop debugging it, use the @samp{detach}
4160 Other remote targets be available in your
4161 configuration of _GDBN__; use @samp{info targets} to list them.
4166 For a target attached through a serial line, this command sends a
4167 ``break'' to the remote target system; this is only useful if the target
4168 has been equipped with a circuit to perform a hard reset (or some other
4169 interesting action) when a break is detected.
4172 @node Controlling _GDBN__,,,
4173 @chapter Controlling _GDBN__
4175 You can alter many aspects of _GDBN__'s interaction with you by using
4176 the @samp{set} command.
4181 _GDBN__ indicates its readiness to read a command by printing a string
4182 called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You can
4183 change the prompt string with the @samp{set prompt} command. For
4184 instance, when debugging _GDBN__ with _GDBN__, it is useful to change the prompt
4185 in one of the _GDBN__<>s so that you tell which one you are talking to.
4188 @item set prompt @var{newprompt}
4190 Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth.
4193 Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
4197 @section Command Editing
4199 @cindex command line editing
4200 _GDBN__ reads its input commands via the @dfn{readline} interface. This
4201 GNU library provides consistent behavior for programs which provide a
4202 command line interface to the user. Advantages are @samp{emacs}-style
4203 or @samp{vi}-style inline editing of commands, @samp{csh}-like history
4204 substitution, and a storage and recall of command history across
4207 You may control the behavior of command line editing in _GDBN__ with the
4208 command @samp{set}. You may check the status of any of these settings
4209 with the command @samp{show}.
4215 @itemx set editing on
4216 Enable command line editing (enabled by default).
4218 @item set editing off
4219 Disable command line editing.
4221 @kindex show editing
4223 Show whether command line editing is enabled.
4226 @section Command History
4227 @cindex history substitution
4228 @cindex history file
4229 @kindex set history file
4230 @item set history file @var{filename}
4231 Set the name of the _GDBN__ command history file to @var{filename}. This is
4232 the file from which _GDBN__ will read an initial command history
4233 list or to which it will write this list when it exits. This list is
4234 accessed through history expansion or through the history
4235 command editing characters listed below. This file defaults to the
4236 value of the environmental variable @code{GDBHISTFILE}, or to
4237 @file{./.gdb_history} if this variable is not set.
4239 @cindex history write
4240 @kindex set history write
4241 @item set history write
4242 @itemx set history write on
4243 Record command history in a file, whose name may be specified with the
4244 @samp{set history file} command. By default, this option is disabled.
4246 @item set history write off
4247 Stop recording command history in a file.
4249 @cindex history size
4250 @kindex set history size
4251 @item set history size @var{size}
4252 Set the number of commands which _GDBN__ will keep in its history list.
4253 This defaults to the value of the environmental variable
4254 @code{HISTSIZE}, or to 256 if this variable is not set.
4257 @cindex history expansion
4258 History expansion assigns special meaning to the character @samp{!}.
4260 (@xref{Event Designators}.)
4262 Since @samp{!} is also the logical not operator in C, history expansion
4263 is off by default. If you decide to enable history expansion with the
4264 @samp{set history expansion on} command, you may sometimes need to
4265 follow @samp{!} (when it is used as logical not, in an expression) with
4266 a space or a tab to prevent it from being expanded. The readline
4267 history facilities will not attempt substitution on the strings
4268 @samp{!=} and @samp{!(}, even when history expansion is enabled.
4270 The commands to control history expansion are:
4274 @kindex set history expansion
4275 @item set history expansion on
4276 @itemx set history expansion
4277 Enable history expansion. History expansion is off by default.
4279 @item set history expansion off
4280 Disable history expansion.
4282 The readline code comes with more complete documentation of
4283 editing and history expansion features. Users unfamiliar with @samp{emacs}
4284 or @samp{vi} may wish to read it.
4286 @xref{Command Line Editing}.
4289 @kindex show history
4291 @itemx show history file
4292 @itemx show history write
4293 @itemx show history size
4294 @itemx show history expansion
4295 These commands display the state of the _GDBN__ history parameters.
4296 @samp{show history} by itself displays all four states.
4301 @kindex info editing
4303 Display the last ten commands in the command history.
4305 @item info editing @var{n}
4306 Print ten commands centered on command number @var{n}.
4308 @item info editing +
4309 Print ten commands just after the commands last printed.
4313 @node Screen Size,,,
4314 @section Screen Size
4315 @cindex size of screen
4316 @cindex pauses in output
4317 Certain commands to _GDBN__ may produce large amounts of information output
4318 to the screen. To help you read all of it, _GDBN__ pauses and asks you for
4319 input at the end of each page of output. Type @key{RET} when you want
4320 to continue the output. Normally _GDBN__ knows the size of the screen from
4321 the termcap data base together with the value of the @code{TERM}
4322 environment variable and the @code{stty rows} and @code{stty cols}
4323 settings. If this is not correct, you can override it with
4324 the @samp{set screen-height} and @samp{set screen-width} commands:
4326 _GDBN__ also uses the screen width setting to determine when to wrap lines
4327 of output. Depending what is being printed, it tries to break the
4328 line at a readable place, rather than simply letting it overflow onto
4332 @item set screen-height @var{lpp}
4333 @itemx show screen-height
4334 @itemx set screen-width @var{cpl}
4335 @itemx show screen-width
4336 @kindex set screen-height
4337 @kindex set screen-width
4338 @kindex show screen-width
4339 @kindex show screen-height
4340 These @samp{set} commands specify a screen height of @var{lpp} lines and
4341 a screen width of @var{cpl} characters. The associated @samp{show}
4342 commands display the current settings.
4344 If you specify a height of zero lines, _GDBN__ will not pause during output
4345 no matter how long the output is. This is useful if output is to a file
4346 or to an editor buffer.
4351 @cindex number representation
4352 @cindex entering numbers
4353 You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by
4354 the usual conventions: octal numbers begin with @samp{0}, decimal
4355 numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}.
4356 Numbers that begin with none of these are, by default, entered in base
4357 10; likewise, the default display for numbers---when no particular
4358 format is specified---is base 10. You can change the default base for
4359 both input and output with the @samp{set radix} command.
4363 @item set radix @var{base}
4364 Set the default base for numeric input and display. Supported choices
4365 for @var{base} are decimal 8, 10, 16. @var{base} must itself be
4366 specified either unambiguously or using the current default radix; for
4376 will set the base to decimal. On the other hand, @samp{set radix 10}
4377 will leave the radix unchanged no matter what it was.
4381 Display the current default base for numeric input and display.
4385 @node Messages/Warnings,,,
4386 @section Optional Warnings and Messages
4387 By default, _GDBN__ is silent about its inner workings. If you are running
4388 on a slow machine, you may want to use the @samp{set verbose} command.
4389 It will make _GDBN__ tell you when it does a lengthy internal operation, so
4390 you won't think it has crashed.
4392 Currently, the messages controlled by @samp{set verbose} are those which
4393 announce that the symbol table for a source file is being read
4394 (@pxref{Files}, in the description of the command
4395 @samp{symbol-file}).
4396 @c The following is the right way to do it, but emacs 18.55 doesn't support
4397 @c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo
4400 see @samp{symbol-file} in @ref{Files}).
4405 @item set verbose on
4406 Enables _GDBN__'s output of certain informational messages.
4408 @item set verbose off
4409 Disables _GDBN__'s output of certain informational messages.
4411 @kindex show verbose
4413 Displays whether @samp{set verbose} is on or off.
4416 By default, if _GDBN__ encounters bugs in the symbol table of an object file,
4417 it prints a single message about each type of problem it finds, then
4418 shuts up. You can suppress these messages, or allow more than one such
4419 message to be printed if you want to see how frequent the problems are.
4423 @kindex set complaints
4424 @item set complaints @var{limit}
4425 Permits _GDBN__ to output @var{limit} complaints about each type of unusual
4426 symbols before becoming silent about the problem. Set @var{limit} to
4427 zero to suppress all complaints; set it to a large number to prevent
4428 complaints from being suppressed.
4430 @kindex show complaints
4431 @item show complaints
4432 Displays how many symbol complaints _GDBN__ is permitted to produce.
4435 By default, _GDBN__ is cautious, and asks what sometimes seem to be a lot of
4436 stupid questions. For example, if you try to run a program which is
4441 The program being debugged has been started already.
4442 Start it from the beginning? (y or n)
4445 If you're willing to unflinchingly face the consequences of your own
4446 commands, you can disable this ``feature'':
4451 @cindex stupid questions
4452 @item set caution off
4453 Disables cautious questions.
4455 @item set caution on
4456 Enables cautious questions (the default).
4459 @kindex show caution
4460 Displays state of cautious questions.
4464 @chapter Canned Sequences of Commands
4466 Aside from breakpoint commands (@pxref{Break Commands}),_GDBN__ provides two
4467 ways to store sequences of commands for execution as a unit:
4468 user-defined commands and command files.
4471 @section User-Defined Commands
4473 @cindex user-defined command
4474 A @dfn{user-defined command} is a sequence of _GDBN__ commands to which you
4475 assign a new name as a command. This is done with the @samp{define}
4479 @item define @var{commandname}
4481 Define a command named @var{commandname}. If there is already a command
4482 by that name, you are asked to confirm that you want to redefine it.
4484 The definition of the command is made up of other _GDBN__ command lines,
4485 which are given following the @samp{define} command. The end of these
4486 commands is marked by a line containing @samp{end}.
4488 @item document @var{commandname}
4490 Give documentation to the user-defined command @var{commandname}. The
4491 command @var{commandname} must already be defined. This command reads
4492 lines of documentation just as @samp{define} reads the lines of the
4493 command definition, ending with @samp{end}. After the @samp{document}
4494 command is finished, @samp{help} on command @var{commandname} will print
4495 the documentation you have specified.
4497 You may use the @samp{document} command again to change the
4498 documentation of a command. Redefining the command with @samp{define}
4499 does not change the documentation.
4502 User-defined commands do not take arguments. When they are executed, the
4503 commands of the definition are not printed. An error in any command
4504 stops execution of the user-defined command.
4506 Commands that would ask for confirmation if used interactively proceed
4507 without asking when used inside a user-defined command. Many _GDBN__ commands
4508 that normally print messages to say what they are doing omit the messages
4509 when used in a user-defined command.
4511 @node Command Files,,,
4512 @section Command Files
4514 @cindex command files
4515 A command file for _GDBN__ is a file of lines that are _GDBN__ commands. Comments
4516 (lines starting with @samp{#}) may also be included. An empty line in a
4517 command file does nothing; it does not mean to repeat the last command, as
4518 it would from the terminal.
4521 @cindex @file{_GDBINIT__}
4522 When you start _GDBN__, it automatically executes commands from its
4523 @dfn{init files}. These are files named @file{_GDBINIT__}. _GDBN__
4524 reads the init file (if any) in your home directory and then the init
4525 file (if any) in the current working directory. (The init files are not
4526 executed if the @samp{-nx} option is given.) You can also request the
4527 execution of a command file with the @samp{source} command:
4530 @item source @var{filename}
4532 Execute the command file @var{filename}.
4535 The lines in a command file are executed sequentially. They are not
4536 printed as they are executed. An error in any command terminates execution
4537 of the command file.
4539 Commands that would ask for confirmation if used interactively proceed
4540 without asking when used in a command file. Many _GDBN__ commands that
4541 normally print messages to say what they are doing omit the messages
4542 when called from command files.
4545 @section Commands for Controlled Output
4547 During the execution of a command file or a user-defined command, the only
4548 output that appears is what is explicitly printed by the commands of the
4549 definition. This section describes three commands useful for generating
4550 exactly the output you want.
4553 @item echo @var{text}
4555 @comment I don't consider backslash-space a standard C escape sequence
4556 @comment because it's not in ANSI.
4557 Print @var{text}. Nonprinting characters can be included in @var{text}
4558 using C escape sequences, such as @samp{\n} to print a newline. @b{No
4559 newline will be printed unless you specify one.} In addition to the
4560 standard C escape sequences a backslash followed by a space stands for a
4561 space. This is useful for outputting a string with spaces at the
4562 beginning or the end, since leading and trailing spaces are otherwise
4563 trimmed from all arguments. Thus, to print @samp{@ and foo =@ }, use the
4564 command @samp{echo \@ and foo = \@ }.
4565 @comment FIXME: verify hard copy actually issues enspaces for '@ '! Will this
4566 @comment confuse texinfo?
4568 A backslash at the end of @var{text} can be used, as in C, to continue
4569 the command onto subsequent lines. For example,
4572 echo This is some text\n\
4573 which is continued\n\
4574 onto several lines.\n
4577 produces the same output as
4580 echo This is some text\n
4581 echo which is continued\n
4582 echo onto several lines.\n
4585 @item output @var{expression}
4587 Print the value of @var{expression} and nothing but that value: no
4588 newlines, no @samp{$@var{nn} = }. The value is not entered in the
4589 value history either. @xref{Expressions} for more information on
4592 @item output/@var{fmt} @var{expression}
4593 Print the value of @var{expression} in format @var{fmt}.
4594 @xref{Output formats}, for more information.
4596 @item printf @var{string}, @var{expressions}@dots{}
4598 Print the values of the @var{expressions} under the control of
4599 @var{string}. The @var{expressions} are separated by commas and may
4600 be either numbers or pointers. Their values are printed as specified
4601 by @var{string}, exactly as if the program were to execute
4604 printf (@var{string}, @var{expressions}@dots{});
4607 For example, you can print two values in hex like this:
4610 printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
4613 The only backslash-escape sequences that you can use in the format
4614 string are the simple ones that consist of backslash followed by a
4619 @chapter Using _GDBN__ under GNU Emacs
4622 A special interface allows you to use GNU Emacs to view (and
4623 edit) the source files for the program you are debugging with
4626 To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
4627 executable file you want to debug as an argument. This command starts
4628 _GDBN__ as a subprocess of Emacs, with input and output through a newly
4629 created Emacs buffer.
4631 Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two
4636 All ``terminal'' input and output goes through the Emacs buffer. This
4637 applies both to _GDBN__ commands and their output, and to the input and
4638 output done by the program you are debugging.
4640 This is useful because it means that you can copy the text of previous
4641 commands and input them again; you can even use parts of the output
4644 All the facilities of Emacs' Shell mode are available for this purpose.
4647 _GDBN__ displays source code through Emacs. Each time _GDBN__ displays a
4648 stack frame, Emacs automatically finds the source file for that frame
4649 and puts an arrow (_0__@samp{=>}_1__) at the left margin of the current line.
4650 Emacs uses a separate buffer for source display, and splits the window
4651 to show both your _GDBN__ session and the source.
4653 Explicit _GDBN__ @samp{list} or search commands still produce output as
4654 usual, but you probably will have no reason to use them.
4658 @emph{Warning:} If the directory where your program resides is not your
4659 current directory, it can be easy to confuse Emacs about the location of
4660 the source files, in which case the auxiliary display buffer will not
4661 appear to show your source. _GDBN__ can find programs by searching your
4662 environment's @samp{PATH} variable, so the _GDBN__ I/O session will proceed
4663 normally; but Emacs doesn't get enough information back from _GDBN__ to
4664 locate the source files in this situation. To avoid this problem,
4665 either start _GDBN__ mode from the directory where your program resides, or
4666 specify a full path name when prompted for the @kbd{M-x gdb} argument.
4668 A similar confusion can result if you use the _GDBN__ @samp{file} command to
4669 switch to debugging a program in some other location, from an existing
4670 _GDBN__ I/O buffer in Emacs.
4673 By default, @kbd{M-x gdb} calls the program called ``@code{gdb}''. If
4674 you need to call _GDBN__ by a different name (for example, if you keep
4675 several configurations around, with different names) you can set the
4676 Emacs variable @code{gdb-command-name}; for example,
4678 (setq gdb-command-name "mygdb")
4681 (preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or
4682 in your @samp{.emacs} file) will make Emacs call the program named
4683 ``@code{mygdb}'' instead.
4685 In the _GDBN__ I/O buffer, you can use these special Emacs commands in
4686 addition to the standard Shell mode commands:
4690 Describe the features of Emacs' _GDBN__ Mode.
4693 Execute to another source line, like the _GDBN__ @samp{step} command; also
4694 update the display window to show the current file and location.
4697 Execute to next source line in this function, skipping all function
4698 calls, like the _GDBN__ @samp{next} command. Then update the display window
4699 to show the current file and location.
4702 Execute one instruction, like the _GDBN__ @samp{stepi} command; update
4703 display window accordingly.
4706 Execute to next instruction, using the _GDBN__ @samp{nexti} command; update
4707 display window accordingly.
4710 Execute until exit from the selected stack frame, like the _GDBN__
4711 @samp{finish} command.
4714 @comment C-c C-p in emacs 19
4715 Continue execution of the program, like the _GDBN__ @samp{cont} command.
4718 @comment C-c C-u in emacs 19
4719 Go up the number of frames indicated by the numeric argument
4720 (@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}),
4721 like the _GDBN__ @samp{up} command.@refill
4724 @comment C-c C-d in emacs 19
4725 Go down the number of frames indicated by the numeric argument, like the
4726 _GDBN__ @samp{down} command.
4729 Read the number where the cursor is positioned, and insert it at the end
4730 of the _GDBN__ I/O buffer. For example, if you wish to disassemble code
4731 around an address that was displayed earlier, type @kbd{disassemble};
4732 then move the cursor to the address display, and pick up the
4733 argument for @samp{disassemble} by typing @kbd{C-x &}.
4735 You can customize this further on the fly by defining elements of the list
4736 @samp{gdb-print-command}; once it is defined, you can format or
4737 otherwise process numbers picked up by @kbd{C-x &} before they are
4738 inserted. A numeric argument to @kbd{C-x &} will both flag that you
4739 wish special formatting, and act as an index to pick an element of the
4740 list. If the list element is a string, the number to be inserted is
4741 formatted using the Emacs function @samp{format}; otherwise the number
4742 is passed as an argument to the corresponding list element.
4744 @item M-x gdb-display-frame
4745 Explicitly request display of the source code surrounding the current
4746 frame location, in another window. _GDBN__ does this display automatically;
4747 but if, for example, you accidentally kill the buffer where it is
4748 displayed, this command is a way of getting it back.
4751 In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break})
4752 tells _GDBN__ to set a breakpoint on the source line point is on.
4754 The source files displayed in Emacs are in ordinary Emacs buffers
4755 which are visiting the source files in the usual way. You can edit
4756 the files with these buffers if you wish; but keep in mind that _GDBN__
4757 communicates with Emacs in terms of line numbers. If you add or
4758 delete lines from the text, the line numbers that _GDBN__ knows will cease
4759 to correspond properly to the code.
4761 @comment The following dropped because Epoch is nonstandard. Reactivate
4762 @comment if/when v19 does something similar. ---pesch@cygnus.com 19dec1990
4764 @kindex emacs epoch environment
4768 Version 18 of Emacs has a built-in window system called the @samp{epoch}
4769 environment. Users of this environment can use a new command,
4770 @samp{inspect} which performs identically to @samp{print} except that
4771 each value is printed in its own window.
4774 @node _GDBN__ Bugs,,,
4775 @comment node-name, next, previous, up
4776 @chapter Reporting Bugs in _GDBN__
4777 @cindex Bugs in _GDBN__
4778 @cindex Reporting Bugs in _GDBN__
4780 Your bug reports play an essential role in making _GDBN__ reliable.
4782 Reporting a bug may help you by bringing a solution to your problem, or it
4783 may not. But in any case the principal function of a bug report is to help
4784 the entire community by making the next version of _GDBN__ work better. Bug
4785 reports are your contribution to the maintenance of _GDBN__.
4787 In order for a bug report to serve its purpose, you must include the
4788 information that enables us to fix the bug.
4790 @node Bug Criteria,,,
4791 @section Have You Found a Bug?
4792 @cindex Bug Criteria
4794 If you are not sure whether you have found a bug, here are some guidelines:
4798 @cindex Fatal Signal
4800 If the debugger gets a fatal signal, for any input whatever, that is a
4801 _GDBN__ bug. Reliable debuggers never crash.
4804 @cindex error on Valid Input
4805 If _GDBN__ produces an error message for valid input, that is a bug.
4808 @cindex Invalid Input
4809 If _GDBN__ does not produce an error message for invalid input,
4810 that is a bug. However, you should note that your idea of
4811 ``invalid input'' might be our idea of ``an extension'' or ``support
4812 for traditional practice''.
4815 If you are an experienced user of debugging tools, your suggestions
4816 for improvement of _GDBN__ are welcome in any case.
4819 @node Bug Reporting,,,
4820 @section How to Report Bugs
4822 @cindex Compiler Bugs, Reporting
4824 A number of companies and individuals offer support for GNU products.
4825 If you obtained _GDBN__ from a support organization, we recommend you
4826 contact that organization first.
4828 Contact information for many support companies and individuals is
4829 available in the file @samp{etc/SERVICE} in the GNU Emacs distribution.
4831 In any event, we also recommend that you send bug reports for _GDBN__ to one
4835 bug-gdb@@prep.ai.mit.edu
4836 @{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb
4839 @strong{Do not send bug reports to @samp{info-gdb}, or to
4840 @samp{help-gdb}, or to any newsgroups.} Most users of _GDBN__ do not want to
4841 receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}.
4843 The mailing list @samp{bug-gdb} has a newsgroup which serves as a
4844 repeater. The mailing list and the newsgroup carry exactly the same
4845 messages. Often people think of posting bug reports to the newsgroup
4846 instead of mailing them. This appears to work, but it has one problem
4847 which can be crucial: a newsgroup posting does not contain a mail path
4848 back to the sender. Thus, if we need to ask for more information, we
4849 may be unable to reach you. For this reason, it is better to send bug
4850 reports to the mailing list.
4852 As a last resort, send bug reports on paper to:
4860 The fundamental principle of reporting bugs usefully is this:
4861 @strong{report all the facts}. If you are not sure whether to state a
4862 fact or leave it out, state it!
4864 Often people omit facts because they think they know what causes the
4865 problem and assume that some details don't matter. Thus, you might
4866 assume that the name of the variable you use in an example does not matter.
4867 Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a
4868 stray memory reference which happens to fetch from the location where that
4869 name is stored in memory; perhaps, if the name were different, the contents
4870 of that location would fool the debugger into doing the right thing despite
4871 the bug. Play it safe and give a specific, complete example. That is the
4872 easiest thing for you to do, and the most helpful.
4874 Keep in mind that the purpose of a bug report is to enable us to fix
4875 the bug if it is new to us. It isn't very important what happens if
4876 the bug is already known. Therefore, always write your bug reports on
4877 the assumption that the bug has not been reported previously.
4879 Sometimes people give a few sketchy facts and ask, ``Does this ring a
4880 bell?'' Those bug reports are useless, and we urge everyone to
4881 @emph{refuse to respond to them} except to chide the sender to report
4884 To enable us to fix the bug, you should include all these things:
4888 The version of _GDBN__. _GDBN__ announces it if you start with no
4889 arguments; you can also print it at any time using @samp{show version}.
4891 Without this, we won't know whether there is any point in looking for
4892 the bug in the current version of _GDBN__.
4895 A complete input script, and all necessary source files, that will
4899 What compiler (and its version) was used to compile _GDBN__---e.g.
4903 What compiler (and its version) was used to compile _GDBN__.
4906 The command arguments you gave the compiler to compile that example and
4907 observe the bug. For example, did you use @samp{-O}? To guarantee
4908 you won't omit something important, list them all.
4910 If we were to try to guess the arguments, we would probably guess wrong
4911 and then we would not encounter the bug.
4914 The type of machine you are using, and the operating system name and
4918 A description of what behavior you observe that you believe is
4919 incorrect. For example, ``It gets a fatal signal.''
4921 Of course, if the bug is that _GDBN__ gets a fatal signal, then we
4922 will certainly notice it. But if the bug is incorrect output, we might
4923 not notice unless it is glaringly wrong.
4925 Even if the problem you experience is a fatal signal, you should still
4926 say so explicitly. Suppose something strange is going on, such as,
4927 your copy of _GDBN__ is out of synch, or you have encountered a
4928 bug in the C library on your system. (This has happened!) Your copy
4929 might crash and ours would not. If you @i{told} us to expect a crash,
4930 then when ours fails to crash, we would know that the bug was not
4931 happening for us. If you had not told us to expect a crash, then we
4932 would not be able to draw any conclusion from our observations.
4935 If you wish to suggest changes to the _GDBN__ source, send us context
4936 diffs. If you even discuss something in the _GDBN__ source, refer to
4937 it by context, not by line number.
4939 The line numbers in our development sources don't match those in your
4940 sources. Your line numbers would convey no useful information to us.
4944 Here are some things that are not necessary:
4948 A description of the envelope of the bug.
4950 Often people who encounter a bug spend a lot of time investigating
4951 which changes to the input file will make the bug go away and which
4952 changes will not affect it.
4954 This is often time consuming and not very useful, because the way we
4955 will find the bug is by running a single example under the debugger
4956 with breakpoints, not by pure deduction from a series of examples.
4957 We recommend that you save your time for something else.
4959 Of course, if you can find a simpler example to report @emph{instead}
4960 of the original one, that is a convenience for us. Errors in the
4961 output will be easier to spot, running under the debugger will take
4964 However, simplification is not vital; if you don't want to do this,
4965 report the bug anyway and send us the entire test case you used.
4968 A patch for the bug.
4970 A patch for the bug does help us if it is a good one. But don't omit
4971 the necessary information, such as the test case, on the assumption that
4972 a patch is all we need. We might see problems with your patch and decide
4973 to fix the problem another way, or we might not understand it at all.
4975 Sometimes with a program as complicated as _GDBN__ it is very hard to
4976 construct an example that will make the program follow a certain path
4977 through the code. If you don't send us the example, we won't be able
4978 to construct one, so we won't be able to verify that the bug is fixed.
4980 And if we can't understand what bug you are trying to fix, or why your
4981 patch should be an improvement, we won't install it. A test case will
4982 help us to understand.
4985 A guess about what the bug is or what it depends on.
4987 Such guesses are usually wrong. Even we can't guess right about such
4988 things without first using the debugger to find the facts.
4992 @include readline/inc-readline.texinfo
4993 @include readline/inc-history.texinfo
4996 @node Installing _GDBN__,,,
4997 @appendix Installing _GDBN__
4998 @cindex configuring _GDBN__
4999 @cindex installation
5001 The script @samp{config.gdb} automates the process of preparing _GDBN__ for
5002 installation; you can then use @samp{make} to actually build it. For
5011 is all that's required to install _GDBN__ on a Sun 3 running SunOS 4.
5015 @item config.gdb @var{machine}
5016 @itemx config.gdb -srcdir=@var{dir} @var{machine}
5017 This is the most usual way of configuring _GDBN__; to debug programs running
5018 on the same machine as _GDBN__ itself. If you wish to build the _GDBN__ binaries
5019 in a completely different directory from the sources, specify a path to
5020 the source directory using the @samp{-srcdir} option.
5022 @item config.gdb -host
5023 @cindex host environments
5024 Display a list of supported host environments for _GDBN__.
5026 @item config.gdb @var{host} @var{target}
5027 @itemx config.gdb -srcdir=@var{dir} @var{host} @var{target}
5028 @cindex cross-debugging
5029 _GDBN__ can also be used as a cross-debugger, running on a machine of one
5030 type while debugging a program running on a machine of another type.
5031 You configure it this way by specifying first the @var{host}, then the
5032 @var{target} environment on the @code{config.gdb} argument list; the
5033 @var{host} is where _GDBN__ runs, and the @var{target} is where your program
5034 runs. @xref{Remote}. Again, you can use @samp{-srcdir} to specify a
5035 path to the _GDBN__ source.
5037 @item config.gdb -target
5038 @cindex target environments
5039 Display a list of supported target environments for _GDBN__.
5043 @unnumbered GNU GENERAL PUBLIC LICENSE
5044 @center Version 1, February 1989
5047 Copyright @copyright{} 1989 Free Software Foundation, Inc.
5048 675 Mass Ave, Cambridge, MA 02139, USA
5050 Everyone is permitted to copy and distribute verbatim copies
5051 of this license document, but changing it is not allowed.
5054 @unnumberedsec Preamble
5056 The license agreements of most software companies try to keep users
5057 at the mercy of those companies. By contrast, our General Public
5058 License is intended to guarantee your freedom to share and change free
5059 software---to make sure the software is free for all its users. The
5060 General Public License applies to the Free Software Foundation's
5061 software and to any other program whose authors commit to using it.
5062 You can use it for your programs, too.
5064 When we speak of free software, we are referring to freedom, not
5065 price. Specifically, the General Public License is designed to make
5066 sure that you have the freedom to give away or sell copies of free
5067 software, that you receive source code or can get it if you want it,
5068 that you can change the software or use pieces of it in new free
5069 programs; and that you know you can do these things.
5071 To protect your rights, we need to make restrictions that forbid
5072 anyone to deny you these rights or to ask you to surrender the rights.
5073 These restrictions translate to certain responsibilities for you if you
5074 distribute copies of the software, or if you modify it.
5076 For example, if you distribute copies of a such a program, whether
5077 gratis or for a fee, you must give the recipients all the rights that
5078 you have. You must make sure that they, too, receive or can get the
5079 source code. And you must tell them their rights.
5081 We protect your rights with two steps: (1) copyright the software, and
5082 (2) offer you this license which gives you legal permission to copy,
5083 distribute and/or modify the software.
5085 Also, for each author's protection and ours, we want to make certain
5086 that everyone understands that there is no warranty for this free
5087 software. If the software is modified by someone else and passed on, we
5088 want its recipients to know that what they have is not the original, so
5089 that any problems introduced by others will not reflect on the original
5090 authors' reputations.
5092 The precise terms and conditions for copying, distribution and
5093 modification follow.
5096 @unnumberedsec TERMS AND CONDITIONS
5099 @center TERMS AND CONDITIONS
5104 This License Agreement applies to any program or other work which
5105 contains a notice placed by the copyright holder saying it may be
5106 distributed under the terms of this General Public License. The
5107 ``Program'', below, refers to any such program or work, and a ``work based
5108 on the Program'' means either the Program or any work containing the
5109 Program or a portion of it, either verbatim or with modifications. Each
5110 licensee is addressed as ``you''.
5113 You may copy and distribute verbatim copies of the Program's source
5114 code as you receive it, in any medium, provided that you conspicuously and
5115 appropriately publish on each copy an appropriate copyright notice and
5116 disclaimer of warranty; keep intact all the notices that refer to this
5117 General Public License and to the absence of any warranty; and give any
5118 other recipients of the Program a copy of this General Public License
5119 along with the Program. You may charge a fee for the physical act of
5120 transferring a copy.
5123 You may modify your copy or copies of the Program or any portion of
5124 it, and copy and distribute such modifications under the terms of Paragraph
5125 1 above, provided that you also do the following:
5129 cause the modified files to carry prominent notices stating that
5130 you changed the files and the date of any change; and
5133 cause the whole of any work that you distribute or publish, that
5134 in whole or in part contains the Program or any part thereof, either
5135 with or without modifications, to be licensed at no charge to all
5136 third parties under the terms of this General Public License (except
5137 that you may choose to grant warranty protection to some or all
5138 third parties, at your option).
5141 If the modified program normally reads commands interactively when
5142 run, you must cause it, when started running for such interactive use
5143 in the simplest and most usual way, to print or display an
5144 announcement including an appropriate copyright notice and a notice
5145 that there is no warranty (or else, saying that you provide a
5146 warranty) and that users may redistribute the program under these
5147 conditions, and telling the user how to view a copy of this General
5151 You may charge a fee for the physical act of transferring a
5152 copy, and you may at your option offer warranty protection in
5156 Mere aggregation of another independent work with the Program (or its
5157 derivative) on a volume of a storage or distribution medium does not bring
5158 the other work under the scope of these terms.
5161 You may copy and distribute the Program (or a portion or derivative of
5162 it, under Paragraph 2) in object code or executable form under the terms of
5163 Paragraphs 1 and 2 above provided that you also do one of the following:
5167 accompany it with the complete corresponding machine-readable
5168 source code, which must be distributed under the terms of
5169 Paragraphs 1 and 2 above; or,
5172 accompany it with a written offer, valid for at least three
5173 years, to give any third party free (except for a nominal charge
5174 for the cost of distribution) a complete machine-readable copy of the
5175 corresponding source code, to be distributed under the terms of
5176 Paragraphs 1 and 2 above; or,
5179 accompany it with the information you received as to where the
5180 corresponding source code may be obtained. (This alternative is
5181 allowed only for noncommercial distribution and only if you
5182 received the program in object code or executable form alone.)
5185 Source code for a work means the preferred form of the work for making
5186 modifications to it. For an executable file, complete source code means
5187 all the source code for all modules it contains; but, as a special
5188 exception, it need not include source code for modules which are standard
5189 libraries that accompany the operating system on which the executable
5190 file runs, or for standard header files or definitions files that
5191 accompany that operating system.
5194 You may not copy, modify, sublicense, distribute or transfer the
5195 Program except as expressly provided under this General Public License.
5196 Any attempt otherwise to copy, modify, sublicense, distribute or transfer
5197 the Program is void, and will automatically terminate your rights to use
5198 the Program under this License. However, parties who have received
5199 copies, or rights to use copies, from you under this General Public
5200 License will not have their licenses terminated so long as such parties
5201 remain in full compliance.
5204 By copying, distributing or modifying the Program (or any work based
5205 on the Program) you indicate your acceptance of this license to do so,
5206 and all its terms and conditions.
5209 Each time you redistribute the Program (or any work based on the
5210 Program), the recipient automatically receives a license from the original
5211 licensor to copy, distribute or modify the Program subject to these
5212 terms and conditions. You may not impose any further restrictions on the
5213 recipients' exercise of the rights granted herein.
5216 The Free Software Foundation may publish revised and/or new versions
5217 of the General Public License from time to time. Such new versions will
5218 be similar in spirit to the present version, but may differ in detail to
5219 address new problems or concerns.
5221 Each version is given a distinguishing version number. If the Program
5222 specifies a version number of the license which applies to it and ``any
5223 later version'', you have the option of following the terms and conditions
5224 either of that version or of any later version published by the Free
5225 Software Foundation. If the Program does not specify a version number of
5226 the license, you may choose any version ever published by the Free Software
5230 If you wish to incorporate parts of the Program into other free
5231 programs whose distribution conditions are different, write to the author
5232 to ask for permission. For software which is copyrighted by the Free
5233 Software Foundation, write to the Free Software Foundation; we sometimes
5234 make exceptions for this. Our decision will be guided by the two goals
5235 of preserving the free status of all derivatives of our free software and
5236 of promoting the sharing and reuse of software generally.
5239 @heading NO WARRANTY
5246 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
5247 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
5248 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
5249 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
5250 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5251 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
5252 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
5253 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
5254 REPAIR OR CORRECTION.
5257 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
5258 ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
5259 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
5260 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
5261 ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT
5262 LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES
5263 SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
5264 WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
5265 ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
5269 @heading END OF TERMS AND CONDITIONS
5272 @center END OF TERMS AND CONDITIONS
5276 @unnumberedsec Applying These Terms to Your New Programs
5278 If you develop a new program, and you want it to be of the greatest
5279 possible use to humanity, the best way to achieve this is to make it
5280 free software which everyone can redistribute and change under these
5283 To do so, attach the following notices to the program. It is safest to
5284 attach them to the start of each source file to most effectively convey
5285 the exclusion of warranty; and each file should have at least the
5286 ``copyright'' line and a pointer to where the full notice is found.
5289 @var{one line to give the program's name and a brief idea of what it does.}
5290 Copyright (C) 19@var{yy} @var{name of author}
5292 This program is free software; you can redistribute it and/or modify
5293 it under the terms of the GNU General Public License as published by
5294 the Free Software Foundation; either version 1, or (at your option)
5297 This program is distributed in the hope that it will be useful,
5298 but WITHOUT ANY WARRANTY; without even the implied warranty of
5299 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5300 GNU General Public License for more details.
5302 You should have received a copy of the GNU General Public License
5303 along with this program; if not, write to the Free Software
5304 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5307 Also add information on how to contact you by electronic and paper mail.
5309 If the program is interactive, make it output a short notice like this
5310 when it starts in an interactive mode:
5313 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
5314 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
5315 This is free software, and you are welcome to redistribute it
5316 under certain conditions; type `show c' for details.
5319 The hypothetical commands `show w' and `show c' should show the
5320 appropriate parts of the General Public License. Of course, the
5321 commands you use may be called something other than `show w' and `show
5322 c'; they could even be mouse-clicks or menu items---whatever suits your
5325 You should also get your employer (if you work as a programmer) or your
5326 school, if any, to sign a ``copyright disclaimer'' for the program, if
5327 necessary. Here is a sample; alter the names:
5330 Yoyodyne, Inc., hereby disclaims all copyright interest in the
5331 program `Gnomovision' (a program to direct compilers to make passes
5332 at assemblers) written by James Hacker.
5334 @var{signature of Ty Coon}, 1 April 1989
5335 Ty Coon, President of Vice
5338 That's all there is to it!
5346 % I think something like @colophon should be in texinfo. In the
5348 \long\def\colophon{\hbox to0pt{}\vfill
5349 \centerline{The body of this manual is set in}
5350 \centerline{\fontname\tenrm,}
5351 \centerline{with headings in {\bf\fontname\tenbf}}
5352 \centerline{and examples in {\tt\fontname\tentt}.}
5353 \centerline{{\it\fontname\tenit\/} and}
5354 \centerline{{\sl\fontname\tensl\/}}
5355 \centerline{are used for emphasis.}\vfill}
5357 % Blame: pesch@cygnus.com, 28mar91.