Changes to accomodate using the freshly built bison in place.
[deliverable/binutils-gdb.git] / gdb / doc / gdb.texinfo
CommitLineData
9bcc06ef
RP
1_dnl__ -*-Texinfo-*-
2_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc.
e91b87a3 3\input texinfo
5a131cc7 4@setfilename _GDBP__.info
8734fc33 5@c $Id$
9c3ad547 6@c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly.
5a131cc7
RP
7@c
8@c NOTE: this manual is marked up for preprocessing with a collection
9@c of m4 macros called "pretex.m4". If you see <_if__> and <_fi__>
10@c scattered around the source, you have the full source before
11@c preprocessing; if you don't, you have the source configured for
12@c _HOST__ architectures (and you can of course get the full source,
13@c with all configurations, from wherever you got this).
14_if__(0)
15
9bcc06ef
RP
16THIS IS THE SOURCE PRIOR TO PREPROCESSING. The full source needs to
17be run through m4 before either tex- or info- formatting: for example,
08665207 18_0__
8734fc33 19 m4 pretex.m4 none.m4 m680x0.m4 gdb.texinfo >gdb-680x0.texinfo
08665207 20_1__
70b88761
RP
21will produce (assuming your path finds either GNU m4 >= 0.84, or SysV
22m4; Berkeley won't do) a file suitable for formatting. See the text in
23"pretex.m4" for a fuller explanation (and the macro definitions).
e91b87a3 24
9bcc06ef 25_fi__(0)
0e0fa7ce
RP
26@tex
27\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
28\xdef\manvers{\$Revision$} % For use in headers, footers too
0e0fa7ce 29@end tex
70b88761
RP
30@c
31@syncodeindex ky cp
32@c FOR UPDATES LEADING TO THIS DRAFT, GDB CHANGELOG CONSULTED BETWEEN:
33@c Sun May 19 05:36:59 1991 John Gilmore (gnu at cygint.cygnus.com)
34@c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint)
35@ifinfo
36This file documents the GNU debugger _GDBN__.
37
38Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
39
40Permission is granted to make and distribute verbatim copies of
41this manual provided the copyright notice and this permission notice
42are preserved on all copies.
43
44@ignore
45Permission is granted to process this file through TeX and print the
46results, provided the printed document carries copying permission
47notice identical to this one except for the removal of this paragraph
48(this paragraph not being relevant to the printed manual).
49
50@end ignore
51Permission is granted to copy and distribute modified versions of this
52manual under the conditions for verbatim copying, provided also that the
53section entitled ``GNU General Public License'' is included exactly as
54in the original, and provided that the entire resulting derived work is
55distributed under the terms of a permission notice identical to this
56one.
57
58Permission is granted to copy and distribute translations of this manual
59into another language, under the above conditions for modified versions,
60except that the section entitled ``GNU General Public License'' may be
61included in a translation approved by the Free Software Foundation
62instead of in the original English.
63@end ifinfo
64@smallbook
65@setchapternewpage odd
66_if__(_GENERIC__)
67@settitle Using _GDBN__ (v4.0)
68_fi__(_GENERIC__)
69_if__(!_GENERIC__)
70@settitle Using _GDBN__ v4.0 (_HOST__)
71_fi__(!_GENERIC__)
72@iftex
73@finalout
74@end iftex
75@titlepage
76@title{Using _GDBN__}
77@subtitle{A Guide to the GNU Source-Level Debugger}
78_if__(!_GENERIC__)
79@subtitle{On _HOST__ Systems}
80_fi__(!_GENERIC__)
81@sp 1
82@c Maybe crank this up to "Fourth Edition" when released at FSF
83@c @subtitle Third Edition---_GDBN__ version 4.0
84@subtitle _GDBN__ version 4.0
85@subtitle May 1991
86@author{Richard M. Stallman@qquad @hfill Free Software Foundation}
87@author{Roland H. Pesch@qquad @hfill Cygnus Support}
88@page
89@tex
90{\parskip=0pt
91\hfill rms\@ai.mit.edu, pesch\@cygnus.com\par
92\hfill {\it Using _GDBN__}, \manvers\par
93\hfill \TeX{}info \texinfoversion\par
94}
95@end tex
96
97@vskip 0pt plus 1filll
98Copyright @copyright{} 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
99
100Permission is granted to make and distribute verbatim copies of
101this manual provided the copyright notice and this permission notice
102are preserved on all copies.
103
104Permission is granted to copy and distribute modified versions of this
105manual under the conditions for verbatim copying, provided also that the
106section entitled ``GNU General Public License'' is included exactly as
107in the original, and provided that the entire resulting derived work is
108distributed under the terms of a permission notice identical to this
109one.
110
111Permission is granted to copy and distribute translations of this manual
112into another language, under the above conditions for modified versions,
113except that the section entitled ``GNU General Public License'' may be
114included in a translation approved by the Free Software Foundation
115instead of in the original English.
116@end titlepage
117@page
118
119@node Top, Summary, (dir), (dir)
120@ifinfo
121This file describes version 4.0 of GDB, the GNU symbolic debugger.
122@end ifinfo
123
124@menu
125* Summary:: Summary of _GDBN__
126* New Features:: New Features in _GDBN__ version 4.0
127* Sample Session:: A Sample _GDBN__ Session
128* Invocation:: Getting In and Out of _GDBN__
129* Commands::
130* Running:: Running Programs Under _GDBN__
131* Stopping:: Stopping and Continuing
132* Stack:: Examining the Stack
133* Source:: Examining Source Files
134* Data:: Examining Data
135* Symbols:: Examining the Symbol Table
136* Altering:: Altering Execution
137* _GDBN__ Files::
138* Targets:: Specifying a Debugging Target
139* Controlling _GDBN__:: Controlling _GDBN__
140* Sequences:: Canned Sequences of Commands
141* Emacs:: Using _GDBN__ under GNU Emacs
142* _GDBN__ Bugs:: Reporting Bugs in _GDBN__
143* Renamed Commands::
144* Installing _GDBN__:: Installing _GDBN__
145* Copying:: GNU GENERAL PUBLIC LICENSE
146* Index:: Index
147 --- The Detailed Node Listing ---
148
149Summary of _GDBN__
150
151* Free Software:: Free Software
152* Contributors:: Contributors to _GDBN__
153
154Getting In and Out of _GDBN__
155
156* Starting _GDBN__:: Starting _GDBN__
157* Leaving _GDBN__:: Leaving _GDBN__
158* Shell Commands:: Shell Commands
159
160Starting _GDBN__
161
162* File Options:: Choosing Files
163* Mode Options:: Choosing Modes
164
165_GDBN__ Commands
166
167* Command Syntax:: Command Syntax
168* Help:: Getting Help
169
170Running Programs Under _GDBN__
171
172* Compilation:: Compiling for Debugging
173* Starting:: Starting your Program
174* Arguments:: Your Program's Arguments
175* Environment:: Your Program's Environment
176* Working Directory:: Your Program's Working Directory
177* Input/Output:: Your Program's Input and Output
178* Attach:: Debugging an Already-Running Process
179* Kill Process:: Killing the Child Process
180
181Stopping and Continuing
182
183* Breakpoints:: Breakpoints, Watchpoints, and Exceptions
184* Stepping:: Stepping
185* Continuing:: Continuing
186* Signals:: Signals
187
188Breakpoints, Watchpoints, and Exceptions
189
190* Set Breaks:: Setting Breakpoints
191* Set Watchpoints:: Setting Watchpoints
192* Exception Handling:: Breakpoints and Exceptions
193* Delete Breaks:: Deleting Breakpoints
194* Disabling:: Disabling Breakpoints
195* Conditions:: Break Conditions
196* Break Commands:: Breakpoint Command Lists
197* Breakpoint Menus:: Breakpoint Menus
198* Error in Breakpoints::
199
200Examining the Stack
201
202* Frames:: Stack Frames
203* Backtrace:: Backtraces
204* Selection:: Selecting a Frame
205* Frame Info:: Information on a Frame
206
207Examining Source Files
208
209* List:: Printing Source Lines
210* Search:: Searching Source Files
211* Source Path:: Specifying Source Directories
212* Machine Code:: Source and Machine Code
213
214Examining Data
215
216* Expressions:: Expressions
217* Variables:: Program Variables
218* Arrays:: Artificial Arrays
219* Output formats:: Output formats
220* Memory:: Examining Memory
221* Auto Display:: Automatic Display
222* Print Settings:: Print Settings
223* Value History:: Value History
224* Convenience Vars:: Convenience Variables
225* Registers:: Registers
226* Floating Point Hardware:: Floating Point Hardware
227
228Altering Execution
229
230* Assignment:: Assignment to Variables
231* Jumping:: Continuing at a Different Address
232* Signaling:: Giving the Program a Signal
233* Returning:: Returning from a Function
234* Calling:: Calling your Program's Functions
235
236_GDBN__'s Files
237
238* Files:: Commands to Specify Files
239* Symbol Errors:: Errors Reading Symbol Files
240
241Specifying a Debugging Target
242
243* Active Targets:: Active Targets
244* Target Commands:: Commands for Managing Targets
245* Remote:: Remote Debugging
246
247Remote Debugging
248
249* i960-Nindy Remote::
250* EB29K Remote::
251* VxWorks Remote::
252
253_GDBN__ with a Remote i960 (Nindy)
254
255* Nindy Startup:: Startup with Nindy
256* Nindy Options:: Options for Nindy
257* Nindy reset:: Nindy Reset Command
258
259_GDBN__ with a Remote EB29K
260
261* Comms (EB29K):: Communications Setup
262* gdb-EB29K:: EB29K cross-debugging
263* Remote Log:: Remote Log
264
265_GDBN__ and VxWorks
266
267* VxWorks connection:: Connecting to VxWorks
268* VxWorks download:: VxWorks Download
269* VxWorks attach:: Running Tasks
270
271Controlling _GDBN__
272
273* Prompt:: Prompt
274* Editing:: Command Editing
275* History:: Command History
276* Screen Size:: Screen Size
277* Numbers:: Numbers
278* Messages/Warnings:: Optional Warnings and Messages
279
280Canned Sequences of Commands
281
282* Define:: User-Defined Commands
283* Command Files:: Command Files
284* Output:: Commands for Controlled Output
285
286Reporting Bugs in _GDBN__
287
288* Bug Criteria:: Have You Found a Bug?
289* Bug Reporting:: How to Report Bugs
290@end menu
291
292@node Summary, New Features, Top, Top
293@unnumbered Summary of _GDBN__
294
295The purpose of a debugger such as _GDBN__ is to allow you to see what is
296going on ``inside'' another program while it executes---or what another
297program was doing at the moment it crashed.
298
299_GDBN__ can do four main kinds of things (plus other things in support of
300these) to help you catch bugs in the act:
301
302@itemize @bullet
303@item
304Start your program, specifying anything that might affect its behavior.
305
306@item
307Make your program stop on specified conditions.
308
309@item
310Examine what has happened, when your program has stopped.
311
312@item
313Change things in your program, so you can experiment with correcting the
314effects of one bug and go on to learn about another.
315@end itemize
316
317_GDBN__ can be used to debug programs written in C and C++. Pascal support
318is being implemented, and Fortran support will be added when a GNU
319Fortran compiler is ready.
320
321@menu
322* Free Software:: Free Software
323* Contributors:: Contributors to GDB
324@end menu
325
326@node Free Software, Contributors, Summary, Summary
327@unnumberedsec Free Software
328_GDBN__ is @dfn{free software}, protected by the GNU General Public License (GPL).
329The GPL gives you the freedom to copy or adapt a licensed
330program---but every person getting a copy also gets with it the
331freedom to modify that copy (which means that they must get access to
332the source code), and the freedom to distribute further copies.
333Typical software companies use copyrights to limit your freedoms; the
334Free Software Foundation uses the GPL to preserve these freedoms.
335
336Fundamentally, the General Public License is a license which says that
337you have these freedoms and that you can't take these freedoms away
338from anyone else.
339
340@c FIXME: (passim) go through all xrefs, expanding to use text headings
341For full details, @pxref{Copying}.
342@node Contributors, , Free Software, Summary
343@unnumberedsec Contributors to GDB
344
345Richard Stallman was the original author of GDB, and of many other GNU
346programs. Many others have contributed to its development. This
347section attempts to credit major contributors. One of the virtues of
348free software is that everyone is free to contribute to it; with
349regret, we cannot actually acknowledge everyone here. The file
350@file{ChangeLog} in the GDB distribution approximates a blow-by-blow
351account.
352
353Changes much prior to version 2.0 are lost in the mists of time.
354
355@quotation
356@emph{Plea:} Additions to this section are particularly welcome. If you
357or your friends (or enemies; let's be evenhanded) have been unfairly
358omitted from this list, we would like to add your names!
359@end quotation
360
361So that they may not regard their long labor as thankless, we
362particularly thank those who shepherded GDB through major releases:
363John Gilmore (release 4.0); Jim Kingdon (releases 3.9, 3.5, 3.4, 3.3);
364and Randy Smith (releases 3.2, 3.1, 3.0). As major maintainer of GDB
365for some period, each contributed significantly to the structure,
366stability, and capabilities of the entire debugger.
367
368Richard Stallman, assisted at various times by Pete TerMaat, Chris
369Hanson, and Richard Mlynarik, handled releases through 2.8.
370
371Michael Tiemann is the author of most of the GNU C++ support in GDB,
372with significant additional contributions from Per Bothner. James
373Clark wrote the GNU C++ demangler. Early work on C++ was by Peter
374TerMaat (who also did much general update work leading to release 3.0).
375
376GDB 4.0 uses the BFD subroutine library to examine multiple
377object-file formats; BFD was a joint project of V. Gumby
378Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
379
380David Johnson wrote the original COFF support; Pace Willison did
381the original support for encapsulated COFF.
382
383Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
384Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
385support. Jean-Daniel Fekete contributed Sun 386i support. Chris
386Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki
387Hasei contributed Sony/News OS 3 support. David Johnson contributed
388Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support.
389Keith Packard contributed NS32K support. Doug Rabson contributed
390Acorn Risc Machine support. Chris Smith contributed Convex support
391(and Fortran debugging). Jonathan Stone contributed Pyramid support.
392Michael Tiemann contributed SPARC support. Tim Tucker contributed
393support for the Gould NP1 and Gould Powernode. Pace Willison
394contributed Intel 386 support. Jay Vosburgh contributed Symmetry
395support.
396
397Rich Schaefer helped with support of SunOS shared libraries.
398
399Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about
400several machine instruction sets.
401
402Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
403develop remote debugging. Intel Corporation and Wind River Systems
404contributed remote debugging modules for their products.
405
406Brian Fox is the author of the readline libraries providing
407command-line editing and command history.
408
409@node New Features, Sample Session, Summary, Top
410@unnumbered New Features since _GDBN__ version 3.5
411
412@table @emph
413@item Targets
414Using the new command @code{target}, you can select at runtime whether
415you are debugging local files, local processes, standalone systems over
416a serial port, realtime systems over a TCP/IP connection, etc.
417Internally, _GDBN__ now uses a function vector to mediate access to
418different targets; if you need to add your own support for a remote
419protocol, this makes it much easier.
420
421@item Watchpoints
422_GDBN__ now sports watchpoints as well as breakpoints. You can use a
423watchpoint to stop execution whenever the value of an expression
424changes, without having to predict a particular place in your program
425where this may happen.
426
427@item Object Code Formats
428_GDBN__ uses a new scheme called Binary File Descriptors (BFD) to permit
429it to switch dynamically, without reconfiguration or recompilation,
430between different object-file formats. Formats currently supported are
431COFF, a.out, and the Intel 960 b.out; files may be read as .o's, archive
432libraries, or core dumps. BFD is available as a subroutine library so
433that other programs may take advantage of it, and the other GNU binary
434utilities are being converted to use it.
435
436@item Configuration
437Compile-time configuration (to select a particular architecture and
7463aadd 438operating system) is much easier. The script @code{configure} now
70b88761
RP
439handles specification of separate host and target configurations.
440
441@item Interaction
442The user interface to _GDBN__'s control variables has been simplified
443and consolidated in two commands, @code{set} and @code{show}. Output
444lines are now broken at readable places, rather than overflowing onto
445the next line. You can suppress output of machine-level addresses,
446displaying only source language information.
447
448
449@item Source Language
450_GDBN__ now has limited support for C++ exception handling: _GDBN__ can
451break when an exception is raised, before the stack is peeled back to
452the exception handler's context.
453
454@item Command Rationalization
455Many _GDBN__ commands have been renamed to make them easier to remember
456and use. In particular, the subcommands of @code{info} and
457@code{show}/@code{set} are grouped to make the former refer to the state
458of your program, and the latter refer to the state of _GDBN__ itself.
459@xref{Renamed Commands}, for details on what commands were renamed.
460
461@item Ports
462_GDBN__ has been ported to the following new architectures: AT&T 3b1,
463Acorn RISC machine, HP300 running HPUX, big- and little-endian MIPS
464machines, Motorola 88k, Sun 386i, and Sun 3 running SunOS 4. In
465addition, the following are supported as targets only: AMD 29k, Intel
466960, and Wind River's VxWorks.
467
468@item Shared Libraries
469_GDBN__ 4.0 supports SunOS shared libraries.
470
471@item Work in Progress
472Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture
473support.
474
475@end table
476
477@node Sample Session, Invocation, New Features, Top
478@chapter A Sample _GDBN__ Session
479
480You can use this manual at your leisure to read all about _GDBN__.
481However, a handful of commands are enough to get started using the
482debugger. This chapter illustrates these commands.
483
484@iftex
485In this sample session, we emphasize user input like this: @i{input},
486to make it easier to pick out from the surrounding output.
487@end iftex
488
489@c FIXME: this example may not be appropriate for some configs, where
490@c FIXME...primary interest is in remote use.
491_0__
492One of the preliminary versions of GNU @code{m4} (a generic macro
493processor) exhibits the following bug: sometimes, when we change its
494quote strings from the default, the commands used to capture one macro's
495definition in another stop working. In the following short @code{m4}
496session, we define a macro @code{foo} which expands to @code{0000}; we
497then use the @code{m4} builtin @code{defn} to define @code{bar} as the
498same thing. However, when we change the open quote string to
499@code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same
500procedure fails to define a new synonym @code{baz}:
501
502@smallexample
503$ @i{cd gnu/m4}
504$ @i{./m4}
505@i{define(foo,0000)}
506
507@i{foo}
5080000
509@i{define(bar,defn(`foo'))}
510
511@i{bar}
5120000
513@i{changequote(<QUOTE>,<UNQUOTE>)}
514
515@i{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
516@i{baz}
517@i{C-d}
518m4: End of input: 0: fatal error: EOF in string
519@end smallexample
520
521@noindent
522Let's use _GDBN__ to try to see what's going on.
523
524@smallexample
525$ @i{_GDBP__ m4}
526Reading symbol data from m4...done.
527(_GDBP__)
528@end smallexample
529
530@noindent
531_GDBN__ reads only enough symbol data to know where to find the rest
532when needed; as a result, the first prompt comes up very quickly. We
533then tell _GDBN__ to use a narrower display width than usual, so
534that examples will fit in this manual.
535
536@smallexample
537(_GDBP__) @i{set width 70}
538@end smallexample
539
540@noindent
541Let's see how the @code{m4} builtin @code{changequote} works.
542Having looked at the source, we know the relevant subroutine is
543@code{m4_changequote}, so we set a breakpoint there with _GDBN__'s
544@code{break} command.
545
546@smallexample
547(_GDBP__) @i{break m4_changequote}
548Breakpoint 1 at 0x62f4: file builtin.c, line 879.
549@end smallexample
550
551@noindent
552Using the @code{run} command, we start @code{m4} running under _GDBN__
553control; as long as control does not reach the @code{m4_changequote}
554subroutine, the program runs as usual:
555
556@smallexample
557(_GDBP__) @i{run}
558Starting program: /work/Editorial/gdb/gnu/m4/m4
559@i{define(foo,0000)}
560
561@i{foo}
5620000
563@end smallexample
564
565@noindent
566To trigger the breakpoint, we call @code{changequote}. _GDBN__
567suspends execution of @code{m4}, displaying information about the
568context where it stops.
569
570@smallexample
571@i{changequote(<QUOTE>,<UNQUOTE>)}
572
573Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) at builtin.c:879
574879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
575@end smallexample
576
577@noindent
578Now we use the command @code{n} (@code{next}) to advance execution to
579the next line of the current function.
580
581@smallexample
582(_GDBP__) @i{n}
583882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1]) : nil,
584@end smallexample
585
586@noindent
587@code{set_quotes} looks like a promising subroutine. We can go into it
588by using the command @code{s} (@code{step}) instead of @code{next}.
589@code{step} goes to the next line to be executed in @emph{any}
590subroutine, so it steps into @code{set_quotes}.
591
592@smallexample
593(_GDBP__) @i{s}
594set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
595 at input.c:530
596530 if (lquote != def_lquote)
597@end smallexample
598
599@noindent
600The summary display showing the subroutine where @code{m4} is now
601suspended (and its arguments) is called a stack frame display. We can
602use the @code{backtrace} command (which can also be spelled @code{bt}),
603to see where we are in the stack: it displays a stack frame for each
604active subroutine.
605
606@smallexample
607(_GDBP__) @i{bt}
608#0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
609 at input.c:530
610#1 0x6344 in m4_changequote (argc=3, argv=0x33c70) at builtin.c:882
611#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
612#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
613 at macro.c:71
614#4 0x79dc in expand_input () at macro.c:40
615#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
616@end smallexample
617
618@noindent
619Let's step through a few more lines to see what happens. The first two
620times, we can use @samp{s}; the next two times we use @code{n} to avoid
621falling into the @code{xstrdup} subroutine.
622@smallexample
623(_GDBP__) @i{s}
6240x3b5c 532 if (rquote != def_rquote)
625(_GDBP__) @i{s}
6260x3b80 535 lquote = (lq == nil || *lq == '\0') ? def_lquote :\
627 xstrdup(lq);
628(_GDBP__) @i{n}
629536 rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
630(rq);
631(_GDBP__) @i{n}
632538 len_lquote = strlen(rquote);
633@end smallexample
634
635@noindent
636The last line displayed looks a little odd; let's examine the variables
637@code{lquote} and @code{rquote} to see if they are in fact the new left
638and right quotes we specified. We can use the command @code{p}
639(@code{print}) to see their values.
640
641@smallexample
642(_GDBP__) @i{p lquote}
643$1 = 0x35d40 "<QUOTE>"
644(_GDBP__) @i{p rquote}
645$2 = 0x35d50 "<UNQUOTE>"
646@end smallexample
647
648@noindent
649@code{lquote} and @code{rquote} are indeed the new left and right quotes.
650Let's look at some context; we can display ten lines of source
651surrounding the current line, with the @code{l} (@code{list}) command.
652
653@smallexample
654(_GDBP__) @i{l}
655533 xfree(rquote);
656534
657535 lquote = (lq == nil || *lq == '\0') ? def_lquote : xstrdup\
658(lq);
659536 rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
660(rq);
661537
662538 len_lquote = strlen(rquote);
663539 len_rquote = strlen(lquote);
664540 @}
665541
666542 void
667@end smallexample
668
669@noindent
670Let's step past the two lines that set @code{len_lquote} and
671@code{len_rquote}, and then examine the values of those variables.
672
673@smallexample
674(_GDBP__) @i{n}
675539 len_rquote = strlen(lquote);
676(_GDBP__) @i{n}
677540 @}
678(_GDBP__) @i{p len_lquote}
679$3 = 9
680(_GDBP__) @i{p len_rquote}
681$4 = 7
682@end smallexample
683
684@noindent
685That certainly looks wrong, assuming @code{len_lquote} and
686@code{len_rquote} are meant to be the lengths of @code{lquote} and
687@code{rquote} respectively. Let's try setting them to better values.
688We can use the @code{p} command for this, since it'll print the value of
689any expression---and that expression can include subroutine calls and
690assignments.
691
692@smallexample
693(_GDBP__) p len_lquote=strlen(lquote)
694$5 = 7
695(_GDBP__) p len_rquote=strlen(rquote)
696$6 = 9
697@end smallexample
698
699@noindent
700Let's see if that fixes the problem of using the new quotes with the
701@code{m4} built-in @code{defn}. We can allow @code{m4} to continue
702executing with the @code{c} (@code{continue}) command, and then try the
703example that caused trouble initially:
704
705@smallexample
706(_GDBP__) @i{c}
707Continuing.
708
709@i{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
710
711baz
7120000
713@end smallexample
714
715@noindent
716Success! The new quotes now work just as well as the default ones. The
717problem seems to have been just the two typos defining the wrong
718lengths. We'll let @code{m4} exit by giving it an EOF as input.
719
720@smallexample
721@i{C-d}
722Program exited normally.
723@end smallexample
724
725@noindent
726The message @samp{Program exited normally.} is from _GDBN__; it
727indicates @code{m4} has finished executing. We can end our _GDBN__
728session with the _GDBN__ @code{quit} command.
729
730@smallexample
731(_GDBP__) @i{quit}
70b88761
RP
732_1__@end smallexample
733
734@node Invocation, Commands, Sample Session, Top
735@chapter Getting In and Out of _GDBN__
736
737@menu
738* Starting _GDBN__:: Starting _GDBN__
739* Leaving _GDBN__:: Leaving _GDBN__
740* Shell Commands:: Shell Commands
741@end menu
742
743@node Starting _GDBN__, Leaving _GDBN__, Invocation, Invocation
744@section Starting _GDBN__
745
746_GDBN__ is invoked with the shell command @code{_GDBP__}. Once started,
747it reads commands from the terminal until you tell it to exit.
748
749You can run @code{_GDBP__} with no arguments or options; but the most
750usual way to start _GDBN__ is with one argument or two, specifying an
751executable program as the argument:
752@example
753_GDBP__ program
754@end example
755@noindent
756You can also start with both an executable program and a core file specified:
757@example
758_GDBP__ program core
759@end example
760
761@noindent
762You can further control how _GDBN__ starts up by using command-line
763options. _GDBN__ itself can remind you of the options available:
764@example
765_GDBP__ -help
766@end example
767@noindent
768will display all available options and briefly describe their use
769(@samp{_GDBP__ -h} is a shorter equivalent).
770
771All options and command line arguments you give are processed
772in sequential order. The order makes a difference when the
773@samp{-x} option is used.
774
775@menu
776* File Options:: Choosing Files
777* Mode Options:: Choosing Modes
778_if__(!_GENERIC__)
779_include__(gdbinv-m.m4)_dnl__
780_fi__(!_GENERIC__)
781@end menu
782
783@node File Options, Mode Options, Starting _GDBN__, Starting _GDBN__
784@subsection Choosing Files
785
786As shown above, any arguments other than options specify an executable
787file and core file; that is, the first argument encountered with no
788associated option flag is equivalent to a @samp{-se} option, and the
789second, if any, is equivalent to a @samp{-c} option. Many options have
790both long and short forms; both are shown here. The long forms are also
791recognized if you truncate them, so long as enough of the option is
792present to be unambiguous. (If you prefer, you can flag option
793arguments with @samp{+} rather than @samp{-}, though we illustrate the
794more usual convention.)
795
796@table @code
797@item -symbols=@var{file}
798@itemx -s @var{file}
799Read symbol table from file @var{file}.
800
801@item -exec=@var{file}
802@itemx -e @var{file}
803Use file @var{file} as the executable file to execute when
804appropriate, and for examining pure data in conjunction with a core
805dump.
806
807@item -se @var{file}
808Read symbol table from file @var{file} and use it as the executable
809file.
810
811@item -core=@var{file}
812@itemx -c @var{file}
813Use file @var{file} as a core dump to examine.
814
815@item -command=@var{file}
816@itemx -x @var{file}
817Execute _GDBN__ commands from file @var{file}. @xref{Command Files}.
818
819@item -directory=@var{directory}
820@itemx -d @var{directory}
821Add @var{directory} to the path to search for source files.
822@end table
823
824_if__(!_GENERIC__)
825@node Mode Options, i960-Nindy Remote, File Options, Starting _GDBN__
826_fi__(!_GENERIC__)
827_if__(_GENERIC__)
828@node Mode Options, , File Options, Starting _GDBN__
829_fi__(_GENERIC__)
830@subsection Choosing Modes
831
832@table @code
833@item -nx
834@itemx -n
835Do not execute commands from any @file{_GDBINIT__} initialization files.
836Normally, the commands in these files are executed after all the
837command options and arguments have been processed. @xref{Command
838Files}.
839
840@item -quiet
841@itemx -q
842``Quiet''. Do not print the introductory and copyright messages. These
843messages are also suppressed in batch mode, or if an executable file name is
844specified on the _GDBN__ command line.
845
846@item -batch
847Run in batch mode. Exit with status @code{0} after processing all the command
848files specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited).
849Exit with nonzero status if an error occurs in executing the _GDBN__
850commands in the command files.
851
852Batch mode may be useful for running _GDBN__ as a filter, for example to
853download and run a program on another computer; in order to make this
854more useful, the message
855@example
856Program exited normally.
857@end example
858@noindent
859(which is ordinarily issued whenever a program running under _GDBN__ control
860terminates) is not issued when running in batch mode.
861
862@item -cd @var{directory}
863Run _GDBN__ using @var{directory} as its working directory,
864instead of the current directory.
865
866@item -fullname
867@itemx -f
868Emacs sets this option when it runs _GDBN__ as a subprocess. It tells _GDBN__
869to output the full file name and line number in a standard,
870recognizable fashion each time a stack frame is displayed (which
871includes each time the program stops). This recognizable format looks
872like two @samp{\032} characters, followed by the file name, line number
873and character position separated by colons, and a newline. The
874Emacs-to-_GDBN__ interface program uses the two @samp{\032} characters as
875a signal to display the source code for the frame.
876
877@item -b @var{bps}
878Set the line speed (baud rate or bits per second) of any serial
879interface used by _GDBN__ for remote debugging.
880
881@item -tty @var{device}
882Run using @var{device} for your program's standard input and output.
883@c FIXME: kingdon thinks there's more to -tty. Investigate.
884@end table
885
886_if__(!_GENERIC__)
887_include__(gdbinv-s.m4)
888_fi__(!_GENERIC__)
889
890@node Leaving _GDBN__, Shell Commands, Starting _GDBN__, Invocation
891@section Leaving _GDBN__
892@cindex exiting _GDBN__
893@table @code
894@item quit
895@kindex quit
896@kindex q
897To exit _GDBN__, use the @code{quit} command (abbreviated @code{q}), or type
898an end-of-file character (usually @kbd{C-d}).
899@end table
900
901@cindex interrupt
902An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather
903will terminate the action of any _GDBN__ command that is in progress and
904return to _GDBN__ command level. It is safe to type the interrupt
905character at any time because _GDBN__ does not allow it to take effect
906until a time when it is safe.
907
908If you've been using _GDBN__ to control an attached process or device,
909you can release it with the @code{detach} command; @pxref{Attach}.
910
911@node Shell Commands, , Leaving _GDBN__, Invocation
912@section Shell Commands
913If you need to execute occasional shell commands during your
914debugging session, there's no need to leave or suspend _GDBN__; you can
915just use the @code{shell} command.
916
917@table @code
918@item shell @var{command string}
919@kindex shell
920@cindex shell escape
921Directs _GDBN__ to invoke an inferior shell to execute @var{command
922string}. If it exists, the environment variable @code{SHELL} is used
923for the name of the shell to run. Otherwise _GDBN__ uses
924@code{/bin/sh}.
925@end table
926
927The utility @code{make} is often needed in development environments.
928You don't have to use the @code{shell} command for this purpose in _GDBN__:
929
930@table @code
931@item make @var{make-args}
932@kindex make
933@cindex calling make
934Causes _GDBN__ to execute an inferior @code{make} program with the specified
935arguments. This is equivalent to @samp{shell make @var{make-args}}.
936@end table
937
938@node Commands, Running, Invocation, Top
939@chapter _GDBN__ Commands
940
941@menu
942* Command Syntax:: Command Syntax
943* Help:: Getting Help
944@end menu
945
946@node Command Syntax, Help, Commands, Commands
947@section Command Syntax
948A _GDBN__ command is a single line of input. There is no limit on how long
949it can be. It starts with a command name, which is followed by arguments
950whose meaning depends on the command name. For example, the command
951@code{step} accepts an argument which is the number of times to step,
952as in @samp{step 5}. You can also use the @code{step} command with
953no arguments. Some command names do not allow any arguments.
954
955@cindex abbreviation
956_GDBN__ command names may always be truncated if that abbreviation is
957unambiguous. Other possible command abbreviations are listed in the
958documentation for individual commands. In some cases, even ambiguous
959abbreviations are allowed; for example, @code{s} is specially defined as
960equivalent to @code{step} even though there are other commands whose
961names start with @code{s}. You can test abbreviations by using them as
7463aadd 962arguments to the @code{help} command.
70b88761
RP
963
964@cindex repeating commands
965@kindex RET
966A blank line as input to _GDBN__ (typing just @key{RET}) means to
967repeat the previous command. Certain commands (for example, @code{run})
968will not repeat this way; these are commands for which unintentional
969repetition might cause trouble and which you are unlikely to want to
970repeat.
971
972The @code{list} and @code{x} commands, when you repeat them with
973@key{RET}, construct new arguments rather than repeating
974exactly as typed. This permits easy scanning of source or memory.
975
976@kindex #
977@cindex comment
978A line of input starting with @kbd{#} is a comment; it does nothing.
979This is useful mainly in command files (@xref{Command Files}).
980
981@node Help, , Command Syntax, Commands
982@section Getting Help
983@cindex online documentation
984@kindex help
985You can always ask _GDBN__ itself for information on its commands, using the
986command @code{help}.
987
988@table @code
989@item help
990@itemx h
991@kindex h
992You can use @code{help} (abbreviated @code{h}) with no arguments to
993display a short list of named classes of commands:
994@smallexample
995(_GDBP__) help
996List of classes of commands:
997
998running -- Running the program
999stack -- Examining the stack
1000data -- Examining data
1001breakpoints -- Making program stop at certain points
1002files -- Specifying and examining files
1003status -- Status inquiries
1004support -- Support facilities
1005user-defined -- User-defined commands
1006aliases -- Aliases of other commands
1007obscure -- Obscure features
1008
1009Type "help" followed by a class name for a list of commands in that class.
1010Type "help" followed by command name for full documentation.
1011Command name abbreviations are allowed if unambiguous.
1012(_GDBP__)
1013@end smallexample
1014
1015@item help @var{class}
1016Using one of the general help classes as an argument, you can get a
1017list of the individual commands in that class. For example, here is the
1018help display for the class @code{status}:
1019@smallexample
1020(_GDBP__) help status
1021Status inquiries.
1022
1023List of commands:
1024
1025show -- Generic command for showing things set with "set"
1026info -- Generic command for printing status
1027
1028Type "help" followed by command name for full documentation.
1029Command name abbreviations are allowed if unambiguous.
1030(_GDBP__)
1031@end smallexample
1032
1033@item help @var{command}
1034With a command name as @code{help} argument, _GDBN__ will display a
1035short paragraph on how to use that command.
1036@end table
1037
1038In addition to @code{help}, you can use the _GDBN__ commands @code{info}
1039and @code{show} to inquire about the state of your program, or the state
1040of _GDBN__ itself. Each command supports many topics of inquiry; this
1041manual introduces each of them in the appropriate context. The listings
1042under @code{info} and under @code{show} in the Index point to
1043all the sub-commands.
1044@c FIXME: @pxref{Index} used to be here, but even though it shows up in
1045@c FIXME...the 'aux' file with a pageno the xref can't find it.
1046
1047@c @group
1048@table @code
1049@item info
1050@kindex info
1051@kindex i
1052This command (abbreviated @code{i}) is for describing the state of your
1053program; for example, it can list the arguments given to your program
1054(@code{info args}), the registers currently in use (@code{info
1055registers}), or the breakpoints you've set (@code{info breakpoints}).
1056You can get a complete list of the @code{info} sub-commands with
1057@w{@code{help info}}.
1058
1059@kindex show
1060@item show
1061In contrast, @code{show} is for describing the state of _GDBN__ itself.
1062You can change most of the things you can @code{show}, by using the
1063related command @code{set}; for example, you can control what number
1064system is used for displays with @code{set radix}, or simply inquire
1065which is currently in use with @code{show radix}.
1066
1067@kindex info set
1068To display all the settable parameters and their current
1069values, you can use @code{show} with no arguments; you may also use
1070@code{info set}. Both commands produce the same display.
1071@c FIXME: "info set" violates the rule that "info" is for state of
1072@c FIXME...program. Ck w/ GNU: "info set" to be called something else,
1073@c FIXME...or change desc of rule---eg "state of prog and debugging session"?
1074@end table
1075@c @end group
1076
1077Here are three miscellaneous @code{show} subcommands, all of which are
1078exceptional in lacking corresponding @code{set} commands:
1079
1080@table @code
1081@kindex show version
1082@item show version
1083Show what version of _GDBN__ is running. You should include this
1084information in _GDBN__ bug-reports. If multiple versions of _GDBN__ are
1085in use at your site, you may occasionally want to make sure what version
1086of _GDBN__ you're running; as _GDBN__ evolves, new commands are
1087introduced, and old ones may wither away. The version number is also
1088announced when you start _GDBN__ with no arguments.
1089
1090@kindex show copying
1091@item show copying
1092Display information about permission for copying _GDBN__.
1093
1094@kindex show warranty
1095@item show warranty
1096Display the GNU ``NO WARRANTY'' statement.
1097@end table
1098
1099@node Running, Stopping, Commands, Top
1100@chapter Running Programs Under _GDBN__
1101
1102@menu
1103* Compilation:: Compiling for Debugging
1104* Starting:: Starting your Program
1105* Arguments:: Your Program's Arguments
1106* Environment:: Your Program's Environment
1107* Working Directory:: Your Program's Working Directory
1108* Input/Output:: Your Program's Input and Output
1109* Attach:: Debugging an Already-Running Process
1110* Kill Process:: Killing the Child Process
1111@end menu
1112
1113@node Compilation, Starting, Running, Running
1114@section Compiling for Debugging
1115
1116In order to debug a program effectively, you need to generate
1117debugging information when you compile it. This debugging information
1118is stored in the object file; it describes the data type of each
1119variable or function and the correspondence between source line numbers
1120and addresses in the executable code.
1121
1122To request debugging information, specify the @samp{-g} option when you run
1123the compiler.
1124
1125Many C compilers are unable to handle the @samp{-g} and @samp{-O}
1126options together. Using those compilers, you cannot generate optimized
1127executables containing debugging information.
1128
1129The GNU C compiler supports @samp{-g} with or without @samp{-O}, making it
1130possible to debug optimized code. We recommend that you @emph{always} use
1131@samp{-g} whenever you compile a program. You may think the program is
1132correct, but there's no sense in pushing your luck.
1133
1134Some things do not work as well with @samp{-g -O} as with just
1135@samp{-g}, particularly on machines with instruction scheduling. If in
1136doubt, recompile with @samp{-g} alone, and if this fixes the problem,
1137please report it as a bug (including a test case!).
1138
1139Older versions of the GNU C compiler permitted a variant option
1140@samp{-gg} for debugging information. _GDBN__ no longer supports this
1141format; if your GNU C compiler has this option, do not use it.
1142
1143@ignore
1144@comment As far as I know, there are no cases in which _GDBN__ will
1145@comment produce strange output in this case. (but no promises).
1146If your program includes archives made with the @code{ar} program, and
1147if the object files used as input to @code{ar} were compiled without the
1148@samp{-g} option and have names longer than 15 characters, _GDBN__ will get
1149confused reading the program's symbol table. No error message will be
1150given, but _GDBN__ may behave strangely. The reason for this problem is a
1151deficiency in the Unix archive file format, which cannot represent file
1152names longer than 15 characters.
1153
1154To avoid this problem, compile the archive members with the @samp{-g}
1155option or use shorter file names. Alternatively, use a version of GNU
1156@code{ar} dated more recently than August 1989.
1157@end ignore
1158
1159
1160@node Starting, Arguments, Compilation, Running
1161@section Starting your Program
1162@cindex starting
1163@cindex running
1164@table @code
1165@item run
1166@itemx r
1167@kindex run
7463aadd
RP
1168Use the @code{run} command to start your program under _GDBN__. You
1169must first specify the program name
1170_if__(_VXWORKS__)
1171(except on VxWorks)
70b88761 1172_fi__(_VXWORKS__)
7463aadd 1173with an argument to _GDBN__
70b88761 1174(@pxref{Invocation}), or using the @code{file} or @code{exec-file}
7463aadd
RP
1175command (@pxref{Files}).
1176@refill
70b88761
RP
1177@end table
1178
1179On targets that support processes, @code{run} creates an inferior
1180process and makes that process run your program. On other targets,
1181@code{run} jumps to the start of the program.
1182
1183The execution of a program is affected by certain information it
1184receives from its superior. _GDBN__ provides ways to specify this
1185information, which you must do @i{before} starting the program. (You
1186can change it after starting the program, but such changes will only affect
1187the program the next time you start it.) This information may be
1188divided into four categories:
1189
1190@table @asis
1191@item The @i{arguments.}
1192You specify the arguments to give your program as the arguments of the
1193@code{run} command. If a shell is available on your target, the shell
1194is used to pass the arguments, so that you may use normal conventions
1195(such as wildcard expansion or variable substitution) in
1196describing the arguments. In Unix systems, you can control which shell
1197is used with the @code{SHELL} environment variable. @xref{Arguments}.@refill
1198
1199@item The @i{environment.}
1200Your program normally inherits its environment from _GDBN__, but you can
1201use the _GDBN__ commands @code{set environment} and @code{unset
1202environment} to change parts of the environment that will be given to
1203the program. @xref{Environment}.@refill
1204
1205@item The @i{working directory.}
1206Your program inherits its working directory from _GDBN__. You can set
1207_GDBN__'s working directory with the @code{cd} command in _GDBN__.
1208@xref{Working Directory}.
1209
1210@item The @i{standard input and output.}
1211Your program normally uses the same device for standard input and
1212standard output as _GDBN__ is using. You can redirect input and output
1213in the @code{run} command line, or you can use the @code{tty} command to
1214set a different device for your program.
1215@xref{Input/Output}.
1216@end table
1217
1218When you issue the @code{run} command, your program begins to execute
1219immediately. @xref{Stopping}, for discussion of how to arrange for your
1220program to stop. Once your program has been started by the @code{run}
1221command (and then stopped), you may evaluate expressions that involve
1222calls to functions in the inferior, using the @code{print} or
1223@code{call} commands. @xref{Data}.
1224
1225If the modification time of your symbol file has changed since the last
1226time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and re-read
1227it. In this process, it tries to retain your current breakpoints.
1228
1229@node Arguments, Environment, Starting, Running
1230@section Your Program's Arguments
1231
1232@cindex arguments (to your program)
1233The arguments to your program can be specified by the arguments of the
1234@code{run} command. They are passed to a shell, which expands wildcard
1235characters and performs redirection of I/O, and thence to the program.
1236_GDBN__ uses the shell indicated by your environment variable
1237@code{SHELL} if it exists; otherwise, _GDBN__ uses @code{/bin/sh}.
1238
1239@code{run} with no arguments uses the same arguments used by the previous
1240@code{run}, or those set by the @code{set args} command.
1241
1242@kindex set args
1243@table @code
1244@item set args
1245Specify the arguments to be used the next time your program is run. If
1246@code{set args} has no arguments, @code{run} will execute your program
1247with no arguments. Once you have run your program with arguments,
1248using @code{set args} before the next @code{run} is the only way to run
1249it again without arguments.
1250
1251@item show args
1252@kindex show args
1253Show the arguments to give your program when it is started.
1254@end table
1255
1256@node Environment, Working Directory, Arguments, Running
1257@section Your Program's Environment
1258
1259@cindex environment (of your program)
1260The @dfn{environment} consists of a set of environment variables and
1261their values. Environment variables conventionally record such things as
1262your user name, your home directory, your terminal type, and your search
1263path for programs to run. Usually you set up environment variables with
1264the shell and they are inherited by all the other programs you run. When
1265debugging, it can be useful to try running the program with a modified
1266environment without having to start _GDBN__ over again.
1267
1268@table @code
1269@item path @var{directory}
1270@kindex path
1271Add @var{directory} to the front of the @code{PATH} environment variable
1272(the search path for executables), for both _GDBN__ and your program.
1273You may specify several directory names, separated by @samp{:} or
1274whitespace. If @var{directory} is already in the path, it is moved to
7463aadd
RP
1275the front, so it will be searched sooner.
1276
1277You can use the string @samp{$cwd} to refer to whatever is the current
1278working directory at the time _GDBN__ searches the path. If you use
1279@samp{.} instead, it refers to the directory where you executed the
1280@code{path} command. _GDBN__ fills in the current path where needed in
1281the @var{directory} argument, before adding it to the search path.
70b88761
RP
1282@c 'path' is explicitly nonrepeatable, but RMS points out it's silly to
1283@c document that, since repeating it would be a no-op.
1284
1285@item show paths
1286@kindex show paths
1287Display the list of search paths for executables (the @code{PATH}
1288environment variable).
1289
1290@item show environment @r{[}@var{varname}@r{]}
1291@kindex show environment
1292Print the value of environment variable @var{varname} to be given to
1293your program when it starts. If you don't supply @var{varname},
1294print the names and values of all environment variables to be given to
1295your program. You can abbreviate @code{environment} as @code{env}.
1296
7463aadd 1297@item set environment @var{varname} @r{[}=@r{]} @var{value}
70b88761
RP
1298@kindex set environment
1299Sets environment variable @var{varname} to @var{value}. The value
1300changes for your program only, not for _GDBN__ itself. @var{value} may
1301be any string; the values of environment variables are just strings, and
1302any interpretation is supplied by your program itself. The @var{value}
1303parameter is optional; if it is eliminated, the variable is set to a
1304null value.
1305@c "any string" here doesn't include leading, trailing
1306@c blanks. Gnu asks: does anyone care?
1307
1308For example, this command:
1309
1310@example
1311set env USER = foo
1312@end example
1313
1314@noindent
1315tells a Unix program, when subsequently run, that its user is named
1316@samp{foo}. (The spaces around @samp{=} are used for clarity here; they
1317are not actually required.)
1318
1319@item unset environment @var{varname}
1320@kindex unset environment
1321Remove variable @var{varname} from the environment to be passed to your
1322program. This is different from @samp{set env @var{varname} =};
1323@code{unset environment} removes the variable from the environment,
1324rather than assigning it an empty value.
1325@end table
1326
1327@node Working Directory, Input/Output, Environment, Running
1328@section Your Program's Working Directory
1329
1330@cindex working directory (of your program)
1331Each time you start your program with @code{run}, it inherits its
1332working directory from the current working directory of _GDBN__. _GDBN__'s
1333working directory is initially whatever it inherited from its parent
1334process (typically the shell), but you can specify a new working
1335directory in _GDBN__ with the @code{cd} command.
1336
1337The _GDBN__ working directory also serves as a default for the commands
1338that specify files for _GDBN__ to operate on. @xref{Files}.
1339
1340@table @code
1341@item cd @var{directory}
1342@kindex cd
1343Set _GDBN__'s working directory to @var{directory}.
1344
1345@item pwd
1346@kindex pwd
1347Print _GDBN__'s working directory.
1348@end table
1349
1350@node Input/Output, Attach, Working Directory, Running
1351@section Your Program's Input and Output
1352
1353@cindex redirection
1354@cindex i/o
1355@cindex terminal
1356By default, the program you run under _GDBN__ does input and output to
1357the same terminal that _GDBN__ uses. _GDBN__ switches the terminal to
1358its own terminal modes to interact with you, but it records the terminal
1359modes your program was using and switches back to them when you continue
1360running your program.
1361
1362@table @code
1363@item info terminal
1364@kindex info terminal
1365Displays _GDBN__'s recorded information about the terminal modes your
1366program is using.
1367@end table
1368
1369You can redirect the program's input and/or output using shell
1370redirection with the @code{run} command. For example,
1371
1372_0__@example
1373run > outfile
1374_1__@end example
1375
1376@noindent
1377starts the program, diverting its output to the file @file{outfile}.
1378
1379@kindex tty
1380@cindex controlling terminal
1381Another way to specify where the program should do input and output is
1382with the @code{tty} command. This command accepts a file name as
1383argument, and causes this file to be the default for future @code{run}
1384commands. It also resets the controlling terminal for the child
1385process, for future @code{run} commands. For example,
1386
1387@example
1388tty /dev/ttyb
1389@end example
1390
1391@noindent
1392directs that processes started with subsequent @code{run} commands
1393default to do input and output on the terminal @file{/dev/ttyb} and have
1394that as their controlling terminal.
1395
1396An explicit redirection in @code{run} overrides the @code{tty} command's
1397effect on the input/output device, but not its effect on the controlling
1398terminal.
1399
1400When you use the @code{tty} command or redirect input in the @code{run}
1401command, only the input @emph{for your program} is affected. The input
1402for _GDBN__ still comes from your terminal.
1403
1404@node Attach, Kill Process, Input/Output, Running
1405@section Debugging an Already-Running Process
1406@kindex attach
1407@cindex attach
1408
1409@table @code
1410@item attach @var{process-id}
1411This command
1412attaches to a running process---one that was started outside _GDBN__.
1413(@code{info files} will show your active targets.) The command takes as
1414argument a process ID. The usual way to find out the process-id of
1415a Unix process is with the @code{ps} utility, or with the @samp{jobs -l}
1416shell command.
1417
1418@code{attach} will not repeat if you press @key{RET} a second time after
1419executing the command.
1420@end table
1421
1422To use @code{attach}, you must be debugging in an environment which
1423supports processes. You must also have permission to send the process a
1424signal, and it must have the same effective user ID as the _GDBN__
1425process.
1426
1427When using @code{attach}, you should first use the @code{file} command
1428to specify the program running in the process and load its symbol table.
1429@xref{Files}.
1430
1431The first thing _GDBN__ does after arranging to debug the specified
1432process is to stop it. You can examine and modify an attached process
1433with all the _GDBN__ commands that are ordinarily available when you start
1434processes with @code{run}. You can insert breakpoints; you can step and
1435continue; you can modify storage. If you would rather the process
1436continue running, you may use the @code{continue} command after
1437attaching _GDBN__ to the process.
1438
1439@table @code
1440@item detach
1441@kindex detach
1442When you have finished debugging the attached process, you can use the
1443@code{detach} command to release it from _GDBN__'s control. Detaching
1444the process continues its execution. After the @code{detach} command,
1445that process and _GDBN__ become completely independent once more, and you
1446are ready to @code{attach} another process or start one with @code{run}.
1447@code{detach} will not repeat if you press @key{RET} again after
1448executing the command.
1449@end table
1450
1451If you exit _GDBN__ or use the @code{run} command while you have an attached
1452process, you kill that process. By default, you will be asked for
1453confirmation if you try to do either of these things; you can control
1454whether or not you need to confirm by using the @code{set confirm} command
1455(@pxref{Messages/Warnings}).
1456
1457@node Kill Process, , Attach, Running
1458@c @group
1459@section Killing the Child Process
1460
1461@table @code
1462@item kill
1463@kindex kill
1464Kill the child process in which your program is running under _GDBN__.
1465@end table
1466
1467This command is useful if you wish to debug a core dump instead of a
1468running process. _GDBN__ ignores any core dump file while your program
1469is running.
1470@c @end group
1471
1472On some operating systems, a program can't be executed outside _GDBN__
1473while you have breakpoints set on it inside _GDBN__. You can use the
1474@code{kill} command in this situation to permit running the program
1475outside the debugger.
1476
1477The @code{kill} command is also useful if you wish to recompile and
1478relink the program, since on many systems it is impossible to modify an
1479executable file while it is running in a process. In this case, when you
1480next type @code{run}, _GDBN__ will notice that the file has changed, and
1481will re-read the symbol table (while trying to preserve your current
1482breakpoint settings).
1483
1484@node Stopping, Stack, Running, Top
1485@chapter Stopping and Continuing
1486
1487The principal purpose of using a debugger is so that you can stop your
1488program before it terminates; or so that, if the program runs into
1489trouble, you can investigate and find out why.
1490
1491Inside _GDBN__, your program may stop for any of several reasons, such
1492as a signal, a breakpoint, or reaching a new line after a _GDBN__
1493command such as @code{step}. You may then examine and change
1494variables, set new breakpoints or remove old ones, and then continue
1495execution. Usually, the messages shown by _GDBN__ provide ample
1496explanation of the status of your program---but you can also explicitly
1497request this information at any time.
1498
1499@table @code
1500@item info program
1501@kindex info program
1502Display information about the status of your program: whether it is
1503running or not, what process it is, and why it stopped.
1504@end table
1505
1506@menu
1507* Breakpoints:: Breakpoints, Watchpoints, and Exceptions
7463aadd 1508* Stepping and Continuing:: Stepping and Continuing
70b88761
RP
1509* Signals:: Signals
1510@end menu
1511
1512@node Breakpoints, Stepping, Stopping, Stopping
1513@section Breakpoints, Watchpoints, and Exceptions
1514
1515@cindex breakpoints
1516A @dfn{breakpoint} makes your program stop whenever a certain point in
1517the program is reached. For each breakpoint, you can add various
1518conditions to control in finer detail whether the program will stop.
1519You can set breakpoints with the @code{break} command and its variants
1520(@pxref{Set Breaks}), to specify the place where the program should stop
1521by line number, function name or exact address in the program. In
1522languages with exception handling (such as GNU C++), you can also set
1523breakpoints where an exception is raised (@pxref{Exception Handling}).
1524
1525@cindex watchpoints
1526A @dfn{watchpoint} is a special breakpoint that stops your program when
1527the value of an expression changes. You must use a different command to
1528set watchpoints (@pxref{Set Watchpoints}), but aside from that, you can
1529manage a watchpoint like any other breakpoint: you enable, disable, and
1530delete both breakpoints and watchpoints using the same commands.
1531
1532Each breakpoint or watchpoint is assigned a number when it is created;
1533these numbers are successive integers starting with one. In many of the
1534commands for controlling various features of breakpoints you use the
1535breakpoint number to say which breakpoint you want to change. Each
1536breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has
1537no effect on the program until you enable it again.
1538
1539@menu
1540* Set Breaks:: Setting Breakpoints
1541* Set Watchpoints:: Setting Watchpoints
1542* Exception Handling:: Breakpoints and Exceptions
1543* Delete Breaks:: Deleting Breakpoints
1544* Disabling:: Disabling Breakpoints
1545* Conditions:: Break Conditions
1546* Break Commands:: Breakpoint Command Lists
1547* Breakpoint Menus:: Breakpoint Menus
1548* Error in Breakpoints::
1549@end menu
1550
1551@node Set Breaks, Set Watchpoints, Breakpoints, Breakpoints
1552@subsection Setting Breakpoints
1553
1554@kindex break
1555@kindex b
1556Breakpoints are set with the @code{break} command (abbreviated @code{b}).
1557
1558You have several ways to say where the breakpoint should go.
1559
1560@table @code
1561@item break @var{function}
1562Set a breakpoint at entry to function @var{function}. When using source
1563languages that permit overloading of symbols, such as C++,
1564@var{function} may refer to more than one possible place to break.
1565@xref{Breakpoint Menus}, for a discussion of that situation.
1566
1567@item break +@var{offset}
1568@itemx break -@var{offset}
1569Set a breakpoint some number of lines forward or back from the position
1570at which execution stopped in the currently selected frame.
1571
1572@item break @var{linenum}
1573Set a breakpoint at line @var{linenum} in the current source file.
1574That file is the last file whose source text was printed. This
1575breakpoint will stop the program just before it executes any of the
1576code on that line.
1577
1578@item break @var{filename}:@var{linenum}
1579Set a breakpoint at line @var{linenum} in source file @var{filename}.
1580
1581@item break @var{filename}:@var{function}
1582Set a breakpoint at entry to function @var{function} found in file
1583@var{filename}. Specifying a file name as well as a function name is
1584superfluous except when multiple files contain similarly named
1585functions.
1586
1587@item break *@var{address}
1588Set a breakpoint at address @var{address}. You can use this to set
1589breakpoints in parts of the program which do not have debugging
1590information or source files.
1591
1592@item break
1593When called without any arguments, @code{break} sets a breakpoint at the
1594next instruction to be executed in the selected stack frame
1595(@pxref{Stack}). In any selected frame but the innermost, this will
1596cause the program to stop as soon as control returns to that frame.
1597This is similar to the effect of a @code{finish} command in the frame
1598inside the selected frame---except that @code{finish} doesn't leave an
1599active breakpoint. If you use @code{break} without an argument in the
1600innermost frame, _GDBN__ will stop the next time it reaches the current
1601location; this may be useful inside loops.
1602
1603_GDBN__ normally ignores breakpoints when it resumes execution, until at
1604least one instruction has been executed. If it did not do this, you
1605would be unable to proceed past a breakpoint without first disabling the
1606breakpoint. This rule applies whether or not the breakpoint already
1607existed when the program stopped.
1608
1609@item break @dots{} if @var{cond}
1610Set a breakpoint with condition @var{cond}; evaluate the expression
1611@var{cond} each time the breakpoint is reached, and stop only if the
1612value is nonzero. @samp{@dots{}} stands for one of the possible
1613arguments described above (or no argument) specifying where to break.
1614@xref{Conditions}, for more information on breakpoint conditions.
1615
1616@item tbreak @var{args}
1617@kindex tbreak
1618Set a breakpoint enabled only for one stop. @var{args} are the
1619same as for the @code{break} command, and the breakpoint is set in the same
1620way, but the breakpoint is automatically disabled the first time it
1621is hit. @xref{Disabling}.
1622
1623@item rbreak @var{regex}
1624@kindex rbreak
1625@cindex regular expression
1626@c FIXME: 2nd sentence below C++ only?
1627Set breakpoints on all functions matching the regular expression
1628@var{regex}. This is useful for setting breakpoints on overloaded
1629functions that are not members of any special classes. This command
1630sets an unconditional breakpoint on all matches, printing a list of all
1631breakpoints it set. Once these breakpoints are set, they are treated
1632just like the breakpoints set with the @code{break} command. They can
1633be deleted, disabled, made conditional, etc., in the standard ways.
1634
1635@kindex info breakpoints
1636@kindex $_
1637@item info breakpoints @r{[}@var{n}@r{]}
1638@item info break @r{[}@var{n}@r{]}
1639Print a list of all breakpoints (but not watchpoints) set and not
1640deleted, showing their numbers, where in the program they are, and any
1641special features in use for them. Disabled breakpoints are included in
1642the list, but marked as disabled. @code{info break} with a breakpoint
1643number @var{n} as argument lists only that breakpoint. The convenience
1644variable @code{$_} and the default examining-address for the @code{x}
1645command are set to the address of the last breakpoint listed
1646(@pxref{Memory}). The equivalent command for watchpoints is @code{info
1647watch}. @end table
1648
1649_GDBN__ allows you to set any number of breakpoints at the same place in the
1650program. There is nothing silly or meaningless about this. When the
1651breakpoints are conditional, this is even useful (@pxref{Conditions}).
1652
1653@node Set Watchpoints, Exception Handling, Set Breaks, Breakpoints
1654@subsection Setting Watchpoints
1655@cindex setting watchpoints
1656You can use a watchpoint to stop execution whenever the value of an
1657expression changes, without having to predict a particular place
1658where this may happen.
1659
1660Watchpoints currently execute two orders of magnitude more slowly than
1661other breakpoints, but this can well be worth it to catch errors where
1662you have no clue what part of your program is the culprit. Some
1663processors provide special hardware to support watchpoint evaluation; future
1664releases of _GDBN__ will use such hardware if it is available.
1665
1666@table @code
1667@kindex watch
1668@item watch @var{expr}
1669Set a watchpoint for an expression.
1670
1671@kindex info watchpoints
1672@item info watchpoints
1673This command prints a list of watchpoints; it is otherwise similar to
1674@code{info break}.
1675@end table
1676
1677@node Exception Handling, Delete Breaks, Set Watchpoints, Breakpoints
1678@subsection Breakpoints and Exceptions
1679@cindex exception handlers
1680
1681Some languages, such as GNU C++, implement exception handling. _GDBN__
1682can be used to examine what caused the program to raise an exception
1683and to list the exceptions the program is prepared to handle at a
1684given point in time.
1685
1686@table @code
1687@item catch @var{exceptions}
1688@kindex catch
1689You can set breakpoints at active exception handlers by using the
1690@code{catch} command. @var{exceptions} is a list of names of exceptions
1691to catch.
1692@end table
1693
1694You can use @code{info catch} to list active exception handlers;
1695@pxref{Frame Info}.
1696
1697There are currently some limitations to exception handling in _GDBN__.
1698These will be corrected in a future release.
1699
1700@itemize @bullet
1701@item
1702If you call a function interactively, _GDBN__ normally returns
1703control to you when the function has finished executing. If the call
1704raises an exception, however, the call may bypass the mechanism that
1705returns control to the user and cause the program to simply continue
1706running until it hits a breakpoint, catches a signal that _GDBN__ is
1707listening for, or exits.
1708@item
1709You cannot raise an exception interactively.
1710@item
1711You cannot interactively install an exception handler.
1712@end itemize
1713
1714@cindex raise exceptions
1715Sometimes @code{catch} is not the best way to debug exception handling:
1716if you need to know exactly where an exception is raised, it's better to
1717stop @emph{before} the exception handler is called, since that way you
1718can see the stack before any unwinding takes place. If you set a
1719breakpoint in an exception handler instead, it may not be easy to find
1720out where the exception was raised.
1721
1722To stop just before an exception handler is called, you need some
1723knowledge of the implementation. In the case of GNU C++ exceptions are
1724raised by calling a library function named @code{__raise_exception}
1725which has the following ANSI C interface:
1726
1727@example
1728 /* ADDR is where the exception identifier is stored.
1729 ID is the exception identifier. */
1730 void __raise_exception (void **@var{addr}, void *@var{id});
1731@end example
1732
1733@noindent
1734To make the debugger catch all exceptions before any stack
1735unwinding takes place, set a breakpoint on @code{__raise_exception}
1736(@pxref{Breakpoints}).
1737
1738With a conditional breakpoint (@xref{Conditions}) that depends on the
1739value of @var{id}, you can stop your program when a specific exception
1740is raised. You can use multiple conditional breakpoints to stop the
1741program when any of a number of exceptions are raised.
1742
1743@node Delete Breaks, Disabling, Exception Handling, Breakpoints
1744@subsection Deleting Breakpoints
1745
1746@cindex clearing breakpoints, watchpoints
1747@cindex deleting breakpoints, watchpoints
1748It is often necessary to eliminate a breakpoint or watchpoint once it
1749has done its job and you no longer want the program to stop there. This
1750is called @dfn{deleting} the breakpoint. A breakpoint that has been
1751deleted no longer exists; it is forgotten.
1752
1753With the @code{clear} command you can delete breakpoints according to
1754where they are in the program. With the @code{delete} command you can
1755delete individual breakpoints or watchpoints by specifying their
1756breakpoint numbers.
1757
1758It is not necessary to delete a breakpoint to proceed past it. _GDBN__
1759automatically ignores breakpoints on the first instruction to be executed
1760when you continue execution without changing the execution address.
1761
1762@table @code
1763@item clear
1764@kindex clear
1765Delete any breakpoints at the next instruction to be executed in the
1766selected stack frame (@pxref{Selection}). When the innermost frame
1767is selected, this is a good way to delete a breakpoint that the program
1768just stopped at.
1769
1770@item clear @var{function}
1771@itemx clear @var{filename}:@var{function}
1772Delete any breakpoints set at entry to the function @var{function}.
1773
1774@item clear @var{linenum}
1775@itemx clear @var{filename}:@var{linenum}
1776Delete any breakpoints set at or within the code of the specified line.
1777
1778@item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
1779@cindex delete breakpoints
1780@kindex delete
1781@kindex d
1782Delete the breakpoints or watchpoints of the numbers specified as
1783arguments. If no argument is specified, delete all breakpoints (_GDBN__
1784asks confirmation, unless you've @code{set confirm off}). You
1785can abbreviate this command as @code{d}.
1786@end table
1787
1788@node Disabling, Conditions, Delete Breaks, Breakpoints
1789@subsection Disabling Breakpoints
1790
1791@cindex disabled breakpoints
1792@cindex enabled breakpoints
1793Rather than deleting a breakpoint or watchpoint, you might prefer to
1794@dfn{disable} it. This makes the breakpoint inoperative as if it had
1795been deleted, but remembers the information on the breakpoint so that
1796you can @dfn{enable} it again later.
1797
1798You disable and enable breakpoints and watchpoints with the
1799@code{enable} and @code{disable} commands, optionally specifying one or
1800more breakpoint numbers as arguments. Use @code{info break} or
1801@code{info watch} to print a list of breakpoints or watchpoints if you
1802don't know which numbers to use.
1803
1804A breakpoint or watchpoint can have any of four different states of
1805enablement:
1806
1807@itemize @bullet
1808@item
1809Enabled. The breakpoint will stop the program. A breakpoint set
1810with the @code{break} command starts out in this state.
1811@item
1812Disabled. The breakpoint has no effect on the program.
1813@item
1814Enabled once. The breakpoint will stop the program, but
1815when it does so it will become disabled. A breakpoint set
1816with the @code{tbreak} command starts out in this state.
1817@item
1818Enabled for deletion. The breakpoint will stop the program, but
1819immediately after it does so it will be deleted permanently.
1820@end itemize
1821
1822You can use the following commands to enable or disable breakpoints and
1823watchpoints:
1824
1825@table @code
1826@item disable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
1827@kindex disable breakpoints
1828@kindex disable
1829@kindex dis
1830Disable the specified breakpoints---or all breakpoints, if none are
1831listed. A disabled breakpoint has no effect but is not forgotten. All
1832options such as ignore-counts, conditions and commands are remembered in
1833case the breakpoint is enabled again later. You may abbreviate
1834@code{disable} as @code{dis}.
1835
1836@item enable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
1837@kindex enable breakpoints
1838@kindex enable
1839Enable the specified breakpoints (or all defined breakpoints). They
1840become effective once again in stopping the program.
1841
1842@item enable @r{[}breakpoints@r{]} once @var{bnums}@dots{}
1843Enable the specified breakpoints temporarily. Each will be disabled
1844again the next time it stops the program.
1845
1846@item enable @r{[}breakpoints@r{]} delete @var{bnums}@dots{}
1847Enable the specified breakpoints to work once and then die. Each of
1848the breakpoints will be deleted the next time it stops the program.
1849@end table
1850
1851Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks}),
1852breakpoints that you set are initially enabled; subsequently, they become
1853disabled or enabled only when you use one of the commands above. (The
1854command @code{until} can set and delete a breakpoint of its own, but it
1855will not change the state of your other breakpoints;
1856@pxref{Stepping}.)
1857
1858@node Conditions, Break Commands, Disabling, Breakpoints
1859@subsection Break Conditions
1860@cindex conditional breakpoints
1861@cindex breakpoint conditions
1862
1863The simplest sort of breakpoint breaks every time the program reaches a
1864specified place. You can also specify a @dfn{condition} for a
1865breakpoint. A condition is just a Boolean expression in your
1866programming language. (@xref{Expressions}). A breakpoint with a
1867condition evaluates the expression each time the program reaches it, and
1868the program stops only if the condition is true.
1869
1870Conditions are also accepted for watchpoints; you may not need them,
1871since a watchpoint is inspecting the value of an expression anyhow---but
1872it might be simpler, say, to just set a watchpoint on a variable name,
1873and specify a condition that tests whether the new value is an interesting
1874one.
1875
1876Break conditions ca have side effects, and may even call functions in
1877your program. This can be useful, for example, to activate functions
1878that log program progress, or to use your own print functions to format
1879special data structures. The effects are completely predictable unless
1880there is another enabled breakpoint at the same address. (In that
1881case, _GDBN__ might see the other breakpoint first and stop the program
1882without checking the condition of this one.) Note that breakpoint
1883commands are usually more convenient and flexible for the purpose of
1884performing side effects when a breakpoint is reached (@pxref{Break
1885Commands}).
1886
1887Break conditions can be specified when a breakpoint is set, by using
1888@samp{if} in the arguments to the @code{break} command. @xref{Set Breaks}.
1889They can also be changed at any time with the @code{condition} command.
1890The @code{watch} command doesn't recognize the @code{if} keyword;
1891@code{condition} is the only way to impose a further condition on a
1892watchpoint.
1893
1894@table @code
1895@item condition @var{bnum} @var{expression}
1896@kindex condition
1897Specify @var{expression} as the break condition for breakpoint or
1898watchpoint number @var{bnum}. From now on, this breakpoint will stop
1899the program only if the value of @var{expression} is true (nonzero, in
1900C). When you use @code{condition}, _GDBN__ checks @var{expression}
1901immediately for syntactic correctness, and to determine whether symbols
1902in it have referents in the context of your breakpoint. _GDBN__ does
1903not actually evaluate @var{expression} at the time the @code{condition}
1904command is given, however. @xref{Expressions}.
1905
1906@item condition @var{bnum}
1907Remove the condition from breakpoint number @var{bnum}. It becomes
1908an ordinary unconditional breakpoint.
1909@end table
1910
1911@cindex ignore count (of breakpoint)
1912A special case of a breakpoint condition is to stop only when the
1913breakpoint has been reached a certain number of times. This is so
1914useful that there is a special way to do it, using the @dfn{ignore
1915count} of the breakpoint. Every breakpoint has an ignore count, which
1916is an integer. Most of the time, the ignore count is zero, and
1917therefore has no effect. But if the program reaches a breakpoint whose
1918ignore count is positive, then instead of stopping, it just decrements
1919the ignore count by one and continues. As a result, if the ignore count
1920value is @var{n}, the breakpoint will not stop the next @var{n} times it
1921is reached.
1922
1923@table @code
1924@item ignore @var{bnum} @var{count}
1925@kindex ignore
1926Set the ignore count of breakpoint number @var{bnum} to @var{count}.
1927The next @var{count} times the breakpoint is reached, your program's
1928execution will not stop; other than to decrement the ignore count, _GDBN__
1929takes no action.
1930
1931To make the breakpoint stop the next time it is reached, specify
1932a count of zero.
1933
1934@item continue @var{count}
1935@itemx c @var{count}
1936@itemx fg @var{count}
1937@kindex continue @var{count}
1938Continue execution of the program, setting the ignore count of the
1939breakpoint that the program stopped at to @var{count} minus one.
1940Thus, the program will not stop at this breakpoint until the
1941@var{count}'th time it is reached.
1942
1943An argument to this command is meaningful only when the program stopped
1944due to a breakpoint. At other times, the argument to @code{continue} is
1945ignored.
1946
1947The synonym @code{fg} is provided purely for convenience, and has
1948exactly the same behavior as other forms of the command.
1949@end table
1950
1951If a breakpoint has a positive ignore count and a condition, the condition
1952is not checked. Once the ignore count reaches zero, the condition will
1953be checked.
1954
1955You could achieve the effect of the ignore count with a
1956condition such as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience
1957variable that is decremented each time. @xref{Convenience Vars}.
1958
1959@node Break Commands, Breakpoint Menus, Conditions, Breakpoints
1960@subsection Breakpoint Command Lists
1961
1962@cindex breakpoint commands
1963You can give any breakpoint (or watchpoint) a series of commands to
1964execute when the program stops due to that breakpoint. For example, you
1965might want to print the values of certain expressions, or enable other
1966breakpoints.
1967
1968@table @code
1969@item commands @r{[}@var{bnum}@r{]}
1970@itemx @dots{} @var{command-list} @dots{}
1971@itemx end
1972@kindex commands
1973@kindex end
1974Specify a list of commands for breakpoint number @var{bnum}. The commands
1975themselves appear on the following lines. Type a line containing just
1976@code{end} to terminate the commands.
1977
1978To remove all commands from a breakpoint, type @code{commands} followed
1979immediately by @code{end}; that is, give no commands.
1980
1981With no @var{bnum} argument, @code{commands} refers to the last
1982breakpoint or watchpoint set (not to the breakpoint most recently
1983encountered).
1984@end table
1985
1986Pressing @key{RET} as a means of repeating the last _GDBN__ command is
1987disabled within a @var{command-list}.
1988
1989You can use breakpoint commands to start the program up again. Simply
1990use the @code{continue} command, or @code{step}, or any other command
1991that resumes execution. Subsequent commands in the command list are
1992ignored.
1993
1994@kindex silent
1995If the first command specified is @code{silent}, the usual message about
1996stopping at a breakpoint is not printed. This may be desirable for
1997breakpoints that are to print a specific message and then continue.
1998If the remaining commands too print nothing, you will see no sign that
1999the breakpoint was reached at all. @code{silent} is meaningful only
2000at the beginning of a breakpoint command list.
2001
2002The commands @code{echo} and @code{output} that allow you to print precisely
2003controlled output are often useful in silent breakpoints. @xref{Output}.
2004
2005For example, here is how you could use breakpoint commands to print the
2006value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
2007
2008_0__@example
2009break foo if x>0
2010commands
2011silent
2012echo x is\040
2013output x
2014echo \n
2015cont
2016end
2017_1__@end example
2018
2019One application for breakpoint commands is to compensate for one bug so
2020you can test for another. Put a breakpoint just after the erroneous line
2021of code, give it a condition to detect the case in which something
2022erroneous has been done, and give it commands to assign correct values
2023to any variables that need them. End with the @code{continue} command
2024so that the program does not stop, and start with the @code{silent}
2025command so that no output is produced. Here is an example:
2026
2027@example
2028break 403
2029commands
2030silent
2031set x = y + 4
2032cont
2033end
2034@end example
2035
2036@cindex lost output
2037One deficiency in the operation of automatically continuing breakpoints
2038under Unix appears when your program uses raw mode for the terminal.
2039_GDBN__ switches back to its own terminal modes (not raw) before executing
2040commands, and then must switch back to raw mode when your program is
2041continued. This causes any pending terminal input to be lost.
2042@c FIXME: revisit below when GNU sys avail.
2043@c In the GNU system, this will be fixed by changing the behavior of
2044@c terminal modes.
2045
2046Under Unix, you can get around this problem by writing actions into
2047the breakpoint condition rather than in commands. For example
2048
2049@example
2050condition 5 (x = y + 4), 0
2051@end example
2052
2053@noindent
2054specifies a condition expression (@xref{Expressions}) that will change
2055@code{x} as needed, then always have the value zero so the program will
2056not stop. No input is lost here, because _GDBN__ evaluates break
2057conditions without changing the terminal modes. When you want to have
2058nontrivial conditions for performing the side effects, the operators
2059@samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful.
2060
2061@node Breakpoint Menus, Error in Breakpoints, Break Commands, Breakpoints
2062@subsection Breakpoint Menus
2063@cindex C++ overloading
2064@cindex symbol overloading
2065
2066Some programming languages (notably C++) permit a single function name
2067to be defined several times, for application in different contexts.
2068This is called @dfn{overloading}. When a function name is overloaded,
2069@samp{break @var{function}} is not enough to tell _GDBN__ where you
2070want a breakpoint. _GDBN__ offers you a menu of numbered choices for
2071different possible breakpoints, and waits for your selection with the
2072prompt @samp{>}. The first two options are always @samp{[0] cancel}
2073and @samp{[1] all}. Typing @kbd{1} sets a breakpoint at each
2074definition of @var{function}, and typing @kbd{0} aborts the
2075@code{break} command without setting any new breakpoints.
2076
2077For example, the following session excerpt shows an attempt to set a
2078breakpoint at the overloaded symbol @code{String::after}.
2079We choose three particular definitions of that function name:
2080
2081@example
2082(_GDBP__) b String::after
2083[0] cancel
2084[1] all
2085[2] file:String.cc; line number:867
2086[3] file:String.cc; line number:860
2087[4] file:String.cc; line number:875
2088[5] file:String.cc; line number:853
2089[6] file:String.cc; line number:846
2090[7] file:String.cc; line number:735
2091> 2 4 6
2092Breakpoint 1 at 0xb26c: file String.cc, line 867.
2093Breakpoint 2 at 0xb344: file String.cc, line 875.
2094Breakpoint 3 at 0xafcc: file String.cc, line 846.
2095Multiple breakpoints were set.
2096Use the "delete" command to delete unwanted breakpoints.
2097(_GDBP__)
2098@end example
2099
2100
2101@node Error in Breakpoints, , Breakpoint Menus, Breakpoints
2102@subsection ``Cannot Insert Breakpoints''
2103
2104@c FIXME: "cannot insert breakpoints" error, v unclear.
2105@c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91
2106Under some operating systems, breakpoints cannot be used in a program if
2107any other process is running that program. In this situation,
2108attempting to run or continue a program with a breakpoint causes _GDBN__
2109to stop the other process.
2110
2111When this happens, you have three ways to proceed:
2112
2113@enumerate
2114@item
2115Remove or disable the breakpoints, then continue.
2116
2117@item
2118Suspend _GDBN__, and copy the file containing the program to a new name.
2119Resume _GDBN__ and use the @code{exec-file} command to specify that _GDBN__
2120should run the program under that name. Then start the program again.
2121
2122@c FIXME: RMS commented here "Show example". Maybe when someone
2123@c explains the first FIXME: in this section...
2124
2125@item
2126Relink the program so that the text segment is nonsharable, using the
2127linker option @samp{-N}. The operating system limitation may not apply
2128to nonsharable executables.
2129@end enumerate
2130
7463aadd
RP
2131@node Stepping and Continuing, Signals, Breakpoints, Stopping
2132@section Stepping and Continuing
70b88761
RP
2133
2134@cindex stepping
7463aadd
RP
2135@cindex continuing
2136@cindex resuming execution
2137@dfn{Stepping} means resuming program execution for a very limited time:
2138one line of source code, or one machine instruction. @dfn {Continuing}
2139means resuming program execution until the program completes normally.
2140In either case, the program may stop even sooner, due to a breakpoint or
2141to a signal. (If due to a signal, you may want to use @code{handle}, or
2142use @samp{signal 0} to resume execution; @pxref{Signals}.)
2143
2144A typical technique for using stepping is to set a breakpoint
70b88761
RP
2145(@pxref{Breakpoints}) at the beginning of the function or the section of
2146the program in which a problem is believed to lie, run the program until
2147it stops at that breakpoint, and then step through the suspect area,
2148examining the variables that are interesting, until you see the problem
2149happen.
2150
2151@table @code
2152@item step
2153@kindex step
2154@kindex s
2155Continue running the program until control reaches a different source
7463aadd 2156line, then stop it and return control to _GDBN__. This command is
70b88761
RP
2157abbreviated @code{s}.
2158
7463aadd
RP
2159You may use the @code{step} command even when control is within a function
2160compiled without debugging information. In that case, execution
70b88761
RP
2161will proceed until control reaches a different function, or is about to
2162return from this function.
2163
2164@item step @var{count}
2165Continue running as in @code{step}, but do so @var{count} times. If a
2166breakpoint is reached or a signal not related to stepping occurs before
2167@var{count} steps, stepping stops right away.
2168
7463aadd 2169@item next @r{[}@var{count}@r{]}
70b88761
RP
2170@kindex next
2171@kindex n
7463aadd
RP
2172Continue to the next source line in the current (innermost) stack frame.
2173Similar to @code{step}, but any function calls appearing within the line
2174of code are executed without stopping. Execution stops when control
2175reaches a different line of code at the stack level which was executing
2176when the @code{next} command was given. This command is abbreviated
2177@code{n}.
70b88761 2178
7463aadd 2179An argument @var{count} is a repeat count, as for @code{step}.
70b88761
RP
2180
2181@code{next} within a function that lacks debugging information acts like
2182@code{step}, but any function calls appearing within the code of the
2183function are executed without stopping.
2184
2185@item finish
2186@kindex finish
7463aadd
RP
2187Continue running until just after function in the selected stack frame
2188returns. Print the returned value (if any).
70b88761
RP
2189
2190Contrast this with the @code{return} command (@pxref{Returning}).
2191
2192@item until
2193@kindex until
2194@item u
2195@kindex u
2196Continue running until a source line past the current line, in the
2197current stack frame, is reached. This command is used to avoid single
2198stepping through a loop more than once. It is like the @code{next}
2199command, except that when @code{until} encounters a jump, it
2200automatically continues execution until the program counter is greater
2201than the address of the jump.
2202
2203This means that when you reach the end of a loop after single stepping
2204though it, @code{until} will cause the program to continue execution
2205until the loop is exited. In contrast, a @code{next} command at the end
2206of a loop will simply step back to the beginning of the loop, which
2207would force you to step through the next iteration.
2208
2209@code{until} always stops the program if it attempts to exit the current
2210stack frame.
2211
2212@code{until} may produce somewhat counterintuitive results if the order
7463aadd 2213of machine code does not match the order of the source lines. For
70b88761
RP
2214example, in the following excerpt from a debugging session, the @code{f}
2215(@code{frame}) command shows that execution is stopped at line
2216@code{206}; yet when we use @code{until}, we get to line @code{195}:
2217
2218@example
2219(_GDBP__) f
2220#0 main (argc=4, argv=0xf7fffae8) at m4.c:206
2221206 expand_input();
2222(_GDBP__) until
2223195 for ( ; argc > 0; NEXTARG) @{
2224@end example
2225
7463aadd
RP
2226This happened because, for execution efficiency, the compiler had
2227generated code for the loop closure test at the end, rather than the
2228start, of the loop---even though the test in a C @code{for}-loop is
2229written before the body of the loop. The @code{until} command appeared
2230to step back to the beginning of the loop when it advanced to this
2231expression; however, it has not really gone to an earlier
2232statement---not in terms of the actual machine code.
70b88761
RP
2233
2234@code{until} with no argument works by means of single
2235instruction stepping, and hence is slower than @code{until} with an
2236argument.
2237
2238@item until @var{location}
2239@item u @var{location}
2240Continue running the program until either the specified location is
7463aadd 2241reached, or the current stack frame returns. @var{location}
70b88761
RP
2242is any of the forms of argument acceptable to @code{break} (@pxref{Set
2243Breaks}). This form of the command uses breakpoints, and hence is
2244quicker than @code{until} without an argument.
2245
2246@item stepi
2247@itemx si
2248@kindex stepi
2249@kindex si
2250Execute one machine instruction, then stop and return to the debugger.
2251
2252It is often useful to do @samp{display/i $pc} when stepping by machine
2253instructions. This will cause the next instruction to be executed to
2254be displayed automatically at each stop. @xref{Auto Display}.
2255
2256An argument is a repeat count, as in @code{step}.
2257
2258@item nexti
2259@itemx ni
2260@kindex nexti
2261@kindex ni
2262Execute one machine instruction, but if it is a function call,
2263proceed until the function returns.
2264
2265An argument is a repeat count, as in @code{next}.
70b88761 2266
7463aadd
RP
2267@item continue @r{[}@var{ignore-count}@r{]}
2268@kindex continue
2269Resume program execution, at the address where the program last stopped;
2270any breakpoints set at that address are bypassed. The optional argument
2271@var{ignore-count} allows you to specify a further number of times to
2272ignore a breakpoint at this location; its effect is like that of
2273@code{ignore} (@pxref{Conditions}).
70b88761 2274
7463aadd
RP
2275To resume execution at a different place, you can use @code{return}
2276(@pxref{Returning}) to go back to the calling function; or @code{jump}
2277(@pxref{Jumping}) to go to an arbitrary location in your program.
70b88761 2278
70b88761
RP
2279@end table
2280
70b88761 2281
7463aadd 2282@node Signals, , Stepping and Continuing, Stopping
70b88761
RP
2283@section Signals
2284@cindex signals
2285
2286A signal is an asynchronous event that can happen in a program. The
2287operating system defines the possible kinds of signals, and gives each
2288kind a name and a number. For example, in Unix @code{SIGINT} is the
2289signal a program gets when you type an interrupt (often @kbd{C-c});
2290@code{SIGSEGV} is the signal a program gets from referencing a place in
2291memory far away from all the areas in use; @code{SIGALRM} occurs when
2292the alarm clock timer goes off (which happens only if the program has
2293requested an alarm).
2294
2295@cindex fatal signals
2296Some signals, including @code{SIGALRM}, are a normal part of the
2297functioning of the program. Others, such as @code{SIGSEGV}, indicate
2298errors; these signals are @dfn{fatal} (kill the program immediately) if the
2299program has not specified in advance some other way to handle the signal.
2300@code{SIGINT} does not indicate an error in the program, but it is normally
2301fatal so it can carry out the purpose of the interrupt: to kill the program.
2302
2303_GDBN__ has the ability to detect any occurrence of a signal in the program
2304running under _GDBN__'s control. You can tell _GDBN__ in advance what to do for
2305each kind of signal.
2306
2307@cindex handling signals
2308Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM}
2309(so as not to interfere with their role in the functioning of the program)
2310but to stop the program immediately whenever an error signal happens.
2311You can change these settings with the @code{handle} command.
2312
2313@table @code
2314@item info signals
2315@kindex info signals
2316Print a table of all the kinds of signals and how _GDBN__ has been told to
2317handle each one. You can use this to see the signal numbers of all
2318the defined types of signals.
2319
2320@item handle @var{signal} @var{keywords}@dots{}
2321@kindex handle
2322Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the
2323number of a signal or its name (with or without the @samp{SIG} at the
2324beginning). The @var{keywords} say what change to make.
2325@end table
2326
2327@c @group
2328The keywords allowed by the @code{handle} command can be abbreviated.
2329Their full names are:
2330
2331@table @code
2332@item nostop
2333_GDBN__ should not stop the program when this signal happens. It may
2334still print a message telling you that the signal has come in.
2335
2336@item stop
2337_GDBN__ should stop the program when this signal happens. This implies
2338the @code{print} keyword as well.
2339
2340@item print
2341_GDBN__ should print a message when this signal happens.
2342
2343@item noprint
2344_GDBN__ should not mention the occurrence of the signal at all. This
2345implies the @code{nostop} keyword as well.
2346
2347@item pass
2348_GDBN__ should allow the program to see this signal; the program will be
2349able to handle the signal, or may be terminated if the signal is fatal
2350and not handled.
2351
2352@item nopass
2353_GDBN__ should not allow the program to see this signal.
2354@end table
2355@c @end group
2356
2357When a signal has been set to stop the program, the program cannot see the
2358signal until you continue. It will see the signal then, if @code{pass} is
2359in effect for the signal in question @i{at that time}. In other words,
2360after _GDBN__ reports a signal, you can use the @code{handle} command with
2361@code{pass} or @code{nopass} to control whether that signal will be seen by
2362the program when you later continue it.
2363
2364You can also use the @code{signal} command to prevent the program from
2365seeing a signal, or cause it to see a signal it normally would not see,
7463aadd
RP
2366or to give it any signal at any time. For example, if the program stopped
2367due to some sort of memory reference error, you might store correct
2368values into the erroneous variables and continue, hoping to see more
2369execution; but the program would probably terminate immediately as
2370a result of the fatal signal once it sees the signal. To prevent this,
2371you can continue with @samp{signal 0}. @xref{Signaling}.
70b88761
RP
2372
2373@node Stack, Source, Stopping, Top
2374@chapter Examining the Stack
2375
2376When your program has stopped, the first thing you need to know is where it
2377stopped and how it got there.
2378
2379@cindex call stack
2380Each time your program performs a function call, the information about
2381where in the program the call was made from is saved in a block of data
2382called a @dfn{stack frame}. The frame also contains the arguments of the
2383call and the local variables of the function that was called. All the
2384stack frames are allocated in a region of memory called the @dfn{call
2385stack}.
2386
2387When your program stops, the _GDBN__ commands for examining the stack allow you
2388to see all of this information.
2389
2390@cindex selected frame
2391One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands
2392refer implicitly to the selected frame. In particular, whenever you ask
2393_GDBN__ for the value of a variable in the program, the value is found in the
2394selected frame. There are special _GDBN__ commands to select whichever frame
2395you are interested in.
2396
2397When the program stops, _GDBN__ automatically selects the currently executing
2398frame and describes it briefly as the @code{frame} command does
2399(@pxref{Frame Info, Info}).
2400
2401@menu
2402* Frames:: Stack Frames
2403* Backtrace:: Backtraces
2404* Selection:: Selecting a Frame
2405* Frame Info:: Information on a Frame
2406@end menu
2407
2408@node Frames, Backtrace, Stack, Stack
2409@section Stack Frames
2410
2411@cindex frame
2412@cindex stack frame
2413The call stack is divided up into contiguous pieces called @dfn{stack
2414frames}, or @dfn{frames} for short; each frame is the data associated
2415with one call to one function. The frame contains the arguments given
2416to the function, the function's local variables, and the address at
2417which the function is executing.
2418
2419@cindex initial frame
2420@cindex outermost frame
2421@cindex innermost frame
2422When your program is started, the stack has only one frame, that of the
2423function @code{main}. This is called the @dfn{initial} frame or the
2424@dfn{outermost} frame. Each time a function is called, a new frame is
2425made. Each time a function returns, the frame for that function invocation
2426is eliminated. If a function is recursive, there can be many frames for
2427the same function. The frame for the function in which execution is
2428actually occurring is called the @dfn{innermost} frame. This is the most
2429recently created of all the stack frames that still exist.
2430
2431@cindex frame pointer
2432Inside your program, stack frames are identified by their addresses. A
2433stack frame consists of many bytes, each of which has its own address; each
2434kind of computer has a convention for choosing one of those bytes whose
2435address serves as the address of the frame. Usually this address is kept
2436in a register called the @dfn{frame pointer register} while execution is
2437going on in that frame.
2438
2439@cindex frame number
2440_GDBN__ assigns numbers to all existing stack frames, starting with
2441zero for the innermost frame, one for the frame that called it,
2442and so on upward. These numbers do not really exist in your program;
2443they are assigned by _GDBN__ to give you a way of designating stack
2444frames in _GDBN__ commands.
2445
2446@cindex frameless execution
2447Some compilers allow functions to be compiled so that they operate
2448without stack frames. (For example, the @code{_GCC__} option
2449@samp{-fomit-frame-pointer} will generate functions without a frame.)
2450This is occasionally done with heavily used library functions to save
2451the frame setup time. _GDBN__ has limited facilities for dealing with
2452these function invocations. If the innermost function invocation has no
2453stack frame, _GDBN__ will nevertheless regard it as though it had a
2454separate frame, which is numbered zero as usual, allowing correct
2455tracing of the function call chain. However, _GDBN__ has no provision
2456for frameless functions elsewhere in the stack.
2457
2458@node Backtrace, Selection, Frames, Stack
2459@section Backtraces
2460
2461A backtrace is a summary of how the program got where it is. It shows one
2462line per frame, for many frames, starting with the currently executing
2463frame (frame zero), followed by its caller (frame one), and on up the
2464stack.
2465
2466@table @code
2467@item backtrace
2468@itemx bt
2469@kindex backtrace
2470@kindex bt
2471Print a backtrace of the entire stack: one line per frame for all
2472frames in the stack.
2473
2474You can stop the backtrace at any time by typing the system interrupt
2475character, normally @kbd{C-c}.
2476
2477@item backtrace @var{n}
2478@itemx bt @var{n}
2479Similar, but print only the innermost @var{n} frames.
2480
2481@item backtrace -@var{n}
2482@itemx bt -@var{n}
2483Similar, but print only the outermost @var{n} frames.
2484@end table
2485
2486@kindex where
2487@kindex info stack
2488@kindex info s
2489The names @code{where} and @code{info stack} (abbreviated @code{info s})
2490are additional aliases for @code{backtrace}.
2491
2492Each line in the backtrace shows the frame number and the function name.
2493The program counter value is also shown---unless you use @code{set
2494print address off}. The backtrace also shows the source file name and
2495line number, as well as the arguments to the function. The program
2496counter value is omitted if it is at the beginning of the code for that
2497line number.
2498
2499Here is an example of a backtrace. It was made with the command
2500@samp{bt 3}, so it shows the innermost three frames.
2501
2502@smallexample
2503@group
2504#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) at builtin.c:993
2505#1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
2506#2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
2507 at macro.c:71
2508(More stack frames follow...)
2509@end group
2510@end smallexample
2511
2512@noindent
2513The display for frame zero doesn't begin with a program counter
2514value, indicating that the program has stopped at the beginning of the
2515code for line @code{993} of @code{builtin.c}.
2516
2517@node Selection, Frame Info, Backtrace, Stack
2518@section Selecting a Frame
2519
2520Most commands for examining the stack and other data in the program work on
2521whichever stack frame is selected at the moment. Here are the commands for
2522selecting a stack frame; all of them finish by printing a brief description
2523of the stack frame just selected.
2524
2525@table @code
2526@item frame @var{n}
2527@itemx f @var{n}
2528@kindex frame
2529@kindex f
2530Select frame number @var{n}. Recall that frame zero is the innermost
2531(currently executing) frame, frame one is the frame that called the
2532innermost one, and so on. The highest-numbered frame is @code{main}'s
2533frame.
2534
2535@item frame @var{addr}
2536@itemx f @var{addr}
2537Select the frame at address @var{addr}. This is useful mainly if the
2538chaining of stack frames has been damaged by a bug, making it
2539impossible for _GDBN__ to assign numbers properly to all frames. In
2540addition, this can be useful when the program has multiple stacks and
2541switches between them.
2542
2543_if_(_SPARC__)
2544On the SPARC architecture, @code{frame} needs two addresses to
2545select an arbitrary frame: a frame pointer and a stack pointer.
2546@c note to future updaters: this is conditioned on a flag
2547@c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used
2548@c by SPARC, hence the specific attribution. Generalize or list all
2549@c possibilities if more supported machines start doing this.
2550_fi_(_SPARC__)
2551
2552@item up @var{n}
2553@kindex up
2554Move @var{n} frames up the stack. For positive numbers @var{n}, this
2555advances toward the outermost frame, to higher frame numbers, to frames
2556that have existed longer. @var{n} defaults to one.
2557
2558@item down @var{n}
2559@kindex down
2560@kindex do
2561Move @var{n} frames down the stack. For positive numbers @var{n}, this
2562advances toward the innermost frame, to lower frame numbers, to frames
2563that were created more recently. @var{n} defaults to one. You may
2564abbreviate @code{down} as @code{do}.
2565@end table
2566
2567All of these commands end by printing two lines of output describing the
2568frame. The first line shows the frame number, the function name, the
2569arguments, and the source file and line number of execution in that
2570frame. The second line shows the text of that source line. For
2571example:
2572
2573@smallexample
2574(_GDBP__) up
2575#1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) at env.c:10
257610 read_input_file (argv[i]);
2577@end smallexample
2578
2579After such a printout, the @code{list} command with no arguments will print
2580ten lines centered on the point of execution in the frame. @xref{List}.
2581
2582@table @code
2583@item up-silently @var{n}
2584@itemx down-silently @var{n}
2585@kindex down-silently
2586@kindex up-silently
2587These two commands are variants of @code{up} and @code{down},
2588respectively; they differ in that they do their work silently, without
2589causing display of the new frame. They are intended primarily for use
2590in _GDBN__ command scripts, where the output might be unnecessary and
2591distracting.
2592
2593@end table
2594
2595@node Frame Info, , Selection, Stack
2596@section Information About a Frame
2597
2598There are several other commands to print information about the selected
2599stack frame.
2600
2601@table @code
2602@item frame
2603@itemx f
2604When used without any argument, this command does not change which frame
2605is selected, but prints a brief description of the currently
2606selected stack frame. It can be abbreviated @code{f}. With an
2607argument, this command is used to select a stack frame (@pxref{Selection}).
2608
2609@item info frame
2610@kindex info frame
2611@itemx info f
2612@kindex info f
2613This command prints a verbose description of the selected stack frame,
2614including the address of the frame, the addresses of the next frame down
2615(called by this frame) and the next frame up (caller of this frame),
2616the address of the frame's arguments, the program counter saved in it
2617(the address of execution in the caller frame), and which registers
2618were saved in the frame. The verbose description is useful when
2619something has gone wrong that has made the stack format fail to fit
2620the usual conventions.
2621
2622@item info frame @var{addr}
2623@itemx info f @var{addr}
2624Print a verbose description of the frame at address @var{addr},
2625without selecting that frame. The selected frame remains unchanged by
2626this command.
2627
2628@item info args
2629@kindex info args
2630Print the arguments of the selected frame, each on a separate line.
2631
2632@item info locals
2633@kindex info locals
2634Print the local variables of the selected frame, each on a separate
2635line. These are all variables declared static or automatic within all
2636program blocks that execution in this frame is currently inside of.
2637
2638@item info catch
2639@kindex info catch
2640@cindex catch exceptions
2641@cindex exception handlers
2642Print a list of all the exception handlers that are active in the
2643current stack frame at the current point of execution. To see other
2644exception handlers, visit the associated frame (using the @code{up},
2645@code{down}, or @code{frame} commands); then type @code{info catch}.
2646@xref{Exception Handling}.
2647@end table
2648
2649@node Source, Data, Stack, Top
2650@chapter Examining Source Files
2651
2652_GDBN__ can print parts of your program's source, since the debugging
2653information recorded in your program tells _GDBN__ what source files
2654were used to built it. When your program stops, _GDBN__ spontaneously
2655prints the line where it stopped. Likewise, when you select a stack
2656frame (@pxref{Selection}), _GDBN__ prints the line where execution in
2657that frame has stopped. You can print other portions of source files by
2658explicit command.
2659
2660If you use _GDBN__ through its GNU Emacs interface, you may prefer to
2661use Emacs facilities to view source; @pxref{Emacs}.
2662
2663@menu
2664* List:: Printing Source Lines
2665* Search:: Searching Source Files
2666* Source Path:: Specifying Source Directories
2667* Machine Code:: Source and Machine Code
2668@end menu
2669
2670@node List, Search, Source, Source
2671@section Printing Source Lines
2672
2673@kindex list
2674@kindex l
2675To print lines from a source file, use the @code{list} command
2676(abbreviated @code{l}). There are several ways to specify what part
2677of the file you want to print.
2678
2679Here are the forms of the @code{list} command most commonly used:
2680
2681@table @code
2682@item list @var{linenum}
2683Print ten lines centered around line number @var{linenum} in the
2684current source file.
2685
2686@item list @var{function}
2687Print ten lines centered around the beginning of function
2688@var{function}.
2689
2690@item list
2691Print ten more lines. If the last lines printed were printed with a
2692@code{list} command, this prints ten lines following the last lines
2693printed; however, if the last line printed was a solitary line printed
2694as part of displaying a stack frame (@pxref{Stack}), this prints ten
2695lines centered around that line.
2696
2697@item list -
2698Print ten lines just before the lines last printed.
2699@end table
2700
2701Repeating a @code{list} command with @key{RET} discards the argument,
2702so it is equivalent to typing just @code{list}. This is more useful
2703than listing the same lines again. An exception is made for an
2704argument of @samp{-}; that argument is preserved in repetition so that
2705each repetition moves up in the source file.
2706
2707@cindex linespec
2708In general, the @code{list} command expects you to supply zero, one or two
2709@dfn{linespecs}. Linespecs specify source lines; there are several ways
2710of writing them but the effect is always to specify some source line.
2711Here is a complete description of the possible arguments for @code{list}:
2712
2713@table @code
2714@item list @var{linespec}
2715Print ten lines centered around the line specified by @var{linespec}.
2716
2717@item list @var{first},@var{last}
2718Print lines from @var{first} to @var{last}. Both arguments are
2719linespecs.
2720
2721@item list ,@var{last}
2722Print ten lines ending with @var{last}.
2723
2724@item list @var{first},
2725Print ten lines starting with @var{first}.
2726
2727@item list +
2728Print ten lines just after the lines last printed.
2729
2730@item list -
2731Print ten lines just before the lines last printed.
2732
2733@item list
2734As described in the preceding table.
2735@end table
2736
2737Here are the ways of specifying a single source line---all the
2738kinds of linespec.
2739
2740@table @code
2741@item @var{number}
2742Specifies line @var{number} of the current source file.
2743When a @code{list} command has two linespecs, this refers to
2744the same source file as the first linespec.
2745
2746@item +@var{offset}
2747Specifies the line @var{offset} lines after the last line printed.
2748When used as the second linespec in a @code{list} command that has
2749two, this specifies the line @var{offset} lines down from the
2750first linespec.
2751
2752@item -@var{offset}
2753Specifies the line @var{offset} lines before the last line printed.
2754
2755@item @var{filename}:@var{number}
2756Specifies line @var{number} in the source file @var{filename}.
2757
2758@item @var{function}
2759@c FIXME: "of the open-brace" is C-centric. When we add other langs...
2760Specifies the line of the open-brace that begins the body of the
2761function @var{function}.
2762
2763@item @var{filename}:@var{function}
2764Specifies the line of the open-brace that begins the body of the
2765function @var{function} in the file @var{filename}. You only need the
2766file name with a function name to avoid ambiguity when there are
2767identically named functions in different source files.
2768
2769@item *@var{address}
2770Specifies the line containing the program address @var{address}.
2771@var{address} may be any expression.
2772@end table
2773
2774@node Search, Source Path, List, Source
2775@section Searching Source Files
2776@cindex searching
2777@kindex reverse-search
2778
2779There are two commands for searching through the current source file for a
2780regular expression.
2781
2782@table @code
2783@item forward-search @var{regexp}
2784@itemx search @var{regexp}
2785@kindex search
2786@kindex forward-search
2787The command @samp{forward-search @var{regexp}} checks each line, starting
2788with the one following the last line listed, for a match for @var{regexp}.
2789It lists the line that is found. You can abbreviate the command name
2790as @code{fo}. The synonym @samp{search @var{regexp}} is also supported.
2791
2792@item reverse-search @var{regexp}
2793The command @samp{reverse-search @var{regexp}} checks each line, starting
2794with the one before the last line listed and going backward, for a match
2795for @var{regexp}. It lists the line that is found. You can abbreviate
2796this command as @code{rev}.
2797@end table
2798
2799@node Source Path, Machine Code, Search, Source
2800@section Specifying Source Directories
2801
2802@cindex source path
2803@cindex directories for source files
2804Executable programs sometimes do not record the directories of the source
2805files from which they were compiled, just the names. Even when they do,
2806the directories could be moved between the compilation and your debugging
2807session. _GDBN__ has a list of directories to search for source files;
2808this is called the @dfn{source path}. Each time _GDBN__ wants a source file,
2809it tries all the directories in the list, in the order they are present
2810in the list, until it finds a file with the desired name. Note that
2811the executable search path is @emph{not} used for this purpose. Neither is
2812the current working directory, unless it happens to be in the source
2813path.
2814
2815If _GDBN__ can't find a source file in the source path, and the object
2816program records a directory, _GDBN__ tries that directory too. If the
2817source path is empty, and there is no record of the compilation
2818directory, _GDBN__ will, as a last resort, look in the current
2819directory.
2820
2821Whenever you reset or rearrange the source path, _GDBN__ will clear out
2822any information it has cached about where source files are found, where
2823each line is in the file, etc.
2824
2825@kindex directory
2826When you start _GDBN__, its source path is empty.
2827To add other directories, use the @code{directory} command.
2828
2829@table @code
2830@item directory @var{dirname} @dots{}
2831Add directory @var{dirname} to the front of the source path. Several
2832directory names may be given to this command, separated by @samp{:} or
2833whitespace. You may specify a directory that is already in the source
7463aadd
RP
2834path; this moves it forward, so it will be searched sooner.
2835
2836You can use the string @samp{$cdir} to refer to the compilation
2837directory (if one is recorded), and @samp{$cwd} to refer to the current
2838working directory. @samp{$cwd} is not the same as @samp{.}---the former
2839tracks the current working directory as it changes during your _GDBN__
2840session, while the latter is immediately expanded to the current
2841directory at the time you add an entry to the source path.
70b88761
RP
2842
2843@item directory
2844Reset the source path to empty again. This requires confirmation.
2845
2846@c RET-repeat for @code{directory} is explicitly disabled, but since
2847@c repeating it would be a no-op we don't say that. (thanks to RMS)
2848
2849@item show directories
2850@kindex show directories
2851Print the source path: show which directories it contains.
2852@end table
2853
2854If your source path is cluttered with directories that are no longer of
2855interest, _GDBN__ may sometimes cause confusion by finding the wrong
2856versions of source. You can correct the situation as follows:
2857
2858@enumerate
2859@item
2860Use @code{directory} with no argument to reset the source path to empty.
2861
2862@item
2863Use @code{directory} with suitable arguments to reinstall the
2864directories you want in the source path. You can add all the
2865directories in one command.
2866@end enumerate
2867
2868@node Machine Code, , Source Path, Source
2869@section Source and Machine Code
2870You can use the command @code{info line} to map source lines to program
2871addresses (and viceversa), and the command @code{disassemble} to display
2872a range of addresses as machine instructions.
2873
2874@table @code
2875@item info line @var{linespec}
2876@kindex info line
2877Print the starting and ending addresses of the compiled code for
2878source line @var{linespec}. You can specify source lines in any of the
2879ways understood by the @code{list} command (@pxref{List}).
2880@end table
2881
2882For example, we can use @code{info line} to inquire on where the object
2883code for the first line of function @code{m4_changequote} lies:
2884@smallexample
2885(_GDBP__) info line m4_changecom
2886Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
2887@end smallexample
2888
2889@noindent
2890We can also inquire (using @code{*@var{addr}} as the form for
2891@var{linespec}) what source line covers a particular address:
2892@smallexample
2893(_GDBP__) info line *0x63ff
2894Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
2895@end smallexample
2896
2897@kindex $_
2898After @code{info line}, the default address for the @code{x}
2899command is changed to the starting address of the line, so that
2900@samp{x/i} is sufficient to begin examining the machine code
2901(@pxref{Memory}). Also, this address is saved as the value of the
2902convenience variable @code{$_} (@pxref{Convenience Vars}).
2903
2904@table @code
2905@kindex disassemble
2906@item disassemble
2907This specialized command is provided to dump a range of memory as
2908machine instructions. The default memory range is the function
2909surrounding the program counter of the selected frame. A single
2910argument to this command is a program counter value; the function
2911surrounding this value will be dumped. Two arguments (separated by one
2912or more spaces) specify a range of addresses (first inclusive, second
2913exclusive) to be dumped.
2914@end table
2915
2916We can use @code{disassemble} to inspect the object code
2917range shown in the last @code{info line} example:
2918
2919@smallexample
2920(_GDBP__) disas 0x63e4 0x6404
2921Dump of assembler code from 0x63e4 to 0x6404:
29220x63e4 <builtin_init+5340>: ble 0x63f8 <builtin_init+5360>
29230x63e8 <builtin_init+5344>: sethi %hi(0x4c00), %o0
29240x63ec <builtin_init+5348>: ld [%i1+4], %o0
29250x63f0 <builtin_init+5352>: b 0x63fc <builtin_init+5364>
29260x63f4 <builtin_init+5356>: ld [%o0+4], %o0
29270x63f8 <builtin_init+5360>: or %o0, 0x1a4, %o0
29280x63fc <builtin_init+5364>: call 0x9288 <path_search>
29290x6400 <builtin_init+5368>: nop
2930End of assembler dump.
2931(_GDBP__)
2932
2933@end smallexample
2934
2935@node Data, Symbols, Source, Top
2936@chapter Examining Data
2937
2938@cindex printing data
2939@cindex examining data
2940@kindex print
2941@kindex inspect
2942@c "inspect" isn't quite a synonym if you're using Epoch, which we don't
2943@c document because it's nonstandard... Under Epoch it displays in a
2944@c different window or something like that.
2945The usual way to examine data in your program is with the @code{print}
2946command (abbreviated @code{p}), or its synonym @code{inspect}. It
2947evaluates and prints the value of any valid expression of the language
2948the program is written in (for now, C or C++). You type
2949
2950@example
2951print @var{exp}
2952@end example
2953
2954@noindent
2955where @var{exp} is any valid expression (in the source language), and
2956the value of @var{exp} is printed in a format appropriate to its data
2957type.
2958
2959A more low-level way of examining data is with the @code{x} command.
2960It examines data in memory at a specified address and prints it in a
2961specified format. @xref{Memory}.
2962
2963@menu
2964* Expressions:: Expressions
2965* Variables:: Program Variables
2966* Arrays:: Artificial Arrays
2967* Output formats:: Output formats
2968* Memory:: Examining Memory
2969* Auto Display:: Automatic Display
2970* Print Settings:: Print Settings
2971* Value History:: Value History
2972* Convenience Vars:: Convenience Variables
2973* Registers:: Registers
2974* Floating Point Hardware:: Floating Point Hardware
2975@end menu
2976
2977@node Expressions, Variables, Data, Data
2978@section Expressions
2979
2980@cindex expressions
2981@code{print} and many other _GDBN__ commands accept an expression and
2982compute its value. Any kind of constant, variable or operator defined
2983by the programming language you are using is legal in an expression in
2984_GDBN__. This includes conditional expressions, function calls, casts
2985and string constants. It unfortunately does not include symbols defined
2986by preprocessor @code{#define} commands, or C++ expressions involving
2987@samp{::}, the name resolution operator.
2988@c FIXME: actually C++ a::b works except in obscure circumstances where it
2989@c FIXME...can conflict with GDB's own name scope resolution.
2990
2991Casts are supported in all languages, not just in C, because it is so
2992useful to cast a number into a pointer so as to examine a structure
2993at that address in memory.
2994
2995_GDBN__ supports three kinds of operator in addition to those of programming
2996languages:
2997
2998@table @code
2999@item @@
3000@samp{@@} is a binary operator for treating parts of memory as arrays.
3001@xref{Arrays}, for more information.
3002
3003@item ::
3004@samp{::} allows you to specify a variable in terms of the file or
3005function where it is defined. @xref{Variables}.
3006
3007@item @{@var{type}@} @var{addr}
3008Refers to an object of type @var{type} stored at address @var{addr} in
3009memory. @var{addr} may be any expression whose value is an integer or
3010pointer (but parentheses are required around binary operators, just as in
3011a cast). This construct is allowed regardless of what kind of data is
3012normally supposed to reside at @var{addr}.@refill
3013@end table
3014
3015@node Variables, Arrays, Expressions, Data
3016@section Program Variables
3017
3018The most common kind of expression to use is the name of a variable
3019in your program.
3020
3021Variables in expressions are understood in the selected stack frame
3022(@pxref{Selection}); they must either be global (or static) or be visible
3023according to the scope rules of the programming language from the point of
3024execution in that frame. This means that in the function
3025
3026@example
3027foo (a)
3028 int a;
3029@{
3030 bar (a);
3031 @{
3032 int b = test ();
3033 bar (b);
3034 @}
3035@}
3036@end example
3037
3038@noindent
3039the variable @code{a} is usable whenever the program is executing
3040within the function @code{foo}, but the variable @code{b} is visible
3041only while the program is executing inside the block in which @code{b}
3042is declared.
3043
3044@cindex variable name conflict
3045There is an exception: you can refer to a variable or function whose
3046scope is a single source file even if the current execution point is not
3047in this file. But it is possible to have more than one such variable or
3048function with the same name (in different source files). If that happens,
3049referring to that name has unpredictable effects. If you wish, you can
3050specify a variable in a particular file, using the colon-colon notation:
3051
3052@cindex colon-colon
3053@kindex ::
3054@example
3055@var{file}::@var{variable}
3056@end example
3057
3058@noindent
3059Here @var{file} is the name of the source file whose variable you want.
3060
3061@cindex C++ name resolution
3062This use of @samp{::} is very rarely in conflict with the very similar
3063use of the same notation in C++. _GDBN__ also supports use of the C++
3064name resolution operator in _GDBN__ expressions.
3065
3066@node Arrays, Output formats, Variables, Data
3067@section Artificial Arrays
3068
3069@cindex artificial array
3070@kindex @@
3071It is often useful to print out several successive objects of the
3072same type in memory; a section of an array, or an array of
3073dynamically determined size for which only a pointer exists in the
3074program.
3075
3076This can be done by constructing an @dfn{artificial array} with the
3077binary operator @samp{@@}. The left operand of @samp{@@} should be
3078the first element of the desired array, as an individual object.
3079The right operand should be the desired length of the array. The result is
3080an array value whose elements are all of the type of the left argument.
3081The first element is actually the left argument; the second element
3082comes from bytes of memory immediately following those that hold the
3083first element, and so on. Here is an example. If a program says
3084
3085@example
3086int *array = (int *) malloc (len * sizeof (int));
3087@end example
3088
3089@noindent
3090you can print the contents of @code{array} with
3091
3092@example
3093p *array@@len
3094@end example
3095
3096The left operand of @samp{@@} must reside in memory. Array values made
3097with @samp{@@} in this way behave just like other arrays in terms of
3098subscripting, and are coerced to pointers when used in expressions.
3099Artificial arrays most often appear in expressions via the value history
3100(@pxref{Value History}), after printing one out.)
3101
3102@node Output formats, Memory, Arrays, Data
3103@section Output formats
3104
3105@cindex formatted output
3106@cindex output formats
3107By default, _GDBN__ prints a value according to its data type. Sometimes
3108this is not what you want. For example, you might want to print a number
3109in hex, or a pointer in decimal. Or you might want to view data in memory
3110at a certain address as a character string or as an instruction. To do
3111these things, specify an @dfn{output format} when you print a value.
3112
3113The simplest use of output formats is to say how to print a value
3114already computed. This is done by starting the arguments of the
3115@code{print} command with a slash and a format letter. The format
3116letters supported are:
3117
3118@table @code
3119@item x
3120Regard the bits of the value as an integer, and print the integer in
3121hexadecimal.
3122
3123@item d
3124Print as integer in signed decimal.
3125
3126@item u
3127Print as integer in unsigned decimal.
3128
3129@item o
3130Print as integer in octal.
3131
3132@item t
3133Print as integer in binary. The letter @samp{t} stands for ``two''.
3134
3135@item a
3136Print as an address, both absolute in hex and as an offset from the
3137nearest preceding symbol. This format can be used to discover where (in
3138what function) an unknown address is located:
3139@example
3140(_GDBP__) p/a 0x54320
3141_0__$3 = 0x54320 <_initialize_vx+396>_1__
3142@end example
3143
3144
3145@item c
3146Regard as an integer and print it as a character constant.
3147
3148@item f
3149Regard the bits of the value as a floating point number and print
3150using typical floating point syntax.
3151@end table
3152
3153For example, to print the program counter in hex (@pxref{Registers}), type
3154
3155@example
3156p/x $pc
3157@end example
3158
3159@noindent
3160Note that no space is required before the slash; this is because command
3161names in _GDBN__ cannot contain a slash.
3162
3163To reprint the last value in the value history with a different format,
3164you can use the @code{print} command with just a format and no
3165expression. For example, @samp{p/x} reprints the last value in hex.
3166
3167@node Memory, Auto Display, Output formats, Data
3168@section Examining Memory
3169
3170@cindex examining memory
3171@table @code
3172@kindex x
3173@item x/@var{nfu} @var{expr}
3174The command @code{x} (for `examine') can be used to examine memory
3175without being constrained by your program's data types. You can specify
3176the unit size @var{u} of memory to inspect, and a repeat count @var{n} of how
3177many of those units to display. @code{x} understands the formats
3178@var{f} used by @code{print}; two additional formats, @samp{s} (string)
3179and @samp{i} (machine instruction) can be used without specifying a unit
3180size.
3181@end table
3182
3183For example, @samp{x/3uh 0x54320} is a request to display three halfwords
3184(@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}),
3185starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four
3186words (@samp{w}) of memory above the stack pointer (here, @samp{$sp};
3187@pxref{Registers}) in hexadecimal (@samp{x}).
3188
3189Since the letters indicating unit sizes are all distinct from the
3190letters specifying output formats, you don't have to remember whether
3191unit size or format comes first; either order will work. The output
3192specifications @samp{4xw} and @samp{4wx} mean exactly the same thing.
3193
3194After the format specification, you supply an expression for the address
3195where _GDBN__ is to begin reading from memory. The expression need not
3196have a pointer value (though it may); it is always interpreted as an
3197integer address of a byte of memory. @xref{Expressions} for more
3198information on expressions.
3199
3200These are the memory units @var{u} you can specify with the @code{x}
3201command:
3202
3203@table @code
3204@item b
3205Examine individual bytes.
3206
3207@item h
3208Examine halfwords (two bytes each).
3209
3210@item w
3211Examine words (four bytes each).
3212
3213@cindex word
3214Many assemblers and cpu designers still use `word' for a 16-bit quantity,
3215as a holdover from specific predecessor machines of the 1970's that really
3216did use two-byte words. But more generally the term `word' has always
3217referred to the size of quantity that a machine normally operates on and
3218stores in its registers. This is 32 bits for all the machines that _GDBN__
3219runs on.
3220
3221@item g
3222Examine giant words (8 bytes).
3223@end table
3224
3225You can combine these unit specifications with any of the formats
3226described for @code{print}. @xref{Output formats}.
3227
3228@code{x} has two additional output specifications which derive the unit
3229size from the data inspected:
3230
3231@table @code
3232@item s
3233Print a null-terminated string of characters. Any explicitly specified
3234unit size is ignored; instead, the unit is however many bytes it takes
3235to reach a null character (including the null character).
3236
3237@item i
3238Print a machine instruction in assembler syntax (or nearly). Any
3239specified unit size is ignored; the number of bytes in an instruction
3240varies depending on the type of machine, the opcode and the addressing
3241modes used. The command @code{disassemble} gives an alternative way of
3242inspecting machine instructions. @xref{Machine Code}.
3243@end table
3244
3245If you omit either the format @var{f} or the unit size @var{u}, @code{x}
3246will use the same one that was used last. If you don't use any letters
3247or digits after the slash, you can omit the slash as well.
3248
3249You can also omit the address to examine. Then the address used is just
3250after the last unit examined. This is why string and instruction
3251formats actually compute a unit-size based on the data: so that the next
3252string or instruction examined will start in the right place.
3253
3254When the @code{print} command shows a value that resides in memory,
3255@code{print} also sets the default address for the @code{x} command.
3256@code{info line} also sets the default for @code{x}, to the address of
3257the start of the machine code for the specified line (@pxref{Machine
3258Code}), and @code{info breakpoints} sets it to the address of the last
3259breakpoint listed (@pxref{Set Breaks}).
3260
3261When you use @key{RET} to repeat an @code{x} command, the address
3262specified previously (if any) is ignored, so that the repeated command
3263examines the successive locations in memory rather than the same ones.
3264
3265You can examine several consecutive units of memory with one command by
3266writing a repeat-count after the slash (before the format letters, if
3267any). Omitting the repeat count @var{n} displays one unit of the
3268appropriate size. The repeat count must be a decimal integer. It has
3269the same effect as repeating the @code{x} command @var{n} times except
3270that the output may be more compact, with several units per line. For
3271example,
3272
3273@example
3274x/10i $pc
3275@end example
3276
3277@noindent
3278prints ten instructions starting with the one to be executed next in the
3279selected frame. After doing this, you could print a further seven
3280instructions with
3281
3282@example
3283x/7
3284@end example
3285
3286@noindent
3287---where the format and address are allowed to default.
3288
3289@kindex $_
3290@kindex $__
3291The addresses and contents printed by the @code{x} command are not put
3292in the value history because there is often too much of them and they
3293would get in the way. Instead, _GDBN__ makes these values available for
3294subsequent use in expressions as values of the convenience variables
3295@code{$_} and @code{$__}. After an @code{x} command, the last address
3296examined is available for use in expressions in the convenience variable
3297@code{$_}. The contents of that address, as examined, are available in
3298the convenience variable @code{$__}.
3299
3300If the @code{x} command has a repeat count, the address and contents saved
3301are from the last memory unit printed; this is not the same as the last
3302address printed if several units were printed on the last line of output.
3303
3304@node Auto Display, Print Settings, Memory, Data
3305@section Automatic Display
3306@cindex automatic display
3307@cindex display of expressions
3308
3309If you find that you want to print the value of an expression frequently
3310(to see how it changes), you might want to add it to the @dfn{automatic
3311display list} so that _GDBN__ will print its value each time the program stops.
3312Each expression added to the list is given a number to identify it;
3313to remove an expression from the list, you specify that number.
3314The automatic display looks like this:
3315
3316@example
33172: foo = 38
33183: bar[5] = (struct hack *) 0x3804
3319@end example
3320
3321@noindent
3322showing item numbers, expressions and their current values. As with
3323displays you request manually using @code{x} or @code{print}, you can
3324specify the output format you prefer; in fact, @code{display} decides
3325whether to use @code{print} or @code{x} depending on how elaborate your
3326format specification is---it uses @code{x} if you specify a unit size,
3327or one of the two formats (@samp{i} and @samp{s}) that are only
3328supported by @code{x}; otherwise it uses @code{print}.
3329
3330@table @code
3331@item display @var{exp}
3332@kindex display
3333Add the expression @var{exp} to the list of expressions to display
3334each time the program stops. @xref{Expressions}.
3335
3336@code{display} will not repeat if you press @key{RET} again after using it.
3337
3338@item display/@var{fmt} @var{exp}
3339For @var{fmt} specifying only a display format and not a size or
3340count, add the expression @var{exp} to the auto-display list but
3341arranges to display it each time in the specified format @var{fmt}.
3342@xref{Output formats}.
3343
3344@item display/@var{fmt} @var{addr}
3345For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
3346number of units, add the expression @var{addr} as a memory address to
3347be examined each time the program stops. Examining means in effect
3348doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory}.
3349@end table
3350
3351For example, @samp{display/i $pc} can be helpful, to see the machine
3352instruction about to be executed each time execution stops (@samp{$pc}
3353is a common name for the program counter; @pxref{Registers}).
3354
3355@table @code
3356@item undisplay @var{dnums}@dots{}
3357@itemx delete display @var{dnums}@dots{}
3358@kindex delete display
3359@kindex undisplay
3360Remove item numbers @var{dnums} from the list of expressions to display.
3361
3362@code{undisplay} will not repeat if you press @key{RET} after using it.
3363(Otherwise you would just get the error @samp{No display number @dots{}}.)
3364
3365@item disable display @var{dnums}@dots{}
3366@kindex disable display
3367Disable the display of item numbers @var{dnums}. A disabled display
3368item is not printed automatically, but is not forgotten. It may be
3369enabled again later.
3370
3371@item enable display @var{dnums}@dots{}
3372@kindex enable display
3373Enable display of item numbers @var{dnums}. It becomes effective once
3374again in auto display of its expression, until you specify otherwise.
3375
3376@item display
3377Display the current values of the expressions on the list, just as is
3378done when the program stops.
3379
3380@item info display
3381@kindex info display
3382Print the list of expressions previously set up to display
3383automatically, each one with its item number, but without showing the
3384values. This includes disabled expressions, which are marked as such.
3385It also includes expressions which would not be displayed right now
3386because they refer to automatic variables not currently available.
3387@end table
3388
3389If a display expression refers to local variables, then it does not make
3390sense outside the lexical context for which it was set up. Such an
3391expression is disabled when execution enters a context where one of its
3392variables is not defined. For example, if you give the command
3393@code{display last_char} while inside a function with an argument
3394@code{last_char}, then this argument will be displayed while the program
3395continues to stop inside that function. When it stops elsewhere---where
3396there is no variable @code{last_char}---display is disabled. The next time
3397your program stops where @code{last_char} is meaningful, you can enable the
3398display expression once again.
3399
3400@node Print Settings, Value History, Auto Display, Data
3401@section Print Settings
3402
3403@cindex format options
3404@cindex print settings
3405_GDBN__ provides the following ways to control how arrays, structures,
3406and symbols are printed.
3407
3408@noindent
3409These settings are useful for debugging programs in any language:
3410
3411@table @code
3412@item set print address
3413@item set print address on
3414@kindex set print address
3415_GDBN__ will print memory addresses showing the location of stack
3416traces, structure values, pointer values, breakpoints, and so forth,
3417even when it also displays the contents of those addresses. The default
3418is on. For example, this is what a stack frame display looks like, with
3419@code{set print address on}:
3420@smallexample
3421(_GDBP__) f
3422#0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
3423 at input.c:530
3424530 if (lquote != def_lquote)
3425@end smallexample
3426
3427@item set print address off
3428Do not print addresses when displaying their contents. For example,
3429this is the same stack frame displayed with @code{set print address off}:
3430@example
3431(_GDBP__) set print addr off
3432(_GDBP__) f
3433#0 set_quotes (lq="<<", rq=">>") at input.c:530
3434530 if (lquote != def_lquote)
3435@end example
3436
3437@item show print address
3438@kindex show print address
3439Show whether or not addresses are to be printed.
3440
3441@item set print array
3442@itemx set print array on
3443@kindex set print array
3444_GDBN__ will pretty print arrays. This format is more convenient to read,
3445but uses more space. The default is off.
3446
3447@item set print array off.
3448Return to compressed format for arrays.
3449
3450@item show print array
3451@kindex show print array
3452Show whether compressed or pretty format is selected for displaying
3453arrays.
3454
3455@item set print elements @var{number-of-elements}
3456@kindex set print elements
3457If _GDBN__ is printing a large array, it will stop printing after it has
3458printed the number of elements set by the @code{set print elements} command.
3459This limit also applies to the display of strings.
3460
3461@item show print elements
3462@kindex show print elements
3463Display the number of elements of a large array that _GDBN__ will print
3464before losing patience.
3465
3466@item set print pretty on
3467@kindex set print pretty
3468Cause _GDBN__ to print structures in an indented format with one member per
3469line, like this:
3470
3471@example
3472$1 = @{
3473 next = 0x0,
3474 flags = @{
3475 sweet = 1,
3476 sour = 1
3477 @},
3478 meat = 0x54 "Pork"
3479@}
3480@end example
3481
3482@item set print pretty off
3483Cause _GDBN__ to print structures in a compact format, like this:
3484
3485@smallexample
3486$1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \
3487= 0x54 "Pork"@}
3488@end smallexample
3489
3490@noindent
3491This is the default format.
3492
3493@item show print pretty
3494@kindex show print pretty
3495Show which format _GDBN__ will use to print structures.
3496
3497@item set print sevenbit-strings on
3498Print using only seven-bit characters; if this option is set,
3499_GDBN__ will display any eight-bit characters (in strings or character
3500values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is
3501displayed as @code{\341}.
3502
3503@item set print sevenbit-strings off
3504Print using either seven-bit or eight-bit characters, as required. This
3505is the default.
3506
3507@item show print sevenbit-strings
3508Show whether or not _GDBN__ will print only seven-bit characters.
3509
3510@item set print union on
3511@kindex set print union
3512Tell _GDBN__ to print unions which are contained in structures. This is the
3513default setting.
3514
3515@item set print union off
3516Tell _GDBN__ not to print unions which are contained in structures.
3517
3518@item show print union
3519@kindex show print union
3520Ask _GDBN__ whether or not it will print unions which are contained in
3521structures.
3522
3523For example, given the declarations
3524
3525@smallexample
3526typedef enum @{Tree, Bug@} Species;
3527typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
3528typedef enum @{Caterpillar, Cocoon, Butterfly@} Bug_forms;
3529
3530struct thing @{
3531 Species it;
3532 union @{
3533 Tree_forms tree;
3534 Bug_forms bug;
3535 @} form;
3536@};
3537
3538struct thing foo = @{Tree, @{Acorn@}@};
3539@end smallexample
3540
3541@noindent
3542with @code{set print union on} in effect @samp{p foo} would print
3543
3544@smallexample
3545$1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
3546@end smallexample
3547
3548@noindent
3549and with @code{set print union off} in effect it would print
3550
3551@smallexample
3552$1 = @{it = Tree, form = @{...@}@}
3553@end smallexample
3554@end table
3555
3556@noindent
3557These settings are of interest when debugging C++ programs:
3558
3559@table @code
3560@item set print demangle
3561@itemx set print demangle on
3562@kindex set print demangle
3563Print C++ names in their source form rather than in the mangled form
3564in which they are passed to the assembler and linker for type-safe linkage.
3565The default is on.
3566
3567@item show print demangle
3568@kindex show print demangle
3569Show whether C++ names will be printed in mangled or demangled form.
3570
3571@item set print asm-demangle
3572@itemx set print asm-demangle on
3573@kindex set print asm-demangle
3574Print C++ names in their source form rather than their mangled form, even
3575in assembler code printouts such as instruction disassemblies.
3576The default is off.
3577
3578@item show print asm-demangle
3579@kindex show print asm-demangle
3580Show whether C++ names in assembly listings will be printed in mangled
3581or demangled form.
3582
3583@item set print object
3584@itemx set print object on
3585@kindex set print object
3586When displaying a pointer to an object, identify the @emph{actual}
3587(derived) type of the object rather than the @emph{declared} type, using
3588the virtual function table.
3589
3590@item set print object off
3591Display only the declared type of objects, without reference to the
3592virtual function table. This is the default setting.
3593
3594@item show print object
3595@kindex show print object
3596Show whether actual, or declared, object types will be displayed.
3597
3598@item set print vtbl
3599@itemx set print vtbl on
3600@kindex set print vtbl
3601Pretty print C++ virtual function tables. The default is off.
3602
3603@item set print vtbl off
3604Do not pretty print C++ virtual function tables.
3605
3606@item show print vtbl
3607@kindex show print vtbl
3608Show whether C++ virtual function tables are pretty printed, or not.
3609
3610@end table
3611
3612@node Value History, Convenience Vars, Print Settings, Data
3613@section Value History
3614
3615@cindex value history
3616Values printed by the @code{print} command are saved in _GDBN__'s @dfn{value
3617history} so that you can refer to them in other expressions. Values are
3618kept until the symbol table is re-read or discarded (for example with
3619the @code{file} or @code{symbol-file} commands). When the symbol table
3620changes, the value history is discarded, since the values may contain
3621pointers back to the types defined in the symbol table.
3622
3623@cindex @code{$}
3624@cindex @code{$$}
3625@cindex history number
3626The values printed are given @dfn{history numbers} for you to refer to them
3627by. These are successive integers starting with one. @code{print} shows you
3628the history number assigned to a value by printing @samp{$@var{num} = }
3629before the value; here @var{num} is the history number.
3630
3631To refer to any previous value, use @samp{$} followed by the value's
3632history number. The way @code{print} labels its output is designed to
3633remind you of this. Just @code{$} refers to the most recent value in
3634the history, and @code{$$} refers to the value before that.
3635@code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
3636is the value just prior to @code{$$}, @code{$$1} is equivalent to
3637@code{$$}, and @code{$$0} is equivalent to @code{$}.
3638
3639For example, suppose you have just printed a pointer to a structure and
3640want to see the contents of the structure. It suffices to type
3641
3642@example
3643p *$
3644@end example
3645
3646If you have a chain of structures where the component @code{next} points
3647to the next one, you can print the contents of the next one with this:
3648
3649@example
3650p *$.next
3651@end example
3652
3653@noindent
3654You can print successive links in the chain by repeating this
3655command---which you can do by just typing @key{RET}.
3656
3657Note that the history records values, not expressions. If the value of
3658@code{x} is 4 and you type these commands:
3659
3660@example
3661print x
3662set x=5
3663@end example
3664
3665@noindent
3666then the value recorded in the value history by the @code{print} command
3667remains 4 even though the value of @code{x} has changed.
3668
3669@table @code
3670@kindex show values
3671@item show values
3672Print the last ten values in the value history, with their item numbers.
3673This is like @samp{p@ $$9} repeated ten times, except that @code{show
3674values} does not change the history.
3675
3676@item show values @var{n}
3677Print ten history values centered on history item number @var{n}.
3678
3679@item show values +
3680Print ten history values just after the values last printed. If no more
3681values are available, produces no display.
3682@end table
3683
3684Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the
3685same effect as @samp{show values +}.
3686
3687@node Convenience Vars, Registers, Value History, Data
3688@section Convenience Variables
3689
3690@cindex convenience variables
3691_GDBN__ provides @dfn{convenience variables} that you can use within
3692_GDBN__ to hold on to a value and refer to it later. These variables
3693exist entirely within _GDBN__; they are not part of your program, and
3694setting a convenience variable has no direct effect on further execution
3695of your program. That's why you can use them freely.
3696
3697Convenience variables are prefixed with @samp{$}. Any name preceded by
3698@samp{$} can be used for a convenience variable, unless it is one of
3699the predefined machine-specific register names (@pxref{Registers}).
3700(Value history references, in contrast, are @emph{numbers} preceded
3701by @samp{$}. @xref{Value History}.)
3702
3703You can save a value in a convenience variable with an assignment
3704expression, just as you would set a variable in your program. Example:
3705
3706@example
3707set $foo = *object_ptr
3708@end example
3709
3710@noindent
3711would save in @code{$foo} the value contained in the object pointed to by
3712@code{object_ptr}.
3713
3714Using a convenience variable for the first time creates it; but its value
3715is @code{void} until you assign a new value. You can alter the value with
3716another assignment at any time.
3717
3718Convenience variables have no fixed types. You can assign a convenience
3719variable any type of value, including structures and arrays, even if
3720that variable already has a value of a different type. The convenience
3721variable, when used as an expression, has the type of its current value.
3722
3723@table @code
3724@item show convenience
3725@kindex show convenience
3726Print a list of convenience variables used so far, and their values.
3727Abbreviated @code{show con}.
3728@end table
3729
3730One of the ways to use a convenience variable is as a counter to be
3731incremented or a pointer to be advanced. For example, to print
3732a field from successive elements of an array of structures:
3733
3734_0__@example
3735set $i = 0
3736print bar[$i++]->contents
3737@i{@dots{} repeat that command by typing @key{RET}.}
3738_1__@end example
3739
3740Some convenience variables are created automatically by _GDBN__ and given
3741values likely to be useful.
3742
3743@table @code
3744@item $_
3745The variable @code{$_} is automatically set by the @code{x} command to
3746the last address examined (@pxref{Memory}). Other commands which
3747provide a default address for @code{x} to examine also set @code{$_}
3748to that address; these commands include @code{info line} and @code{info
3749breakpoint}.
3750
3751@item $__
3752The variable @code{$__} is automatically set by the @code{x} command
3753to the value found in the last address examined.
3754@end table
3755
3756@node Registers, Floating Point Hardware, Convenience Vars, Data
3757@section Registers
3758
3759@cindex registers
3760Machine register contents can be referred to in expressions as variables
3761with names starting with @samp{$}. The names of registers are different
3762for each machine; use @code{info registers} to see the names used on
3763your machine.
3764
3765@table @code
3766@item info registers
3767@kindex info registers
3768Print the names and values of all registers (in the selected stack frame).
3769
3770@item info registers @var{regname}
3771Print the relativized value of register @var{regname}. @var{regname}
3772may be any register name valid on the machine you are using, with
3773or without the initial @samp{$}.
3774@end table
3775
3776The register names @code{$pc} and @code{$sp} are used on most machines
3777for the program counter register and the stack pointer. For example,
3778you could print the program counter in hex with
3779@example
3780p/x $pc
3781@end example
3782
3783@noindent
3784or print the instruction to be executed next with
3785@example
3786x/i $pc
3787@end example
3788
3789@noindent
3790or add four to the stack pointer with
3791@example
3792set $sp += 4
3793@end example
3794
3795@noindent
3796The last is a way of removing one word from the stack, on machines where
3797stacks grow downward in memory (most machines, nowadays). This assumes
3798that the innermost stack frame is selected; setting @code{$sp} is
3799not allowed when other stack frames are selected. (To pop entire frames
3800off the stack, regardless of machine architecture, use @code{return};
3801@pxref{Returning}.)
3802
3803Often @code{$fp} is used for a register that contains a pointer to the
3804current stack frame, and @code{$ps} is sometimes used for a register
3805that contains the processor status. These standard register names may
3806be available on your machine even though the @code{info registers}
3807command shows other names. For example, on the SPARC, @code{info
3808registers} displays the processor status register as @code{$psr} but you
3809can also refer to it as @code{$ps}.
3810
3811_GDBN__ always considers the contents of an ordinary register as an
3812integer when the register is examined in this way. Some machines have
3813special registers which can hold nothing but floating point; these
3814registers are considered to have floating point values. There is no way
3815to refer to the contents of an ordinary register as floating point value
3816(although you can @emph{print} it as a floating point value with
3817@samp{print/f $@var{regname}}).
3818
3819Some registers have distinct ``raw'' and ``virtual'' data formats. This
3820means that the data format in which the register contents are saved by
3821the operating system is not the same one that your program normally
3822sees. For example, the registers of the 68881 floating point
3823coprocessor are always saved in ``extended'' (raw) format, but all C
3824programs expect to work with ``double'' (virtual) format. In such
3825cases, _GDBN__ normally works with the virtual format only (the format that
3826makes sense for your program), but the @code{info registers} command
3827prints the data in both formats.
3828
3829Normally, register values are relative to the selected stack frame
3830(@pxref{Selection}). This means that you get the value that the
3831register would contain if all stack frames farther in were exited and
3832their saved registers restored. In order to see the true contents of
3833hardware registers, you must select the innermost frame (with
3834@samp{frame 0}).
3835
3836However, _GDBN__ must deduce where registers are saved, from the machine
3837code generated by your compiler. If some registers are not saved, or if
3838_GDBN__ is unable to locate the saved registers, the selected stack
3839frame will make no difference.
3840
3841@node Floating Point Hardware, , Registers, Data
3842@section Floating Point Hardware
3843@cindex floating point
3844Depending on the host machine architecture, _GDBN__ may be able to give
3845you more information about the status of the floating point hardware.
3846
3847@table @code
3848@item info float
3849@kindex info float
3850If available, provides hardware-dependent information about the floating
3851point unit. The exact contents and layout vary depending on the
3852floating point chip.
3853@end table
3854@c FIXME: this is a cop-out. Try to get examples, explanations. Only
3855@c FIXME...supported currently on arm's and 386's. Mark properly with
3856@c FIXME... m4 macros to isolate general statements from hardware-dep,
3857@c FIXME... at that point.
3858
3859@node Symbols, Altering, Data, Top
3860@chapter Examining the Symbol Table
3861
3862The commands described in this section allow you to inquire about the
3863symbols (names of variables, functions and types) defined in your
3864program. This information is inherent in the text of your program and
3865does not change as the program executes. _GDBN__ finds it in your
3866program's symbol table, in the file indicated when you started _GDBN__
3867(@pxref{File Options}), or by one of the file-management commands
3868(@pxref{Files}).
3869
3870@table @code
3871@item info address @var{symbol}
3872@kindex info address
3873Describe where the data for @var{symbol} is stored. For a register
3874variable, this says which register it is kept in. For a non-register
3875local variable, this prints the stack-frame offset at which the variable
3876is always stored.
3877
3878Note the contrast with @samp{print &@var{symbol}}, which does not work
3879at all for a register variables, and for a stack local variable prints
3880the exact address of the current instantiation of the variable.
3881
3882@item whatis @var{exp}
3883@kindex whatis
3884Print the data type of expression @var{exp}. @var{exp} is not
3885actually evaluated, and any side-effecting operations (such as
3886assignments or function calls) inside it do not take place.
3887@xref{Expressions}.
3888
3889@item whatis
3890Print the data type of @code{$}, the last value in the value history.
3891
3892@item ptype @var{typename}
3893@kindex ptype
3894Print a description of data type @var{typename}. @var{typename} may be
3895the name of a type, or for C code it may have the form
3896@samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or
3897@samp{enum @var{enum-tag}}.@refill
3898
3899@item ptype @var{exp}
3900Print a description of the type of expression @var{exp}. @code{ptype}
3901differs from @code{whatis} by printing a detailed description, instead of just
3902the name of the type. For example, if your program declares a variable
3903as
3904@example
3905struct complex @{double real; double imag;@} v;
3906@end example
3907@noindent
3908compare the output of the two commands:
3909@example
3910(_GDBP__) whatis v
3911type = struct complex
3912(_GDBP__) ptype v
3913type = struct complex @{
3914 double real;
3915 double imag;
3916@}
3917@end example
3918
3919@item info types @var{regexp}
3920@itemx info types
3921@kindex info types
3922Print a brief description of all types whose name matches @var{regexp}
3923(or all types in your program, if you supply no argument). Each
3924complete typename is matched as though it were a complete line; thus,
3925@samp{i type value} gives information on all types in your program whose
3926name includes the string @code{value}, but @samp{i type ^value$} gives
3927information only on types whose complete name is @code{value}.
3928
3929This command differs from @code{ptype} in two ways: first, like
3930@code{whatis}, it does not print a detailed description; second, it
3931lists all source files where a type is defined.
3932
3933@item info source
3934@kindex info source
3935Show the name of the current source file---that is, the source file for
3936the function containing the current point of execution.
3937
3938@item info sources
3939@kindex info sources
3940Print the names of all source files in the program for which there is
3941debugging information, organized into two lists: those for which symbols
3942have been read in, and those for which symbols will be read in on
3943demand.
3944@c FIXME: above passive AND awkward!
3945
3946@item info functions
3947@kindex info functions
3948Print the names and data types of all defined functions.
3949
3950@item info functions @var{regexp}
3951Print the names and data types of all defined functions
3952whose names contain a match for regular expression @var{regexp}.
3953Thus, @samp{info fun step} finds all functions whose names
3954include @code{step}; @samp{info fun ^step} finds those whose names
3955start with @code{step}.
3956
3957@item info variables
3958@kindex info variables
3959Print the names and data types of all variables that are declared
3960outside of functions (i.e., excluding local variables).
3961
3962@item info variables @var{regexp}
3963Print the names and data types of all variables (except for local
3964variables) whose names contain a match for regular expression
3965@var{regexp}.
3966
3967
3968@ignore
3969This was never implemented.
3970@item info methods
3971@itemx info methods @var{regexp}
3972@kindex info methods
3973The @code{info methods} command permits the user to examine all defined
3974methods within C++ program, or (with the @var{regexp} argument) a
3975specific set of methods found in the various C++ classes. Many
3976C++ classes provide a large number of methods. Thus, the output
3977from the @code{ptype} command can be overwhelming and hard to use. The
3978@code{info-methods} command filters the methods, printing only those
3979which match the regular-expression @var{regexp}.
3980@end ignore
3981
3982@item printsyms @var{filename}
3983@kindex printsyms
3984Write a complete dump of the debugger's symbol data into the
3985file @var{filename}.
3986@end table
3987
3988@node Altering, _GDBN__ Files, Symbols, Top
3989@chapter Altering Execution
3990
3991Once you think you have found an error in the program, you might want to
3992find out for certain whether correcting the apparent error would lead to
3993correct results in the rest of the run. You can find the answer by
3994experiment, using the _GDBN__ features for altering execution of the
3995program.
3996
3997For example, you can store new values into variables or memory
3998locations, give the program a signal, restart it at a different address,
3999or even return prematurely from a function to its caller.
4000
4001@menu
4002* Assignment:: Assignment to Variables
4003* Jumping:: Continuing at a Different Address
4004* Signaling:: Giving the Program a Signal
4005* Returning:: Returning from a Function
4006* Calling:: Calling your Program's Functions
4007@end menu
4008
4009@node Assignment, Jumping, Altering, Altering
4010@section Assignment to Variables
4011
4012@cindex assignment
4013@cindex setting variables
4014To alter the value of a variable, evaluate an assignment expression.
4015@xref{Expressions}. For example,
4016
4017@example
4018print x=4
4019@end example
4020
4021@noindent
4022would store the value 4 into the variable @code{x}, and then print the
4023value of the assignment expression (which is 4). All the assignment
4024operators of C are supported, including the increment operators
4025@samp{++} and @samp{--}, and combining assignments such as @samp{+=} and
4026_0__@samp{<<=}_1__.
4027
4028@kindex set
4029@kindex set variable
4030@cindex variables, setting
4031If you are not interested in seeing the value of the assignment, use the
4032@code{set} command instead of the @code{print} command. @code{set} is
4033really the same as @code{print} except that the expression's value is not
4034printed and is not put in the value history (@pxref{Value History}). The
4035expression is evaluated only for its effects.
4036
4037If the beginning of the argument string of the @code{set} command
4038appears identical to a @code{set} subcommand, use the @code{set
4039variable} command instead of just @code{set}. This command is identical
4040to @code{set} except for its lack of subcommands. For example, a
4041program might well have a variable @code{width}---which leads to
4042an error if we try to set a new value with just @samp{set width=13}, as
4043we might if @code{set width} didn't happen to be a _GDBN__ command:
4044@example
4045(_GDBP__) whatis width
4046type = double
4047(_GDBP__) p width
4048$4 = 13
4049(_GDBP__) set width=47
4050Invalid syntax in expression.
4051@end example
4052@noindent
4053The invalid expression, of course, is @samp{=47}. What we can do in
4054order to actually set our program's variable @code{width} is
4055@example
4056(_GDBP__) set var width=47
4057@end example
4058
4059_GDBN__ allows more implicit conversions in assignments than C does; you can
4060freely store an integer value into a pointer variable or vice versa, and
4061any structure can be converted to any other structure that is the same
4062length or shorter.
4063@comment FIXME: how do structs align/pad in these conversions?
4064@comment /pesch@cygnus.com 18dec1990
4065
4066To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
4067construct to generate a value of specified type at a specified address
4068(@pxref{Expressions}). For example, @code{@{int@}0x83040} refers
4069to memory location @code{0x83040} as an integer (which implies a certain size
4070and representation in memory), and
4071
4072@example
4073set @{int@}0x83040 = 4
4074@end example
4075
4076@noindent
4077stores the value 4 into that memory location.
4078
4079@node Jumping, Signaling, Assignment, Altering
4080@section Continuing at a Different Address
4081
4082Ordinarily, when you continue the program, you do so at the place where
4083it stopped, with the @code{continue} command. You can instead continue at
4084an address of your own choosing, with the following commands:
4085
4086@table @code
4087@item jump @var{linespec}
4088@kindex jump
4089Resume execution at line @var{linespec}. Execution will stop
4090immediately if there is a breakpoint there. @xref{List} for a
4091description of the different forms of @var{linespec}.
4092
4093The @code{jump} command does not change the current stack frame, or
4094the stack pointer, or the contents of any memory location or any
4095register other than the program counter. If line @var{linespec} is in
4096a different function from the one currently executing, the results may
4097be bizarre if the two functions expect different patterns of arguments or
4098of local variables. For this reason, the @code{jump} command requests
4099confirmation if the specified line is not in the function currently
4100executing. However, even bizarre results are predictable if you are
4101well acquainted with the machine-language code of the program.
4102
4103@item jump *@var{address}
4104Resume execution at the instruction at address @var{address}.
4105@end table
4106
4107You can get much the same effect as the @code{jump} command by storing a
4108new value into the register @code{$pc}. The difference is that this
4109does not start the program running; it only changes the address where it
4110@emph{will} run when it is continued. For example,
4111
4112@example
4113set $pc = 0x485
4114@end example
4115
4116@noindent
4117causes the next @code{continue} command or stepping command to execute at
4118address 0x485, rather than at the address where the program stopped.
4119@xref{Stepping}.
4120
4121The most common occasion to use the @code{jump} command is to back up,
4122perhaps with more breakpoints set, over a portion of a program that has
4123already executed, in order to examine its execution in more detail.
4124
4125@node Signaling, Returning, Jumping, Altering
4126@c @group
4127@section Giving the Program a Signal
4128
4129@table @code
4130@item signal @var{signalnum}
4131@kindex signal
4132Resume execution where the program stopped, but give it immediately the
4133signal number @var{signalnum}.
4134
4135Alternatively, if @var{signalnum} is zero, continue execution without
4136giving a signal. This is useful when the program stopped on account of
4137a signal and would ordinary see the signal when resumed with the
4138@code{continue} command; @samp{signal 0} causes it to resume without a
4139signal.
4140
4141@code{signal} does not repeat when you press @key{RET} a second time
4142after executing the command.
4143@end table
4144@c @end group
4145
4146@node Returning, Calling, Signaling, Altering
4147@section Returning from a Function
4148
4149@table @code
4150@item return
4151@itemx return @var{expression}
4152@cindex returning from a function
4153@kindex return
4154You can cancel execution of a function call with the @code{return}
4155command. If you give an
4156@var{expression} argument, its value is used as the function's return
4157value.
4158@end table
4159
4160When you use @code{return}, _GDBN__ discards the selected stack frame
4161(and all frames within it). You can think of this as making the
4162discarded frame return prematurely. If you wish to specify a value to
4163be returned, give that value as the argument to @code{return}.
4164
4165This pops the selected stack frame (@pxref{Selection}), and any other
4166frames inside of it, leaving its caller as the innermost remaining
4167frame. That frame becomes selected. The specified value is stored in
4168the registers used for returning values of functions.
4169
4170The @code{return} command does not resume execution; it leaves the
4171program stopped in the state that would exist if the function had just
4172returned. In contrast, the @code{finish} command (@pxref{Stepping})
4173resumes execution until the selected stack frame returns naturally.
4174
4175@node Calling, , Returning, Altering
4176@section Calling your Program's Functions
4177
4178@cindex calling functions
4179@kindex call
4180@table @code
4181@item call @var{expr}
4182Evaluate the expression @var{expr} without displaying @code{void}
4183returned values.
4184@end table
4185
4186You can use this variant of the @code{print} command if you want to
4187execute a function from your program, but without cluttering the output
4188with @code{void} returned values. The result is printed and saved in
4189the value history, if it is not void.
4190
4191@node _GDBN__ Files, Targets, Altering, Top
4192@chapter _GDBN__'s Files
4193
4194@menu
4195* Files:: Commands to Specify Files
4196* Symbol Errors:: Errors Reading Symbol Files
4197@end menu
4198
4199@node Files, Symbol Errors, _GDBN__ Files, _GDBN__ Files
4200@section Commands to Specify Files
4201@cindex core dump file
4202@cindex symbol table
4203_GDBN__ needs to know the file name of the program to be debugged, both in
4204order to read its symbol table and in order to start the program. To
4205debug a core dump of a previous run, _GDBN__ must be told the file name of
4206the core dump.
4207
4208The usual way to specify the executable and core dump file names is with
4209the command arguments given when you start _GDBN__, as discussed in
4210@pxref{Invocation}.
4211
4212Occasionally it is necessary to change to a different file during a
4213_GDBN__ session. Or you may run _GDBN__ and forget to specify the files you
4214want to use. In these situations the _GDBN__ commands to specify new files
4215are useful.
4216
4217@table @code
4218@item file @var{filename}
4219@cindex executable file
4220@kindex file
4221Use @var{filename} as the program to be debugged. It is read for its
4222symbols and for the contents of pure memory. It is also the program
4223executed when you use the @code{run} command. If you do not specify a
4224directory and the file is not found in _GDBN__'s working directory,
4225
4226_GDBN__ uses the environment variable @code{PATH} as a list of
4227directories to search, just as the shell does when looking for a program
4228to run. You can change the value of this variable, for both _GDBN__ and
4229your program, using the @code{path} command.
4230
4231@code{file} with no argument makes _GDBN__ discard any information it
4232has on both executable file and the symbol table.
4233
4234@item exec-file @var{filename}
4235@kindex exec-file
4236Specify that the program to be run (but not the symbol table) is found
4237in @var{filename}. _GDBN__ will search the environment variable @code{PATH}
4238if necessary to locate the program.
4239
4240@item symbol-file @var{filename}
4241@kindex symbol-file
4242Read symbol table information from file @var{filename}. @code{PATH} is
4243searched when necessary. Use the @code{file} command to get both symbol
4244table and program to run from the same file.
4245
4246@code{symbol-file} with no argument clears out _GDBN__'s information on your
4247program's symbol table.
4248
4249The @code{symbol-file} command causes _GDBN__ to forget the contents of its
4250convenience variables, the value history, and all breakpoints and
4251auto-display expressions. This is because they may contain pointers to
4252the internal data recording symbols and data types, which are part of
4253the old symbol table data being discarded inside _GDBN__.
4254
4255@code{symbol-file} will not repeat if you press @key{RET} again after
4256executing it once.
4257
4258On some kinds of object files, the @code{symbol-file} command does not
4259actually read the symbol table in full right away. Instead, it scans
4260the symbol table quickly to find which source files and which symbols
4261are present. The details are read later, one source file at a time,
4262when they are needed.
4263
4264The purpose of this two-stage reading strategy is to make _GDBN__ start up
4265faster. For the most part, it is invisible except for occasional pauses
4266while the symbol table details for a particular source file are being
4267read. (The @code{set verbose} command can turn these pauses into
4268messages if desired. @xref{Messages/Warnings}).
4269
4270When the symbol table is stored in COFF format, @code{symbol-file} does
4271read the symbol table data in full right away. We haven't implemented
4272the two-stage strategy for COFF yet.
4273
4274When _GDBN__ is configured for a particular environment, it will
4275understand debugging information in whatever format is the standard
4276generated for that environment; you may use either a GNU compiler, or
4277other compilers that adhere to the local conventions. Best results are
4278usually obtained from GNU compilers; for example, using @code{_GCC__}
4279you can generate debugging information for optimized code.
4280
4281@item core-file @var{filename}
4282@itemx core @var{filename}
4283@kindex core
4284@kindex core-file
4285Specify the whereabouts of a core dump file to be used as the ``contents
4286of memory''. Traditionally, core files contain only some parts of the
4287address space of the process that generated them; _GDBN__ can access the
4288executable file itself for other parts.
4289
4290@code{core-file} with no argument specifies that no core file is
4291to be used.
4292
4293Note that the core file is ignored when your program is actually running
4294under _GDBN__. So, if you have been running the program and you wish to
4295debug a core file instead, you must kill the subprocess in which the
4296program is running. To do this, use the @code{kill} command
4297(@pxref{Kill Process}).
4298
4299@item load @var{filename}
4300@kindex load
4301_if__(_GENERIC__)
4302Depending on what remote debugging facilities are configured into
4303_GDBN__, the @code{load} command may be available. Where it exists, it
4304is meant to make @var{filename} (an executable) available for debugging
4305on the remote system---by downloading, or dynamic linking, for example.
4306@code{load} also records @var{filename}'s symbol table in _GDBN__, like
4307the @code{add-symbol-file} command.
4308
4309If @code{load} is not available on your _GDBN__, attempting to execute
4310it gets the error message ``@code{You can't do that when your target is
4311@dots{}}''
4312_fi__(_GENERIC__)
4313
4314_if__(_VXWORKS__)
4315On VxWorks, @code{load} will dynamically link @var{filename} on the
4316current target system as well as adding its symbols in _GDBN__.
4317_fi__(_VXWORKS__)
4318
4319_if__(_I960__)
4320@cindex download to Nindy-960
4321With the Nindy interface to an Intel 960 board, @code{load} will
4322download @var{filename} to the 960 as well as adding its symbols in
4323_GDBN__.
4324_fi__(_I960__)
4325
4326@code{load} will not repeat if you press @key{RET} again after using it.
4327
4328@item add-symbol-file @var{filename} @var{address}
4329@kindex add-symbol-file
4330@cindex dynamic linking
4331The @code{add-symbol-file} command reads additional symbol table information
4332from the file @var{filename}. You would use this command when that file
4333has been dynamically loaded (by some other means) into the program that
4334is running. @var{address} should be the memory address at which the
4335file has been loaded; _GDBN__ cannot figure this out for itself.
4336
4337The symbol table of the file @var{filename} is added to the symbol table
4338originally read with the @code{symbol-file} command. You can use the
4339@code{add-symbol-file} command any number of times; the new symbol data thus
4340read keeps adding to the old. To discard all old symbol data instead,
4341use the @code{symbol-file} command.
4342
4343@code{add-symbol-file} will not repeat if you press @key{RET} after using it.
4344
4345@item info files
4346@itemx info target
4347@kindex info files
4348@kindex info target
4349@code{info files} and @code{info target} are synonymous; both print the
4350current targets (@pxref{Targets}), including the names of the executable
4351and core dump files currently in use by _GDBN__, and the files from
4352which symbols were loaded. The command @code{help targets} lists all
4353possible targets rather than current ones.
4354
4355@end table
4356
4357All file-specifying commands allow both absolute and relative file names
4358as arguments. _GDBN__ always converts the file name to an absolute path
4359name and remembers it that way.
4360
4361@kindex sharedlibrary
4362@kindex share
4363@cindex shared libraries
4364
4365_GDBN__ supports the SunOS shared library format. Symbols from a shared
4366library cannot be referenced before the shared library has been linked
4367with the program. (That is to say, until after you type @code{run} and
4368the function @code{main} has been entered; or when examining core
4369files.) Once the shared library has been linked in, you can use the
4370following commands:
4371
4372@table @code
4373@item sharedlibrary @var{regex}
4374@itemx share @var{regex}
4375Load shared object library symbols for files matching a UNIX regular
4376expression.
4377
4378@item share
4379@itemx sharedlibrary
4380Load symbols for all shared libraries.
4381
4382@item info share
4383@itemx info sharedlibrary
4384@kindex info sharedlibrary
4385@kindex info share
4386Print the names of the shared libraries which you have loaded with the
4387@code{sharedlibrary} command.
4388@end table
4389
4390@code{sharedlibrary} does not repeat automatically when you press
4391@key{RET} after using it once.
4392
4393@node Symbol Errors, , Files, _GDBN__ Files
4394@section Errors Reading Symbol Files
4395While a symbol file is being read, _GDBN__ will occasionally encounter
4396problems, such as symbol types it does not recognize, or known bugs in
4397compiler output. By default, it prints one message about each such
4398type of problem, no matter how many times the problem occurs. You can
4399ask it to print more messages, to see how many times the problems occur,
4400or can shut the messages off entirely, with the @code{set
4401complaints} command (@xref{Messages/Warnings}).
4402
4403The messages currently printed, and their meanings, are:
4404
4405@table @code
4406@item inner block not inside outer block in @var{symbol}
4407
4408The symbol information shows where symbol scopes begin and end
4409(such as at the start of a function or a block of statements). This
4410error indicates that an inner scope block is not fully contained
4411in its outer scope blocks.
4412
4413_GDBN__ circumvents the problem by treating the inner block as if it had
4414the same scope as the outer block. In the error message, @var{symbol}
4415may be shown as ``@code{(don't know)}'' if the outer block is not a
4416function.
4417
4418@item block at @var{address} out of order
4419
4420The symbol information for symbol scope blocks should occur in
4421order of increasing addresses. This error indicates that it does not
4422do so.
4423
4424_GDBN__ does not circumvent this problem, and will have trouble locating
4425symbols in the source file whose symbols being read. (You can often
4426determine what source file is affected by specifying @code{set verbose
4427on}. @xref{Messages/Warnings}.)
4428
4429@item bad block start address patched
4430
4431The symbol information for a symbol scope block has a start address
4432smaller than the address of the preceding source line. This is known
4433to occur in the SunOS 4.1.1 (and earlier) C compiler.
4434
4435_GDBN__ circumvents the problem by treating the symbol scope block as
4436starting on the previous source line.
4437
4438@c @item{encountered DBX-style class variable debugging information.
4439@c You seem to have compiled your program with "g++ -g0" instead of "g++ -g".
4440@c Therefore _GDBN__ will not know about your class variables}
4441@c
4442@c This error indicates that the symbol information produced for a C++
4443@c program includes zero-size fields, which indicated static fields in
4444@c a previous release of the G++ compiler. This message is probably
4445@c obsolete.
4446@c
4447@item bad string table offset in symbol @var{n}
4448
4449@cindex foo
4450Symbol number @var{n} contains a pointer into the string table which is
4451larger than the size of the string table.
4452
4453_GDBN__ circumvents the problem by considering the symbol to have the
4454name @code{foo}, which may cause other problems if many symbols end up
4455with this name.
4456
4457@item unknown symbol type @code{0x@var{nn}}
4458
4459The symbol information contains new data types that _GDBN__ does not yet
4460know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood
4461information, in hexadecimal.
4462
4463_GDBN__ circumvents the error by ignoring this symbol information. This
4464will usually allow the program to be debugged, though certain symbols
4465will not be accessible. If you encounter such a problem and feel like
4466debugging it, you can debug @code{_GDBP__} with itself, breakpoint on
4467@code{complain}, then go up to the function @code{read_dbx_symtab} and
4468examine @code{*bufp} to see the symbol.
4469
4470@item stub type has NULL name
4471_GDBN__ could not find the full definition for a struct or class.
4472
4473@ignore
4474@c this is #if 0'd in dbxread.c as of (at least!) 17 may 1991
4475@item const/volatile indicator missing, got '@var{X}'
4476
4477The symbol information for a C++ member function is missing some
4478information that the compiler should have output for it.
4479@end ignore
4480
4481@item C++ type mismatch between compiler and debugger
4482
4483The debugger could not parse a type specification output by the compiler
4484for some C++ object.
4485
4486@end table
4487
4488@node Targets, Controlling _GDBN__, _GDBN__ Files, Top
4489@chapter Specifying a Debugging Target
4490@cindex debugging target
4491@kindex target
4492A @dfn{target} is an interface between the debugger and a particular
4493kind of file or process.
4494
4495Often, you will be able to run _GDBN__ in the same host environment as the
4496program you are debugging; in that case, the debugging target can just be
4497specified as a side effect of the @code{file} or @code{core} commands.
4498When you need more flexibility---for example, running _GDBN__ on a
4499physically separate host, controlling standalone systems over a
4500serial port, or realtime systems over a TCP/IP connection---you can use
4501the @code{target} command.
4502
4503@menu
4504* Active Targets:: Active Targets
4505* Target Commands:: Commands for Managing Targets
4506* Remote:: Remote Debugging
4507@end menu
4508
4509@node Active Targets, Target Commands, Targets, Targets
4510@section Active Targets
4511@cindex stacking targets
4512@cindex active targets
4513@cindex multiple targets
4514
4515Targets are managed in three @dfn{strata} that correspond to different
4516classes of target: processes, core files, and executable files. This
4517allows you to (for example) start a process and inspect its activity
4518without abandoning your work on a core file.
4519
4520More than one target can potentially respond to a request. In
4521particular, when you access memory _GDBN__ will examine the three strata of
4522targets until it finds a target that can handle that particular address.
4523Strata are always examined in a fixed order: first a process if there is
4524one, then a core file if there is one, and finally an executable file if
4525there is one of those.
4526
4527When you specify a new target in a given stratum, it replaces any target
4528previously in that stratum.
4529
4530To get rid of a target without replacing it, use the @code{detach}
4531command. The related command @code{attach} provides you with a way of
4532choosing a particular running process as a new target. @xref{Attach}.
4533
4534@node Target Commands, Remote, Active Targets, Targets
4535@section Commands for Managing Targets
4536
4537@table @code
4538@item target @var{type} @var{parameters}
4539Connects the _GDBN__ host environment to a target machine or process. A
4540target is typically a protocol for talking to debugging facilities. You
4541use the argument @var{type} to specify the type or protocol of the
4542target machine.
4543
4544Further @var{parameters} are interpreted by the target protocol, but
4545typically include things like device names or host names to connect
4546with, process numbers, and baud rates.
4547
4548The @code{target} command will not repeat if you press @key{RET} again
4549after executing the command.
4550
4551@item help target
4552@kindex help target
4553Displays the names of all targets available. To display targets
4554currently selected, use either @code{info target} or @code{info files}
4555(@pxref{Files}).
4556
4557@item help target @var{name}
4558Describe a particular target, including any parameters necessary to
4559select it.
4560@end table
4561
4562Here are some common targets (available, or not, depending on the _GDBN__
4563configuration):
4564
4565@table @code
4566@item target exec @var{prog}
4567@kindex target exec
4568An executable file. @samp{target exec @var{prog}} is the same as
4569@samp{exec-file @var{prog}}.
4570
4571@item target core @var{filename}
4572@kindex target core
4573A core dump file. @samp{target core @var{filename}} is the same as
4574@samp{core-file @var{filename}}.
4575
4576@item target remote @var{dev}
4577@kindex target remote
4578Remote serial target in _GDBN__-specific protocol. The argument @var{dev}
4579specifies what serial device to use for the connection (e.g.
4580@file{/dev/ttya}). @xref{Remote}.
4581
4582_if__(_AMD29K__)
4583@item target amd-eb @var{dev} @var{speed} @var{PROG}
4584@kindex target amd-eb
4585@cindex AMD EB29K
4586Remote PC-resident AMD EB29K board, attached over serial lines.
4587@var{dev} is the serial device, as for @code{target remote};
4588@var{speed} allows you to specify the linespeed; and @var{PROG} is the
4589name of the program to be debugged, as it appears to DOS on the PC.
4590@xref{EB29K Remote}.
4591
4592_fi__(_AMD29K__)
4593_if__(_I960__)
4594@item target nindy @var{devicename}
4595@kindex target nindy
4596An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is
4597the name of the serial device to use for the connection, e.g.
4598@file{/dev/ttya}. @xref{i960-Nindy Remote}.
4599
4600_fi__(_I960__)
4601_if__(_VXWORKS__)
4602@item target vxworks @var{machinename}
4603@kindex target vxworks
4604A VxWorks system, attached via TCP/IP. The argument @var{machinename}
4605is the target system's machine name or IP address.
4606@xref{VxWorks Remote}.
4607_fi__(_VXWORKS__)
4608@end table
4609
4610_if__(_GENERIC__)
4611Different targets are available on different configurations of _GDBN__; your
4612configuration may have more or fewer targets.
4613_fi__(_GENERIC__)
4614
4615@node Remote, , Target Commands, Targets
4616@section Remote Debugging
4617@cindex remote debugging
4618
4619_if__(_GENERIC__)
4620@menu
4621_include__(gdbinv-m.m4)<>_dnl__
4622@end menu
4623_fi__(_GENERIC__)
4624
4625If you are trying to debug a program running on a machine that can't run
4626_GDBN__ in the usual way, it is often useful to use remote debugging. For
4627example, you might use remote debugging on an operating system kernel, or on
4628a small system which does not have a general purpose operating system
4629powerful enough to run a full-featured debugger.
4630
4631Some configurations of _GDBN__ have special serial or TCP/IP interfaces
4632to make this work with particular debugging targets. In addition,
4633_GDBN__ comes with a generic serial protocol (specific to _GDBN__, but
4634not specific to any particular target system) which you can use if you
4635write the remote stubs---the code that will run on the remote system to
4636communicate with _GDBN__.
4637
4638To use the _GDBN__ remote serial protocol, the program to be debugged on
4639the remote machine needs to contain a debugging stub which talks to
4640_GDBN__ over the serial line. Several working remote stubs are
4641distributed with _GDBN__; see the @file{README} file in the _GDBN__
4642distribution for more information.
4643
4644For details of this communication protocol, see the comments in the
4645_GDBN__ source file @file{remote.c}.
4646
4647To start remote debugging, first run _GDBN__ and specify as an executable file
4648the program that is running in the remote machine. This tells _GDBN__ how
4649to find the program's symbols and the contents of its pure text. Then
4650establish communication using the @code{target remote} command with a device
4651name as an argument. For example:
4652
4653@example
4654target remote /dev/ttyb
4655@end example
4656
4657@noindent
4658if the serial line is connected to the device named @file{/dev/ttyb}. This
4659will stop the remote machine if it is not already stopped.
4660
4661Now you can use all the usual commands to examine and change data and to
4662step and continue the remote program.
4663
4664To resume the remote program and stop debugging it, use the @code{detach}
4665command.
4666
4667Other remote targets may be available in your
4668configuration of _GDBN__; use @code{help targets} to list them.
4669
4670_if__(_GENERIC__)
4671@c Text on starting up GDB in various specific cases; it goes up front
4672@c in manuals configured for any of those particular situations, here
4673@c otherwise.
4674_include__(gdbinv-s.m4)
4675_fi__(_GENERIC__)
4676
4677@node Controlling _GDBN__, Sequences, Targets, Top
4678@chapter Controlling _GDBN__
4679
4680You can alter many aspects of _GDBN__'s interaction with you by using
4681the @code{set} command. For commands controlling how _GDBN__ displays
4682data, @pxref{Print Settings}; other settings are described here.
4683
4684@menu
4685* Prompt:: Prompt
4686* Editing:: Command Editing
4687* History:: Command History
4688* Screen Size:: Screen Size
4689* Numbers:: Numbers
4690* Messages/Warnings:: Optional Warnings and Messages
4691@end menu
4692
4693@node Prompt, Editing, Controlling _GDBN__, Controlling _GDBN__
4694@section Prompt
4695@cindex prompt
4696_GDBN__ indicates its readiness to read a command by printing a string
4697called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You
4698can change the prompt string with the @code{set prompt} command. For
4699instance, when debugging _GDBN__ with _GDBN__, it is useful to change
4700the prompt in one of the _GDBN__<>s so that you can always tell which
4701one you are talking to.
4702
4703@table @code
4704@item set prompt @var{newprompt}
4705@kindex set prompt
4706Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth.
4707@kindex show prompt
4708@item show prompt
4709Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
4710@end table
4711
4712@node Editing, History, Prompt, Controlling _GDBN__
4713@section Command Editing
4714@cindex readline
4715@cindex command line editing
4716_GDBN__ reads its input commands via the @dfn{readline} interface. This
4717GNU library provides consistent behavior for programs which provide a
4718command line interface to the user. Advantages are @code{emacs}-style
4719or @code{vi}-style inline editing of commands, @code{csh}-like history
4720substitution, and a storage and recall of command history across
4721debugging sessions.
4722
4723You may control the behavior of command line editing in _GDBN__ with the
4724command @code{set}.
4725
4726@table @code
4727@kindex set editing
4728@cindex editing
4729@item set editing
4730@itemx set editing on
4731Enable command line editing (enabled by default).
4732
4733@item set editing off
4734Disable command line editing.
4735
4736@kindex show editing
4737@item show editing
4738Show whether command line editing is enabled.
4739@end table
4740
4741@node History, Screen Size, Editing, Controlling _GDBN__
4742@section Command History
4743@table @code
4744@cindex history substitution
4745@cindex history file
4746@kindex set history filename
4747@item set history filename @var{fname}
4748Set the name of the _GDBN__ command history file to @var{fname}. This is
4749the file from which _GDBN__ will read an initial command history
4750list or to which it will write this list when it exits. This list is
4751accessed through history expansion or through the history
4752command editing characters listed below. This file defaults to the
4753value of the environment variable @code{GDBHISTFILE}, or to
4754@file{./.gdb_history} if this variable is not set.
4755
4756@cindex history save
4757@kindex set history save
4758@item set history save
4759@itemx set history save on
4760Record command history in a file, whose name may be specified with the
4761@code{set history filename} command. By default, this option is disabled.
4762
4763@item set history save off
4764Stop recording command history in a file.
4765
4766@cindex history size
4767@kindex set history size
4768@item set history size @var{size}
4769Set the number of commands which _GDBN__ will keep in its history list.
4770This defaults to the value of the environment variable
4771@code{HISTSIZE}, or to 256 if this variable is not set.
4772@end table
4773
4774@cindex history expansion
4775History expansion assigns special meaning to the character @kbd{!}.
4776@iftex
4777(@xref{Event Designators}.)
4778@end iftex
4779Since @kbd{!} is also the logical not operator in C, history expansion
4780is off by default. If you decide to enable history expansion with the
4781@code{set history expansion on} command, you may sometimes need to
4782follow @kbd{!} (when it is used as logical not, in an expression) with
4783a space or a tab to prevent it from being expanded. The readline
4784history facilities will not attempt substitution on the strings
4785@kbd{!=} and @kbd{!(}, even when history expansion is enabled.
4786
4787The commands to control history expansion are:
4788
4789@table @code
4790
4791@kindex set history expansion
4792@item set history expansion on
4793@itemx set history expansion
4794Enable history expansion. History expansion is off by default.
4795
4796@item set history expansion off
4797Disable history expansion.
4798
4799The readline code comes with more complete documentation of
4800editing and history expansion features. Users unfamiliar with @code{emacs}
4801or @code{vi} may wish to read it.
4802@iftex
4803@xref{Command Line Editing}.
4804@end iftex
4805
4806@c @group
4807@kindex show history
4808@item show history
4809@itemx show history filename
4810@itemx show history save
4811@itemx show history size
4812@itemx show history expansion
4813These commands display the state of the _GDBN__ history parameters.
4814@code{show history} by itself displays all four states.
4815@c @end group
4816
4817@end table
4818
4819@table @code
4820@kindex show commands
4821@item show commands
4822Display the last ten commands in the command history.
4823
4824@item show commands @var{n}
4825Print ten commands centered on command number @var{n}.
4826
4827@item show commands +
4828Print ten commands just after the commands last printed.
4829
4830@end table
4831
4832@node Screen Size, Numbers, History, Controlling _GDBN__
4833@section Screen Size
4834@cindex size of screen
4835@cindex pauses in output
4836Certain commands to _GDBN__ may produce large amounts of information
4837output to the screen. To help you read all of it, _GDBN__ pauses and
4838asks you for input at the end of each page of output. Type @key{RET}
4839when you want to continue the output. _GDBN__ also uses the screen
4840width setting to determine when to wrap lines of output. Depending on
4841what is being printed, it tries to break the line at a readable place,
4842rather than simply letting it overflow onto the following line.
4843
4844Normally _GDBN__ knows the size of the screen from the termcap data base
4845together with the value of the @code{TERM} environment variable and the
4846@code{stty rows} and @code{stty cols} settings. If this is not correct,
4847you can override it with the @code{set height} and @code{set
4848width} commands:
4849
4850@table @code
4851@item set height @var{lpp}
4852@itemx show height
4853@itemx set width @var{cpl}
4854@itemx show width
4855@kindex set height
4856@kindex set width
4857@kindex show width
4858@kindex show height
4859These @code{set} commands specify a screen height of @var{lpp} lines and
4860a screen width of @var{cpl} characters. The associated @code{show}
4861commands display the current settings.
4862
4863If you specify a height of zero lines, _GDBN__ will not pause during output
4864no matter how long the output is. This is useful if output is to a file
4865or to an editor buffer.
4866@end table
4867
4868@node Numbers, Messages/Warnings, Screen Size, Controlling _GDBN__
4869@section Numbers
4870@cindex number representation
4871@cindex entering numbers
4872You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by
4873the usual conventions: octal numbers begin with @samp{0}, decimal
4874numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}.
4875Numbers that begin with none of these are, by default, entered in base
487610; likewise, the default display for numbers---when no particular
4877format is specified---is base 10. You can change the default base for
4878both input and output with the @code{set radix} command.
4879
4880@table @code
4881@kindex set radix
4882@item set radix @var{base}
4883Set the default base for numeric input and display. Supported choices
4884for @var{base} are decimal 8, 10, 16. @var{base} must itself be
4885specified either unambiguously or using the current default radix; for
4886example, any of
4887
4888@example
4889set radix 012
4890set radix 10.
4891set radix 0xa
4892@end example
4893
4894@noindent
4895will set the base to decimal. On the other hand, @samp{set radix 10}
4896will leave the radix unchanged no matter what it was.
4897
4898@kindex show radix
4899@item show radix
4900Display the current default base for numeric input and display.
4901
4902@end table
4903
4904@node Messages/Warnings, , Numbers, Controlling _GDBN__
4905@section Optional Warnings and Messages
4906By default, _GDBN__ is silent about its inner workings. If you are running
4907on a slow machine, you may want to use the @code{set verbose} command.
4908It will make _GDBN__ tell you when it does a lengthy internal operation, so
4909you won't think it has crashed.
4910
4911Currently, the messages controlled by @code{set verbose} are those which
4912announce that the symbol table for a source file is being read
4913(@pxref{Files}, in the description of the command
4914@code{symbol-file}).
4915@c The following is the right way to do it, but emacs 18.55 doesn't support
4916@c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo
4917@c is released.
4918@ignore
4919see @code{symbol-file} in @ref{Files}).
4920@end ignore
4921
4922@table @code
4923@kindex set verbose
4924@item set verbose on
4925Enables _GDBN__'s output of certain informational messages.
4926
4927@item set verbose off
4928Disables _GDBN__'s output of certain informational messages.
4929
4930@kindex show verbose
4931@item show verbose
4932Displays whether @code{set verbose} is on or off.
4933@end table
4934
4935By default, if _GDBN__ encounters bugs in the symbol table of an object file,
4936it prints a single message about each type of problem it finds, then
4937shuts up (@pxref{Symbol Errors}). You can suppress these messages, or allow more than one such
4938message to be printed if you want to see how frequent the problems are.
4939
4940@table @code
4941@kindex set complaints
4942@item set complaints @var{limit}
4943Permits _GDBN__ to output @var{limit} complaints about each type of unusual
4944symbols before becoming silent about the problem. Set @var{limit} to
4945zero to suppress all complaints; set it to a large number to prevent
4946complaints from being suppressed.
4947
4948@kindex show complaints
4949@item show complaints
4950Displays how many symbol complaints _GDBN__ is permitted to produce.
4951@end table
4952
4953By default, _GDBN__ is cautious, and asks what sometimes seem to be a
4954lot of stupid questions to confirm certain commands. For example, if
4955you try to run a program which is already running:
4956@example
4957(_GDBP__) run
4958The program being debugged has been started already.
4959Start it from the beginning? (y or n)
4960@end example
4961
4962If you're willing to unflinchingly face the consequences of your own
4963commands, you can disable this ``feature'':
4964
4965@table @code
4966@kindex set confirm
4967@cindex flinching
4968@cindex confirmation
4969@cindex stupid questions
4970@item set confirm off
4971Disables confirmation requests.
4972
4973@item set confirm on
4974Enables confirmation requests (the default).
4975
4976@item show confirm
4977@kindex show confirm
4978Displays state of confirmation requests.
4979@end table
4980
4981@node Sequences, Emacs, Controlling _GDBN__, Top
4982@chapter Canned Sequences of Commands
4983
4984Aside from breakpoint commands (@pxref{Break Commands}), _GDBN__ provides two
4985ways to store sequences of commands for execution as a unit:
4986user-defined commands and command files.
4987
4988@menu
4989* Define:: User-Defined Commands
4990* Command Files:: Command Files
4991* Output:: Commands for Controlled Output
4992@end menu
4993
4994@node Define, Command Files, Sequences, Sequences
4995@section User-Defined Commands
4996
4997@cindex user-defined command
4998A @dfn{user-defined command} is a sequence of _GDBN__ commands to which you
4999assign a new name as a command. This is done with the @code{define}
5000command.
5001
5002@table @code
5003@item define @var{commandname}
5004@kindex define
5005Define a command named @var{commandname}. If there is already a command
5006by that name, you are asked to confirm that you want to redefine it.
5007
5008The definition of the command is made up of other _GDBN__ command lines,
5009which are given following the @code{define} command. The end of these
5010commands is marked by a line containing @code{end}.
5011
5012@item document @var{commandname}
5013@kindex document
5014Give documentation to the user-defined command @var{commandname}. The
5015command @var{commandname} must already be defined. This command reads
5016lines of documentation just as @code{define} reads the lines of the
5017command definition, ending with @code{end}. After the @code{document}
5018command is finished, @code{help} on command @var{commandname} will print
5019the documentation you have specified.
5020
5021You may use the @code{document} command again to change the
5022documentation of a command. Redefining the command with @code{define}
5023does not change the documentation.
5024
5025@item help user-defined
5026@kindex help user-defined
5027List all user-defined commands, with the first line of the documentation
5028(if any) for each.
5029
5030@item info user
5031@itemx info user @var{commandname}
5032@kindex info user
5033Display the _GDBN__ commands used to define @var{commandname} (but not its
5034documentation). If no @var{commandname} is given, display the
5035definitions for all user-defined commands.
5036@end table
5037
5038User-defined commands do not take arguments. When they are executed, the
5039commands of the definition are not printed. An error in any command
5040stops execution of the user-defined command.
5041
5042Commands that would ask for confirmation if used interactively proceed
5043without asking when used inside a user-defined command. Many _GDBN__ commands
5044that normally print messages to say what they are doing omit the messages
5045when used in a user-defined command.
5046
5047@node Command Files, Output, Define, Sequences
5048@section Command Files
5049
5050@cindex command files
5051A command file for _GDBN__ is a file of lines that are _GDBN__ commands. Comments
5052(lines starting with @kbd{#}) may also be included. An empty line in a
5053command file does nothing; it does not mean to repeat the last command, as
5054it would from the terminal.
5055
5056@cindex init file
5057@cindex @file{_GDBINIT__}
5058When you start _GDBN__, it automatically executes commands from its
5059@dfn{init files}. These are files named @file{_GDBINIT__}. _GDBN__
5060reads the init file (if any) in your home directory and then the init
5061file (if any) in the current working directory. (The init files are not
5062executed if you use the @samp{-nx} option; @pxref{Mode Options}.) You
5063can also request the execution of a command file with the @code{source}
5064command:
5065
5066@table @code
5067@item source @var{filename}
5068@kindex source
5069Execute the command file @var{filename}.
5070@end table
5071
5072The lines in a command file are executed sequentially. They are not
5073printed as they are executed. An error in any command terminates execution
5074of the command file.
5075
5076Commands that would ask for confirmation if used interactively proceed
5077without asking when used in a command file. Many _GDBN__ commands that
5078normally print messages to say what they are doing omit the messages
5079when called from command files.
5080
5081@node Output, , Command Files, Sequences
5082@section Commands for Controlled Output
5083
5084During the execution of a command file or a user-defined command, normal
5085_GDBN__ output is suppressed; the only output that appears is what is
5086explicitly printed by the commands in the definition. This section
5087describes three commands useful for generating exactly the output you
5088want.
5089
5090@table @code
5091@item echo @var{text}
5092@kindex echo
5093@c I don't consider backslash-space a standard C escape sequence
5094@c because it's not in ANSI.
5095Print @var{text}. Nonprinting characters can be included in @var{text}
5096using C escape sequences, such as @samp{\n} to print a newline. @b{No
5097newline will be printed unless you specify one.} In addition to the
5098standard C escape sequences, a backslash followed by a space stands for a
5099space. This is useful for outputting a string with spaces at the
5100beginning or the end, since leading and trailing spaces are otherwise
5101trimmed from all arguments. Thus, to print @samp{@ and foo =@ }, use the
5102command @samp{echo \@ and foo = \@ }.
5103@c FIXME: verify hard copy actually issues enspaces for '@ '! Will this
5104@c confuse texinfo?
5105
5106A backslash at the end of @var{text} can be used, as in C, to continue
5107the command onto subsequent lines. For example,
5108
5109@example
5110echo This is some text\n\
5111which is continued\n\
5112onto several lines.\n
5113@end example
5114
5115produces the same output as
5116
5117@example
5118echo This is some text\n
5119echo which is continued\n
5120echo onto several lines.\n
5121@end example
5122
5123@item output @var{expression}
5124@kindex output
5125Print the value of @var{expression} and nothing but that value: no
5126newlines, no @samp{$@var{nn} = }. The value is not entered in the
5127value history either. @xref{Expressions} for more information on
5128expressions.
5129
5130@item output/@var{fmt} @var{expression}
5131Print the value of @var{expression} in format @var{fmt}. You can use
5132the same formats as for @code{print}; @pxref{Output formats}, for more
5133information.
5134
5135@item printf @var{string}, @var{expressions}@dots{}
5136@kindex printf
5137Print the values of the @var{expressions} under the control of
5138@var{string}. The @var{expressions} are separated by commas and may
5139be either numbers or pointers. Their values are printed as specified
5140by @var{string}, exactly as if the program were to execute
5141
5142@example
5143printf (@var{string}, @var{expressions}@dots{});
5144@end example
5145
5146For example, you can print two values in hex like this:
5147
5148@example
5149printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
5150@end example
5151
5152The only backslash-escape sequences that you can use in the format
5153string are the simple ones that consist of backslash followed by a
5154letter.
5155@end table
5156
5157@node Emacs, _GDBN__ Bugs, Sequences, Top
5158@chapter Using _GDBN__ under GNU Emacs
5159
5160@cindex emacs
5161A special interface allows you to use GNU Emacs to view (and
5162edit) the source files for the program you are debugging with
5163_GDBN__.
5164
5165To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
5166executable file you want to debug as an argument. This command starts
5167_GDBN__ as a subprocess of Emacs, with input and output through a newly
5168created Emacs buffer.
5169
5170Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two
5171things:
5172
5173@itemize @bullet
5174@item
5175All ``terminal'' input and output goes through the Emacs buffer.
5176@end itemize
5177
5178This applies both to _GDBN__ commands and their output, and to the input
5179and output done by the program you are debugging.
5180
5181This is useful because it means that you can copy the text of previous
5182commands and input them again; you can even use parts of the output
5183in this way.
5184
5185All the facilities of Emacs' Shell mode are available for this purpose.
5186
5187@itemize @bullet
5188@item
5189_GDBN__ displays source code through Emacs.
5190@end itemize
5191
5192Each time _GDBN__ displays a stack frame, Emacs automatically finds the
5193source file for that frame and puts an arrow (_0__@samp{=>}_1__) at the
5194left margin of the current line. Emacs uses a separate buffer for
5195source display, and splits the window to show both your _GDBN__ session
5196and the source.
5197
5198Explicit _GDBN__ @code{list} or search commands still produce output as
5199usual, but you probably will have no reason to use them.
5200
5201@quotation
5202@emph{Warning:} If the directory where your program resides is not your
5203current directory, it can be easy to confuse Emacs about the location of
5204the source files, in which case the auxiliary display buffer will not
5205appear to show your source. _GDBN__ can find programs by searching your
5206environment's @code{PATH} variable, so the _GDBN__ input and output
5207session will proceed normally; but Emacs doesn't get enough information
5208back from _GDBN__ to locate the source files in this situation. To
5209avoid this problem, either start _GDBN__ mode from the directory where
5210your program resides, or specify a full path name when prompted for the
5211@kbd{M-x gdb} argument.
5212
5213A similar confusion can result if you use the _GDBN__ @code{file} command to
5214switch to debugging a program in some other location, from an existing
5215_GDBN__ buffer in Emacs.
5216@end quotation
5217
5218By default, @kbd{M-x gdb} calls the program called @file{gdb}. If
5219you need to call _GDBN__ by a different name (for example, if you keep
5220several configurations around, with different names) you can set the
5221Emacs variable @code{gdb-command-name}; for example,
5222@example
5223(setq gdb-command-name "mygdb")
5224@end example
5225@noindent
5226(preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or
5227in your @file{.emacs} file) will make Emacs call the program named
5228``@code{mygdb}'' instead.
5229
5230In the _GDBN__ I/O buffer, you can use these special Emacs commands in
5231addition to the standard Shell mode commands:
5232
5233@table @kbd
5234@item C-h m
5235Describe the features of Emacs' _GDBN__ Mode.
5236
5237@item M-s
5238Execute to another source line, like the _GDBN__ @code{step} command; also
5239update the display window to show the current file and location.
5240
5241@item M-n
5242Execute to next source line in this function, skipping all function
5243calls, like the _GDBN__ @code{next} command. Then update the display window
5244to show the current file and location.
5245
5246@item M-i
5247Execute one instruction, like the _GDBN__ @code{stepi} command; update
5248display window accordingly.
5249
5250@item M-x gdb-nexti
5251Execute to next instruction, using the _GDBN__ @code{nexti} command; update
5252display window accordingly.
5253
5254@item C-c C-f
5255Execute until exit from the selected stack frame, like the _GDBN__
5256@code{finish} command.
5257
5258@item M-c
5259Continue execution of the program, like the _GDBN__ @code{continue}
5260command. @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}.
5261
5262@item M-u
5263Go up the number of frames indicated by the numeric argument
5264(@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}),
5265like the _GDBN__ @code{up} command. @emph{Warning:} In Emacs v19, this
5266command is @kbd{C-c C-u}.@refill
5267
5268@item M-d
5269Go down the number of frames indicated by the numeric argument, like the
5270_GDBN__ @code{down} command. @emph{Warning:} In Emacs v19, this command
5271is @kbd{C-c C-d}.
5272
5273@item C-x &
5274Read the number where the cursor is positioned, and insert it at the end
5275of the _GDBN__ I/O buffer. For example, if you wish to disassemble code
5276around an address that was displayed earlier, type @kbd{disassemble};
5277then move the cursor to the address display, and pick up the
5278argument for @code{disassemble} by typing @kbd{C-x &}.
5279
5280You can customize this further on the fly by defining elements of the list
5281@code{gdb-print-command}; once it is defined, you can format or
5282otherwise process numbers picked up by @kbd{C-x &} before they are
5283inserted. A numeric argument to @kbd{C-x &} will both flag that you
5284wish special formatting, and act as an index to pick an element of the
5285list. If the list element is a string, the number to be inserted is
5286formatted using the Emacs function @code{format}; otherwise the number
5287is passed as an argument to the corresponding list element.
5288
5289@end table
5290
5291In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break})
5292tells _GDBN__ to set a breakpoint on the source line point is on.
5293
5294If you accidentally delete the source-display buffer, an easy way to get
5295it back is to type the command @code{f} in the _GDBN__ buffer, to
5296request a frame display; when you run under Emacs, this will recreate
5297the source buffer if necessary to show you the context of the current
5298frame.
5299
5300The source files displayed in Emacs are in ordinary Emacs buffers
5301which are visiting the source files in the usual way. You can edit
5302the files with these buffers if you wish; but keep in mind that _GDBN__
5303communicates with Emacs in terms of line numbers. If you add or
5304delete lines from the text, the line numbers that _GDBN__ knows will cease
5305to correspond properly to the code.
5306
5307@c The following dropped because Epoch is nonstandard. Reactivate
5308@c if/when v19 does something similar. ---pesch@cygnus.com 19dec1990
5309@ignore
5310@kindex emacs epoch environment
5311@kindex epoch
5312@kindex inspect
5313
5314Version 18 of Emacs has a built-in window system called the @code{epoch}
5315environment. Users of this environment can use a new command,
5316@code{inspect} which performs identically to @code{print} except that
5317each value is printed in its own window.
5318@end ignore
5319
5320@node _GDBN__ Bugs, Renamed Commands, Emacs, Top
5321@chapter Reporting Bugs in _GDBN__
5322@cindex Bugs in _GDBN__
5323@cindex Reporting Bugs in _GDBN__
5324
5325Your bug reports play an essential role in making _GDBN__ reliable.
5326
5327Reporting a bug may help you by bringing a solution to your problem, or it
5328may not. But in any case the principal function of a bug report is to help
5329the entire community by making the next version of _GDBN__ work better. Bug
5330reports are your contribution to the maintenance of _GDBN__.
5331
5332In order for a bug report to serve its purpose, you must include the
5333information that enables us to fix the bug.
5334
5335@menu
5336* Bug Criteria:: Have You Found a Bug?
5337* Bug Reporting:: How to Report Bugs
5338@end menu
5339
5340@node Bug Criteria, Bug Reporting, _GDBN__ Bugs, _GDBN__ Bugs
5341@section Have You Found a Bug?
5342@cindex Bug Criteria
5343
5344If you are not sure whether you have found a bug, here are some guidelines:
5345
5346@itemize @bullet
5347@item
5348@cindex Fatal Signal
5349@cindex Core Dump
5350If the debugger gets a fatal signal, for any input whatever, that is a
5351_GDBN__ bug. Reliable debuggers never crash.
5352
5353@item
5354@cindex error on Valid Input
5355If _GDBN__ produces an error message for valid input, that is a bug.
5356
5357@item
5358@cindex Invalid Input
5359If _GDBN__ does not produce an error message for invalid input,
5360that is a bug. However, you should note that your idea of
5361``invalid input'' might be our idea of ``an extension'' or ``support
5362for traditional practice''.
5363
5364@item
5365If you are an experienced user of debugging tools, your suggestions
5366for improvement of _GDBN__ are welcome in any case.
5367@end itemize
5368
5369@node Bug Reporting, , Bug Criteria, _GDBN__ Bugs
5370@section How to Report Bugs
5371@cindex Bug Reports
5372@cindex Compiler Bugs, Reporting
5373
5374A number of companies and individuals offer support for GNU products.
5375If you obtained _GDBN__ from a support organization, we recommend you
5376contact that organization first.
5377
5378Contact information for many support companies and individuals is
5379available in the file @file{etc/SERVICE} in the GNU Emacs distribution.
5380
5381In any event, we also recommend that you send bug reports for _GDBN__ to one
5382of these addresses:
5383
5384@example
5385bug-gdb@@prep.ai.mit.edu
5386@{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb
5387@end example
5388
5389@strong{Do not send bug reports to @samp{info-gdb}, or to
5390@samp{help-gdb}, or to any newsgroups.} Most users of _GDBN__ do not want to
5391receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}.
5392
5393The mailing list @samp{bug-gdb} has a newsgroup which serves as a
5394repeater. The mailing list and the newsgroup carry exactly the same
5395messages. Often people think of posting bug reports to the newsgroup
5396instead of mailing them. This appears to work, but it has one problem
5397which can be crucial: a newsgroup posting often lacks a mail path
5398back to the sender. Thus, if we need to ask for more information, we
5399may be unable to reach you. For this reason, it is better to send bug
5400reports to the mailing list.
5401
5402As a last resort, send bug reports on paper to:
5403
5404@example
5405GNU Debugger Bugs
5406545 Tech Square
5407Cambridge, MA 02139
5408@end example
5409
5410The fundamental principle of reporting bugs usefully is this:
5411@strong{report all the facts}. If you are not sure whether to state a
5412fact or leave it out, state it!
5413
5414Often people omit facts because they think they know what causes the
5415problem and assume that some details don't matter. Thus, you might
5416assume that the name of the variable you use in an example does not matter.
5417Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a
5418stray memory reference which happens to fetch from the location where that
5419name is stored in memory; perhaps, if the name were different, the contents
5420of that location would fool the debugger into doing the right thing despite
5421the bug. Play it safe and give a specific, complete example. That is the
5422easiest thing for you to do, and the most helpful.
5423
5424Keep in mind that the purpose of a bug report is to enable us to fix
5425the bug if it is new to us. It isn't as important what happens if
5426the bug is already known. Therefore, always write your bug reports on
5427the assumption that the bug has not been reported previously.
5428
5429Sometimes people give a few sketchy facts and ask, ``Does this ring a
5430bell?'' Those bug reports are useless, and we urge everyone to
5431@emph{refuse to respond to them} except to chide the sender to report
5432bugs properly.
5433
5434To enable us to fix the bug, you should include all these things:
5435
5436@itemize @bullet
5437@item
5438The version of _GDBN__. _GDBN__ announces it if you start with no
5439arguments; you can also print it at any time using @code{show version}.
5440
5441Without this, we won't know whether there is any point in looking for
5442the bug in the current version of _GDBN__.
5443
5444@item
5445A complete input script, and all necessary source files, that will
5446reproduce the bug.
5447
5448@item
5449What compiler (and its version) was used to compile _GDBN__---e.g.
5450``_GCC__-1.37.1''.
5451
5452@item
5453The command arguments you gave the compiler to compile your example and
5454observe the bug. For example, did you use @samp{-O}? To guarantee
5455you won't omit something important, list them all.
5456
5457If we were to try to guess the arguments, we would probably guess wrong
5458and then we might not encounter the bug.
5459
5460@item
5461The type of machine you are using, and the operating system name and
5462version number.
5463
5464@item
5465A description of what behavior you observe that you believe is
5466incorrect. For example, ``It gets a fatal signal.''
5467
5468Of course, if the bug is that _GDBN__ gets a fatal signal, then we will
5469certainly notice it. But if the bug is incorrect output, we might not
5470notice unless it is glaringly wrong. We are human, after all. You
5471might as well not give us a chance to make a mistake.
5472
5473Even if the problem you experience is a fatal signal, you should still
5474say so explicitly. Suppose something strange is going on, such as,
5475your copy of _GDBN__ is out of synch, or you have encountered a
5476bug in the C library on your system. (This has happened!) Your copy
5477might crash and ours would not. If you told us to expect a crash,
5478then when ours fails to crash, we would know that the bug was not
5479happening for us. If you had not told us to expect a crash, then we
5480would not be able to draw any conclusion from our observations.
5481
5482@item
5483If you wish to suggest changes to the _GDBN__ source, send us context
5484diffs. If you even discuss something in the _GDBN__ source, refer to
5485it by context, not by line number.
5486
5487The line numbers in our development sources won't match those in your
5488sources. Your line numbers would convey no useful information to us.
5489
5490@end itemize
5491
5492Here are some things that are not necessary:
5493
5494@itemize @bullet
5495@item
5496A description of the envelope of the bug.
5497
5498Often people who encounter a bug spend a lot of time investigating
5499which changes to the input file will make the bug go away and which
5500changes will not affect it.
5501
5502This is often time consuming and not very useful, because the way we
5503will find the bug is by running a single example under the debugger
5504with breakpoints, not by pure deduction from a series of examples.
5505We recommend that you save your time for something else.
5506
5507Of course, if you can find a simpler example to report @emph{instead}
5508of the original one, that is a convenience for us. Errors in the
5509output will be easier to spot, running under the debugger will take
5510less time, etc.
5511
5512However, simplification is not vital; if you don't want to do this,
5513report the bug anyway and send us the entire test case you used.
5514
5515@item
5516A patch for the bug.
5517
5518A patch for the bug does help us if it is a good one. But don't omit
5519the necessary information, such as the test case, on the assumption that
5520a patch is all we need. We might see problems with your patch and decide
5521to fix the problem another way, or we might not understand it at all.
5522
5523Sometimes with a program as complicated as _GDBN__ it is very hard to
5524construct an example that will make the program follow a certain path
5525through the code. If you don't send us the example, we won't be able
5526to construct one, so we won't be able to verify that the bug is fixed.
5527
5528And if we can't understand what bug you are trying to fix, or why your
5529patch should be an improvement, we won't install it. A test case will
5530help us to understand.
5531
5532@item
5533A guess about what the bug is or what it depends on.
5534
5535Such guesses are usually wrong. Even we can't guess right about such
5536things without first using the debugger to find the facts.
5537@end itemize
5538
5539@iftex
5540@include rdl-apps.texinfo
5541@end iftex
5542
5543@node Renamed Commands, Installing _GDBN__, _GDBN__ Bugs, Top
5544@appendix Renamed Commands
5545
5546The following commands were renamed in _GDBN__ 4.0, in order to make the
5547command set as a whole more consistent and easier to use and remember:
5548
5549@kindex add-syms
5550@kindex delete environment
5551@kindex info copying
5552@kindex info convenience
5553@kindex info directories
5554@kindex info editing
5555@kindex info history
5556@kindex info targets
5557@kindex info values
5558@kindex info version
5559@kindex info warranty
5560@kindex set addressprint
5561@kindex set arrayprint
5562@kindex set prettyprint
5563@kindex set screen-height
5564@kindex set screen-width
5565@kindex set unionprint
5566@kindex set vtblprint
5567@kindex set demangle
5568@kindex set asm-demangle
5569@kindex set sevenbit-strings
5570@kindex set array-max
5571@kindex set caution
5572@kindex set history write
5573@kindex show addressprint
5574@kindex show arrayprint
5575@kindex show prettyprint
5576@kindex show screen-height
5577@kindex show screen-width
5578@kindex show unionprint
5579@kindex show vtblprint
5580@kindex show demangle
5581@kindex show asm-demangle
5582@kindex show sevenbit-strings
5583@kindex show array-max
5584@kindex show caution
5585@kindex show history write
5586@kindex unset
5587
5588@ifinfo
5589OLD COMMAND NEW COMMAND
5590--------------- ----------------------------------
5591add-syms add-symbol-file
5592delete environment unset environment
5593info convenience show convenience
5594info copying show copying
5595info directories show directories
5596info editing show commands
5597info history show values
5598info targets help target
5599info values show values
5600info version show version
5601info warranty show warranty
5602set/show addressprint set/show print address
5603set/show array-max set/show print elements
5604set/show arrayprint set/show print array
5605set/show asm-demangle set/show print asm-demangle
5606set/show caution set/show confirm
5607set/show demangle set/show print demangle
5608set/show history write set/show history save
5609set/show prettyprint set/show print pretty
5610set/show screen-height set/show height
5611set/show screen-width set/show width
5612set/show sevenbit-strings set/show print sevenbit-strings
5613set/show unionprint set/show print union
5614set/show vtblprint set/show print vtbl
5615
5616unset [ No longer an alias for delete ]
5617@end ifinfo
5618
5619@tex
5620\vskip \parskip\vskip \baselineskip
5621\halign{\tt #\hfil &\qquad#&\tt #\hfil\cr
5622{\bf Old Command} &&{\bf New Command}\cr
5623add-syms &&add-symbol-file\cr
5624delete environment &&unset environment\cr
5625info convenience &&show convenience\cr
5626info copying &&show copying\cr
5627info directories &&show directories \cr
5628info editing &&show commands\cr
5629info history &&show values\cr
5630info targets &&help target\cr
5631info values &&show values\cr
5632info version &&show version\cr
5633info warranty &&show warranty\cr
5634set{\rm / }show addressprint &&set{\rm / }show print address\cr
5635set{\rm / }show array-max &&set{\rm / }show print elements\cr
5636set{\rm / }show arrayprint &&set{\rm / }show print array\cr
5637set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr
5638set{\rm / }show caution &&set{\rm / }show confirm\cr
5639set{\rm / }show demangle &&set{\rm / }show print demangle\cr
5640set{\rm / }show history write &&set{\rm / }show history save\cr
5641set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr
5642set{\rm / }show screen-height &&set{\rm / }show height\cr
5643set{\rm / }show screen-width &&set{\rm / }show width\cr
5644set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr
5645set{\rm / }show unionprint &&set{\rm / }show print union\cr
5646set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr
5647\cr
5648unset &&\rm(No longer an alias for delete)\cr
5649}
5650@end tex
5651
5652@node Installing _GDBN__, Copying, Renamed Commands, Top
5653@appendix Installing _GDBN__
5654@cindex configuring _GDBN__
5655@cindex installation
5656
7463aadd
RP
5657_GDBN__ is distributed with a script @code{configure} that automates the
5658process of preparing _GDBN__ for installation; you can then use
5659@code{make} to actually build it.
5660
5661You can find the @code{configure} script that's specific to _GDBN__ in
5662the main _GDBN__ source directory. However, @code{configure} is
5663designed to be called recursively, so it is most convenient to run the
5664version of @code{configure} for the @emph{parent} of that directory,
5665which should include not only @code{_GDBP__} but also other @sc{gnu}
5666tools and libraries. Building _GDBN__ requires some of these associated
5667directories; at a minimum, you need a source directory that includes the
5668directories
5669@example
5670bfd gdb include libiberty readline
5671@end example
5672@noindent
5673to build _GDBN__. It should also include @file{texinfo} if you want to
5674format and print copies of this manual.
5675
5676The simplest way to configure and build _GDBN__ is the following:
5677@example
5678cd @var{gnusrc}
5679./configure @var{machine}
5680make
5681@end example
5682@noindent
5683where @var{gnusrc} is the directory containing both _GDBN__ source and
5684source for supporting libraries, in subdirectories; and @var{machine} is
5685something like @samp{sun4} or @samp{vax}, that identifies the platform
5686where _GDBN__ will run.
5687
5688The best way to build _GDBN__ is to use subdirectories that record the
70b88761
RP
5689configuration options used; this gives you a clean way of building
5690_GDBN__ binaries with several different configuration options.
7463aadd
RP
5691@code{configure} only requires this when you simultaneously create
5692several configurations; but it's a good habit even for a single
5693configuration. You can specify the use of subdirectories using the
5694@samp{+forcesubdirs} option (abbreviated @samp{+f}). For example,
5695assuming the @sc{gnu} source directory that includes _GDBN__ source and
5696the supporting libraries is in a directory called @file{gnusrc}:
70b88761
RP
5697
5698@example
7463aadd
RP
5699cd gnusrc
5700./configure +f sun4
5701cd Host-sun4/Target-sun4
70b88761
RP
5702make
5703@end example
5704
5705@noindent
7463aadd
RP
5706will build _GDBN__ on a Sun 4.
5707
5708Here is a summary of all the @code{configure} options and arguments that
5709you might use for building _GDBN__:
5710
5711@example
5712configure @rm{[}+destdir=@var{dir}@rm{]} @rm{[}+forcesubdirs@rm{]} @rm{[}+norecur@rm{]} @rm{[}+rm@rm{]}
5713 @rm{[}+target=@var{machine}@dots{}@rm{]} @var{host}@dots{}
5714@end example
5715
5716You may introduce options with the character @samp{-} rather than
5717@samp{+} if you prefer; but options introduced with @samp{+} may be truncated.
5718@code{configure} accepts other options, for compatibility with
5719configuring other @sc{gnu} tools recursively; but these are the only
5720options that affect _GDBN__ or its supporting libraries.
70b88761
RP
5721
5722@table @code
7463aadd
RP
5723@item +destdir=@var{dir}
5724@var{dir} is an installation directory for use by @code{make install}.
5725
5726@item +forcesubdirs
5727Build binaries in subdirectories of the form
5728@example
5729Host-@var{machine}/Target-@var{machine}
5730@end example
5731@noindent
5732Without this option, if you specify only one configuration for _GDBN__,
5733@code{configure} will use the same directory for source, configured
5734files, and binaries. This option is used automatically if you specify
5735more than one @var{host} or more than one @samp{+target=@var{machine}}
5736option on the @code{configure} command line.
5737
5738@item +norecur
5739Configure only the directory where @code{configure} is executed; do not
5740propagate configuration to subdirectories.
5741
5742@item +rm
5743Remove the configuration specified by other arguments.
5744
5745@item +target=@var{machine} @dots{}
5746Configure _GDBN__ for cross-debugging programs running on specified
5747@var{machine}s. You may specify as many @samp{+target} options as you
5748wish. To see a list of available targets, execute @samp{ls tconfig} in
5749the _GDBN__ source directory. Without this option, _GDBN__ is
5750configured to debug programs that run on the same machine (@var{host})
5751as _GDBN__ itself.
5752
5753@item @var{host} @dots{}
5754Configure _GDBN__ to run on specified @var{host}s. You may specify as
5755many host names as you wish. To see a list of available hosts, execute
5756@samp{ls xconfig} in the _GDBN__ source directory.
70b88761
RP
5757@end table
5758
5759@node Copying, Index, Installing _GDBN__, Top
70b88761 5760@unnumbered GNU GENERAL PUBLIC LICENSE
7463aadd 5761@center Version 2, June 1991
70b88761
RP
5762
5763@display
7463aadd 5764Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
70b88761
RP
5765675 Mass Ave, Cambridge, MA 02139, USA
5766
5767Everyone is permitted to copy and distribute verbatim copies
5768of this license document, but changing it is not allowed.
5769@end display
5770
5771@unnumberedsec Preamble
5772
7463aadd
RP
5773 The licenses for most software are designed to take away your
5774freedom to share and change it. By contrast, the GNU General Public
70b88761 5775License is intended to guarantee your freedom to share and change free
7463aadd
RP
5776software---to make sure the software is free for all its users. This
5777General Public License applies to most of the Free Software
5778Foundation's software and to any other program whose authors commit to
5779using it. (Some other Free Software Foundation software is covered by
5780the GNU Library General Public License instead.) You can apply it to
5781your programs, too.
70b88761
RP
5782
5783 When we speak of free software, we are referring to freedom, not
7463aadd
RP
5784price. Our General Public Licenses are designed to make sure that you
5785have the freedom to distribute copies of free software (and charge for
5786this service if you wish), that you receive source code or can get it
5787if you want it, that you can change the software or use pieces of it
5788in new free programs; and that you know you can do these things.
70b88761
RP
5789
5790 To protect your rights, we need to make restrictions that forbid
5791anyone to deny you these rights or to ask you to surrender the rights.
5792These restrictions translate to certain responsibilities for you if you
5793distribute copies of the software, or if you modify it.
5794
7463aadd 5795 For example, if you distribute copies of such a program, whether
70b88761
RP
5796gratis or for a fee, you must give the recipients all the rights that
5797you have. You must make sure that they, too, receive or can get the
7463aadd
RP
5798source code. And you must show them these terms so they know their
5799rights.
70b88761
RP
5800
5801 We protect your rights with two steps: (1) copyright the software, and
5802(2) offer you this license which gives you legal permission to copy,
5803distribute and/or modify the software.
5804
5805 Also, for each author's protection and ours, we want to make certain
5806that everyone understands that there is no warranty for this free
5807software. If the software is modified by someone else and passed on, we
5808want its recipients to know that what they have is not the original, so
5809that any problems introduced by others will not reflect on the original
5810authors' reputations.
5811
7463aadd
RP
5812 Finally, any free program is threatened constantly by software
5813patents. We wish to avoid the danger that redistributors of a free
5814program will individually obtain patent licenses, in effect making the
5815program proprietary. To prevent this, we have made it clear that any
5816patent must be licensed for everyone's free use or not licensed at all.
5817
70b88761
RP
5818 The precise terms and conditions for copying, distribution and
5819modification follow.
5820
5821@iftex
7463aadd 5822@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
70b88761
RP
5823@end iftex
5824@ifinfo
7463aadd 5825@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
70b88761
RP
5826@end ifinfo
5827
5828@enumerate
5829@item
7463aadd
RP
5830This License applies to any program or other work which contains
5831a notice placed by the copyright holder saying it may be distributed
5832under the terms of this General Public License. The ``Program'', below,
5833refers to any such program or work, and a ``work based on the Program''
5834means either the Program or any derivative work under copyright law:
5835that is to say, a work containing the Program or a portion of it,
5836either verbatim or with modifications and/or translated into another
5837language. (Hereinafter, translation is included without limitation in
5838the term ``modification''.) Each licensee is addressed as ``you''.
5839
5840Activities other than copying, distribution and modification are not
5841covered by this License; they are outside its scope. The act of
5842running the Program is not restricted, and the output from the Program
5843is covered only if its contents constitute a work based on the
5844Program (independent of having been made by running the Program).
5845Whether that is true depends on what the Program does.
70b88761
RP
5846
5847@item
7463aadd
RP
5848You may copy and distribute verbatim copies of the Program's
5849source code as you receive it, in any medium, provided that you
5850conspicuously and appropriately publish on each copy an appropriate
5851copyright notice and disclaimer of warranty; keep intact all the
5852notices that refer to this License and to the absence of any warranty;
5853and give any other recipients of the Program a copy of this License
5854along with the Program.
70b88761 5855
7463aadd
RP
5856You may charge a fee for the physical act of transferring a copy, and
5857you may at your option offer warranty protection in exchange for a fee.
70b88761 5858
70b88761 5859@item
7463aadd
RP
5860You may modify your copy or copies of the Program or any portion
5861of it, thus forming a work based on the Program, and copy and
5862distribute such modifications or work under the terms of Section 1
5863above, provided that you also meet all of these conditions:
70b88761 5864
7463aadd 5865@alphaenumerate
70b88761 5866@item
7463aadd
RP
5867You must cause the modified files to carry prominent notices
5868stating that you changed the files and the date of any change.
70b88761
RP
5869
5870@item
7463aadd
RP
5871You must cause any work that you distribute or publish, that in
5872whole or in part contains or is derived from the Program or any
5873part thereof, to be licensed as a whole at no charge to all third
5874parties under the terms of this License.
70b88761
RP
5875
5876@item
7463aadd
RP
5877If the modified program normally reads commands interactively
5878when run, you must cause it, when started running for such
5879interactive use in the most ordinary way, to print or display an
5880announcement including an appropriate copyright notice and a
5881notice that there is no warranty (or else, saying that you provide
5882a warranty) and that users may redistribute the program under
5883these conditions, and telling the user how to view a copy of this
5884License. (Exception: if the Program itself is interactive but
5885does not normally print such an announcement, your work based on
5886the Program is not required to print an announcement.)
5887@end alphaenumerate
5888
5889These requirements apply to the modified work as a whole. If
5890identifiable sections of that work are not derived from the Program,
5891and can be reasonably considered independent and separate works in
5892themselves, then this License, and its terms, do not apply to those
5893sections when you distribute them as separate works. But when you
5894distribute the same sections as part of a whole which is a work based
5895on the Program, the distribution of the whole must be on the terms of
5896this License, whose permissions for other licensees extend to the
5897entire whole, and thus to each and every part regardless of who wrote it.
5898
5899Thus, it is not the intent of this section to claim rights or contest
5900your rights to work written entirely by you; rather, the intent is to
5901exercise the right to control the distribution of derivative or
5902collective works based on the Program.
5903
5904In addition, mere aggregation of another work not based on the Program
5905with the Program (or with a work based on the Program) on a volume of
5906a storage or distribution medium does not bring the other work under
5907the scope of this License.
70b88761
RP
5908
5909@item
7463aadd
RP
5910You may copy and distribute the Program (or a work based on it,
5911under Section 2) in object code or executable form under the terms of
5912Sections 1 and 2 above provided that you also do one of the following:
70b88761 5913
7463aadd 5914@alphaenumerate
70b88761 5915@item
7463aadd
RP
5916Accompany it with the complete corresponding machine-readable
5917source code, which must be distributed under the terms of Sections
59181 and 2 above on a medium customarily used for software interchange; or,
70b88761
RP
5919
5920@item
7463aadd
RP
5921Accompany it with a written offer, valid for at least three
5922years, to give any third party, for a charge no more than your
5923cost of physically performing source distribution, a complete
5924machine-readable copy of the corresponding source code, to be
5925distributed under the terms of Sections 1 and 2 above on a medium
5926customarily used for software interchange; or,
70b88761
RP
5927
5928@item
7463aadd
RP
5929Accompany it with the information you received as to the offer
5930to distribute corresponding source code. (This alternative is
70b88761 5931allowed only for noncommercial distribution and only if you
7463aadd
RP
5932received the program in object code or executable form with such
5933an offer, in accord with Subsection b above.)
5934@end alphaenumerate
5935
5936The source code for a work means the preferred form of the work for
5937making modifications to it. For an executable work, complete source
5938code means all the source code for all modules it contains, plus any
5939associated interface definition files, plus the scripts used to
5940control compilation and installation of the executable. However, as a
5941special exception, the source code distributed need not include
5942anything that is normally distributed (in either source or binary
5943form) with the major components (compiler, kernel, and so on) of the
5944operating system on which the executable runs, unless that component
5945itself accompanies the executable.
5946
5947If distribution of executable or object code is made by offering
5948access to copy from a designated place, then offering equivalent
5949access to copy the source code from the same place counts as
5950distribution of the source code, even though third parties are not
5951compelled to copy the source along with the object code.
70b88761
RP
5952
5953@item
7463aadd
RP
5954You may not copy, modify, sublicense, or distribute the Program
5955except as expressly provided under this License. Any attempt
5956otherwise to copy, modify, sublicense or distribute the Program is
5957void, and will automatically terminate your rights under this License.
5958However, parties who have received copies, or rights, from you under
5959this License will not have their licenses terminated so long as such
5960parties remain in full compliance.
70b88761
RP
5961
5962@item
7463aadd
RP
5963You are not required to accept this License, since you have not
5964signed it. However, nothing else grants you permission to modify or
5965distribute the Program or its derivative works. These actions are
5966prohibited by law if you do not accept this License. Therefore, by
5967modifying or distributing the Program (or any work based on the
5968Program), you indicate your acceptance of this License to do so, and
5969all its terms and conditions for copying, distributing or modifying
5970the Program or works based on it.
70b88761
RP
5971
5972@item
5973Each time you redistribute the Program (or any work based on the
7463aadd
RP
5974Program), the recipient automatically receives a license from the
5975original licensor to copy, distribute or modify the Program subject to
5976these terms and conditions. You may not impose any further
5977restrictions on the recipients' exercise of the rights granted herein.
5978You are not responsible for enforcing compliance by third parties to
5979this License.
5980
5981@item
5982If, as a consequence of a court judgment or allegation of patent
5983infringement or for any other reason (not limited to patent issues),
5984conditions are imposed on you (whether by court order, agreement or
5985otherwise) that contradict the conditions of this License, they do not
5986excuse you from the conditions of this License. If you cannot
5987distribute so as to satisfy simultaneously your obligations under this
5988License and any other pertinent obligations, then as a consequence you
5989may not distribute the Program at all. For example, if a patent
5990license would not permit royalty-free redistribution of the Program by
5991all those who receive copies directly or indirectly through you, then
5992the only way you could satisfy both it and this License would be to
5993refrain entirely from distribution of the Program.
5994
5995If any portion of this section is held invalid or unenforceable under
5996any particular circumstance, the balance of the section is intended to
5997apply and the section as a whole is intended to apply in other
5998circumstances.
5999
6000It is not the purpose of this section to induce you to infringe any
6001patents or other property right claims or to contest validity of any
6002such claims; this section has the sole purpose of protecting the
6003integrity of the free software distribution system, which is
6004implemented by public license practices. Many people have made
6005generous contributions to the wide range of software distributed
6006through that system in reliance on consistent application of that
6007system; it is up to the author/donor to decide if he or she is willing
6008to distribute software through any other system and a licensee cannot
6009impose that choice.
6010
6011This section is intended to make thoroughly clear what is believed to
6012be a consequence of the rest of this License.
6013
6014@item
6015If the distribution and/or use of the Program is restricted in
6016certain countries either by patents or by copyrighted interfaces, the
6017original copyright holder who places the Program under this License
6018may add an explicit geographical distribution limitation excluding
6019those countries, so that distribution is permitted only in or among
6020countries not thus excluded. In such case, this License incorporates
6021the limitation as if written in the body of this License.
70b88761
RP
6022
6023@item
6024The Free Software Foundation may publish revised and/or new versions
6025of the General Public License from time to time. Such new versions will
6026be similar in spirit to the present version, but may differ in detail to
6027address new problems or concerns.
6028
6029Each version is given a distinguishing version number. If the Program
7463aadd 6030specifies a version number of this License which applies to it and ``any
70b88761
RP
6031later version'', you have the option of following the terms and conditions
6032either of that version or of any later version published by the Free
6033Software Foundation. If the Program does not specify a version number of
7463aadd 6034this License, you may choose any version ever published by the Free Software
70b88761
RP
6035Foundation.
6036
6037@item
6038If you wish to incorporate parts of the Program into other free
6039programs whose distribution conditions are different, write to the author
6040to ask for permission. For software which is copyrighted by the Free
6041Software Foundation, write to the Free Software Foundation; we sometimes
6042make exceptions for this. Our decision will be guided by the two goals
6043of preserving the free status of all derivatives of our free software and
6044of promoting the sharing and reuse of software generally.
6045
6046@iftex
6047@heading NO WARRANTY
6048@end iftex
6049@ifinfo
6050@center NO WARRANTY
6051@end ifinfo
6052
6053@item
6054BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
6055FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
6056OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
6057PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
6058OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
6059MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
6060TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
6061PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
6062REPAIR OR CORRECTION.
6063
6064@item
7463aadd
RP
6065IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
6066WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
70b88761 6067REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
7463aadd
RP
6068INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
6069OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
6070TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
6071YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
6072PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
6073POSSIBILITY OF SUCH DAMAGES.
70b88761
RP
6074@end enumerate
6075
6076@iftex
6077@heading END OF TERMS AND CONDITIONS
6078@end iftex
6079@ifinfo
6080@center END OF TERMS AND CONDITIONS
6081@end ifinfo
6082
6083@page
7463aadd 6084@unnumberedsec Appendix: How to Apply These Terms to Your New Programs
70b88761
RP
6085
6086 If you develop a new program, and you want it to be of the greatest
7463aadd
RP
6087possible use to the public, the best way to achieve this is to make it
6088free software which everyone can redistribute and change under these terms.
70b88761 6089
7463aadd
RP
6090 To do so, attach the following notices to the program. It is safest
6091to attach them to the start of each source file to most effectively
6092convey the exclusion of warranty; and each file should have at least
6093the ``copyright'' line and a pointer to where the full notice is found.
70b88761
RP
6094
6095@smallexample
6096@var{one line to give the program's name and a brief idea of what it does.}
6097Copyright (C) 19@var{yy} @var{name of author}
6098
6099This program is free software; you can redistribute it and/or modify
6100it under the terms of the GNU General Public License as published by
7463aadd
RP
6101the Free Software Foundation; either version 2 of the License, or
6102(at your option) any later version.
70b88761
RP
6103
6104This program is distributed in the hope that it will be useful,
6105but WITHOUT ANY WARRANTY; without even the implied warranty of
6106MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6107GNU General Public License for more details.
6108
6109You should have received a copy of the GNU General Public License
6110along with this program; if not, write to the Free Software
6111Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6112@end smallexample
6113
6114Also add information on how to contact you by electronic and paper mail.
6115
6116If the program is interactive, make it output a short notice like this
6117when it starts in an interactive mode:
6118
6119@smallexample
6120Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
6121Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
6122This is free software, and you are welcome to redistribute it
6123under certain conditions; type `show c' for details.
6124@end smallexample
6125
7463aadd
RP
6126The hypothetical commands @samp{show w} and @samp{show c} should show
6127the appropriate parts of the General Public License. Of course, the
6128commands you use may be called something other than @samp{show w} and
6129@samp{show c}; they could even be mouse-clicks or menu items---whatever
6130suits your program.
70b88761
RP
6131
6132You should also get your employer (if you work as a programmer) or your
6133school, if any, to sign a ``copyright disclaimer'' for the program, if
6134necessary. Here is a sample; alter the names:
6135
7463aadd
RP
6136@example
6137Yoyodyne, Inc., hereby disclaims all copyright interest in the program
6138`Gnomovision' (which makes passes at compilers) written by James Hacker.
70b88761
RP
6139
6140@var{signature of Ty Coon}, 1 April 1989
6141Ty Coon, President of Vice
7463aadd
RP
6142@end example
6143
6144This General Public License does not permit incorporating your program into
6145proprietary programs. If your program is a subroutine library, you may
6146consider it more useful to permit linking proprietary applications with the
6147library. If this is what you want to do, use the GNU Library General
6148Public License instead of this License.
70b88761 6149
d2e08421 6150
9c3ad547 6151@node Index, , Copying, Top
d2e08421 6152@unnumbered Index
e91b87a3 6153
6154@printindex cp
6155
fe3f5fc8
RP
6156@tex
6157% I think something like @colophon should be in texinfo. In the
6158% meantime:
6159\long\def\colophon{\hbox to0pt{}\vfill
6160\centerline{The body of this manual is set in}
6161\centerline{\fontname\tenrm,}
6162\centerline{with headings in {\bf\fontname\tenbf}}
6163\centerline{and examples in {\tt\fontname\tentt}.}
6164\centerline{{\it\fontname\tenit\/} and}
6165\centerline{{\sl\fontname\tensl\/}}
6166\centerline{are used for emphasis.}\vfill}
6167\page\colophon
6168% Blame: pesch@cygnus.com, 28mar91.
6169@end tex
6170
e91b87a3 6171@contents
6172@bye
This page took 0.296128 seconds and 4 git commands to generate.