]> Git Repo - binutils.git/blame - gdb/doc/gdb.texinfo
* infcmd.c (jump_command): Use cleanups to avoid memory leaks.
[binutils.git] / gdb / doc / gdb.texinfo
CommitLineData
b80282d5 1_dnl__ -*-Texinfo-*-
1041a570 2_dnl__ Copyright (c) 1988 1989 1990 1991 1992 Free Software Foundation, Inc.
29a2b744
RP
3_dnl__ $Id$
4\input texinfo @c -*-texinfo-*-
1041a570 5@c Copyright (c) 1988 1989 1990 1991 1992 Free Software Foundation, Inc.
29a2b744 6@c %**start of header
5a131cc7 7@setfilename _GDBP__.info
29a2b744 8_if__(_GENERIC__)
b7662623 9@settitle _GDBN__, The GNU Debugger
29a2b744
RP
10_fi__(_GENERIC__)
11_if__(!_GENERIC__)
95d5ceb9 12@settitle _GDB__, The GNU Debugger (_HOST__)
29a2b744
RP
13_fi__(!_GENERIC__)
14@setchapternewpage odd
73e44aaf
RP
15@c @smallbook
16@c @cropmarks
29a2b744
RP
17@c %**end of header
18
19@finalout
20@syncodeindex ky cp
21
22_0__@c ===> NOTE! <==_1__
23@c Determine the edition number in *three* places by hand:
24@c 1. First ifinfo section 2. title page 3. top node
25@c To find the locations, search for !!set
26
27@c The following is for Pesch for his RCS system.
28@c This revision number *not* the same as the Edition number.
29@tex
30\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
31\xdef\manvers{\$Revision$} % For use in headers, footers too
32@end tex
33
d24e0922 34@c GDB CHANGELOG CONSULTED BETWEEN:
29a2b744
RP
35@c Fri Oct 11 23:27:06 1991 John Gilmore (gnu at cygnus.com)
36@c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint)
37
9c3ad547 38@c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly.
29a2b744 39
b7becc8f
RP
40@ifinfo
41@format
42START-INFO-DIR-ENTRY
29a2b744 43* Gdb: (gdb). The GNU debugger.
b7becc8f
RP
44END-INFO-DIR-ENTRY
45@end format
46@end ifinfo
5a131cc7
RP
47_if__(0)
48
a6d0b6d3
RP
49NOTE: this manual is marked up for preprocessing with a collection
50of m4 macros called "pretex.m4".
51
9bcc06ef
RP
52THIS IS THE SOURCE PRIOR TO PREPROCESSING. The full source needs to
53be run through m4 before either tex- or info- formatting: for example,
08665207 54_0__
3e0d0a27 55 m4 pretex.m4 none.m4 all.m4 gdb.texinfo >gdb-all.texinfo
70b88761 56will produce (assuming your path finds either GNU m4 >= 0.84, or SysV
1041a570 57m4; Berkeley will not do) a file suitable for formatting. See the text in
70b88761 58"pretex.m4" for a fuller explanation (and the macro definitions).
29a2b744 59_1__
e91b87a3 60
9bcc06ef 61_fi__(0)
70b88761 62@c
70b88761
RP
63@ifinfo
64This file documents the GNU debugger _GDBN__.
65
29a2b744 66@c !!set edition, date, version
d24e0922 67This is Edition 4.04, March 1992,
29a2b744
RP
68of @cite{Using GDB: A Guide to the GNU Source-Level Debugger}
69for GDB Version _GDB_VN__.
70
95d5ceb9 71Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
70b88761
RP
72
73Permission is granted to make and distribute verbatim copies of
74this manual provided the copyright notice and this permission notice
75are preserved on all copies.
76
77@ignore
78Permission is granted to process this file through TeX and print the
79results, provided the printed document carries copying permission
80notice identical to this one except for the removal of this paragraph
81(this paragraph not being relevant to the printed manual).
82
83@end ignore
84Permission is granted to copy and distribute modified versions of this
85manual under the conditions for verbatim copying, provided also that the
86section entitled ``GNU General Public License'' is included exactly as
87in the original, and provided that the entire resulting derived work is
88distributed under the terms of a permission notice identical to this
89one.
90
91Permission is granted to copy and distribute translations of this manual
92into another language, under the above conditions for modified versions,
93except that the section entitled ``GNU General Public License'' may be
94included in a translation approved by the Free Software Foundation
95instead of in the original English.
96@end ifinfo
1041a570 97
70b88761 98@titlepage
92b73793 99@title Using _GDBN__
95d5ceb9 100@subtitle The GNU Source-Level Debugger
70b88761 101_if__(!_GENERIC__)
c7cb8acb 102@subtitle on _HOST__ Systems
70b88761
RP
103_fi__(!_GENERIC__)
104@sp 1
29a2b744 105@c !!set edition, date, version
d24e0922
RP
106@subtitle Edition 4.04, for _GDBN__ version _GDB_VN__
107@subtitle March 1992
29a2b744 108@author by Richard M. Stallman and Roland H. Pesch
70b88761
RP
109@page
110@tex
111{\parskip=0pt
93ac5532 112\hfill pesch\@cygnus.com\par
70b88761
RP
113\hfill {\it Using _GDBN__}, \manvers\par
114\hfill \TeX{}info \texinfoversion\par
115}
116@end tex
117
118@vskip 0pt plus 1filll
1041a570 119Copyright @copyright{} 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
70b88761
RP
120
121Permission is granted to make and distribute verbatim copies of
122this manual provided the copyright notice and this permission notice
123are preserved on all copies.
124
125Permission is granted to copy and distribute modified versions of this
126manual under the conditions for verbatim copying, provided also that the
127section entitled ``GNU General Public License'' is included exactly as
128in the original, and provided that the entire resulting derived work is
129distributed under the terms of a permission notice identical to this
130one.
131
132Permission is granted to copy and distribute translations of this manual
133into another language, under the above conditions for modified versions,
134except that the section entitled ``GNU General Public License'' may be
135included in a translation approved by the Free Software Foundation
136instead of in the original English.
137@end titlepage
138@page
139
70b88761 140@ifinfo
29a2b744
RP
141@node Top, Summary, (dir), (dir)
142@top _GDBN__, the GNU symbolic debugger
143
144This file describes _GDBN__, the GNU symbolic debugger.
145
146@c !!set edition, date, version
d24e0922 147This is Edition 4.04, March 1992, for GDB Version _GDB_VN__.
70b88761
RP
148@end ifinfo
149
150@menu
b80282d5 151* Summary:: Summary of _GDBN__
c7cb8acb 152* New Features:: New features since GDB version 3.5
95d5ceb9 153* Sample Session:: A sample _GDBN__ session
29a2b744
RP
154* Invocation:: Getting in and out of _GDBN__
155* Commands:: _GDBN__ commands
156* Running:: Running programs under _GDBN__
157* Stopping:: Stopping and continuing
158* Stack:: Examining the stack
159* Source:: Examining source files
160* Data:: Examining data
161* Languages:: Using _GDBN__ with different languages
162* Symbols:: Examining the symbol table
163* Altering:: Altering execution
164* _GDBN__ Files:: _GDBN__'s files
165* Targets:: Specifying a debugging target
c2bbbb22 166* Controlling _GDBN__:: Controlling _GDBN__
29a2b744 167* Sequences:: Canned sequences of commands
b80282d5 168* Emacs:: Using _GDBN__ under GNU Emacs
29a2b744 169* _GDBN__ Bugs:: Reporting bugs in _GDBN__
e251e767 170* Renamed Commands::
77b46d13 171* Formatting Documentation:: How to format and print GDB documentation
c7cb8acb 172* Installing GDB:: Installing GDB
b80282d5
RP
173* Copying:: GNU GENERAL PUBLIC LICENSE
174* Index:: Index
c2bbbb22 175
70b88761
RP
176 --- The Detailed Node Listing ---
177
178Summary of _GDBN__
179
95d5ceb9 180* Free Software:: Freely redistributable software
b80282d5 181* Contributors:: Contributors to _GDBN__
70b88761
RP
182
183Getting In and Out of _GDBN__
184
95d5ceb9
RP
185* Invoking _GDBN__:: How to start _GDBN__
186* Leaving _GDBN__:: How to quit _GDBN__
187* Shell Commands:: How to use shell commands inside _GDBN__
70b88761
RP
188
189Starting _GDBN__
190
b80282d5
RP
191* File Options:: Choosing Files
192* Mode Options:: Choosing Modes
70b88761
RP
193
194_GDBN__ Commands
195
b80282d5
RP
196* Command Syntax:: Command Syntax
197* Help:: Getting Help
70b88761
RP
198
199Running Programs Under _GDBN__
200
b80282d5
RP
201* Compilation:: Compiling for Debugging
202* Starting:: Starting your Program
203* Arguments:: Your Program's Arguments
204* Environment:: Your Program's Environment
205* Working Directory:: Your Program's Working Directory
206* Input/Output:: Your Program's Input and Output
207* Attach:: Debugging an Already-Running Process
208* Kill Process:: Killing the Child Process
d24e0922 209* Process Information:: Additional Process Information
70b88761
RP
210
211Stopping and Continuing
212
b80282d5
RP
213* Breakpoints:: Breakpoints, Watchpoints, and Exceptions
214* Continuing and Stepping:: Resuming Execution
215* Signals:: Signals
70b88761
RP
216
217Breakpoints, Watchpoints, and Exceptions
218
b80282d5
RP
219* Set Breaks:: Setting Breakpoints
220* Set Watchpoints:: Setting Watchpoints
221* Exception Handling:: Breakpoints and Exceptions
222* Delete Breaks:: Deleting Breakpoints
223* Disabling:: Disabling Breakpoints
224* Conditions:: Break Conditions
225* Break Commands:: Breakpoint Command Lists
226* Breakpoint Menus:: Breakpoint Menus
c2bbbb22 227* Error in Breakpoints:: ``Cannot insert breakpoints''
70b88761
RP
228
229Examining the Stack
230
b80282d5
RP
231* Frames:: Stack Frames
232* Backtrace:: Backtraces
233* Selection:: Selecting a Frame
234* Frame Info:: Information on a Frame
70b88761
RP
235
236Examining Source Files
237
b80282d5
RP
238* List:: Printing Source Lines
239* Search:: Searching Source Files
240* Source Path:: Specifying Source Directories
241* Machine Code:: Source and Machine Code
70b88761
RP
242
243Examining Data
244
b80282d5
RP
245* Expressions:: Expressions
246* Variables:: Program Variables
247* Arrays:: Artificial Arrays
248* Output formats:: Output formats
249* Memory:: Examining Memory
250* Auto Display:: Automatic Display
251* Print Settings:: Print Settings
252* Value History:: Value History
253* Convenience Vars:: Convenience Variables
254* Registers:: Registers
255* Floating Point Hardware:: Floating Point Hardware
70b88761 256
c2bbbb22
RP
257Using GDB with Different Languages
258
259* Setting:: Switching between source languages
260* Show:: Displaying the language
261* Checks:: Type and Range checks
262* Support:: Supported languages
263
264Switching between source languages
265
266* Manually:: Setting the working language manually
267* Automatically:: Having GDB infer the source language
268
269Type and range Checking
270
271* Type Checking:: An overview of type checking
272* Range Checking:: An overview of range checking
273
274Supported Languages
275
276* C:: C and C++
277* Modula-2:: Modula-2
278
279C and C++
280
281* C Operators:: C and C++ Operators
282* C Constants:: C and C++ Constants
283* Cplusplus expressions:: C++ Expressions
284* C Defaults:: Default settings for C and C++
285* C Checks:: C and C++ Type and Range Checks
286* Debugging C:: _GDBN__ and C
287* Debugging C plus plus:: Special features for C++
288
289Modula-2
290
291* M2 Operators:: Built-in operators
29a2b744 292* Built-In Func/Proc:: Built-in Functions and Procedures
c2bbbb22
RP
293* M2 Constants:: Modula-2 Constants
294* M2 Defaults:: Default settings for Modula-2
295* Deviations:: Deviations from standard Modula-2
296* M2 Checks:: Modula-2 Type and Range Checks
297* M2 Scope:: The scope operators @code{::} and @code{.}
298* GDB/M2:: GDB and Modula-2
299
70b88761
RP
300Altering Execution
301
b80282d5
RP
302* Assignment:: Assignment to Variables
303* Jumping:: Continuing at a Different Address
29a2b744 304* Signaling:: Giving your program a Signal
b80282d5
RP
305* Returning:: Returning from a Function
306* Calling:: Calling your Program's Functions
c338a2fd 307* Patching:: Patching your Program
70b88761
RP
308
309_GDBN__'s Files
310
b80282d5
RP
311* Files:: Commands to Specify Files
312* Symbol Errors:: Errors Reading Symbol Files
70b88761 313
e251e767 314Specifying a Debugging Target
70b88761 315
b80282d5
RP
316* Active Targets:: Active Targets
317* Target Commands:: Commands for Managing Targets
318* Remote:: Remote Debugging
70b88761
RP
319
320Remote Debugging
321
c2bbbb22
RP
322* i960-Nindy Remote:: _GDBN__ with a Remote i960 (Nindy)
323* EB29K Remote:: _GDBN__ with a Remote EB29K
324* VxWorks Remote:: _GDBN__ and VxWorks
70b88761
RP
325
326_GDBN__ with a Remote i960 (Nindy)
327
b80282d5
RP
328* Nindy Startup:: Startup with Nindy
329* Nindy Options:: Options for Nindy
330* Nindy reset:: Nindy Reset Command
70b88761
RP
331
332_GDBN__ with a Remote EB29K
333
b80282d5
RP
334* Comms (EB29K):: Communications Setup
335* gdb-EB29K:: EB29K cross-debugging
336* Remote Log:: Remote Log
70b88761
RP
337
338_GDBN__ and VxWorks
339
b80282d5
RP
340* VxWorks connection:: Connecting to VxWorks
341* VxWorks download:: VxWorks Download
342* VxWorks attach:: Running Tasks
70b88761
RP
343
344Controlling _GDBN__
345
b80282d5
RP
346* Prompt:: Prompt
347* Editing:: Command Editing
348* History:: Command History
349* Screen Size:: Screen Size
350* Numbers:: Numbers
351* Messages/Warnings:: Optional Warnings and Messages
70b88761
RP
352
353Canned Sequences of Commands
354
b80282d5
RP
355* Define:: User-Defined Commands
356* Command Files:: Command Files
357* Output:: Commands for Controlled Output
70b88761
RP
358
359Reporting Bugs in _GDBN__
360
b80282d5
RP
361* Bug Criteria:: Have You Found a Bug?
362* Bug Reporting:: How to Report Bugs
c2bbbb22
RP
363
364Installing GDB
365
f672bb7f 366* Separate Objdir:: Compiling _GDBN__ in another directory
c2bbbb22
RP
367* Config Names:: Specifying names for hosts and targets
368* configure Options:: Summary of options for configure
70b88761
RP
369@end menu
370
371@node Summary, New Features, Top, Top
372@unnumbered Summary of _GDBN__
373
374The purpose of a debugger such as _GDBN__ is to allow you to see what is
375going on ``inside'' another program while it executes---or what another
1041a570 376program was doing at the moment it crashed.
70b88761
RP
377
378_GDBN__ can do four main kinds of things (plus other things in support of
1041a570 379these) to help you catch bugs in the act:
70b88761
RP
380
381@itemize @bullet
382@item
383Start your program, specifying anything that might affect its behavior.
384
385@item
386Make your program stop on specified conditions.
387
388@item
389Examine what has happened, when your program has stopped.
390
391@item
392Change things in your program, so you can experiment with correcting the
393effects of one bug and go on to learn about another.
394@end itemize
395
c2bbbb22
RP
396You can use _GDBN__ to debug programs written in C, C++, and Modula-2.
397Fortran support will be added when a GNU Fortran compiler is ready.
70b88761
RP
398
399@menu
b80282d5
RP
400* Free Software:: Free Software
401* Contributors:: Contributors to GDB
70b88761
RP
402@end menu
403
404@node Free Software, Contributors, Summary, Summary
405@unnumberedsec Free Software
1041a570
RP
406
407_GDBN__ is @dfn{free software}, protected by the GNU General Public License
408(GPL). The GPL gives you the freedom to copy or adapt a licensed
70b88761
RP
409program---but every person getting a copy also gets with it the
410freedom to modify that copy (which means that they must get access to
411the source code), and the freedom to distribute further copies.
412Typical software companies use copyrights to limit your freedoms; the
413Free Software Foundation uses the GPL to preserve these freedoms.
414
415Fundamentally, the General Public License is a license which says that
29a2b744 416you have these freedoms and that you cannot take these freedoms away
70b88761
RP
417from anyone else.
418
29a2b744 419For full details, @pxref{Copying, ,GNU GENERAL PUBLIC LICENSE}.
1041a570 420
70b88761
RP
421@node Contributors, , Free Software, Summary
422@unnumberedsec Contributors to GDB
423
424Richard Stallman was the original author of GDB, and of many other GNU
425programs. Many others have contributed to its development. This
426section attempts to credit major contributors. One of the virtues of
427free software is that everyone is free to contribute to it; with
428regret, we cannot actually acknowledge everyone here. The file
429@file{ChangeLog} in the GDB distribution approximates a blow-by-blow
430account.
431
432Changes much prior to version 2.0 are lost in the mists of time.
433
434@quotation
435@emph{Plea:} Additions to this section are particularly welcome. If you
436or your friends (or enemies; let's be evenhanded) have been unfairly
437omitted from this list, we would like to add your names!
438@end quotation
439
440So that they may not regard their long labor as thankless, we
69bbcf05 441particularly thank those who shepherded GDB through major releases: Stu
14d01801 442Grossman and John Gilmore (releases 4.5, 4.4), John Gilmore (releases 4.3, 4.2,
69bbcf05
RP
4434.1, 4.0, and 3.9); Jim Kingdon (releases 3.5, 3.4, 3.3); and Randy
444Smith (releases 3.2, 3.1, 3.0). As major maintainer of GDB for some
445period, each contributed significantly to the structure, stability, and
446capabilities of the entire debugger.
70b88761
RP
447
448Richard Stallman, assisted at various times by Pete TerMaat, Chris
449Hanson, and Richard Mlynarik, handled releases through 2.8.
450
451Michael Tiemann is the author of most of the GNU C++ support in GDB,
452with significant additional contributions from Per Bothner. James
453Clark wrote the GNU C++ demangler. Early work on C++ was by Peter
454TerMaat (who also did much general update work leading to release 3.0).
455
1041a570
RP
456GDB 4 uses the BFD subroutine library to examine multiple
457object-file formats; BFD was a joint project of David V.
458Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
70b88761 459
1041a570
RP
460David Johnson wrote the original COFF support; Pace Willison did
461the original support for encapsulated COFF.
70b88761
RP
462
463Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
464Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
1041a570
RP
465support. Jean-Daniel Fekete contributed Sun 386i support. Chris
466Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki
467Hasei contributed Sony/News OS 3 support. David Johnson contributed
468Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support.
469Keith Packard contributed NS32K support. Doug Rabson contributed
470Acorn Risc Machine support. Chris Smith contributed Convex support
471(and Fortran debugging). Jonathan Stone contributed Pyramid support.
472Michael Tiemann contributed SPARC support. Tim Tucker contributed
473support for the Gould NP1 and Gould Powernode. Pace Willison
474contributed Intel 386 support. Jay Vosburgh contributed Symmetry
475support.
70b88761 476
c338a2fd
RP
477Rich Schaefer and Peter Schauer helped with support of SunOS shared
478libraries.
70b88761
RP
479
480Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about
481several machine instruction sets.
482
1041a570
RP
483Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
484develop remote debugging. Intel Corporation and Wind River Systems
485contributed remote debugging modules for their products.
70b88761 486
1041a570
RP
487Brian Fox is the author of the readline libraries providing
488command-line editing and command history.
70b88761 489
1041a570
RP
490Andrew Beers of SUNY Buffalo wrote the language-switching code and
491the Modula-2 support, and contributed the Languages chapter of this
492manual.
c2bbbb22 493
14d01801
RP
494Fred Fish wrote most of the support for Unix System Vr4.
495
70b88761 496@node New Features, Sample Session, Summary, Top
c7cb8acb 497@unnumbered New Features since GDB version 3.5
70b88761
RP
498
499@table @emph
500@item Targets
501Using the new command @code{target}, you can select at runtime whether
502you are debugging local files, local processes, standalone systems over
b80282d5
RP
503a serial port, realtime systems over a TCP/IP connection, etc. The
504command @code{load} can download programs into a remote system. Serial
505stubs are available for Motorola 680x0 and Intel 80386 remote systems;
c7cb8acb 506GDB also supports debugging realtime processes running under
b80282d5 507VxWorks, using SunRPC Remote Procedure Calls over TCP/IP to talk to a
c7cb8acb 508debugger stub on the target system. Internally, GDB now uses a
b80282d5
RP
509function vector to mediate access to different targets; if you need to
510add your own support for a remote protocol, this makes it much easier.
70b88761
RP
511
512@item Watchpoints
c7cb8acb 513GDB now sports watchpoints as well as breakpoints. You can use a
70b88761
RP
514watchpoint to stop execution whenever the value of an expression
515changes, without having to predict a particular place in your program
516where this may happen.
517
b80282d5
RP
518@item Wide Output
519Commands that issue wide output now insert newlines at places designed
520to make the output more readable.
521
70b88761 522@item Object Code Formats
c7cb8acb 523GDB uses a new library called the Binary File Descriptor (BFD)
3d3ab540
RP
524Library to permit it to switch dynamically, without reconfiguration or
525recompilation, between different object-file formats. Formats currently
526supported are COFF, a.out, and the Intel 960 b.out; files may be read as
527.o's, archive libraries, or core dumps. BFD is available as a
528subroutine library so that other programs may take advantage of it, and
529the other GNU binary utilities are being converted to use it.
70b88761 530
b80282d5 531@item Configuration and Ports
70b88761 532Compile-time configuration (to select a particular architecture and
7463aadd 533operating system) is much easier. The script @code{configure} now
c7cb8acb
RP
534allows you to configure GDB as either a native debugger or a
535cross-debugger. @xref{Installing GDB}, for details on how to
b80282d5 536configure and on what architectures are now available.
70b88761
RP
537
538@item Interaction
c7cb8acb 539The user interface to GDB's control variables has been simplified
70b88761
RP
540and consolidated in two commands, @code{set} and @code{show}. Output
541lines are now broken at readable places, rather than overflowing onto
542the next line. You can suppress output of machine-level addresses,
543displaying only source language information.
544
b80282d5 545@item C++
c7cb8acb 546GDB now supports C++ multiple inheritance (if used with a GCC
b80282d5 547version 2 compiler), and also has limited support for C++ exception
c7cb8acb 548handling, with the commands @code{catch} and @code{info catch}: GDB
b80282d5
RP
549can break when an exception is raised, before the stack is peeled back
550to the exception handler's context.
70b88761 551
c2bbbb22 552@item Modula-2
c7cb8acb 553GDB now has preliminary support for the GNU Modula-2 compiler,
c2bbbb22 554currently under development at the State University of New York at
c7cb8acb 555Buffalo. Coordinated development of both GDB and the GNU Modula-2
5b0fdf7b
RP
556compiler will continue into 1992. Other Modula-2 compilers are
557currently not supported, and attempting to debug programs compiled with
558them will likely result in an error as the symbol table of the
559executable is read in.
c2bbbb22 560
70b88761 561@item Command Rationalization
c7cb8acb 562Many GDB commands have been renamed to make them easier to remember
70b88761
RP
563and use. In particular, the subcommands of @code{info} and
564@code{show}/@code{set} are grouped to make the former refer to the state
c7cb8acb 565of your program, and the latter refer to the state of GDB itself.
70b88761
RP
566@xref{Renamed Commands}, for details on what commands were renamed.
567
70b88761 568@item Shared Libraries
77b46d13
JG
569GDB 4 can debug programs and core files that use SunOS, SVR4, or IBM RS/6000
570shared libraries.
b80282d5
RP
571
572@item Reference Card
c7cb8acb 573GDB 4 has a reference card. @xref{Formatting Documentation} for
b80282d5 574instructions on printing it.
70b88761
RP
575
576@item Work in Progress
577Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture
578support.
70b88761
RP
579@end table
580
581@node Sample Session, Invocation, New Features, Top
582@chapter A Sample _GDBN__ Session
583
584You can use this manual at your leisure to read all about _GDBN__.
585However, a handful of commands are enough to get started using the
586debugger. This chapter illustrates these commands.
587
588@iftex
6ca72cc6 589In this sample session, we emphasize user input like this: @b{input},
70b88761
RP
590to make it easier to pick out from the surrounding output.
591@end iftex
592
593@c FIXME: this example may not be appropriate for some configs, where
594@c FIXME...primary interest is in remote use.
595_0__
596One of the preliminary versions of GNU @code{m4} (a generic macro
597processor) exhibits the following bug: sometimes, when we change its
598quote strings from the default, the commands used to capture one macro's
599definition in another stop working. In the following short @code{m4}
600session, we define a macro @code{foo} which expands to @code{0000}; we
29a2b744 601then use the @code{m4} built-in @code{defn} to define @code{bar} as the
70b88761
RP
602same thing. However, when we change the open quote string to
603@code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same
604procedure fails to define a new synonym @code{baz}:
605
606@smallexample
6ca72cc6
RP
607$ @b{cd gnu/m4}
608$ @b{./m4}
609@b{define(foo,0000)}
70b88761 610
6ca72cc6 611@b{foo}
70b88761 6120000
6ca72cc6 613@b{define(bar,defn(`foo'))}
70b88761 614
6ca72cc6 615@b{bar}
70b88761 6160000
6ca72cc6 617@b{changequote(<QUOTE>,<UNQUOTE>)}
70b88761 618
6ca72cc6
RP
619@b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
620@b{baz}
621@b{C-d}
70b88761
RP
622m4: End of input: 0: fatal error: EOF in string
623@end smallexample
624
625@noindent
626Let's use _GDBN__ to try to see what's going on.
627
628@smallexample
6ca72cc6 629$ @b{_GDBP__ m4}
203eea5d
RP
630@c FIXME: this falsifies the exact text played out, to permit smallbook
631@c FIXME... format to come out better.
632GDB is free software and you are welcome to distribute copies
633 of it under certain conditions; type "show copying" to see
634 the conditions.
635There is absolutely no warranty for GDB; type "show warranty"
636for details.
5b0fdf7b 637GDB _GDB_VN__, Copyright 1992 Free Software Foundation, Inc...
e251e767 638(_GDBP__)
70b88761
RP
639@end smallexample
640
641@noindent
1041a570
RP
642_GDBN__ reads only enough symbol data to know where to find the rest when
643needed; as a result, the first prompt comes up very quickly. We now
644tell _GDBN__ to use a narrower display width than usual, so that examples
645will fit in this manual.
70b88761
RP
646
647@smallexample
6ca72cc6 648(_GDBP__) @b{set width 70}
70b88761
RP
649@end smallexample
650
e251e767 651@noindent
29a2b744 652Let's see how the @code{m4} built-in @code{changequote} works.
70b88761
RP
653Having looked at the source, we know the relevant subroutine is
654@code{m4_changequote}, so we set a breakpoint there with _GDBN__'s
655@code{break} command.
656
657@smallexample
6ca72cc6 658(_GDBP__) @b{break m4_changequote}
70b88761
RP
659Breakpoint 1 at 0x62f4: file builtin.c, line 879.
660@end smallexample
661
662@noindent
663Using the @code{run} command, we start @code{m4} running under _GDBN__
664control; as long as control does not reach the @code{m4_changequote}
665subroutine, the program runs as usual:
666
667@smallexample
6ca72cc6 668(_GDBP__) @b{run}
e251e767 669Starting program: /work/Editorial/gdb/gnu/m4/m4
6ca72cc6 670@b{define(foo,0000)}
70b88761 671
6ca72cc6 672@b{foo}
70b88761
RP
6730000
674@end smallexample
675
676@noindent
677To trigger the breakpoint, we call @code{changequote}. _GDBN__
678suspends execution of @code{m4}, displaying information about the
679context where it stops.
680
681@smallexample
6ca72cc6 682@b{changequote(<QUOTE>,<UNQUOTE>)}
70b88761 683
203eea5d
RP
684Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
685 at builtin.c:879
38962738 686879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
70b88761
RP
687@end smallexample
688
689@noindent
690Now we use the command @code{n} (@code{next}) to advance execution to
691the next line of the current function.
692
693@smallexample
6ca72cc6 694(_GDBP__) @b{n}
203eea5d
RP
695882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
696 : nil,
70b88761
RP
697@end smallexample
698
699@noindent
700@code{set_quotes} looks like a promising subroutine. We can go into it
701by using the command @code{s} (@code{step}) instead of @code{next}.
702@code{step} goes to the next line to be executed in @emph{any}
e251e767 703subroutine, so it steps into @code{set_quotes}.
70b88761
RP
704
705@smallexample
6ca72cc6 706(_GDBP__) @b{s}
70b88761
RP
707set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
708 at input.c:530
709530 if (lquote != def_lquote)
710@end smallexample
711
712@noindent
29a2b744
RP
713The display that shows the subroutine where @code{m4} is now
714suspended (and its arguments) is called a stack frame display. It
715shows a summary of the stack. We can use the @code{backtrace}
716command (which can also be spelled @code{bt}), to see where we are
717in the stack as a whole: the @code{backtrace} command displays a
718stack frame for each active subroutine.
70b88761
RP
719
720@smallexample
6ca72cc6 721(_GDBP__) @b{bt}
70b88761
RP
722#0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
723 at input.c:530
203eea5d
RP
724#1 0x6344 in m4_changequote (argc=3, argv=0x33c70)
725 at builtin.c:882
70b88761
RP
726#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
727#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
728 at macro.c:71
729#4 0x79dc in expand_input () at macro.c:40
730#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
731@end smallexample
732
733@noindent
734Let's step through a few more lines to see what happens. The first two
735times, we can use @samp{s}; the next two times we use @code{n} to avoid
736falling into the @code{xstrdup} subroutine.
1041a570 737
70b88761 738@smallexample
6ca72cc6 739(_GDBP__) @b{s}
70b88761 7400x3b5c 532 if (rquote != def_rquote)
6ca72cc6 741(_GDBP__) @b{s}
203eea5d
RP
7420x3b80 535 lquote = (lq == nil || *lq == '\0') ? \
743def_lquote : xstrdup(lq);
6ca72cc6 744(_GDBP__) @b{n}
203eea5d
RP
745536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
746 : xstrdup(rq);
6ca72cc6 747(_GDBP__) @b{n}
70b88761
RP
748538 len_lquote = strlen(rquote);
749@end smallexample
750
751@noindent
752The last line displayed looks a little odd; let's examine the variables
753@code{lquote} and @code{rquote} to see if they are in fact the new left
754and right quotes we specified. We can use the command @code{p}
755(@code{print}) to see their values.
756
757@smallexample
6ca72cc6 758(_GDBP__) @b{p lquote}
70b88761 759$1 = 0x35d40 "<QUOTE>"
6ca72cc6 760(_GDBP__) @b{p rquote}
70b88761
RP
761$2 = 0x35d50 "<UNQUOTE>"
762@end smallexample
763
764@noindent
765@code{lquote} and @code{rquote} are indeed the new left and right quotes.
766Let's look at some context; we can display ten lines of source
767surrounding the current line, with the @code{l} (@code{list}) command.
768
769@smallexample
6ca72cc6 770(_GDBP__) @b{l}
70b88761 771533 xfree(rquote);
e251e767 772534
203eea5d
RP
773535 lquote = (lq == nil || *lq == '\0') ? def_lquote\
774 : xstrdup (lq);
775536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
776 : xstrdup (rq);
e251e767 777537
70b88761
RP
778538 len_lquote = strlen(rquote);
779539 len_rquote = strlen(lquote);
780540 @}
e251e767 781541
70b88761
RP
782542 void
783@end smallexample
784
785@noindent
786Let's step past the two lines that set @code{len_lquote} and
787@code{len_rquote}, and then examine the values of those variables.
788
789@smallexample
6ca72cc6 790(_GDBP__) @b{n}
70b88761 791539 len_rquote = strlen(lquote);
6ca72cc6 792(_GDBP__) @b{n}
70b88761 793540 @}
6ca72cc6 794(_GDBP__) @b{p len_lquote}
70b88761 795$3 = 9
6ca72cc6 796(_GDBP__) @b{p len_rquote}
70b88761
RP
797$4 = 7
798@end smallexample
799
800@noindent
801That certainly looks wrong, assuming @code{len_lquote} and
802@code{len_rquote} are meant to be the lengths of @code{lquote} and
803@code{rquote} respectively. Let's try setting them to better values.
804We can use the @code{p} command for this, since it'll print the value of
805any expression---and that expression can include subroutine calls and
e251e767 806assignments.
70b88761
RP
807
808@smallexample
6ca72cc6 809(_GDBP__) @b{p len_lquote=strlen(lquote)}
70b88761 810$5 = 7
6ca72cc6 811(_GDBP__) @b{p len_rquote=strlen(rquote)}
70b88761
RP
812$6 = 9
813@end smallexample
814
815@noindent
816Let's see if that fixes the problem of using the new quotes with the
817@code{m4} built-in @code{defn}. We can allow @code{m4} to continue
818executing with the @code{c} (@code{continue}) command, and then try the
819example that caused trouble initially:
820
821@smallexample
6ca72cc6 822(_GDBP__) @b{c}
70b88761
RP
823Continuing.
824
6ca72cc6 825@b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
70b88761
RP
826
827baz
8280000
829@end smallexample
830
831@noindent
832Success! The new quotes now work just as well as the default ones. The
833problem seems to have been just the two typos defining the wrong
834lengths. We'll let @code{m4} exit by giving it an EOF as input.
835
836@smallexample
6ca72cc6 837@b{C-d}
70b88761
RP
838Program exited normally.
839@end smallexample
840
e251e767 841@noindent
70b88761
RP
842The message @samp{Program exited normally.} is from _GDBN__; it
843indicates @code{m4} has finished executing. We can end our _GDBN__
844session with the _GDBN__ @code{quit} command.
845
846@smallexample
6ca72cc6 847(_GDBP__) @b{quit}
70b88761
RP
848_1__@end smallexample
849
850@node Invocation, Commands, Sample Session, Top
851@chapter Getting In and Out of _GDBN__
852
c7cb8acb
RP
853This chapter discusses how to start _GDBN__, and how to get out of it.
854(The essentials: type @samp{_GDBP__} to start GDB, and type @kbd{quit}
855or @kbd{C-d} to exit.)
29a2b744 856
70b88761 857@menu
29a2b744 858* Invoking _GDBN__:: Starting _GDBN__
c2bbbb22 859* Leaving _GDBN__:: Leaving _GDBN__
b80282d5 860* Shell Commands:: Shell Commands
70b88761
RP
861@end menu
862
29a2b744 863@node Invoking _GDBN__, Leaving _GDBN__, Invocation, Invocation
70b88761
RP
864@section Starting _GDBN__
865
1041a570
RP
866Start _GDBN__ with the shell command @code{_GDBP__}. Once it's running,
867_GDBN__ reads commands from the terminal until you tell it to exit.
70b88761 868
c7cb8acb
RP
869You can also run @code{_GDBP__} with a variety of arguments and options,
870to specify more of your debugging environment at the outset.
871
872The command-line options described here are designed
873to cover a variety of situations; in some environments, some of these
874options may effectively be unavailable.
875
876_if__(_H8__)
877For details on starting up _GDBP__ as a
878remote debugger attached to a Hitachi H8/300 board, see @ref{Hitachi
879H8/300 Remote,,_GDBN__ and the Hitachi H8/300}.
880_fi__(_H8__)
881
882The most usual way to start _GDBN__ is with one argument or two,
883specifying an executable program as the argument:
1041a570 884
70b88761 885@example
29a2b744 886_GDBP__ @var{program}
70b88761 887@end example
1041a570 888
70b88761 889@noindent
29a2b744
RP
890You can also start with both an executable program and a core file
891specified:
1041a570 892
70b88761 893@example
29a2b744 894_GDBP__ @var{program} @var{core}
70b88761
RP
895@end example
896
b80282d5
RP
897You can, instead, specify a process ID as a second argument, if you want
898to debug a running process:
1041a570 899
b80282d5 900@example
29a2b744 901_GDBP__ @var{program} 1234
b80282d5 902@end example
1041a570 903
b80282d5
RP
904@noindent
905would attach _GDBN__ to process @code{1234} (unless you also have a file
906named @file{1234}; _GDBN__ does check for a core file first).
907
c7cb8acb
RP
908Taking advantage of the second command-line argument requires a fairly
909complete operating system; when you use _GDBN__ as a remote debugger
910attached to a bare board, there may not be any notion of ``process'',
911and there is often no way to get a core dump.
912
70b88761
RP
913@noindent
914You can further control how _GDBN__ starts up by using command-line
29a2b744
RP
915options. _GDBN__ itself can remind you of the options available.
916
917@noindent
918Type
919
70b88761
RP
920@example
921_GDBP__ -help
922@end example
29a2b744 923
70b88761 924@noindent
29a2b744 925to display all available options and briefly describe their use
70b88761
RP
926(@samp{_GDBP__ -h} is a shorter equivalent).
927
928All options and command line arguments you give are processed
929in sequential order. The order makes a difference when the
e251e767 930@samp{-x} option is used.
70b88761
RP
931
932@menu
b80282d5
RP
933* File Options:: Choosing Files
934* Mode Options:: Choosing Modes
70b88761
RP
935_if__(!_GENERIC__)
936_include__(gdbinv-m.m4)_dnl__
937_fi__(!_GENERIC__)
938@end menu
939
29a2b744 940@node File Options, Mode Options, Invoking _GDBN__, Invoking _GDBN__
70b88761
RP
941@subsection Choosing Files
942
29a2b744
RP
943When _GDBN__ starts, it reads any arguments other than options as
944specifying an executable file and core file (or process ID). This is
945the same as if the arguments were specified by the @samp{-se} and
946@samp{-c} options respectively. (_GDBN__ reads the first argument
947that does not have an associated option flag as equivalent to the
948@samp{-se} option followed by that argument; and the second argument
949that does not have an associated option flag, if any, as equivalent to
950the @samp{-c} option followed by that argument.)
951
952Many options have both long and short forms; both are shown in the
953following list. _GDBN__ also recognizes the long forms if you truncate
954them, so long as enough of the option is present to be unambiguous.
955(If you prefer, you can flag option arguments with @samp{--} rather
956than @samp{-}, though we illustrate the more usual convention.)
70b88761
RP
957
958@table @code
959@item -symbols=@var{file}
960@itemx -s @var{file}
961Read symbol table from file @var{file}.
962
963@item -exec=@var{file}
964@itemx -e @var{file}
965Use file @var{file} as the executable file to execute when
966appropriate, and for examining pure data in conjunction with a core
967dump.
968
3d3ab540 969@item -se=@var{file}
70b88761
RP
970Read symbol table from file @var{file} and use it as the executable
971file.
972
973@item -core=@var{file}
974@itemx -c @var{file}
975Use file @var{file} as a core dump to examine.
976
977@item -command=@var{file}
978@itemx -x @var{file}
979Execute _GDBN__ commands from file @var{file}. @xref{Command Files}.
980
981@item -directory=@var{directory}
982@itemx -d @var{directory}
983Add @var{directory} to the path to search for source files.
14d01801
RP
984
985@item -m
986@itemx -mapped
987@emph{Warning: this option depends on operating system facilities that are not
988supported on all systems.}@*
77b46d13
JG
989If memory-mapped files are available on your system through the @code{mmap}
990system call, you can use this option
991to cause _GDBN__ to write the symbols from your
992program into a reusable file in the current directory. If the program you are debugging is
993called @file{/tmp/fred}, the mapped symbol file will be @file{./fred.syms}.
994Future _GDBN__ debugging sessions will notice the presence of this file,
995and will quickly map in symbol information from it, rather than reading
996the symbol table from the executable program.
997
998The @file{.syms} file is specific to the host machine on which _GDBN__ is run.
999It holds an exact image of _GDBN__'s internal symbol table. It cannot be
1000shared across multiple host platforms.
1001
1002@item -r
1003@itemx -readnow
1004Read each symbol file's entire symbol table immediately, rather than
1005the default, which is to read it incrementally as it is needed.
1006This makes startup slower, but makes future operations faster.
70b88761
RP
1007@end table
1008
77b46d13
JG
1009The @code{-mapped} and @code{-readnow} options are typically combined in order to
1010build a @file{.syms} file that contains complete symbol information.
1011A simple GDB invocation to do nothing but build a @file{.syms} file for future
1012use is:
1013
1014@example
1015 gdb -batch -nx -mapped -readnow programname
1016@end example
1017
70b88761 1018_if__(!_GENERIC__)
29a2b744 1019@node Mode Options, Mode Options, File Options, Invoking _GDBN__
70b88761
RP
1020_fi__(!_GENERIC__)
1021_if__(_GENERIC__)
29a2b744
RP
1022@node Mode Options, , File Options, Invoking _GDBN__
1023_fi__(_GENERIC__)
1041a570
RP
1024@subsection Choosing Modes
1025
29a2b744
RP
1026You can run _GDBN__ in various alternative modes---for example, in
1027batch mode or quiet mode.
70b88761
RP
1028
1029@table @code
1030@item -nx
1031@itemx -n
1032Do not execute commands from any @file{_GDBINIT__} initialization files.
1033Normally, the commands in these files are executed after all the
e251e767 1034command options and arguments have been processed.
c728f1f0 1035@xref{Command Files}.
70b88761
RP
1036
1037@item -quiet
1038@itemx -q
1039``Quiet''. Do not print the introductory and copyright messages. These
c338a2fd 1040messages are also suppressed in batch mode.
70b88761
RP
1041
1042@item -batch
1043Run in batch mode. Exit with status @code{0} after processing all the command
1044files specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited).
1045Exit with nonzero status if an error occurs in executing the _GDBN__
e251e767 1046commands in the command files.
70b88761
RP
1047
1048Batch mode may be useful for running _GDBN__ as a filter, for example to
1049download and run a program on another computer; in order to make this
e251e767 1050more useful, the message
1041a570 1051
70b88761
RP
1052@example
1053Program exited normally.
1054@end example
1041a570 1055
70b88761
RP
1056@noindent
1057(which is ordinarily issued whenever a program running under _GDBN__ control
1058terminates) is not issued when running in batch mode.
1059
3d3ab540 1060@item -cd=@var{directory}
70b88761
RP
1061Run _GDBN__ using @var{directory} as its working directory,
1062instead of the current directory.
1063
6ca72cc6 1064_if__(_LUCID__)
45c53080 1065@item -context @var{authentication}
6ca72cc6
RP
1066When the Energize programming system starts up _GDBN__, it uses this
1067option to trigger an alternate mode of interaction.
1068@var{authentication} is a pair of numeric codes that identify _GDBN__
1069as a client in the Energize environment. Avoid this option when you run
1070_GDBN__ directly from the command line. See @ref{Energize,,Using
1071_GDBN__ with Energize} for more discussion of using _GDBN__ with Energize.
1072_fi__(_LUCID__)
1073
70b88761
RP
1074@item -fullname
1075@itemx -f
1076Emacs sets this option when it runs _GDBN__ as a subprocess. It tells _GDBN__
1077to output the full file name and line number in a standard,
1078recognizable fashion each time a stack frame is displayed (which
29a2b744 1079includes each time your program stops). This recognizable format looks
70b88761
RP
1080like two @samp{\032} characters, followed by the file name, line number
1081and character position separated by colons, and a newline. The
1082Emacs-to-_GDBN__ interface program uses the two @samp{\032} characters as
1083a signal to display the source code for the frame.
1084
1085@item -b @var{bps}
1086Set the line speed (baud rate or bits per second) of any serial
1087interface used by _GDBN__ for remote debugging.
1088
3d3ab540 1089@item -tty=@var{device}
70b88761 1090Run using @var{device} for your program's standard input and output.
29a2b744 1091@c FIXME: kingdon thinks there is more to -tty. Investigate.
70b88761
RP
1092@end table
1093
1094_if__(!_GENERIC__)
1095_include__(gdbinv-s.m4)
1096_fi__(!_GENERIC__)
29a2b744 1097@node Leaving _GDBN__, Shell Commands, Invoking _GDBN__, Invocation
70b88761
RP
1098@section Leaving _GDBN__
1099@cindex exiting _GDBN__
1041a570 1100
70b88761
RP
1101@table @code
1102@item quit
1103@kindex quit
1104@kindex q
1105To exit _GDBN__, use the @code{quit} command (abbreviated @code{q}), or type
e251e767 1106an end-of-file character (usually @kbd{C-d}).
70b88761
RP
1107@end table
1108
1109@cindex interrupt
1110An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather
1111will terminate the action of any _GDBN__ command that is in progress and
1112return to _GDBN__ command level. It is safe to type the interrupt
1113character at any time because _GDBN__ does not allow it to take effect
1114until a time when it is safe.
1115
1041a570
RP
1116If you have been using _GDBN__ to control an attached process or device, you
1117can release it with the @code{detach} command; @pxref{Attach,
1118,Debugging an Already-Running Process}..
70b88761
RP
1119
1120@node Shell Commands, , Leaving _GDBN__, Invocation
1121@section Shell Commands
1041a570 1122
70b88761 1123If you need to execute occasional shell commands during your
29a2b744 1124debugging session, there is no need to leave or suspend _GDBN__; you can
70b88761
RP
1125just use the @code{shell} command.
1126
1127@table @code
1128@item shell @var{command string}
1129@kindex shell
1130@cindex shell escape
1131Directs _GDBN__ to invoke an inferior shell to execute @var{command
1132string}. If it exists, the environment variable @code{SHELL} is used
1133for the name of the shell to run. Otherwise _GDBN__ uses
1134@code{/bin/sh}.
1135@end table
1136
1137The utility @code{make} is often needed in development environments.
29a2b744 1138You do not have to use the @code{shell} command for this purpose in _GDBN__:
70b88761
RP
1139
1140@table @code
1141@item make @var{make-args}
1142@kindex make
1143@cindex calling make
1144Causes _GDBN__ to execute an inferior @code{make} program with the specified
1145arguments. This is equivalent to @samp{shell make @var{make-args}}.
1146@end table
1147
1148@node Commands, Running, Invocation, Top
1149@chapter _GDBN__ Commands
1150
29a2b744
RP
1151You can abbreviate GDB command if that abbreviation is unambiguous;
1152and you can repeat certain GDB commands by typing just @key{RET}.
1153
70b88761 1154@menu
b80282d5
RP
1155* Command Syntax:: Command Syntax
1156* Help:: Getting Help
70b88761
RP
1157@end menu
1158
1159@node Command Syntax, Help, Commands, Commands
1160@section Command Syntax
1041a570 1161
70b88761
RP
1162A _GDBN__ command is a single line of input. There is no limit on how long
1163it can be. It starts with a command name, which is followed by arguments
1164whose meaning depends on the command name. For example, the command
1165@code{step} accepts an argument which is the number of times to step,
1166as in @samp{step 5}. You can also use the @code{step} command with
1167no arguments. Some command names do not allow any arguments.
1168
1169@cindex abbreviation
1170_GDBN__ command names may always be truncated if that abbreviation is
1171unambiguous. Other possible command abbreviations are listed in the
1172documentation for individual commands. In some cases, even ambiguous
1173abbreviations are allowed; for example, @code{s} is specially defined as
1174equivalent to @code{step} even though there are other commands whose
1175names start with @code{s}. You can test abbreviations by using them as
7463aadd 1176arguments to the @code{help} command.
70b88761 1177
e251e767 1178@cindex repeating commands
70b88761
RP
1179@kindex RET
1180A blank line as input to _GDBN__ (typing just @key{RET}) means to
1181repeat the previous command. Certain commands (for example, @code{run})
1182will not repeat this way; these are commands for which unintentional
1183repetition might cause trouble and which you are unlikely to want to
1184repeat.
1185
1186The @code{list} and @code{x} commands, when you repeat them with
1187@key{RET}, construct new arguments rather than repeating
1188exactly as typed. This permits easy scanning of source or memory.
1189
b80282d5
RP
1190_GDBN__ can also use @key{RET} in another way: to partition lengthy
1191output, in a way similar to the common utility @code{more}
29a2b744 1192(@pxref{Screen Size}). Since it is easy to press one @key{RET} too many
b80282d5
RP
1193in this situation, _GDBN__ disables command repetition after any command
1194that generates this sort of display.
1195
70b88761
RP
1196@kindex #
1197@cindex comment
1198A line of input starting with @kbd{#} is a comment; it does nothing.
29a2b744 1199This is useful mainly in command files (@pxref{Command Files}).
70b88761
RP
1200
1201@node Help, , Command Syntax, Commands
1202@section Getting Help
1203@cindex online documentation
1204@kindex help
1041a570 1205
70b88761 1206You can always ask _GDBN__ itself for information on its commands, using the
e251e767 1207command @code{help}.
70b88761
RP
1208
1209@table @code
1210@item help
1211@itemx h
1212@kindex h
1213You can use @code{help} (abbreviated @code{h}) with no arguments to
1214display a short list of named classes of commands:
1041a570 1215
70b88761
RP
1216@smallexample
1217(_GDBP__) help
1218List of classes of commands:
1219
1220running -- Running the program
1221stack -- Examining the stack
1222data -- Examining data
1223breakpoints -- Making program stop at certain points
1224files -- Specifying and examining files
1225status -- Status inquiries
1226support -- Support facilities
1227user-defined -- User-defined commands
1228aliases -- Aliases of other commands
1229obscure -- Obscure features
1230
203eea5d
RP
1231Type "help" followed by a class name for a list of
1232commands in that class.
1233Type "help" followed by command name for full
1234documentation.
70b88761 1235Command name abbreviations are allowed if unambiguous.
e251e767 1236(_GDBP__)
70b88761
RP
1237@end smallexample
1238
1239@item help @var{class}
1240Using one of the general help classes as an argument, you can get a
1241list of the individual commands in that class. For example, here is the
1242help display for the class @code{status}:
1041a570 1243
70b88761
RP
1244@smallexample
1245(_GDBP__) help status
1246Status inquiries.
1247
1248List of commands:
1249
1250show -- Generic command for showing things set with "set"
1251info -- Generic command for printing status
1252
203eea5d
RP
1253Type "help" followed by command name for full
1254documentation.
70b88761 1255Command name abbreviations are allowed if unambiguous.
e251e767 1256(_GDBP__)
70b88761
RP
1257@end smallexample
1258
1259@item help @var{command}
1260With a command name as @code{help} argument, _GDBN__ will display a
e251e767 1261short paragraph on how to use that command.
70b88761
RP
1262@end table
1263
1264In addition to @code{help}, you can use the _GDBN__ commands @code{info}
1265and @code{show} to inquire about the state of your program, or the state
1266of _GDBN__ itself. Each command supports many topics of inquiry; this
1267manual introduces each of them in the appropriate context. The listings
1268under @code{info} and under @code{show} in the Index point to
29a2b744 1269all the sub-commands. @xref{Index}.
70b88761
RP
1270
1271@c @group
1272@table @code
1273@item info
1274@kindex info
1275@kindex i
1276This command (abbreviated @code{i}) is for describing the state of your
1277program; for example, it can list the arguments given to your program
1278(@code{info args}), the registers currently in use (@code{info
1041a570 1279registers}), or the breakpoints you have set (@code{info breakpoints}).
70b88761
RP
1280You can get a complete list of the @code{info} sub-commands with
1281@w{@code{help info}}.
1282
1283@kindex show
1284@item show
1285In contrast, @code{show} is for describing the state of _GDBN__ itself.
1286You can change most of the things you can @code{show}, by using the
1287related command @code{set}; for example, you can control what number
1288system is used for displays with @code{set radix}, or simply inquire
e251e767 1289which is currently in use with @code{show radix}.
70b88761
RP
1290
1291@kindex info set
1292To display all the settable parameters and their current
1293values, you can use @code{show} with no arguments; you may also use
1294@code{info set}. Both commands produce the same display.
1295@c FIXME: "info set" violates the rule that "info" is for state of
1296@c FIXME...program. Ck w/ GNU: "info set" to be called something else,
1297@c FIXME...or change desc of rule---eg "state of prog and debugging session"?
1298@end table
1299@c @end group
1300
1301Here are three miscellaneous @code{show} subcommands, all of which are
1302exceptional in lacking corresponding @code{set} commands:
1303
1304@table @code
1305@kindex show version
3d3ab540 1306@cindex version number
70b88761
RP
1307@item show version
1308Show what version of _GDBN__ is running. You should include this
1041a570
RP
1309information in _GDBN__ bug-reports. If multiple versions of _GDBN__ are in
1310use at your site, you may occasionally want to make sure what version
1311of _GDBN__ you are running; as _GDBN__ evolves, new commands are introduced,
1312and old ones may wither away. The version number is also announced
1313when you start _GDBN__ with no arguments.
70b88761
RP
1314
1315@kindex show copying
1316@item show copying
1317Display information about permission for copying _GDBN__.
1318
1319@kindex show warranty
1320@item show warranty
1321Display the GNU ``NO WARRANTY'' statement.
1322@end table
1323
1324@node Running, Stopping, Commands, Top
1325@chapter Running Programs Under _GDBN__
1326
1041a570
RP
1327To debug a program, you must run it under _GDBN__.
1328
70b88761 1329@menu
b80282d5
RP
1330* Compilation:: Compiling for Debugging
1331* Starting:: Starting your Program
1332* Arguments:: Your Program's Arguments
1333* Environment:: Your Program's Environment
1334* Working Directory:: Your Program's Working Directory
1335* Input/Output:: Your Program's Input and Output
1336* Attach:: Debugging an Already-Running Process
1337* Kill Process:: Killing the Child Process
d24e0922 1338* Process Information:: Additional Process Information
70b88761
RP
1339@end menu
1340
1341@node Compilation, Starting, Running, Running
1342@section Compiling for Debugging
1343
1344In order to debug a program effectively, you need to generate
1345debugging information when you compile it. This debugging information
1346is stored in the object file; it describes the data type of each
1347variable or function and the correspondence between source line numbers
1348and addresses in the executable code.
1349
1350To request debugging information, specify the @samp{-g} option when you run
1351the compiler.
1352
1353Many C compilers are unable to handle the @samp{-g} and @samp{-O}
1354options together. Using those compilers, you cannot generate optimized
1355executables containing debugging information.
1356
c7cb8acb
RP
1357_GCC__, the GNU C compiler, supports @samp{-g} with or without
1358@samp{-O}, making it possible to debug optimized code. We recommend
1359that you @emph{always} use @samp{-g} whenever you compile a program.
1360You may think your program is correct, but there is no sense in pushing
1361your luck.
70b88761 1362
6ca72cc6
RP
1363@cindex optimized code, debugging
1364@cindex debugging optimized code
1365When you debug a program compiled with @samp{-g -O}, remember that the
1366optimizer is rearranging your code; the debugger will show you what's
1367really there. Don't be too surprised when the execution path doesn't
1368exactly match your source file! An extreme example: if you define a
1369variable, but never use it, _GDBN__ will never see that
1370variable---because the compiler optimizes it out of existence.
1371
70b88761
RP
1372Some things do not work as well with @samp{-g -O} as with just
1373@samp{-g}, particularly on machines with instruction scheduling. If in
1374doubt, recompile with @samp{-g} alone, and if this fixes the problem,
1375please report it as a bug (including a test case!).
1376
1377Older versions of the GNU C compiler permitted a variant option
c7cb8acb 1378@w{@samp{-gg}} for debugging information. _GDBN__ no longer supports this
70b88761
RP
1379format; if your GNU C compiler has this option, do not use it.
1380
1381@ignore
1382@comment As far as I know, there are no cases in which _GDBN__ will
1383@comment produce strange output in this case. (but no promises).
1384If your program includes archives made with the @code{ar} program, and
1385if the object files used as input to @code{ar} were compiled without the
1386@samp{-g} option and have names longer than 15 characters, _GDBN__ will get
29a2b744 1387confused reading your program's symbol table. No error message will be
70b88761
RP
1388given, but _GDBN__ may behave strangely. The reason for this problem is a
1389deficiency in the Unix archive file format, which cannot represent file
1390names longer than 15 characters.
1391
1392To avoid this problem, compile the archive members with the @samp{-g}
1393option or use shorter file names. Alternatively, use a version of GNU
1394@code{ar} dated more recently than August 1989.
1395@end ignore
1396
70b88761
RP
1397@node Starting, Arguments, Compilation, Running
1398@section Starting your Program
1399@cindex starting
1400@cindex running
1041a570 1401
70b88761
RP
1402@table @code
1403@item run
1404@itemx r
1405@kindex run
1041a570
RP
1406Use the @code{run} command to start your program under _GDBN__. You must
1407first specify the program name
e251e767 1408_if__(_VXWORKS__)
7463aadd 1409(except on VxWorks)
70b88761 1410_fi__(_VXWORKS__)
1041a570
RP
1411with an argument to
1412_GDBN__ (@pxref{Invocation, ,Getting In and Out of _GDBN__}), or by using the
1413@code{file} or @code{exec-file} command (@pxref{Files, ,Commands to
1414Specify Files}).
1415
70b88761
RP
1416@end table
1417
29a2b744
RP
1418If you are running your program in an execution environment that
1419supports processes, @code{run} creates an inferior process and makes
1420that process run your program. (In environments without processes,
1421@code{run} jumps to the start of your program.)
70b88761
RP
1422
1423The execution of a program is affected by certain information it
1424receives from its superior. _GDBN__ provides ways to specify this
6ca72cc6 1425information, which you must do @emph{before} starting your program. (You
29a2b744
RP
1426can change it after starting your program, but such changes will only affect
1427your program the next time you start it.) This information may be
70b88761
RP
1428divided into four categories:
1429
1430@table @asis
6ca72cc6 1431@item The @emph{arguments.}
29a2b744 1432Specify the arguments to give your program as the arguments of the
1041a570
RP
1433@code{run} command. If a shell is available on your target, the shell
1434is used to pass the arguments, so that you may use normal conventions
1435(such as wildcard expansion or variable substitution) in describing
1436the arguments. In Unix systems, you can control which shell is used
1437with the @code{SHELL} environment variable. @xref{Arguments, ,Your
1438Program's Arguments}.
70b88761 1439
6ca72cc6 1440@item The @emph{environment.}
70b88761
RP
1441Your program normally inherits its environment from _GDBN__, but you can
1442use the _GDBN__ commands @code{set environment} and @code{unset
1443environment} to change parts of the environment that will be given to
1041a570 1444your program. @xref{Environment, ,Your Program's Environment}.
70b88761 1445
6ca72cc6 1446@item The @emph{working directory.}
70b88761
RP
1447Your program inherits its working directory from _GDBN__. You can set
1448_GDBN__'s working directory with the @code{cd} command in _GDBN__.
29a2b744 1449@xref{Working Directory, ,Your Program's Working Directory}.
70b88761 1450
6ca72cc6 1451@item The @emph{standard input and output.}
70b88761
RP
1452Your program normally uses the same device for standard input and
1453standard output as _GDBN__ is using. You can redirect input and output
1454in the @code{run} command line, or you can use the @code{tty} command to
1455set a different device for your program.
1041a570 1456@xref{Input/Output, ,Your Program's Input and Output}.
3d3ab540
RP
1457
1458@cindex pipes
29a2b744
RP
1459@emph{Warning:} While input and output redirection work, you cannot use
1460pipes to pass the output of the program you are debugging to another
3d3ab540
RP
1461program; if you attempt this, _GDBN__ is likely to wind up debugging the
1462wrong program.
70b88761
RP
1463@end table
1464
29a2b744 1465@c FIXME: Rewrite following paragraph, especially its third sentence.
1041a570
RP
1466When you issue the @code{run} command, your program begins to execute
1467immediately. @xref{Stopping, ,Stopping and Continuing}, for
29a2b744
RP
1468discussion of how to arrange for your program to stop. Once your
1469program has been started by the @code{run} command (and then stopped),
1041a570
RP
1470you may evaluate expressions that involve calls to functions in your
1471program, using the @code{print} or @code{call} commands. @xref{Data,
1472,Examining Data}.
70b88761 1473
29a2b744 1474If the modification time of your symbol file has changed since the
1041a570
RP
1475last time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and
1476re-read it. When it does this, _GDBN__ tries to retain your current
1477breakpoints.
70b88761
RP
1478
1479@node Arguments, Environment, Starting, Running
1480@section Your Program's Arguments
1481
1482@cindex arguments (to your program)
1483The arguments to your program can be specified by the arguments of the
1484@code{run} command. They are passed to a shell, which expands wildcard
29a2b744 1485characters and performs redirection of I/O, and thence to your program.
70b88761
RP
1486_GDBN__ uses the shell indicated by your environment variable
1487@code{SHELL} if it exists; otherwise, _GDBN__ uses @code{/bin/sh}.
1488
1489@code{run} with no arguments uses the same arguments used by the previous
1490@code{run}, or those set by the @code{set args} command.
1491
1492@kindex set args
1493@table @code
1494@item set args
1495Specify the arguments to be used the next time your program is run. If
1496@code{set args} has no arguments, @code{run} will execute your program
e251e767 1497with no arguments. Once you have run your program with arguments,
70b88761
RP
1498using @code{set args} before the next @code{run} is the only way to run
1499it again without arguments.
1500
1501@item show args
1502@kindex show args
1503Show the arguments to give your program when it is started.
1504@end table
1505
1506@node Environment, Working Directory, Arguments, Running
1507@section Your Program's Environment
1508
1509@cindex environment (of your program)
1510The @dfn{environment} consists of a set of environment variables and
1511their values. Environment variables conventionally record such things as
1512your user name, your home directory, your terminal type, and your search
1513path for programs to run. Usually you set up environment variables with
1514the shell and they are inherited by all the other programs you run. When
29a2b744 1515debugging, it can be useful to try running your program with a modified
70b88761
RP
1516environment without having to start _GDBN__ over again.
1517
1518@table @code
1519@item path @var{directory}
1520@kindex path
1521Add @var{directory} to the front of the @code{PATH} environment variable
1522(the search path for executables), for both _GDBN__ and your program.
1523You may specify several directory names, separated by @samp{:} or
1524whitespace. If @var{directory} is already in the path, it is moved to
e251e767 1525the front, so it will be searched sooner.
7463aadd
RP
1526
1527You can use the string @samp{$cwd} to refer to whatever is the current
1528working directory at the time _GDBN__ searches the path. If you use
1529@samp{.} instead, it refers to the directory where you executed the
1530@code{path} command. _GDBN__ fills in the current path where needed in
1531the @var{directory} argument, before adding it to the search path.
29a2b744 1532@c 'path' is explicitly nonrepeatable, but RMS points out it is silly to
70b88761
RP
1533@c document that, since repeating it would be a no-op.
1534
1535@item show paths
1536@kindex show paths
1537Display the list of search paths for executables (the @code{PATH}
1538environment variable).
1539
1540@item show environment @r{[}@var{varname}@r{]}
1541@kindex show environment
1542Print the value of environment variable @var{varname} to be given to
29a2b744 1543your program when it starts. If you do not supply @var{varname},
70b88761
RP
1544print the names and values of all environment variables to be given to
1545your program. You can abbreviate @code{environment} as @code{env}.
1546
7463aadd 1547@item set environment @var{varname} @r{[}=@r{]} @var{value}
70b88761
RP
1548@kindex set environment
1549Sets environment variable @var{varname} to @var{value}. The value
1550changes for your program only, not for _GDBN__ itself. @var{value} may
1551be any string; the values of environment variables are just strings, and
1552any interpretation is supplied by your program itself. The @var{value}
1553parameter is optional; if it is eliminated, the variable is set to a
1554null value.
29a2b744 1555@c "any string" here does not include leading, trailing
70b88761
RP
1556@c blanks. Gnu asks: does anyone care?
1557
1558For example, this command:
1559
1560@example
1561set env USER = foo
1562@end example
1563
1564@noindent
1565tells a Unix program, when subsequently run, that its user is named
1566@samp{foo}. (The spaces around @samp{=} are used for clarity here; they
1567are not actually required.)
1568
1569@item unset environment @var{varname}
1570@kindex unset environment
1571Remove variable @var{varname} from the environment to be passed to your
1572program. This is different from @samp{set env @var{varname} =};
1573@code{unset environment} removes the variable from the environment,
e251e767 1574rather than assigning it an empty value.
70b88761
RP
1575@end table
1576
1577@node Working Directory, Input/Output, Environment, Running
1578@section Your Program's Working Directory
1579
1580@cindex working directory (of your program)
1581Each time you start your program with @code{run}, it inherits its
1582working directory from the current working directory of _GDBN__. _GDBN__'s
1583working directory is initially whatever it inherited from its parent
1584process (typically the shell), but you can specify a new working
1585directory in _GDBN__ with the @code{cd} command.
1586
1587The _GDBN__ working directory also serves as a default for the commands
1041a570
RP
1588that specify files for _GDBN__ to operate on. @xref{Files, ,Commands to
1589Specify Files}.
70b88761
RP
1590
1591@table @code
1592@item cd @var{directory}
1593@kindex cd
1594Set _GDBN__'s working directory to @var{directory}.
1595
1596@item pwd
1597@kindex pwd
1598Print _GDBN__'s working directory.
1599@end table
1600
1601@node Input/Output, Attach, Working Directory, Running
1602@section Your Program's Input and Output
1603
1604@cindex redirection
1605@cindex i/o
1606@cindex terminal
1607By default, the program you run under _GDBN__ does input and output to
1608the same terminal that _GDBN__ uses. _GDBN__ switches the terminal to
1609its own terminal modes to interact with you, but it records the terminal
1610modes your program was using and switches back to them when you continue
1611running your program.
1612
1613@table @code
1614@item info terminal
1615@kindex info terminal
1616Displays _GDBN__'s recorded information about the terminal modes your
1617program is using.
1618@end table
1619
29a2b744 1620You can redirect your program's input and/or output using shell
70b88761
RP
1621redirection with the @code{run} command. For example,
1622
1623_0__@example
1624run > outfile
1625_1__@end example
1626
1627@noindent
29a2b744 1628starts your program, diverting its output to the file @file{outfile}.
70b88761
RP
1629
1630@kindex tty
1631@cindex controlling terminal
29a2b744 1632Another way to specify where your program should do input and output is
70b88761
RP
1633with the @code{tty} command. This command accepts a file name as
1634argument, and causes this file to be the default for future @code{run}
1635commands. It also resets the controlling terminal for the child
1636process, for future @code{run} commands. For example,
1637
1638@example
1639tty /dev/ttyb
1640@end example
1641
1642@noindent
1643directs that processes started with subsequent @code{run} commands
1644default to do input and output on the terminal @file{/dev/ttyb} and have
1645that as their controlling terminal.
1646
1647An explicit redirection in @code{run} overrides the @code{tty} command's
1648effect on the input/output device, but not its effect on the controlling
1649terminal.
1650
1651When you use the @code{tty} command or redirect input in the @code{run}
1652command, only the input @emph{for your program} is affected. The input
1653for _GDBN__ still comes from your terminal.
1654
1655@node Attach, Kill Process, Input/Output, Running
1656@section Debugging an Already-Running Process
1657@kindex attach
1658@cindex attach
1659
1660@table @code
1661@item attach @var{process-id}
1662This command
1663attaches to a running process---one that was started outside _GDBN__.
1664(@code{info files} will show your active targets.) The command takes as
1665argument a process ID. The usual way to find out the process-id of
1666a Unix process is with the @code{ps} utility, or with the @samp{jobs -l}
e251e767 1667shell command.
70b88761
RP
1668
1669@code{attach} will not repeat if you press @key{RET} a second time after
1670executing the command.
1671@end table
1672
1673To use @code{attach}, you must be debugging in an environment which
1674supports processes. You must also have permission to send the process a
1675signal, and it must have the same effective user ID as the _GDBN__
1676process.
1677
1678When using @code{attach}, you should first use the @code{file} command
1679to specify the program running in the process and load its symbol table.
29a2b744 1680@xref{Files, ,Commands to Specify Files}.
70b88761
RP
1681
1682The first thing _GDBN__ does after arranging to debug the specified
1683process is to stop it. You can examine and modify an attached process
1684with all the _GDBN__ commands that are ordinarily available when you start
1685processes with @code{run}. You can insert breakpoints; you can step and
1686continue; you can modify storage. If you would rather the process
1687continue running, you may use the @code{continue} command after
1688attaching _GDBN__ to the process.
1689
1690@table @code
1691@item detach
1692@kindex detach
1693When you have finished debugging the attached process, you can use the
1694@code{detach} command to release it from _GDBN__'s control. Detaching
1695the process continues its execution. After the @code{detach} command,
1696that process and _GDBN__ become completely independent once more, and you
1697are ready to @code{attach} another process or start one with @code{run}.
1698@code{detach} will not repeat if you press @key{RET} again after
1699executing the command.
1700@end table
1701
1702If you exit _GDBN__ or use the @code{run} command while you have an attached
1703process, you kill that process. By default, you will be asked for
1704confirmation if you try to do either of these things; you can control
1705whether or not you need to confirm by using the @code{set confirm} command
29a2b744 1706(@pxref{Messages/Warnings, ,Optional Warnings and Messages}).
70b88761 1707
d24e0922 1708@node Kill Process, Process Information, Attach, Running
70b88761
RP
1709@c @group
1710@section Killing the Child Process
1711
1712@table @code
1713@item kill
1714@kindex kill
1715Kill the child process in which your program is running under _GDBN__.
1716@end table
1717
1718This command is useful if you wish to debug a core dump instead of a
1719running process. _GDBN__ ignores any core dump file while your program
1720is running.
1721@c @end group
1722
29a2b744 1723On some operating systems, a program cannot be executed outside _GDBN__
70b88761 1724while you have breakpoints set on it inside _GDBN__. You can use the
29a2b744 1725@code{kill} command in this situation to permit running your program
70b88761
RP
1726outside the debugger.
1727
1728The @code{kill} command is also useful if you wish to recompile and
29a2b744 1729relink your program, since on many systems it is impossible to modify an
70b88761
RP
1730executable file while it is running in a process. In this case, when you
1731next type @code{run}, _GDBN__ will notice that the file has changed, and
1732will re-read the symbol table (while trying to preserve your current
1733breakpoint settings).
1734
d24e0922
RP
1735@node Process Information, , Kill Process, Running
1736@section Additional Process Information
1737
1738@kindex /proc
1739@cindex process image
1740Some operating systems provide a facility called @samp{/proc} that can
cc9bc574
RP
1741be used to examine the image of a running process using file-system
1742subroutines. If _GDBN__ is configured for an operating system with this
1743facility, the command @code{info proc} is available to report on several
1744kinds of information about the process running your program.
d24e0922
RP
1745
1746@table @code
1747@item info proc
1748@kindex info proc
1749Summarize available information about the process.
1750
1751@item info proc mappings
1752@kindex info proc mappings
1753Report on the address ranges accessible in the program, with information
1754on whether your program may read, write, or execute each range.
1755
1756@item info proc times
1757@kindex info proc times
1758Starting time, user CPU time, and system CPU time for your program and
1759its children.
1760
1761@item info proc id
1762@kindex info proc id
1763Report on the process ID's related to your program: its own process id,
1764the id of its parent, the process group id, and the session id.
1765
1766@item info proc status
1767@kindex info proc status
1768General information on the state of the process. If the process is
1769stopped, this report includes the reason for stopping, and any signal
1770received.
cc9bc574
RP
1771
1772@item info proc all
1773Show all the above information about the process.
d24e0922
RP
1774@end table
1775
70b88761
RP
1776@node Stopping, Stack, Running, Top
1777@chapter Stopping and Continuing
1778
1779The principal purpose of using a debugger is so that you can stop your
29a2b744 1780program before it terminates; or so that, if your program runs into
70b88761
RP
1781trouble, you can investigate and find out why.
1782
1783Inside _GDBN__, your program may stop for any of several reasons, such
1784as a signal, a breakpoint, or reaching a new line after a _GDBN__
1785command such as @code{step}. You may then examine and change
1786variables, set new breakpoints or remove old ones, and then continue
1787execution. Usually, the messages shown by _GDBN__ provide ample
1788explanation of the status of your program---but you can also explicitly
1789request this information at any time.
1790
1791@table @code
1792@item info program
1793@kindex info program
1794Display information about the status of your program: whether it is
1795running or not, what process it is, and why it stopped.
1796@end table
1797
1798@menu
b80282d5
RP
1799* Breakpoints:: Breakpoints, Watchpoints, and Exceptions
1800* Continuing and Stepping:: Resuming Execution
1801* Signals:: Signals
70b88761
RP
1802@end menu
1803
3d3ab540 1804@node Breakpoints, Continuing and Stepping, Stopping, Stopping
70b88761
RP
1805@section Breakpoints, Watchpoints, and Exceptions
1806
1807@cindex breakpoints
1808A @dfn{breakpoint} makes your program stop whenever a certain point in
1041a570 1809the program is reached. For each breakpoint, you can add various
29a2b744 1810conditions to control in finer detail whether your program will stop.
70b88761 1811You can set breakpoints with the @code{break} command and its variants
29a2b744
RP
1812(@pxref{Set Breaks, ,Setting Breakpoints}), to specify the place where
1813your program should stop by line number, function name or exact address
1041a570 1814in the program. In languages with exception handling (such as GNU
29a2b744 1815C++), you can also set breakpoints where an exception is raised
1041a570 1816(@pxref{Exception Handling, ,Breakpoints and Exceptions}).
70b88761
RP
1817
1818@cindex watchpoints
6ca72cc6
RP
1819@cindex memory tracing
1820@cindex breakpoint on memory address
1821@cindex breakpoint on variable modification
29a2b744
RP
1822A @dfn{watchpoint} is a special breakpoint that stops your program
1823when the value of an expression changes. You must use a different
1824command to set watchpoints (@pxref{Set Watchpoints, ,Setting
1825Watchpoints}), but aside from that, you can manage a watchpoint like
1826any other breakpoint: you enable, disable, and delete both breakpoints
1041a570 1827and watchpoints using the same commands.
70b88761 1828
6ca72cc6
RP
1829@cindex breakpoint numbers
1830@cindex numbers for breakpoints
1831_GDBN__ assigns a number to each breakpoint or watchpoint when you
1832create it; these numbers are successive integers starting with one. In
1833many of the commands for controlling various features of breakpoints you
1834use the breakpoint number to say which breakpoint you want to change.
1835Each breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has
29a2b744 1836no effect on your program until you enable it again.
70b88761
RP
1837
1838@menu
b80282d5
RP
1839* Set Breaks:: Setting Breakpoints
1840* Set Watchpoints:: Setting Watchpoints
1841* Exception Handling:: Breakpoints and Exceptions
1842* Delete Breaks:: Deleting Breakpoints
1843* Disabling:: Disabling Breakpoints
1844* Conditions:: Break Conditions
1845* Break Commands:: Breakpoint Command Lists
1846* Breakpoint Menus:: Breakpoint Menus
e251e767 1847* Error in Breakpoints::
70b88761
RP
1848@end menu
1849
1850@node Set Breaks, Set Watchpoints, Breakpoints, Breakpoints
1851@subsection Setting Breakpoints
1852
4906534f
RP
1853@c FIXME LMB what does GDB do if no code on line of breakpt?
1854@c consider in particular declaration with/without initialization.
1855@c
1856@c FIXME 2 is there stuff on this already? break at fun start, already init?
1857
70b88761
RP
1858@kindex break
1859@kindex b
6ca72cc6
RP
1860@kindex $bpnum
1861@cindex latest breakpoint
1862Breakpoints are set with the @code{break} command (abbreviated
1863@code{b}). The debugger convenience variable @samp{$bpnum} records the
1864number of the beakpoint you've set most recently; see @ref{Convenience
d24e0922 1865Vars,, Convenience Variables}, for a discussion of what you can do with
6ca72cc6 1866convenience variables.
70b88761
RP
1867
1868You have several ways to say where the breakpoint should go.
1869
1870@table @code
1871@item break @var{function}
1872Set a breakpoint at entry to function @var{function}. When using source
1873languages that permit overloading of symbols, such as C++,
1874@var{function} may refer to more than one possible place to break.
1875@xref{Breakpoint Menus}, for a discussion of that situation.
1876
1877@item break +@var{offset}
1878@itemx break -@var{offset}
1879Set a breakpoint some number of lines forward or back from the position
1880at which execution stopped in the currently selected frame.
1881
1882@item break @var{linenum}
1883Set a breakpoint at line @var{linenum} in the current source file.
1884That file is the last file whose source text was printed. This
29a2b744 1885breakpoint will stop your program just before it executes any of the
70b88761
RP
1886code on that line.
1887
1888@item break @var{filename}:@var{linenum}
1889Set a breakpoint at line @var{linenum} in source file @var{filename}.
1890
1891@item break @var{filename}:@var{function}
1892Set a breakpoint at entry to function @var{function} found in file
1893@var{filename}. Specifying a file name as well as a function name is
1894superfluous except when multiple files contain similarly named
1895functions.
1896
1897@item break *@var{address}
1898Set a breakpoint at address @var{address}. You can use this to set
29a2b744 1899breakpoints in parts of your program which do not have debugging
70b88761
RP
1900information or source files.
1901
1902@item break
29a2b744
RP
1903When called without any arguments, @code{break} sets a breakpoint at
1904the next instruction to be executed in the selected stack frame
1905(@pxref{Stack, ,Examining the Stack}). In any selected frame but the
1906innermost, this will cause your program to stop as soon as control
1907returns to that frame. This is similar to the effect of a
1908@code{finish} command in the frame inside the selected frame---except
1909that @code{finish} does not leave an active breakpoint. If you use
1041a570
RP
1910@code{break} without an argument in the innermost frame, _GDBN__ will stop
1911the next time it reaches the current location; this may be useful
1912inside loops.
70b88761
RP
1913
1914_GDBN__ normally ignores breakpoints when it resumes execution, until at
1915least one instruction has been executed. If it did not do this, you
1916would be unable to proceed past a breakpoint without first disabling the
1917breakpoint. This rule applies whether or not the breakpoint already
29a2b744 1918existed when your program stopped.
70b88761
RP
1919
1920@item break @dots{} if @var{cond}
1921Set a breakpoint with condition @var{cond}; evaluate the expression
1922@var{cond} each time the breakpoint is reached, and stop only if the
3d3ab540 1923value is nonzero---that is, if @var{cond} evaluates as true.
1041a570
RP
1924@samp{@dots{}} stands for one of the possible arguments described
1925above (or no argument) specifying where to break. @xref{Conditions,
1926,Break Conditions}, for more information on breakpoint conditions.
70b88761
RP
1927
1928@item tbreak @var{args}
1929@kindex tbreak
1930Set a breakpoint enabled only for one stop. @var{args} are the
1931same as for the @code{break} command, and the breakpoint is set in the same
29a2b744
RP
1932way, but the breakpoint is automatically disabled after the first time your
1933program stops there. @xref{Disabling, ,Disabling Breakpoints}.
70b88761
RP
1934
1935@item rbreak @var{regex}
1936@kindex rbreak
1937@cindex regular expression
4906534f 1938@c FIXME what kind of regexp?
70b88761 1939Set breakpoints on all functions matching the regular expression
b80282d5 1940@var{regex}. This command
70b88761
RP
1941sets an unconditional breakpoint on all matches, printing a list of all
1942breakpoints it set. Once these breakpoints are set, they are treated
1943just like the breakpoints set with the @code{break} command. They can
1944be deleted, disabled, made conditional, etc., in the standard ways.
1945
b80282d5
RP
1946When debugging C++ programs, @code{rbreak} is useful for setting
1947breakpoints on overloaded functions that are not members of any special
1948classes.
1949
70b88761 1950@kindex info breakpoints
c338a2fd 1951@cindex @code{$_} and @code{info breakpoints}
70b88761 1952@item info breakpoints @r{[}@var{n}@r{]}
6ca72cc6
RP
1953@itemx info break @r{[}@var{n}@r{]}
1954@itemx info watchpoints @r{[}@var{n}@r{]}
1955Print a table of all breakpoints and watchpoints set and not
1956deleted, with the following columns for each breakpoint:
1957
1958@table @emph
1959@item Breakpoint Numbers
1960@item Type
1961Breakpoint or watchpoint.
1962@item Disposition
1963Whether the breakpoint is marked to be disabled or deleted when hit.
1964@item Enabled or Disabled
d24e0922 1965Enabled breakpoints are marked with @samp{y}. @samp{n} marks breakpoints
6ca72cc6
RP
1966that are not enabled.
1967@item Address
1968Where the breakpoint is in your program, as a memory address
1969@item What
1970Where the breakpoint is in the source for your program, as a file and
1971line number.
1972@end table
1973
1974@noindent
1975Breakpoint commands, if any, are listed after the line for the
1976corresponding breakpoint.
1977
1978@noindent
1979@code{info break} with a breakpoint
29a2b744
RP
1980number @var{n} as argument lists only that breakpoint. The
1981convenience variable @code{$_} and the default examining-address for
1982the @code{x} command are set to the address of the last breakpoint
6ca72cc6 1983listed (@pxref{Memory, ,Examining Memory}).
1041a570 1984@end table
70b88761 1985
1041a570
RP
1986_GDBN__ allows you to set any number of breakpoints at the same place in
1987your program. There is nothing silly or meaningless about this. When
1988the breakpoints are conditional, this is even useful
29a2b744 1989(@pxref{Conditions, ,Break Conditions}).
70b88761 1990
6ca72cc6
RP
1991@cindex negative breakpoint numbers
1992@cindex internal _GDBN__ breakpoints
1993_GDBN__ itself sometimes sets breakpoints in your program for special
1994purposes, such as proper handling of @code{longjmp} (in C programs).
1995These internal breakpoints are assigned negative numbers, starting with
1996@code{-1}; @samp{info breakpoints} does not display them, but the
1997similar command @samp{info all-breakpoints} does.
1998
1999@table @code
2000@kindex all-breakpoints
2001@item info all-breakpoints
2002Using the same format as @samp{info breakpoints}, display both the
2003breakpoints you've set explicitly, and those _GDBN__ is using for
2004internal purposes. Internal breakpoints are shown with negative
2005breakpoint numbers. The type column identifies what kind of breakpoint
2006is shown:
2007
2008@table @code
2009@item breakpoint
2010Normal, explicitly set breakpoint.
2011
2012@item watchpoint
2013Normal, explicitly set watchpoint.
2014
2015@item longjmp
2016Internal breakpoint, used to handle correctly stepping through
2017@code{longjmp} calls.
2018
2019@item longjmp resume
2020Internal breakpoint at the target of a @code{longjmp}.
2021
2022@item until
2023Temporary internal breakpoint used by the _GDBN__ @code{until} command.
2024
2025@item finish
2026Temporary internal breakpoint used by the _GDBN__ @code{finish} command.
2027@end table
2028
2029@end table
2030
2031
70b88761
RP
2032@node Set Watchpoints, Exception Handling, Set Breaks, Breakpoints
2033@subsection Setting Watchpoints
2034@cindex setting watchpoints
1041a570 2035
70b88761 2036You can use a watchpoint to stop execution whenever the value of an
e251e767 2037expression changes, without having to predict a particular place
70b88761
RP
2038where this may happen.
2039
2040Watchpoints currently execute two orders of magnitude more slowly than
2041other breakpoints, but this can well be worth it to catch errors where
2042you have no clue what part of your program is the culprit. Some
2043processors provide special hardware to support watchpoint evaluation; future
2044releases of _GDBN__ will use such hardware if it is available.
2045
2046@table @code
e251e767 2047@kindex watch
70b88761
RP
2048@item watch @var{expr}
2049Set a watchpoint for an expression.
2050
2051@kindex info watchpoints
2052@item info watchpoints
6ca72cc6
RP
2053This command prints a list of watchpoints and breakpoints; it is the
2054same as @code{info break}.
70b88761
RP
2055@end table
2056
2057@node Exception Handling, Delete Breaks, Set Watchpoints, Breakpoints
2058@subsection Breakpoints and Exceptions
2059@cindex exception handlers
2060
b80282d5 2061Some languages, such as GNU C++, implement exception handling. You can
29a2b744
RP
2062use _GDBN__ to examine what caused your program to raise an exception,
2063and to list the exceptions your program is prepared to handle at a
70b88761
RP
2064given point in time.
2065
2066@table @code
2067@item catch @var{exceptions}
2068@kindex catch
2069You can set breakpoints at active exception handlers by using the
2070@code{catch} command. @var{exceptions} is a list of names of exceptions
2071to catch.
2072@end table
2073
29a2b744
RP
2074You can use @code{info catch} to list active exception handlers.
2075@xref{Frame Info, ,Information About a Frame}.
70b88761
RP
2076
2077There are currently some limitations to exception handling in _GDBN__.
2078These will be corrected in a future release.
2079
2080@itemize @bullet
2081@item
2082If you call a function interactively, _GDBN__ normally returns
2083control to you when the function has finished executing. If the call
2084raises an exception, however, the call may bypass the mechanism that
29a2b744 2085returns control to you and cause your program to simply continue
70b88761
RP
2086running until it hits a breakpoint, catches a signal that _GDBN__ is
2087listening for, or exits.
2088@item
2089You cannot raise an exception interactively.
2090@item
2091You cannot interactively install an exception handler.
2092@end itemize
2093
2094@cindex raise exceptions
2095Sometimes @code{catch} is not the best way to debug exception handling:
29a2b744 2096if you need to know exactly where an exception is raised, it is better to
70b88761
RP
2097stop @emph{before} the exception handler is called, since that way you
2098can see the stack before any unwinding takes place. If you set a
2099breakpoint in an exception handler instead, it may not be easy to find
2100out where the exception was raised.
2101
2102To stop just before an exception handler is called, you need some
b80282d5 2103knowledge of the implementation. In the case of GNU C++, exceptions are
70b88761
RP
2104raised by calling a library function named @code{__raise_exception}
2105which has the following ANSI C interface:
2106
2107@example
b80282d5 2108 /* @var{addr} is where the exception identifier is stored.
70b88761
RP
2109 ID is the exception identifier. */
2110 void __raise_exception (void **@var{addr}, void *@var{id});
2111@end example
2112
2113@noindent
2114To make the debugger catch all exceptions before any stack
2115unwinding takes place, set a breakpoint on @code{__raise_exception}
29a2b744 2116(@pxref{Breakpoints, ,Breakpoints Watchpoints and Exceptions}).
70b88761 2117
29a2b744
RP
2118With a conditional breakpoint (@pxref{Conditions, ,Break Conditions})
2119that depends on the value of @var{id}, you can stop your program when
2120a specific exception is raised. You can use multiple conditional
2121breakpoints to stop your program when any of a number of exceptions are
2122raised.
70b88761
RP
2123
2124@node Delete Breaks, Disabling, Exception Handling, Breakpoints
2125@subsection Deleting Breakpoints
2126
2127@cindex clearing breakpoints, watchpoints
2128@cindex deleting breakpoints, watchpoints
2129It is often necessary to eliminate a breakpoint or watchpoint once it
29a2b744 2130has done its job and you no longer want your program to stop there. This
70b88761
RP
2131is called @dfn{deleting} the breakpoint. A breakpoint that has been
2132deleted no longer exists; it is forgotten.
2133
2134With the @code{clear} command you can delete breakpoints according to
29a2b744 2135where they are in your program. With the @code{delete} command you can
70b88761
RP
2136delete individual breakpoints or watchpoints by specifying their
2137breakpoint numbers.
2138
2139It is not necessary to delete a breakpoint to proceed past it. _GDBN__
2140automatically ignores breakpoints on the first instruction to be executed
2141when you continue execution without changing the execution address.
2142
2143@table @code
2144@item clear
2145@kindex clear
2146Delete any breakpoints at the next instruction to be executed in the
29a2b744
RP
2147selected stack frame (@pxref{Selection, ,Selecting a Frame}). When
2148the innermost frame is selected, this is a good way to delete a
2149breakpoint where your program just stopped.
70b88761
RP
2150
2151@item clear @var{function}
2152@itemx clear @var{filename}:@var{function}
2153Delete any breakpoints set at entry to the function @var{function}.
2154
2155@item clear @var{linenum}
2156@itemx clear @var{filename}:@var{linenum}
2157Delete any breakpoints set at or within the code of the specified line.
2158
2159@item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
2160@cindex delete breakpoints
2161@kindex delete
2162@kindex d
2163Delete the breakpoints or watchpoints of the numbers specified as
2164arguments. If no argument is specified, delete all breakpoints (_GDBN__
1041a570 2165asks confirmation, unless you have @code{set confirm off}). You
70b88761
RP
2166can abbreviate this command as @code{d}.
2167@end table
2168
2169@node Disabling, Conditions, Delete Breaks, Breakpoints
2170@subsection Disabling Breakpoints
2171
2172@cindex disabled breakpoints
2173@cindex enabled breakpoints
2174Rather than deleting a breakpoint or watchpoint, you might prefer to
2175@dfn{disable} it. This makes the breakpoint inoperative as if it had
2176been deleted, but remembers the information on the breakpoint so that
2177you can @dfn{enable} it again later.
2178
2179You disable and enable breakpoints and watchpoints with the
2180@code{enable} and @code{disable} commands, optionally specifying one or
2181more breakpoint numbers as arguments. Use @code{info break} or
2182@code{info watch} to print a list of breakpoints or watchpoints if you
29a2b744 2183do not know which numbers to use.
70b88761
RP
2184
2185A breakpoint or watchpoint can have any of four different states of
2186enablement:
2187
2188@itemize @bullet
2189@item
29a2b744 2190Enabled. The breakpoint will stop your program. A breakpoint set
70b88761
RP
2191with the @code{break} command starts out in this state.
2192@item
29a2b744 2193Disabled. The breakpoint has no effect on your program.
70b88761 2194@item
29a2b744 2195Enabled once. The breakpoint will stop your program, but
70b88761
RP
2196when it does so it will become disabled. A breakpoint set
2197with the @code{tbreak} command starts out in this state.
2198@item
29a2b744 2199Enabled for deletion. The breakpoint will stop your program, but
70b88761
RP
2200immediately after it does so it will be deleted permanently.
2201@end itemize
2202
2203You can use the following commands to enable or disable breakpoints and
2204watchpoints:
2205
2206@table @code
2207@item disable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
2208@kindex disable breakpoints
2209@kindex disable
2210@kindex dis
2211Disable the specified breakpoints---or all breakpoints, if none are
2212listed. A disabled breakpoint has no effect but is not forgotten. All
2213options such as ignore-counts, conditions and commands are remembered in
2214case the breakpoint is enabled again later. You may abbreviate
2215@code{disable} as @code{dis}.
2216
2217@item enable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
2218@kindex enable breakpoints
2219@kindex enable
2220Enable the specified breakpoints (or all defined breakpoints). They
29a2b744 2221become effective once again in stopping your program.
70b88761
RP
2222
2223@item enable @r{[}breakpoints@r{]} once @var{bnums}@dots{}
2224Enable the specified breakpoints temporarily. Each will be disabled
29a2b744 2225again the next time it stops your program.
70b88761
RP
2226
2227@item enable @r{[}breakpoints@r{]} delete @var{bnums}@dots{}
2228Enable the specified breakpoints to work once and then die. Each of
29a2b744 2229the breakpoints will be deleted the next time it stops your program.
70b88761
RP
2230@end table
2231
29a2b744
RP
2232Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks,
2233,Setting Breakpoints}), breakpoints that you set are initially
2234enabled; subsequently, they become disabled or enabled only when you
2235use one of the commands above. (The command @code{until} can set and
2236delete a breakpoint of its own, but it will not change the state of
98fe4566 2237your other breakpoints; see @ref{Continuing and Stepping, ,Continuing and Stepping}.)
70b88761
RP
2238
2239@node Conditions, Break Commands, Disabling, Breakpoints
2240@subsection Break Conditions
2241@cindex conditional breakpoints
2242@cindex breakpoint conditions
2243
4906534f
RP
2244@c FIXME what is scope of break condition expr? Context where wanted?
2245@c in particular for a watchpoint?
29a2b744 2246The simplest sort of breakpoint breaks every time your program reaches a
70b88761
RP
2247specified place. You can also specify a @dfn{condition} for a
2248breakpoint. A condition is just a Boolean expression in your
1041a570
RP
2249programming language (@pxref{Expressions, ,Expressions}). A breakpoint with
2250a condition evaluates the expression each time your program reaches it,
2251and your program stops only if the condition is @emph{true}.
3d3ab540
RP
2252
2253This is the converse of using assertions for program validation; in that
2254situation, you want to stop when the assertion is violated---that is,
2255when the condition is false. In C, if you want to test an assertion expressed
e251e767 2256by the condition @var{assert}, you should set the condition
3d3ab540 2257@samp{! @var{assert}} on the appropriate breakpoint.
70b88761
RP
2258
2259Conditions are also accepted for watchpoints; you may not need them,
2260since a watchpoint is inspecting the value of an expression anyhow---but
2261it might be simpler, say, to just set a watchpoint on a variable name,
2262and specify a condition that tests whether the new value is an interesting
e251e767 2263one.
70b88761 2264
29a2b744 2265Break conditions can have side effects, and may even call functions in
70b88761 2266your program. This can be useful, for example, to activate functions
29a2b744
RP
2267that log program progress, or to use your own print functions to
2268format special data structures. The effects are completely predictable
2269unless there is another enabled breakpoint at the same address. (In
2270that case, _GDBN__ might see the other breakpoint first and stop your
2271program without checking the condition of this one.) Note that
2272breakpoint commands are usually more convenient and flexible for the
2273purpose of performing side effects when a breakpoint is reached
2274(@pxref{Break Commands, ,Breakpoint Command Lists}).
70b88761
RP
2275
2276Break conditions can be specified when a breakpoint is set, by using
29a2b744
RP
2277@samp{if} in the arguments to the @code{break} command. @xref{Set
2278Breaks, ,Setting Breakpoints}. They can also be changed at any time
2279with the @code{condition} command. The @code{watch} command does not
2280recognize the @code{if} keyword; @code{condition} is the only way to
2281impose a further condition on a watchpoint.
70b88761 2282
e251e767
RP
2283@table @code
2284@item condition @var{bnum} @var{expression}
2285@kindex condition
70b88761
RP
2286Specify @var{expression} as the break condition for breakpoint or
2287watchpoint number @var{bnum}. From now on, this breakpoint will stop
29a2b744 2288your program only if the value of @var{expression} is true (nonzero, in
70b88761
RP
2289C). When you use @code{condition}, _GDBN__ checks @var{expression}
2290immediately for syntactic correctness, and to determine whether symbols
1041a570 2291in it have referents in the context of your breakpoint.
29a2b744 2292@c FIXME so what does GDB do if there is no referent? Moreover, what
4906534f
RP
2293@c about watchpoints?
2294_GDBN__ does
70b88761 2295not actually evaluate @var{expression} at the time the @code{condition}
1041a570 2296command is given, however. @xref{Expressions, ,Expressions}.
70b88761
RP
2297
2298@item condition @var{bnum}
2299Remove the condition from breakpoint number @var{bnum}. It becomes
2300an ordinary unconditional breakpoint.
2301@end table
2302
2303@cindex ignore count (of breakpoint)
2304A special case of a breakpoint condition is to stop only when the
2305breakpoint has been reached a certain number of times. This is so
2306useful that there is a special way to do it, using the @dfn{ignore
2307count} of the breakpoint. Every breakpoint has an ignore count, which
2308is an integer. Most of the time, the ignore count is zero, and
29a2b744 2309therefore has no effect. But if your program reaches a breakpoint whose
70b88761
RP
2310ignore count is positive, then instead of stopping, it just decrements
2311the ignore count by one and continues. As a result, if the ignore count
2312value is @var{n}, the breakpoint will not stop the next @var{n} times it
2313is reached.
2314
2315@table @code
2316@item ignore @var{bnum} @var{count}
2317@kindex ignore
2318Set the ignore count of breakpoint number @var{bnum} to @var{count}.
2319The next @var{count} times the breakpoint is reached, your program's
2320execution will not stop; other than to decrement the ignore count, _GDBN__
2321takes no action.
2322
2323To make the breakpoint stop the next time it is reached, specify
2324a count of zero.
2325
2326@item continue @var{count}
2327@itemx c @var{count}
2328@itemx fg @var{count}
2329@kindex continue @var{count}
29a2b744
RP
2330Continue execution of your program, setting the ignore count of the
2331breakpoint where your program stopped to @var{count} minus one.
2332Thus, your program will not stop at this breakpoint until the
70b88761
RP
2333@var{count}'th time it is reached.
2334
29a2b744 2335An argument to this command is meaningful only when your program stopped
70b88761
RP
2336due to a breakpoint. At other times, the argument to @code{continue} is
2337ignored.
2338
2339The synonym @code{fg} is provided purely for convenience, and has
2340exactly the same behavior as other forms of the command.
2341@end table
2342
2343If a breakpoint has a positive ignore count and a condition, the condition
2344is not checked. Once the ignore count reaches zero, the condition will
2345be checked.
2346
29a2b744 2347You could achieve the effect of the ignore count with a condition such
1041a570
RP
2348as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience variable that
2349is decremented each time. @xref{Convenience Vars, ,Convenience
2350Variables}.
70b88761
RP
2351
2352@node Break Commands, Breakpoint Menus, Conditions, Breakpoints
2353@subsection Breakpoint Command Lists
2354
2355@cindex breakpoint commands
2356You can give any breakpoint (or watchpoint) a series of commands to
29a2b744 2357execute when your program stops due to that breakpoint. For example, you
70b88761
RP
2358might want to print the values of certain expressions, or enable other
2359breakpoints.
2360
2361@table @code
2362@item commands @r{[}@var{bnum}@r{]}
2363@itemx @dots{} @var{command-list} @dots{}
2364@itemx end
2365@kindex commands
2366@kindex end
2367Specify a list of commands for breakpoint number @var{bnum}. The commands
2368themselves appear on the following lines. Type a line containing just
2369@code{end} to terminate the commands.
2370
203eea5d
RP
2371To remove all commands from a breakpoint, type @code{commands} and
2372follow it immediately with @code{end}; that is, give no commands.
70b88761
RP
2373
2374With no @var{bnum} argument, @code{commands} refers to the last
2375breakpoint or watchpoint set (not to the breakpoint most recently
2376encountered).
2377@end table
2378
2379Pressing @key{RET} as a means of repeating the last _GDBN__ command is
2380disabled within a @var{command-list}.
2381
29a2b744 2382You can use breakpoint commands to start your program up again. Simply
70b88761
RP
2383use the @code{continue} command, or @code{step}, or any other command
2384that resumes execution. Subsequent commands in the command list are
2385ignored.
2386
2387@kindex silent
2388If the first command specified is @code{silent}, the usual message about
2389stopping at a breakpoint is not printed. This may be desirable for
2390breakpoints that are to print a specific message and then continue.
2391If the remaining commands too print nothing, you will see no sign that
e251e767 2392the breakpoint was reached at all. @code{silent} is meaningful only
70b88761
RP
2393at the beginning of a breakpoint command list.
2394
29a2b744
RP
2395The commands @code{echo} and @code{output} that allow you to print
2396precisely controlled output are often useful in silent breakpoints.
2397@xref{Output, ,Commands for Controlled Output}.
70b88761
RP
2398
2399For example, here is how you could use breakpoint commands to print the
2400value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
2401
2402_0__@example
2403break foo if x>0
2404commands
2405silent
2406echo x is\040
2407output x
2408echo \n
2409cont
2410end
2411_1__@end example
2412
2413One application for breakpoint commands is to compensate for one bug so
2414you can test for another. Put a breakpoint just after the erroneous line
2415of code, give it a condition to detect the case in which something
2416erroneous has been done, and give it commands to assign correct values
2417to any variables that need them. End with the @code{continue} command
29a2b744 2418so that your program does not stop, and start with the @code{silent}
70b88761
RP
2419command so that no output is produced. Here is an example:
2420
2421@example
2422break 403
2423commands
2424silent
2425set x = y + 4
2426cont
2427end
2428@end example
2429
2430@cindex lost output
2431One deficiency in the operation of automatically continuing breakpoints
2432under Unix appears when your program uses raw mode for the terminal.
2433_GDBN__ switches back to its own terminal modes (not raw) before executing
2434commands, and then must switch back to raw mode when your program is
e251e767 2435continued. This causes any pending terminal input to be lost.
70b88761
RP
2436@c FIXME: revisit below when GNU sys avail.
2437@c In the GNU system, this will be fixed by changing the behavior of
2438@c terminal modes.
2439
2440Under Unix, you can get around this problem by writing actions into
2441the breakpoint condition rather than in commands. For example
2442
2443@example
2444condition 5 (x = y + 4), 0
2445@end example
2446
2447@noindent
1041a570
RP
2448specifies a condition expression (@pxref{Expressions, ,Expressions}) that will
2449change @code{x} as needed, then always have the value zero so your
2450program will not stop. No input is lost here, because _GDBN__ evaluates
2451break conditions without changing the terminal modes. When you want
2452to have nontrivial conditions for performing the side effects, the
2453operators @samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful.
70b88761
RP
2454
2455@node Breakpoint Menus, Error in Breakpoints, Break Commands, Breakpoints
2456@subsection Breakpoint Menus
b80282d5 2457@cindex overloading
e251e767 2458@cindex symbol overloading
70b88761
RP
2459
2460Some programming languages (notably C++) permit a single function name
2461to be defined several times, for application in different contexts.
2462This is called @dfn{overloading}. When a function name is overloaded,
2463@samp{break @var{function}} is not enough to tell _GDBN__ where you
2464want a breakpoint. _GDBN__ offers you a menu of numbered choices for
2465different possible breakpoints, and waits for your selection with the
2466prompt @samp{>}. The first two options are always @samp{[0] cancel}
2467and @samp{[1] all}. Typing @kbd{1} sets a breakpoint at each
2468definition of @var{function}, and typing @kbd{0} aborts the
2469@code{break} command without setting any new breakpoints.
2470
2471For example, the following session excerpt shows an attempt to set a
e251e767 2472breakpoint at the overloaded symbol @code{String::after}.
70b88761
RP
2473We choose three particular definitions of that function name:
2474
2475@example
2476(_GDBP__) b String::after
2477[0] cancel
2478[1] all
2479[2] file:String.cc; line number:867
2480[3] file:String.cc; line number:860
2481[4] file:String.cc; line number:875
2482[5] file:String.cc; line number:853
2483[6] file:String.cc; line number:846
2484[7] file:String.cc; line number:735
2485> 2 4 6
2486Breakpoint 1 at 0xb26c: file String.cc, line 867.
2487Breakpoint 2 at 0xb344: file String.cc, line 875.
2488Breakpoint 3 at 0xafcc: file String.cc, line 846.
2489Multiple breakpoints were set.
2490Use the "delete" command to delete unwanted breakpoints.
e251e767 2491(_GDBP__)
70b88761
RP
2492@end example
2493
70b88761
RP
2494@node Error in Breakpoints, , Breakpoint Menus, Breakpoints
2495@subsection ``Cannot Insert Breakpoints''
2496
e251e767 2497@c FIXME: "cannot insert breakpoints" error, v unclear.
70b88761 2498@c Q in pending mail to Gilmore. [email protected], 26mar91
e251e767 2499@c some light may be shed by looking at instances of
d24e0922 2500@c ONE_PROCESS_WRITETEXT. But error message seems possible otherwise
c338a2fd 2501@c too. pesch, 20sep91
70b88761
RP
2502Under some operating systems, breakpoints cannot be used in a program if
2503any other process is running that program. In this situation,
2504attempting to run or continue a program with a breakpoint causes _GDBN__
2505to stop the other process.
2506
2507When this happens, you have three ways to proceed:
2508
2509@enumerate
2510@item
2511Remove or disable the breakpoints, then continue.
2512
2513@item
29a2b744 2514Suspend _GDBN__, and copy the file containing your program to a new name.
70b88761 2515Resume _GDBN__ and use the @code{exec-file} command to specify that _GDBN__
29a2b744 2516should run your program under that name. Then start your program again.
70b88761
RP
2517
2518@c FIXME: RMS commented here "Show example". Maybe when someone
2519@c explains the first FIXME: in this section...
2520
2521@item
29a2b744 2522Relink your program so that the text segment is nonsharable, using the
70b88761
RP
2523linker option @samp{-N}. The operating system limitation may not apply
2524to nonsharable executables.
2525@end enumerate
2526
3d3ab540
RP
2527@node Continuing and Stepping, Signals, Breakpoints, Stopping
2528@section Continuing and Stepping
70b88761
RP
2529
2530@cindex stepping
7463aadd
RP
2531@cindex continuing
2532@cindex resuming execution
3d3ab540 2533@dfn{Continuing} means resuming program execution until your program
cedaf8bc
RP
2534completes normally. In contrast, @dfn{stepping} means executing just
2535one more ``step'' of your program, where ``step'' may mean either one
2536line of source code, or one machine instruction (depending on what
2537particular command you use). Either when continuing
29a2b744 2538or when stepping, your program may stop even sooner, due to a breakpoint
cedaf8bc 2539or to a signal. (If due to a signal, you may want to use @code{handle},
1041a570 2540or use @samp{signal 0} to resume execution. @xref{Signals, ,Signals}.)
3d3ab540
RP
2541
2542@table @code
2543@item continue @r{[}@var{ignore-count}@r{]}
2544@kindex continue
29a2b744 2545Resume program execution, at the address where your program last stopped;
3d3ab540
RP
2546any breakpoints set at that address are bypassed. The optional argument
2547@var{ignore-count} allows you to specify a further number of times to
2548ignore a breakpoint at this location; its effect is like that of
29a2b744 2549@code{ignore} (@pxref{Conditions, ,Break Conditions}).
3d3ab540
RP
2550
2551To resume execution at a different place, you can use @code{return}
29a2b744
RP
2552(@pxref{Returning, ,Returning from a Function}) to go back to the
2553calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a
1041a570 2554Different Address}) to go to an arbitrary location in your program.
3d3ab540 2555@end table
7463aadd
RP
2556
2557A typical technique for using stepping is to set a breakpoint
29a2b744
RP
2558(@pxref{Breakpoints, ,Breakpoints Watchpoints and Exceptions}) at the
2559beginning of the function or the section of your program where a
2560problem is believed to lie, run your program until it stops at that
2561breakpoint, and then step through the suspect area, examining the
2562variables that are interesting, until you see the problem happen.
70b88761
RP
2563
2564@table @code
2565@item step
2566@kindex step
2567@kindex s
29a2b744 2568Continue running your program until control reaches a different source
7463aadd 2569line, then stop it and return control to _GDBN__. This command is
70b88761
RP
2570abbreviated @code{s}.
2571
3d3ab540
RP
2572@quotation
2573@emph{Warning:} If you use the @code{step} command while control is
2574within a function that was compiled without debugging information,
2575execution will proceed until control reaches another function.
2576@end quotation
70b88761
RP
2577
2578@item step @var{count}
2579Continue running as in @code{step}, but do so @var{count} times. If a
2580breakpoint is reached or a signal not related to stepping occurs before
2581@var{count} steps, stepping stops right away.
2582
7463aadd 2583@item next @r{[}@var{count}@r{]}
70b88761
RP
2584@kindex next
2585@kindex n
7463aadd
RP
2586Continue to the next source line in the current (innermost) stack frame.
2587Similar to @code{step}, but any function calls appearing within the line
2588of code are executed without stopping. Execution stops when control
2589reaches a different line of code at the stack level which was executing
2590when the @code{next} command was given. This command is abbreviated
2591@code{n}.
70b88761 2592
7463aadd 2593An argument @var{count} is a repeat count, as for @code{step}.
70b88761
RP
2594
2595@code{next} within a function that lacks debugging information acts like
2596@code{step}, but any function calls appearing within the code of the
2597function are executed without stopping.
2598
2599@item finish
2600@kindex finish
7463aadd
RP
2601Continue running until just after function in the selected stack frame
2602returns. Print the returned value (if any).
70b88761 2603
29a2b744 2604Contrast this with the @code{return} command (@pxref{Returning,
1041a570 2605,Returning from a Function}).
70b88761
RP
2606
2607@item until
2608@kindex until
2609@item u
2610@kindex u
2611Continue running until a source line past the current line, in the
2612current stack frame, is reached. This command is used to avoid single
2613stepping through a loop more than once. It is like the @code{next}
2614command, except that when @code{until} encounters a jump, it
2615automatically continues execution until the program counter is greater
2616than the address of the jump.
2617
2618This means that when you reach the end of a loop after single stepping
29a2b744 2619though it, @code{until} will cause your program to continue execution
70b88761
RP
2620until the loop is exited. In contrast, a @code{next} command at the end
2621of a loop will simply step back to the beginning of the loop, which
2622would force you to step through the next iteration.
2623
29a2b744 2624@code{until} always stops your program if it attempts to exit the current
70b88761
RP
2625stack frame.
2626
2627@code{until} may produce somewhat counterintuitive results if the order
7463aadd 2628of machine code does not match the order of the source lines. For
70b88761
RP
2629example, in the following excerpt from a debugging session, the @code{f}
2630(@code{frame}) command shows that execution is stopped at line
2631@code{206}; yet when we use @code{until}, we get to line @code{195}:
2632
2633@example
2634(_GDBP__) f
2635#0 main (argc=4, argv=0xf7fffae8) at m4.c:206
b80282d5 2636206 expand_input();
70b88761 2637(_GDBP__) until
b80282d5 2638195 for ( ; argc > 0; NEXTARG) @{
70b88761
RP
2639@end example
2640
7463aadd
RP
2641This happened because, for execution efficiency, the compiler had
2642generated code for the loop closure test at the end, rather than the
2643start, of the loop---even though the test in a C @code{for}-loop is
2644written before the body of the loop. The @code{until} command appeared
2645to step back to the beginning of the loop when it advanced to this
2646expression; however, it has not really gone to an earlier
2647statement---not in terms of the actual machine code.
70b88761
RP
2648
2649@code{until} with no argument works by means of single
2650instruction stepping, and hence is slower than @code{until} with an
2651argument.
2652
2653@item until @var{location}
2654@item u @var{location}
29a2b744
RP
2655Continue running your program until either the specified location is
2656reached, or the current stack frame returns. @var{location} is any of
2657the forms of argument acceptable to @code{break} (@pxref{Set Breaks,
2658,Setting Breakpoints}). This form of the command uses breakpoints,
1041a570 2659and hence is quicker than @code{until} without an argument.
70b88761
RP
2660
2661@item stepi
2662@itemx si
2663@kindex stepi
2664@kindex si
2665Execute one machine instruction, then stop and return to the debugger.
2666
2667It is often useful to do @samp{display/i $pc} when stepping by machine
2668instructions. This will cause the next instruction to be executed to
29a2b744
RP
2669be displayed automatically at each stop. @xref{Auto Display,
2670,Automatic Display}.
70b88761
RP
2671
2672An argument is a repeat count, as in @code{step}.
2673
2674@item nexti
2675@itemx ni
2676@kindex nexti
2677@kindex ni
2678Execute one machine instruction, but if it is a function call,
2679proceed until the function returns.
2680
2681An argument is a repeat count, as in @code{next}.
70b88761
RP
2682@end table
2683
3d3ab540 2684@node Signals, , Continuing and Stepping, Stopping
70b88761
RP
2685@section Signals
2686@cindex signals
2687
2688A signal is an asynchronous event that can happen in a program. The
2689operating system defines the possible kinds of signals, and gives each
2690kind a name and a number. For example, in Unix @code{SIGINT} is the
2691signal a program gets when you type an interrupt (often @kbd{C-c});
2692@code{SIGSEGV} is the signal a program gets from referencing a place in
2693memory far away from all the areas in use; @code{SIGALRM} occurs when
29a2b744 2694the alarm clock timer goes off (which happens only if your program has
70b88761
RP
2695requested an alarm).
2696
2697@cindex fatal signals
2698Some signals, including @code{SIGALRM}, are a normal part of the
29a2b744
RP
2699functioning of your program. Others, such as @code{SIGSEGV}, indicate
2700errors; these signals are @dfn{fatal} (kill your program immediately) if the
70b88761 2701program has not specified in advance some other way to handle the signal.
29a2b744 2702@code{SIGINT} does not indicate an error in your program, but it is normally
70b88761
RP
2703fatal so it can carry out the purpose of the interrupt: to kill the program.
2704
29a2b744
RP
2705_GDBN__ has the ability to detect any occurrence of a signal in your
2706program. You can tell _GDBN__ in advance what to do for each kind of
2707signal.
70b88761
RP
2708
2709@cindex handling signals
2710Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM}
29a2b744
RP
2711(so as not to interfere with their role in the functioning of your program)
2712but to stop your program immediately whenever an error signal happens.
70b88761
RP
2713You can change these settings with the @code{handle} command.
2714
2715@table @code
2716@item info signals
2717@kindex info signals
2718Print a table of all the kinds of signals and how _GDBN__ has been told to
2719handle each one. You can use this to see the signal numbers of all
2720the defined types of signals.
2721
2722@item handle @var{signal} @var{keywords}@dots{}
2723@kindex handle
2724Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the
2725number of a signal or its name (with or without the @samp{SIG} at the
2726beginning). The @var{keywords} say what change to make.
2727@end table
2728
2729@c @group
2730The keywords allowed by the @code{handle} command can be abbreviated.
2731Their full names are:
2732
2733@table @code
2734@item nostop
29a2b744 2735_GDBN__ should not stop your program when this signal happens. It may
70b88761
RP
2736still print a message telling you that the signal has come in.
2737
2738@item stop
29a2b744 2739_GDBN__ should stop your program when this signal happens. This implies
70b88761
RP
2740the @code{print} keyword as well.
2741
2742@item print
2743_GDBN__ should print a message when this signal happens.
2744
2745@item noprint
2746_GDBN__ should not mention the occurrence of the signal at all. This
2747implies the @code{nostop} keyword as well.
2748
2749@item pass
29a2b744 2750_GDBN__ should allow your program to see this signal; your program will be
70b88761
RP
2751able to handle the signal, or may be terminated if the signal is fatal
2752and not handled.
2753
2754@item nopass
29a2b744 2755_GDBN__ should not allow your program to see this signal.
70b88761
RP
2756@end table
2757@c @end group
2758
29a2b744 2759When a signal has been set to stop your program, your program cannot see the
70b88761 2760signal until you continue. It will see the signal then, if @code{pass} is
6ca72cc6 2761in effect for the signal in question @emph{at that time}. In other words,
70b88761
RP
2762after _GDBN__ reports a signal, you can use the @code{handle} command with
2763@code{pass} or @code{nopass} to control whether that signal will be seen by
29a2b744 2764your program when you later continue it.
70b88761 2765
29a2b744 2766You can also use the @code{signal} command to prevent your program from
70b88761 2767seeing a signal, or cause it to see a signal it normally would not see,
29a2b744 2768or to give it any signal at any time. For example, if your program stopped
7463aadd
RP
2769due to some sort of memory reference error, you might store correct
2770values into the erroneous variables and continue, hoping to see more
29a2b744
RP
2771execution; but your program would probably terminate immediately as
2772a result of the fatal signal once it saw the signal. To prevent this,
2773you can continue with @samp{signal 0}. @xref{Signaling, ,Giving your
2774Program a Signal}.
70b88761
RP
2775
2776@node Stack, Source, Stopping, Top
2777@chapter Examining the Stack
2778
2779When your program has stopped, the first thing you need to know is where it
2780stopped and how it got there.
2781
2782@cindex call stack
2783Each time your program performs a function call, the information about
29a2b744 2784where in your program the call was made from is saved in a block of data
70b88761
RP
2785called a @dfn{stack frame}. The frame also contains the arguments of the
2786call and the local variables of the function that was called. All the
2787stack frames are allocated in a region of memory called the @dfn{call
2788stack}.
2789
2790When your program stops, the _GDBN__ commands for examining the stack allow you
2791to see all of this information.
2792
2793@cindex selected frame
2794One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands
2795refer implicitly to the selected frame. In particular, whenever you ask
29a2b744 2796_GDBN__ for the value of a variable in your program, the value is found in the
70b88761
RP
2797selected frame. There are special _GDBN__ commands to select whichever frame
2798you are interested in.
2799
29a2b744 2800When your program stops, _GDBN__ automatically selects the currently executing
70b88761 2801frame and describes it briefly as the @code{frame} command does
29a2b744 2802(@pxref{Frame Info, ,Information About a Frame}).
70b88761
RP
2803
2804@menu
b80282d5
RP
2805* Frames:: Stack Frames
2806* Backtrace:: Backtraces
2807* Selection:: Selecting a Frame
2808* Frame Info:: Information on a Frame
70b88761
RP
2809@end menu
2810
2811@node Frames, Backtrace, Stack, Stack
2812@section Stack Frames
2813
2814@cindex frame
2815@cindex stack frame
2816The call stack is divided up into contiguous pieces called @dfn{stack
2817frames}, or @dfn{frames} for short; each frame is the data associated
2818with one call to one function. The frame contains the arguments given
2819to the function, the function's local variables, and the address at
2820which the function is executing.
2821
2822@cindex initial frame
2823@cindex outermost frame
2824@cindex innermost frame
2825When your program is started, the stack has only one frame, that of the
2826function @code{main}. This is called the @dfn{initial} frame or the
2827@dfn{outermost} frame. Each time a function is called, a new frame is
2828made. Each time a function returns, the frame for that function invocation
2829is eliminated. If a function is recursive, there can be many frames for
2830the same function. The frame for the function in which execution is
2831actually occurring is called the @dfn{innermost} frame. This is the most
2832recently created of all the stack frames that still exist.
2833
2834@cindex frame pointer
2835Inside your program, stack frames are identified by their addresses. A
2836stack frame consists of many bytes, each of which has its own address; each
2837kind of computer has a convention for choosing one of those bytes whose
2838address serves as the address of the frame. Usually this address is kept
2839in a register called the @dfn{frame pointer register} while execution is
2840going on in that frame.
2841
2842@cindex frame number
2843_GDBN__ assigns numbers to all existing stack frames, starting with
2844zero for the innermost frame, one for the frame that called it,
2845and so on upward. These numbers do not really exist in your program;
2846they are assigned by _GDBN__ to give you a way of designating stack
2847frames in _GDBN__ commands.
2848
2849@cindex frameless execution
2850Some compilers allow functions to be compiled so that they operate
2851without stack frames. (For example, the @code{_GCC__} option
2852@samp{-fomit-frame-pointer} will generate functions without a frame.)
2853This is occasionally done with heavily used library functions to save
2854the frame setup time. _GDBN__ has limited facilities for dealing with
2855these function invocations. If the innermost function invocation has no
2856stack frame, _GDBN__ will nevertheless regard it as though it had a
2857separate frame, which is numbered zero as usual, allowing correct
2858tracing of the function call chain. However, _GDBN__ has no provision
2859for frameless functions elsewhere in the stack.
2860
2861@node Backtrace, Selection, Frames, Stack
2862@section Backtraces
2863
29a2b744 2864A backtrace is a summary of how your program got where it is. It shows one
70b88761
RP
2865line per frame, for many frames, starting with the currently executing
2866frame (frame zero), followed by its caller (frame one), and on up the
2867stack.
2868
2869@table @code
2870@item backtrace
2871@itemx bt
2872@kindex backtrace
2873@kindex bt
2874Print a backtrace of the entire stack: one line per frame for all
2875frames in the stack.
2876
2877You can stop the backtrace at any time by typing the system interrupt
2878character, normally @kbd{C-c}.
2879
2880@item backtrace @var{n}
2881@itemx bt @var{n}
2882Similar, but print only the innermost @var{n} frames.
2883
2884@item backtrace -@var{n}
2885@itemx bt -@var{n}
2886Similar, but print only the outermost @var{n} frames.
2887@end table
2888
2889@kindex where
2890@kindex info stack
2891@kindex info s
2892The names @code{where} and @code{info stack} (abbreviated @code{info s})
2893are additional aliases for @code{backtrace}.
2894
2895Each line in the backtrace shows the frame number and the function name.
2896The program counter value is also shown---unless you use @code{set
2897print address off}. The backtrace also shows the source file name and
2898line number, as well as the arguments to the function. The program
2899counter value is omitted if it is at the beginning of the code for that
2900line number.
2901
2902Here is an example of a backtrace. It was made with the command
2903@samp{bt 3}, so it shows the innermost three frames.
2904
2905@smallexample
2906@group
203eea5d
RP
2907#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
2908 at builtin.c:993
70b88761
RP
2909#1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
2910#2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
2911 at macro.c:71
2912(More stack frames follow...)
2913@end group
2914@end smallexample
2915
2916@noindent
29a2b744
RP
2917The display for frame zero does not begin with a program counter
2918value, indicating that your program has stopped at the beginning of the
70b88761
RP
2919code for line @code{993} of @code{builtin.c}.
2920
2921@node Selection, Frame Info, Backtrace, Stack
2922@section Selecting a Frame
2923
29a2b744 2924Most commands for examining the stack and other data in your program work on
70b88761
RP
2925whichever stack frame is selected at the moment. Here are the commands for
2926selecting a stack frame; all of them finish by printing a brief description
2927of the stack frame just selected.
2928
2929@table @code
2930@item frame @var{n}
2931@itemx f @var{n}
2932@kindex frame
2933@kindex f
2934Select frame number @var{n}. Recall that frame zero is the innermost
2935(currently executing) frame, frame one is the frame that called the
2936innermost one, and so on. The highest-numbered frame is @code{main}'s
2937frame.
2938
2939@item frame @var{addr}
2940@itemx f @var{addr}
2941Select the frame at address @var{addr}. This is useful mainly if the
2942chaining of stack frames has been damaged by a bug, making it
2943impossible for _GDBN__ to assign numbers properly to all frames. In
29a2b744 2944addition, this can be useful when your program has multiple stacks and
70b88761
RP
2945switches between them.
2946
c728f1f0 2947_if__(_SPARC__)
70b88761 2948On the SPARC architecture, @code{frame} needs two addresses to
e251e767 2949select an arbitrary frame: a frame pointer and a stack pointer.
70b88761
RP
2950@c note to future updaters: this is conditioned on a flag
2951@c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used
2952@c by SPARC, hence the specific attribution. Generalize or list all
2953@c possibilities if more supported machines start doing this.
c728f1f0 2954_fi__(_SPARC__)
70b88761
RP
2955
2956@item up @var{n}
2957@kindex up
2958Move @var{n} frames up the stack. For positive numbers @var{n}, this
2959advances toward the outermost frame, to higher frame numbers, to frames
2960that have existed longer. @var{n} defaults to one.
2961
2962@item down @var{n}
2963@kindex down
2964@kindex do
2965Move @var{n} frames down the stack. For positive numbers @var{n}, this
2966advances toward the innermost frame, to lower frame numbers, to frames
2967that were created more recently. @var{n} defaults to one. You may
2968abbreviate @code{down} as @code{do}.
2969@end table
2970
2971All of these commands end by printing two lines of output describing the
2972frame. The first line shows the frame number, the function name, the
2973arguments, and the source file and line number of execution in that
2974frame. The second line shows the text of that source line. For
2975example:
2976
2977@smallexample
29a2b744 2978@group
70b88761 2979(_GDBP__) up
203eea5d
RP
2980#1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
2981 at env.c:10
70b88761 298210 read_input_file (argv[i]);
29a2b744 2983@end group
70b88761
RP
2984@end smallexample
2985
29a2b744
RP
2986After such a printout, the @code{list} command with no arguments will
2987print ten lines centered on the point of execution in the frame.
2988@xref{List, ,Printing Source Lines}.
70b88761
RP
2989
2990@table @code
2991@item up-silently @var{n}
2992@itemx down-silently @var{n}
2993@kindex down-silently
2994@kindex up-silently
2995These two commands are variants of @code{up} and @code{down},
2996respectively; they differ in that they do their work silently, without
2997causing display of the new frame. They are intended primarily for use
2998in _GDBN__ command scripts, where the output might be unnecessary and
e251e767 2999distracting.
70b88761
RP
3000@end table
3001
3002@node Frame Info, , Selection, Stack
3003@section Information About a Frame
3004
3005There are several other commands to print information about the selected
3006stack frame.
3007
3008@table @code
3009@item frame
3010@itemx f
29a2b744
RP
3011When used without any argument, this command does not change which
3012frame is selected, but prints a brief description of the currently
70b88761 3013selected stack frame. It can be abbreviated @code{f}. With an
29a2b744
RP
3014argument, this command is used to select a stack frame
3015(@pxref{Selection, ,Selecting a Frame}).
70b88761
RP
3016
3017@item info frame
70b88761 3018@itemx info f
29a2b744 3019@kindex info frame
70b88761
RP
3020@kindex info f
3021This command prints a verbose description of the selected stack frame,
3022including the address of the frame, the addresses of the next frame down
c2bbbb22
RP
3023(called by this frame) and the next frame up (caller of this frame), the
3024language that the source code corresponding to this frame was written in,
70b88761
RP
3025the address of the frame's arguments, the program counter saved in it
3026(the address of execution in the caller frame), and which registers
3027were saved in the frame. The verbose description is useful when
3028something has gone wrong that has made the stack format fail to fit
3029the usual conventions.
3030
3031@item info frame @var{addr}
3032@itemx info f @var{addr}
3033Print a verbose description of the frame at address @var{addr},
3034without selecting that frame. The selected frame remains unchanged by
3035this command.
3036
3037@item info args
3038@kindex info args
3039Print the arguments of the selected frame, each on a separate line.
3040
3041@item info locals
3042@kindex info locals
3043Print the local variables of the selected frame, each on a separate
3044line. These are all variables declared static or automatic within all
3045program blocks that execution in this frame is currently inside of.
3046
3047@item info catch
3048@kindex info catch
3049@cindex catch exceptions
3050@cindex exception handlers
3051Print a list of all the exception handlers that are active in the
3052current stack frame at the current point of execution. To see other
3053exception handlers, visit the associated frame (using the @code{up},
3054@code{down}, or @code{frame} commands); then type @code{info catch}.
1041a570 3055@xref{Exception Handling, ,Breakpoints and Exceptions}.
70b88761
RP
3056@end table
3057
3058@node Source, Data, Stack, Top
3059@chapter Examining Source Files
3060
3061_GDBN__ can print parts of your program's source, since the debugging
1041a570
RP
3062information recorded in your program tells _GDBN__ what source files were
3063used to build it. When your program stops, _GDBN__ spontaneously prints
3064the line where it stopped. Likewise, when you select a stack frame
3065(@pxref{Selection, ,Selecting a Frame}), _GDBN__ prints the line where
3066execution in that frame has stopped. You can print other portions of
3067source files by explicit command.
70b88761 3068
1041a570
RP
3069If you use _GDBN__ through its GNU Emacs interface, you may prefer to use
3070Emacs facilities to view source; @pxref{Emacs, ,Using _GDBN__ under GNU
3071Emacs}.
70b88761
RP
3072
3073@menu
b80282d5
RP
3074* List:: Printing Source Lines
3075* Search:: Searching Source Files
3076* Source Path:: Specifying Source Directories
3077* Machine Code:: Source and Machine Code
70b88761
RP
3078@end menu
3079
3080@node List, Search, Source, Source
3081@section Printing Source Lines
3082
3083@kindex list
3084@kindex l
3085To print lines from a source file, use the @code{list} command
3086(abbreviated @code{l}). There are several ways to specify what part
3087of the file you want to print.
3088
3089Here are the forms of the @code{list} command most commonly used:
3090
3091@table @code
3092@item list @var{linenum}
c338a2fd 3093Print lines centered around line number @var{linenum} in the
70b88761
RP
3094current source file.
3095
3096@item list @var{function}
c338a2fd 3097Print lines centered around the beginning of function
70b88761
RP
3098@var{function}.
3099
3100@item list
c338a2fd
RP
3101Print more lines. If the last lines printed were printed with a
3102@code{list} command, this prints lines following the last lines
70b88761 3103printed; however, if the last line printed was a solitary line printed
29a2b744 3104as part of displaying a stack frame (@pxref{Stack, ,Examining the
1041a570 3105Stack}), this prints lines centered around that line.
70b88761
RP
3106
3107@item list -
c338a2fd
RP
3108Print lines just before the lines last printed.
3109@end table
3110
3111By default, _GDBN__ prints ten source lines with any of these forms of
3112the @code{list} command. You can change this using @code{set listsize}:
3113
3114@table @code
3115@item set listsize @var{count}
3116@kindex set listsize
3117Make the @code{list} command display @var{count} source lines (unless
3118the @code{list} argument explicitly specifies some other number).
3119
3120@item show listsize
3121@kindex show listsize
3122Display the number of lines that @code{list} will currently display by
e251e767 3123default.
70b88761
RP
3124@end table
3125
3126Repeating a @code{list} command with @key{RET} discards the argument,
3127so it is equivalent to typing just @code{list}. This is more useful
3128than listing the same lines again. An exception is made for an
3129argument of @samp{-}; that argument is preserved in repetition so that
3130each repetition moves up in the source file.
3131
3132@cindex linespec
3133In general, the @code{list} command expects you to supply zero, one or two
3134@dfn{linespecs}. Linespecs specify source lines; there are several ways
3135of writing them but the effect is always to specify some source line.
3136Here is a complete description of the possible arguments for @code{list}:
3137
3138@table @code
3139@item list @var{linespec}
c338a2fd 3140Print lines centered around the line specified by @var{linespec}.
70b88761
RP
3141
3142@item list @var{first},@var{last}
3143Print lines from @var{first} to @var{last}. Both arguments are
3144linespecs.
3145
3146@item list ,@var{last}
c338a2fd 3147Print lines ending with @var{last}.
70b88761
RP
3148
3149@item list @var{first},
c338a2fd 3150Print lines starting with @var{first}.
70b88761
RP
3151
3152@item list +
c338a2fd 3153Print lines just after the lines last printed.
70b88761
RP
3154
3155@item list -
c338a2fd 3156Print lines just before the lines last printed.
70b88761
RP
3157
3158@item list
3159As described in the preceding table.
3160@end table
3161
3162Here are the ways of specifying a single source line---all the
3163kinds of linespec.
3164
3165@table @code
3166@item @var{number}
3167Specifies line @var{number} of the current source file.
3168When a @code{list} command has two linespecs, this refers to
3169the same source file as the first linespec.
3170
3171@item +@var{offset}
3172Specifies the line @var{offset} lines after the last line printed.
3173When used as the second linespec in a @code{list} command that has
3174two, this specifies the line @var{offset} lines down from the
3175first linespec.
3176
3177@item -@var{offset}
3178Specifies the line @var{offset} lines before the last line printed.
3179
3180@item @var{filename}:@var{number}
3181Specifies line @var{number} in the source file @var{filename}.
3182
3183@item @var{function}
3184@c FIXME: "of the open-brace" is C-centric. When we add other langs...
3185Specifies the line of the open-brace that begins the body of the
3186function @var{function}.
3187
3188@item @var{filename}:@var{function}
3189Specifies the line of the open-brace that begins the body of the
3190function @var{function} in the file @var{filename}. You only need the
3191file name with a function name to avoid ambiguity when there are
3192identically named functions in different source files.
3193
3194@item *@var{address}
3195Specifies the line containing the program address @var{address}.
3196@var{address} may be any expression.
3197@end table
3198
3199@node Search, Source Path, List, Source
3200@section Searching Source Files
3201@cindex searching
3202@kindex reverse-search
3203
3204There are two commands for searching through the current source file for a
3205regular expression.
3206
3207@table @code
3208@item forward-search @var{regexp}
3209@itemx search @var{regexp}
3210@kindex search
3211@kindex forward-search
1041a570
RP
3212The command @samp{forward-search @var{regexp}} checks each line,
3213starting with the one following the last line listed, for a match for
3214@var{regexp}. It lists the line that is found. You can use
3215synonym @samp{search @var{regexp}} or abbreviate the command name as
3216@code{fo}.
70b88761
RP
3217
3218@item reverse-search @var{regexp}
3219The command @samp{reverse-search @var{regexp}} checks each line, starting
3220with the one before the last line listed and going backward, for a match
3221for @var{regexp}. It lists the line that is found. You can abbreviate
3222this command as @code{rev}.
3223@end table
3224
3225@node Source Path, Machine Code, Search, Source
3226@section Specifying Source Directories
3227
3228@cindex source path
3229@cindex directories for source files
3230Executable programs sometimes do not record the directories of the source
3231files from which they were compiled, just the names. Even when they do,
3232the directories could be moved between the compilation and your debugging
3233session. _GDBN__ has a list of directories to search for source files;
3234this is called the @dfn{source path}. Each time _GDBN__ wants a source file,
3235it tries all the directories in the list, in the order they are present
3236in the list, until it finds a file with the desired name. Note that
3237the executable search path is @emph{not} used for this purpose. Neither is
3238the current working directory, unless it happens to be in the source
3239path.
3240
29a2b744 3241If _GDBN__ cannot find a source file in the source path, and the object
70b88761
RP
3242program records a directory, _GDBN__ tries that directory too. If the
3243source path is empty, and there is no record of the compilation
3244directory, _GDBN__ will, as a last resort, look in the current
3245directory.
3246
3247Whenever you reset or rearrange the source path, _GDBN__ will clear out
3248any information it has cached about where source files are found, where
3249each line is in the file, etc.
3250
3251@kindex directory
3252When you start _GDBN__, its source path is empty.
3253To add other directories, use the @code{directory} command.
3254
3255@table @code
3256@item directory @var{dirname} @dots{}
3257Add directory @var{dirname} to the front of the source path. Several
3258directory names may be given to this command, separated by @samp{:} or
3259whitespace. You may specify a directory that is already in the source
e251e767 3260path; this moves it forward, so it will be searched sooner.
7463aadd
RP
3261
3262You can use the string @samp{$cdir} to refer to the compilation
3263directory (if one is recorded), and @samp{$cwd} to refer to the current
3264working directory. @samp{$cwd} is not the same as @samp{.}---the former
3265tracks the current working directory as it changes during your _GDBN__
3266session, while the latter is immediately expanded to the current
3267directory at the time you add an entry to the source path.
70b88761
RP
3268
3269@item directory
3270Reset the source path to empty again. This requires confirmation.
3271
3272@c RET-repeat for @code{directory} is explicitly disabled, but since
29a2b744 3273@c repeating it would be a no-op we do not say that. (thanks to RMS)
70b88761
RP
3274
3275@item show directories
3276@kindex show directories
3277Print the source path: show which directories it contains.
3278@end table
3279
3280If your source path is cluttered with directories that are no longer of
3281interest, _GDBN__ may sometimes cause confusion by finding the wrong
3282versions of source. You can correct the situation as follows:
3283
3284@enumerate
3285@item
3286Use @code{directory} with no argument to reset the source path to empty.
3287
3288@item
3289Use @code{directory} with suitable arguments to reinstall the
3290directories you want in the source path. You can add all the
3291directories in one command.
3292@end enumerate
3293
3294@node Machine Code, , Source Path, Source
3295@section Source and Machine Code
1041a570 3296
70b88761
RP
3297You can use the command @code{info line} to map source lines to program
3298addresses (and viceversa), and the command @code{disassemble} to display
3299a range of addresses as machine instructions.
3300
3301@table @code
3302@item info line @var{linespec}
3303@kindex info line
3304Print the starting and ending addresses of the compiled code for
1041a570
RP
3305source line @var{linespec}. You can specify source lines in any of
3306the ways understood by the @code{list} command (@pxref{List, ,Printing
3307Source Lines}).
70b88761
RP
3308@end table
3309
1041a570
RP
3310For example, we can use @code{info line} to discover the location of
3311the object code for the first line of function
3312@code{m4_changequote}:
3313
70b88761
RP
3314@smallexample
3315(_GDBP__) info line m4_changecom
3316Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
3317@end smallexample
3318
3319@noindent
3320We can also inquire (using @code{*@var{addr}} as the form for
3321@var{linespec}) what source line covers a particular address:
3322@smallexample
3323(_GDBP__) info line *0x63ff
3324Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
3325@end smallexample
3326
c338a2fd 3327@cindex @code{$_} and @code{info line}
29a2b744
RP
3328After @code{info line}, the default address for the @code{x} command
3329is changed to the starting address of the line, so that @samp{x/i} is
3330sufficient to begin examining the machine code (@pxref{Memory,
3331,Examining Memory}). Also, this address is saved as the value of the
3332convenience variable @code{$_} (@pxref{Convenience Vars, ,Convenience
3333Variables}).
70b88761
RP
3334
3335@table @code
3336@kindex disassemble
3337@item disassemble
e94b4a2b
RP
3338This specialized command dumps a range of memory as machine
3339instructions. The default memory range is the function surrounding the
3340program counter of the selected frame. A single argument to this
3341command is a program counter value; the function surrounding this value
3342will be dumped. Two arguments specify a range of addresses (first
3343inclusive, second exclusive) to dump.
70b88761
RP
3344@end table
3345
3346We can use @code{disassemble} to inspect the object code
3347range shown in the last @code{info line} example:
3348
3349@smallexample
3350(_GDBP__) disas 0x63e4 0x6404
3351Dump of assembler code from 0x63e4 to 0x6404:
b80282d5
RP
33520x63e4 <builtin_init+5340>: ble 0x63f8 <builtin_init+5360>
33530x63e8 <builtin_init+5344>: sethi %hi(0x4c00), %o0
33540x63ec <builtin_init+5348>: ld [%i1+4], %o0
33550x63f0 <builtin_init+5352>: b 0x63fc <builtin_init+5364>
33560x63f4 <builtin_init+5356>: ld [%o0+4], %o0
33570x63f8 <builtin_init+5360>: or %o0, 0x1a4, %o0
33580x63fc <builtin_init+5364>: call 0x9288 <path_search>
e251e767 33590x6400 <builtin_init+5368>: nop
70b88761 3360End of assembler dump.
70b88761
RP
3361@end smallexample
3362
c2bbbb22 3363@node Data, Languages, Source, Top
70b88761
RP
3364@chapter Examining Data
3365
3366@cindex printing data
3367@cindex examining data
3368@kindex print
3369@kindex inspect
1041a570 3370@c "inspect" is not quite a synonym if you are using Epoch, which we do not
29a2b744 3371@c document because it is nonstandard... Under Epoch it displays in a
70b88761
RP
3372@c different window or something like that.
3373The usual way to examine data in your program is with the @code{print}
3374command (abbreviated @code{p}), or its synonym @code{inspect}. It
b80282d5 3375evaluates and prints the value of an expression of the language your
1041a570
RP
3376program is written in (@pxref{Languages, ,Using _GDBN__ with Different
3377Languages}).
70b88761 3378
e0dacfd1
RP
3379@table @code
3380@item print @var{exp}
3381@itemx print /@var{f} @var{exp}
3382@var{exp} is an expression (in the source language). By default
70b88761 3383the value of @var{exp} is printed in a format appropriate to its data
e0dacfd1
RP
3384type; you can choose a different format by specifying @samp{/@var{f}},
3385where @var{f} is a letter specifying the format; @pxref{Output formats}.
3386
3387@item print
3388@itemx print /@var{f}
3389If you omit @var{exp}, _GDBN__ displays the last value again (from the
1041a570 3390@dfn{value history}; @pxref{Value History, ,Value History}). This allows you to
e0dacfd1
RP
3391conveniently inspect the same value in an alternative format.
3392@end table
70b88761
RP
3393
3394A more low-level way of examining data is with the @code{x} command.
3395It examines data in memory at a specified address and prints it in a
29a2b744 3396specified format. @xref{Memory, ,Examining Memory}.
70b88761 3397
29a2b744 3398If you are interested in information about types, or about how the fields
b80282d5 3399of a struct or class are declared, use the @code{ptype @var{exp}}
1041a570 3400command rather than @code{print}. @xref{Symbols, ,Examining the Symbol Table}.
b80282d5 3401
70b88761 3402@menu
b80282d5
RP
3403* Expressions:: Expressions
3404* Variables:: Program Variables
3405* Arrays:: Artificial Arrays
3406* Output formats:: Output formats
3407* Memory:: Examining Memory
3408* Auto Display:: Automatic Display
3409* Print Settings:: Print Settings
3410* Value History:: Value History
3411* Convenience Vars:: Convenience Variables
3412* Registers:: Registers
3413* Floating Point Hardware:: Floating Point Hardware
70b88761
RP
3414@end menu
3415
3416@node Expressions, Variables, Data, Data
3417@section Expressions
3418
3419@cindex expressions
3420@code{print} and many other _GDBN__ commands accept an expression and
3421compute its value. Any kind of constant, variable or operator defined
3422by the programming language you are using is legal in an expression in
3423_GDBN__. This includes conditional expressions, function calls, casts
3424and string constants. It unfortunately does not include symbols defined
b80282d5 3425by preprocessor @code{#define} commands.
70b88761 3426
c2bbbb22 3427Because C is so widespread, most of the expressions shown in examples in
1041a570 3428this manual are in C. @xref{Languages, , Using _GDBN__ with Different
c2bbbb22 3429Languages}, for information on how to use expressions in other
e251e767 3430languages.
c2bbbb22
RP
3431
3432In this section, we discuss operators that you can use in _GDBN__
e251e767 3433expressions regardless of your programming language.
c2bbbb22 3434
70b88761
RP
3435Casts are supported in all languages, not just in C, because it is so
3436useful to cast a number into a pointer so as to examine a structure
3437at that address in memory.
c2bbbb22 3438@c FIXME: casts supported---Mod2 true?
70b88761 3439
c2bbbb22 3440_GDBN__ supports these operators in addition to those of programming
70b88761
RP
3441languages:
3442
3443@table @code
3444@item @@
3445@samp{@@} is a binary operator for treating parts of memory as arrays.
1041a570 3446@xref{Arrays, ,Artificial Arrays}, for more information.
70b88761
RP
3447
3448@item ::
3449@samp{::} allows you to specify a variable in terms of the file or
1041a570 3450function where it is defined. @xref{Variables, ,Program Variables}.
70b88761
RP
3451
3452@item @{@var{type}@} @var{addr}
3453Refers to an object of type @var{type} stored at address @var{addr} in
3454memory. @var{addr} may be any expression whose value is an integer or
3455pointer (but parentheses are required around binary operators, just as in
3456a cast). This construct is allowed regardless of what kind of data is
1041a570 3457normally supposed to reside at @var{addr}.
70b88761
RP
3458@end table
3459
3460@node Variables, Arrays, Expressions, Data
3461@section Program Variables
3462
3463The most common kind of expression to use is the name of a variable
3464in your program.
3465
3466Variables in expressions are understood in the selected stack frame
29a2b744
RP
3467(@pxref{Selection, ,Selecting a Frame}); they must either be global
3468(or static) or be visible according to the scope rules of the
3469programming language from the point of execution in that frame. This
3470means that in the function
70b88761
RP
3471
3472@example
3473foo (a)
3474 int a;
3475@{
3476 bar (a);
3477 @{
3478 int b = test ();
3479 bar (b);
3480 @}
3481@}
3482@end example
3483
3484@noindent
29a2b744 3485the variable @code{a} is usable whenever your program is executing
70b88761 3486within the function @code{foo}, but the variable @code{b} is visible
29a2b744 3487only while your program is executing inside the block in which @code{b}
70b88761
RP
3488is declared.
3489
3490@cindex variable name conflict
3491There is an exception: you can refer to a variable or function whose
3492scope is a single source file even if the current execution point is not
3493in this file. But it is possible to have more than one such variable or
6ca72cc6
RP
3494function with the same name (in different source files). If that
3495happens, referring to that name has unpredictable effects. If you wish,
3496you can specify a static variable in a particular function or file,
3497using the colon-colon notation:
70b88761
RP
3498
3499@cindex colon-colon
a6d0b6d3 3500@iftex
29a2b744 3501@c info cannot cope with a :: index entry, but why deprive hard copy readers?
70b88761 3502@kindex ::
a6d0b6d3 3503@end iftex
70b88761
RP
3504@example
3505@var{file}::@var{variable}
6ca72cc6 3506@var{function}::@var{variable}
70b88761
RP
3507@end example
3508
3509@noindent
6ca72cc6
RP
3510Here @var{file} or @var{function} is the name of the context for the
3511static @var{variable}.
70b88761 3512
c2bbbb22 3513@cindex C++ scope resolution
70b88761
RP
3514This use of @samp{::} is very rarely in conflict with the very similar
3515use of the same notation in C++. _GDBN__ also supports use of the C++
c2bbbb22 3516scope resolution operator in _GDBN__ expressions.
70b88761 3517
3d3ab540
RP
3518@cindex wrong values
3519@cindex variable values, wrong
3520@quotation
3521@emph{Warning:} Occasionally, a local variable may appear to have the
3522wrong value at certain points in a function---just after entry to the
29a2b744 3523function, and just before exit. You may see this problem when you are
3d3ab540
RP
3524stepping by machine instructions. This is because on most machines, it
3525takes more than one instruction to set up a stack frame (including local
29a2b744 3526variable definitions); if you are stepping by machine instructions,
3d3ab540
RP
3527variables may appear to have the wrong values until the stack frame is
3528completely built. On function exit, it usually also takes more than one
3529machine instruction to destroy a stack frame; after you begin stepping
3530through that group of instructions, local variable definitions may be
3531gone.
3532@end quotation
3533
70b88761
RP
3534@node Arrays, Output formats, Variables, Data
3535@section Artificial Arrays
3536
3537@cindex artificial array
3538@kindex @@
3539It is often useful to print out several successive objects of the
3540same type in memory; a section of an array, or an array of
3541dynamically determined size for which only a pointer exists in the
3542program.
3543
3544This can be done by constructing an @dfn{artificial array} with the
3545binary operator @samp{@@}. The left operand of @samp{@@} should be
3546the first element of the desired array, as an individual object.
3547The right operand should be the desired length of the array. The result is
3548an array value whose elements are all of the type of the left argument.
3549The first element is actually the left argument; the second element
3550comes from bytes of memory immediately following those that hold the
3551first element, and so on. Here is an example. If a program says
3552
3553@example
3554int *array = (int *) malloc (len * sizeof (int));
3555@end example
3556
3557@noindent
3558you can print the contents of @code{array} with
3559
3560@example
3561p *array@@len
3562@end example
3563
3564The left operand of @samp{@@} must reside in memory. Array values made
3565with @samp{@@} in this way behave just like other arrays in terms of
3566subscripting, and are coerced to pointers when used in expressions.
3567Artificial arrays most often appear in expressions via the value history
1041a570 3568(@pxref{Value History, ,Value History}), after printing one out.)
70b88761 3569
1041a570 3570Sometimes the artificial array mechanism is not quite enough; in
3d3ab540 3571moderately complex data structures, the elements of interest may not
1041a570
RP
3572actually be adjacent---for example, if you are interested in the values
3573of pointers in an array. One useful work-around in this situation is
3574to use a convenience variable (@pxref{Convenience Vars, ,Convenience
3575Variables}) as a counter in an expression that prints the first
3576interesting value, and then repeat that expression via @key{RET}. For
3577instance, suppose you have an array @code{dtab} of pointers to
3578structures, and you are interested in the values of a field @code{fv}
3579in each structure. Here is an example of what you might type:
3580
3d3ab540
RP
3581@example
3582set $i = 0
3583p dtab[$i++]->fv
3584@key{RET}
3585@key{RET}
3586@dots{}
3587@end example
3588
70b88761
RP
3589@node Output formats, Memory, Arrays, Data
3590@section Output formats
3591
3592@cindex formatted output
3593@cindex output formats
3594By default, _GDBN__ prints a value according to its data type. Sometimes
3595this is not what you want. For example, you might want to print a number
3596in hex, or a pointer in decimal. Or you might want to view data in memory
3597at a certain address as a character string or as an instruction. To do
3598these things, specify an @dfn{output format} when you print a value.
3599
3600The simplest use of output formats is to say how to print a value
3601already computed. This is done by starting the arguments of the
3602@code{print} command with a slash and a format letter. The format
3603letters supported are:
3604
3605@table @code
3606@item x
3607Regard the bits of the value as an integer, and print the integer in
3608hexadecimal.
3609
3610@item d
3611Print as integer in signed decimal.
3612
3613@item u
3614Print as integer in unsigned decimal.
3615
3616@item o
3617Print as integer in octal.
3618
3619@item t
3620Print as integer in binary. The letter @samp{t} stands for ``two''.
3621
3622@item a
3623Print as an address, both absolute in hex and as an offset from the
3624nearest preceding symbol. This format can be used to discover where (in
3625what function) an unknown address is located:
1041a570 3626
70b88761
RP
3627@example
3628(_GDBP__) p/a 0x54320
3629_0__$3 = 0x54320 <_initialize_vx+396>_1__
3630@end example
3631
70b88761
RP
3632@item c
3633Regard as an integer and print it as a character constant.
3634
3635@item f
3636Regard the bits of the value as a floating point number and print
3637using typical floating point syntax.
3638@end table
3639
3640For example, to print the program counter in hex (@pxref{Registers}), type
3641
3642@example
3643p/x $pc
3644@end example
3645
3646@noindent
3647Note that no space is required before the slash; this is because command
3648names in _GDBN__ cannot contain a slash.
3649
3650To reprint the last value in the value history with a different format,
3651you can use the @code{print} command with just a format and no
3652expression. For example, @samp{p/x} reprints the last value in hex.
3653
3654@node Memory, Auto Display, Output formats, Data
3655@section Examining Memory
3656
1041a570
RP
3657You can use the command @code{x} (for ``examine'') to examine memory in
3658any of several formats, independently of your program's data types.
3659
70b88761
RP
3660@cindex examining memory
3661@table @code
3662@kindex x
cedaf8bc
RP
3663@item x/@var{nfu} @var{addr}
3664@itemx x @var{addr}
3665@itemx x
1041a570
RP
3666Use the command @code{x} to examine memory.
3667@end table
3668
3669@var{n}, @var{f}, and @var{u} are all optional parameters that specify how
3670much memory to display and how to format it; @var{addr} is an
cedaf8bc
RP
3671expression giving the address where you want to start displaying memory.
3672If you use defaults for @var{nfu}, you need not type the slash @samp{/}.
3673Several commands set convenient defaults for @var{addr}.
70b88761 3674
1041a570
RP
3675@table @r
3676@item @var{n}, the repeat count
3677The repeat count is a decimal integer; the default is 1. It specifies
3678how much memory (counting by units @var{u}) to display.
cedaf8bc
RP
3679@c This really is **decimal**; unaffected by 'set radix' as of GDB
3680@c 4.1.2.
70b88761 3681
1041a570
RP
3682@item @var{f}, the display format
3683The display format is one of the formats used by @code{print},
cedaf8bc
RP
3684or @samp{s} (null-terminated string) or @samp{i} (machine instruction).
3685The default is @samp{x} (hexadecimal) initially, or the format from the
3686last time you used either @code{x} or @code{print}.
70b88761 3687
1041a570
RP
3688@item @var{u}, the unit size
3689The unit size is any of
70b88761
RP
3690@table @code
3691@item b
cedaf8bc 3692Bytes.
70b88761 3693@item h
cedaf8bc 3694Halfwords (two bytes).
70b88761 3695@item w
cedaf8bc 3696Words (four bytes). This is the initial default.
70b88761 3697@item g
cedaf8bc 3698Giant words (eight bytes).
70b88761
RP
3699@end table
3700
cedaf8bc
RP
3701Each time you specify a unit size with @code{x}, that size becomes the
3702default unit the next time you use @code{x}. (For the @samp{s} and
3703@samp{i} formats, the unit size is ignored and is normally not written.)
3704
1041a570 3705@item @var{addr}, starting display address
cedaf8bc
RP
3706@var{addr} is the address where you want _GDBN__ to begin displaying
3707memory. The expression need not have a pointer value (though it may);
3708it is always interpreted as an integer address of a byte of memory.
1041a570 3709@xref{Expressions, ,Expressions}, for more information on expressions. The default for
cedaf8bc
RP
3710@var{addr} is usually just after the last address examined---but several
3711other commands also set the default address: @code{info breakpoints} (to
3712the address of the last breakpoint listed), @code{info line} (to the
3713starting address of a line), and @code{print} (if you use it to display
3714a value from memory).
1041a570 3715@end table
70b88761 3716
cedaf8bc
RP
3717For example, @samp{x/3uh 0x54320} is a request to display three halfwords
3718(@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}),
3719starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four
3720words (@samp{w}) of memory above the stack pointer (here, @samp{$sp};
3721@pxref{Registers}) in hexadecimal (@samp{x}).
70b88761 3722
cedaf8bc 3723Since the letters indicating unit sizes are all distinct from the
29a2b744 3724letters specifying output formats, you do not have to remember whether
cedaf8bc
RP
3725unit size or format comes first; either order will work. The output
3726specifications @samp{4xw} and @samp{4wx} mean exactly the same thing.
3727(However, the count @var{n} must come first; @samp{wx4} will not work.)
3728
3729Even though the unit size @var{u} is ignored for the formats @samp{s}
3730and @samp{i}, you might still want to use a count @var{n}; for example,
3731@samp{3i} specifies that you want to see three machine instructions,
3732including any operands. The command @code{disassemble} gives an
3733alternative way of inspecting machine instructions; @pxref{Machine
3734Code}.
3735
3736All the defaults for the arguments to @code{x} are designed to make it
3737easy to continue scanning memory with minimal specifications each time
1041a570 3738you use @code{x}. For example, after you have inspected three machine
cedaf8bc
RP
3739instructions with @samp{x/3i @var{addr}}, you can inspect the next seven
3740with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command,
3741the repeat count @var{n} is used again; the other arguments default as
3742for successive uses of @code{x}.
70b88761 3743
c338a2fd 3744@cindex @code{$_}, @code{$__}, and value history
cedaf8bc 3745The addresses and contents printed by the @code{x} command are not saved
70b88761
RP
3746in the value history because there is often too much of them and they
3747would get in the way. Instead, _GDBN__ makes these values available for
3748subsequent use in expressions as values of the convenience variables
3749@code{$_} and @code{$__}. After an @code{x} command, the last address
3750examined is available for use in expressions in the convenience variable
3751@code{$_}. The contents of that address, as examined, are available in
3752the convenience variable @code{$__}.
3753
3754If the @code{x} command has a repeat count, the address and contents saved
3755are from the last memory unit printed; this is not the same as the last
3756address printed if several units were printed on the last line of output.
3757
3758@node Auto Display, Print Settings, Memory, Data
3759@section Automatic Display
3760@cindex automatic display
3761@cindex display of expressions
3762
3763If you find that you want to print the value of an expression frequently
3764(to see how it changes), you might want to add it to the @dfn{automatic
29a2b744 3765display list} so that _GDBN__ will print its value each time your program stops.
70b88761
RP
3766Each expression added to the list is given a number to identify it;
3767to remove an expression from the list, you specify that number.
3768The automatic display looks like this:
3769
3770@example
37712: foo = 38
37723: bar[5] = (struct hack *) 0x3804
3773@end example
3774
3775@noindent
3776showing item numbers, expressions and their current values. As with
3777displays you request manually using @code{x} or @code{print}, you can
3778specify the output format you prefer; in fact, @code{display} decides
3779whether to use @code{print} or @code{x} depending on how elaborate your
3780format specification is---it uses @code{x} if you specify a unit size,
3781or one of the two formats (@samp{i} and @samp{s}) that are only
3782supported by @code{x}; otherwise it uses @code{print}.
3783
3784@table @code
3785@item display @var{exp}
3786@kindex display
3787Add the expression @var{exp} to the list of expressions to display
1041a570 3788each time your program stops. @xref{Expressions, ,Expressions}.
70b88761
RP
3789
3790@code{display} will not repeat if you press @key{RET} again after using it.
3791
3792@item display/@var{fmt} @var{exp}
3793For @var{fmt} specifying only a display format and not a size or
3794count, add the expression @var{exp} to the auto-display list but
3795arranges to display it each time in the specified format @var{fmt}.
3796@xref{Output formats}.
3797
3798@item display/@var{fmt} @var{addr}
3799For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
3800number of units, add the expression @var{addr} as a memory address to
29a2b744
RP
3801be examined each time your program stops. Examining means in effect
3802doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory, ,Examining Memory}.
70b88761
RP
3803@end table
3804
3805For example, @samp{display/i $pc} can be helpful, to see the machine
3806instruction about to be executed each time execution stops (@samp{$pc}
3807is a common name for the program counter; @pxref{Registers}).
3808
3809@table @code
3810@item undisplay @var{dnums}@dots{}
3811@itemx delete display @var{dnums}@dots{}
3812@kindex delete display
3813@kindex undisplay
3814Remove item numbers @var{dnums} from the list of expressions to display.
3815
3816@code{undisplay} will not repeat if you press @key{RET} after using it.
3817(Otherwise you would just get the error @samp{No display number @dots{}}.)
3818
3819@item disable display @var{dnums}@dots{}
3820@kindex disable display
3821Disable the display of item numbers @var{dnums}. A disabled display
3822item is not printed automatically, but is not forgotten. It may be
3823enabled again later.
3824
3825@item enable display @var{dnums}@dots{}
3826@kindex enable display
3827Enable display of item numbers @var{dnums}. It becomes effective once
3828again in auto display of its expression, until you specify otherwise.
3829
3830@item display
3831Display the current values of the expressions on the list, just as is
29a2b744 3832done when your program stops.
70b88761
RP
3833
3834@item info display
3835@kindex info display
3836Print the list of expressions previously set up to display
3837automatically, each one with its item number, but without showing the
3838values. This includes disabled expressions, which are marked as such.
3839It also includes expressions which would not be displayed right now
3840because they refer to automatic variables not currently available.
3841@end table
3842
3843If a display expression refers to local variables, then it does not make
3844sense outside the lexical context for which it was set up. Such an
3845expression is disabled when execution enters a context where one of its
3846variables is not defined. For example, if you give the command
3847@code{display last_char} while inside a function with an argument
29a2b744 3848@code{last_char}, then this argument will be displayed while your program
70b88761
RP
3849continues to stop inside that function. When it stops elsewhere---where
3850there is no variable @code{last_char}---display is disabled. The next time
3851your program stops where @code{last_char} is meaningful, you can enable the
3852display expression once again.
3853
3854@node Print Settings, Value History, Auto Display, Data
3855@section Print Settings
3856
3857@cindex format options
3858@cindex print settings
3859_GDBN__ provides the following ways to control how arrays, structures,
e251e767 3860and symbols are printed.
70b88761
RP
3861
3862@noindent
3863These settings are useful for debugging programs in any language:
3864
3865@table @code
3866@item set print address
3867@item set print address on
3868@kindex set print address
3869_GDBN__ will print memory addresses showing the location of stack
3870traces, structure values, pointer values, breakpoints, and so forth,
3871even when it also displays the contents of those addresses. The default
3872is on. For example, this is what a stack frame display looks like, with
3873@code{set print address on}:
1041a570 3874
70b88761 3875@smallexample
1041a570 3876@group
70b88761 3877(_GDBP__) f
e251e767 3878#0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
70b88761 3879 at input.c:530
b80282d5 3880530 if (lquote != def_lquote)
1041a570 3881@end group
70b88761
RP
3882@end smallexample
3883
3884@item set print address off
3885Do not print addresses when displaying their contents. For example,
3886this is the same stack frame displayed with @code{set print address off}:
1041a570 3887
70b88761 3888@example
1041a570 3889@group
70b88761
RP
3890(_GDBP__) set print addr off
3891(_GDBP__) f
3892#0 set_quotes (lq="<<", rq=">>") at input.c:530
b80282d5 3893530 if (lquote != def_lquote)
1041a570 3894@end group
70b88761
RP
3895@end example
3896
3897@item show print address
3898@kindex show print address
3899Show whether or not addresses are to be printed.
3900
3901@item set print array
3902@itemx set print array on
3903@kindex set print array
3904_GDBN__ will pretty print arrays. This format is more convenient to read,
3905but uses more space. The default is off.
3906
3907@item set print array off.
3908Return to compressed format for arrays.
3909
3910@item show print array
3911@kindex show print array
3912Show whether compressed or pretty format is selected for displaying
e251e767 3913arrays.
70b88761
RP
3914
3915@item set print elements @var{number-of-elements}
3916@kindex set print elements
3917If _GDBN__ is printing a large array, it will stop printing after it has
3918printed the number of elements set by the @code{set print elements} command.
3919This limit also applies to the display of strings.
3920
3921@item show print elements
3922@kindex show print elements
3923Display the number of elements of a large array that _GDBN__ will print
3924before losing patience.
3925
3926@item set print pretty on
3927@kindex set print pretty
3928Cause _GDBN__ to print structures in an indented format with one member per
3929line, like this:
3930
3931@example
1041a570 3932@group
70b88761
RP
3933$1 = @{
3934 next = 0x0,
3935 flags = @{
3936 sweet = 1,
3937 sour = 1
3938 @},
3939 meat = 0x54 "Pork"
3940@}
1041a570 3941@end group
70b88761
RP
3942@end example
3943
3944@item set print pretty off
3945Cause _GDBN__ to print structures in a compact format, like this:
3946
3947@smallexample
1041a570 3948@group
38962738
RP
3949$1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, \
3950meat = 0x54 "Pork"@}
1041a570 3951@end group
70b88761
RP
3952@end smallexample
3953
3954@noindent
3955This is the default format.
3956
3957@item show print pretty
3958@kindex show print pretty
3959Show which format _GDBN__ will use to print structures.
3960
3961@item set print sevenbit-strings on
f2857bd9 3962@kindex set print sevenbit-strings
e251e767 3963Print using only seven-bit characters; if this option is set,
70b88761
RP
3964_GDBN__ will display any eight-bit characters (in strings or character
3965values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is
3966displayed as @code{\341}.
3967
3968@item set print sevenbit-strings off
3969Print using either seven-bit or eight-bit characters, as required. This
3970is the default.
3971
3972@item show print sevenbit-strings
f2857bd9 3973@kindex show print sevenbit-strings
70b88761
RP
3974Show whether or not _GDBN__ will print only seven-bit characters.
3975
3976@item set print union on
3977@kindex set print union
3978Tell _GDBN__ to print unions which are contained in structures. This is the
3979default setting.
3980
3981@item set print union off
3982Tell _GDBN__ not to print unions which are contained in structures.
3983
3984@item show print union
3985@kindex show print union
3986Ask _GDBN__ whether or not it will print unions which are contained in
e251e767 3987structures.
70b88761
RP
3988
3989For example, given the declarations
3990
3991@smallexample
3992typedef enum @{Tree, Bug@} Species;
3993typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
203eea5d
RP
3994typedef enum @{Caterpillar, Cocoon, Butterfly@}
3995 Bug_forms;
70b88761
RP
3996
3997struct thing @{
3998 Species it;
3999 union @{
4000 Tree_forms tree;
4001 Bug_forms bug;
4002 @} form;
4003@};
4004
4005struct thing foo = @{Tree, @{Acorn@}@};
4006@end smallexample
4007
4008@noindent
4009with @code{set print union on} in effect @samp{p foo} would print
4010
4011@smallexample
4012$1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
4013@end smallexample
4014
4015@noindent
4016and with @code{set print union off} in effect it would print
4017
4018@smallexample
4019$1 = @{it = Tree, form = @{...@}@}
4020@end smallexample
4021@end table
4022
4023@noindent
4024These settings are of interest when debugging C++ programs:
4025
4026@table @code
e251e767
RP
4027@item set print demangle
4028@itemx set print demangle on
70b88761
RP
4029@kindex set print demangle
4030Print C++ names in their source form rather than in the mangled form
4031in which they are passed to the assembler and linker for type-safe linkage.
4032The default is on.
4033
4034@item show print demangle
4035@kindex show print demangle
4036Show whether C++ names will be printed in mangled or demangled form.
4037
e251e767
RP
4038@item set print asm-demangle
4039@itemx set print asm-demangle on
70b88761
RP
4040@kindex set print asm-demangle
4041Print C++ names in their source form rather than their mangled form, even
4042in assembler code printouts such as instruction disassemblies.
4043The default is off.
4044
4045@item show print asm-demangle
4046@kindex show print asm-demangle
4047Show whether C++ names in assembly listings will be printed in mangled
4048or demangled form.
4049
4050@item set print object
4051@itemx set print object on
4052@kindex set print object
4053When displaying a pointer to an object, identify the @emph{actual}
4054(derived) type of the object rather than the @emph{declared} type, using
4055the virtual function table.
4056
4057@item set print object off
4058Display only the declared type of objects, without reference to the
4059virtual function table. This is the default setting.
4060
4061@item show print object
4062@kindex show print object
4063Show whether actual, or declared, object types will be displayed.
4064
e251e767
RP
4065@item set print vtbl
4066@itemx set print vtbl on
70b88761
RP
4067@kindex set print vtbl
4068Pretty print C++ virtual function tables. The default is off.
4069
4070@item set print vtbl off
4071Do not pretty print C++ virtual function tables.
4072
4073@item show print vtbl
4074@kindex show print vtbl
4075Show whether C++ virtual function tables are pretty printed, or not.
70b88761
RP
4076@end table
4077
4078@node Value History, Convenience Vars, Print Settings, Data
4079@section Value History
4080
4081@cindex value history
4082Values printed by the @code{print} command are saved in _GDBN__'s @dfn{value
4083history} so that you can refer to them in other expressions. Values are
4084kept until the symbol table is re-read or discarded (for example with
4085the @code{file} or @code{symbol-file} commands). When the symbol table
4086changes, the value history is discarded, since the values may contain
4087pointers back to the types defined in the symbol table.
4088
4089@cindex @code{$}
4090@cindex @code{$$}
4091@cindex history number
4092The values printed are given @dfn{history numbers} for you to refer to them
4093by. These are successive integers starting with one. @code{print} shows you
4094the history number assigned to a value by printing @samp{$@var{num} = }
4095before the value; here @var{num} is the history number.
4096
4097To refer to any previous value, use @samp{$} followed by the value's
4098history number. The way @code{print} labels its output is designed to
4099remind you of this. Just @code{$} refers to the most recent value in
4100the history, and @code{$$} refers to the value before that.
4101@code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
4102is the value just prior to @code{$$}, @code{$$1} is equivalent to
4103@code{$$}, and @code{$$0} is equivalent to @code{$}.
4104
4105For example, suppose you have just printed a pointer to a structure and
4106want to see the contents of the structure. It suffices to type
4107
4108@example
4109p *$
4110@end example
4111
4112If you have a chain of structures where the component @code{next} points
4113to the next one, you can print the contents of the next one with this:
4114
4115@example
4116p *$.next
4117@end example
4118
4119@noindent
4120You can print successive links in the chain by repeating this
4121command---which you can do by just typing @key{RET}.
4122
4123Note that the history records values, not expressions. If the value of
4124@code{x} is 4 and you type these commands:
4125
4126@example
4127print x
4128set x=5
4129@end example
4130
4131@noindent
4132then the value recorded in the value history by the @code{print} command
4133remains 4 even though the value of @code{x} has changed.
4134
4135@table @code
4136@kindex show values
4137@item show values
4138Print the last ten values in the value history, with their item numbers.
4139This is like @samp{p@ $$9} repeated ten times, except that @code{show
4140values} does not change the history.
4141
4142@item show values @var{n}
4143Print ten history values centered on history item number @var{n}.
4144
4145@item show values +
4146Print ten history values just after the values last printed. If no more
4147values are available, produces no display.
4148@end table
4149
4150Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the
e251e767 4151same effect as @samp{show values +}.
70b88761
RP
4152
4153@node Convenience Vars, Registers, Value History, Data
4154@section Convenience Variables
4155
4156@cindex convenience variables
4157_GDBN__ provides @dfn{convenience variables} that you can use within
4158_GDBN__ to hold on to a value and refer to it later. These variables
4159exist entirely within _GDBN__; they are not part of your program, and
4160setting a convenience variable has no direct effect on further execution
1041a570 4161of your program. That is why you can use them freely.
70b88761
RP
4162
4163Convenience variables are prefixed with @samp{$}. Any name preceded by
4164@samp{$} can be used for a convenience variable, unless it is one of
4165the predefined machine-specific register names (@pxref{Registers}).
4166(Value history references, in contrast, are @emph{numbers} preceded
1041a570 4167by @samp{$}. @xref{Value History, ,Value History}.)
70b88761
RP
4168
4169You can save a value in a convenience variable with an assignment
4170expression, just as you would set a variable in your program. Example:
4171
4172@example
4173set $foo = *object_ptr
4174@end example
4175
4176@noindent
4177would save in @code{$foo} the value contained in the object pointed to by
4178@code{object_ptr}.
4179
4180Using a convenience variable for the first time creates it; but its value
4181is @code{void} until you assign a new value. You can alter the value with
4182another assignment at any time.
4183
4184Convenience variables have no fixed types. You can assign a convenience
4185variable any type of value, including structures and arrays, even if
4186that variable already has a value of a different type. The convenience
4187variable, when used as an expression, has the type of its current value.
4188
4189@table @code
4190@item show convenience
4191@kindex show convenience
4192Print a list of convenience variables used so far, and their values.
4193Abbreviated @code{show con}.
4194@end table
4195
4196One of the ways to use a convenience variable is as a counter to be
4197incremented or a pointer to be advanced. For example, to print
4198a field from successive elements of an array of structures:
4199
4200_0__@example
4201set $i = 0
4202print bar[$i++]->contents
4203@i{@dots{} repeat that command by typing @key{RET}.}
4204_1__@end example
4205
4206Some convenience variables are created automatically by _GDBN__ and given
4207values likely to be useful.
4208
4209@table @code
4210@item $_
c338a2fd 4211@kindex $_
70b88761 4212The variable @code{$_} is automatically set by the @code{x} command to
29a2b744
RP
4213the last address examined (@pxref{Memory, ,Examining Memory}). Other
4214commands which provide a default address for @code{x} to examine also
4215set @code{$_} to that address; these commands include @code{info line}
4216and @code{info breakpoint}. The type of @code{$_} is @code{void *}
4217except when set by the @code{x} command, in which case it is a pointer
4218to the type of @code{$__}.
70b88761
RP
4219
4220@item $__
c338a2fd 4221@kindex $__
70b88761 4222The variable @code{$__} is automatically set by the @code{x} command
c2bbbb22
RP
4223to the value found in the last address examined. Its type is chosen
4224to match the format in which the data was printed.
70b88761
RP
4225@end table
4226
4227@node Registers, Floating Point Hardware, Convenience Vars, Data
4228@section Registers
4229
4230@cindex registers
b80282d5 4231You can refer to machine register contents, in expressions, as variables
70b88761
RP
4232with names starting with @samp{$}. The names of registers are different
4233for each machine; use @code{info registers} to see the names used on
e251e767 4234your machine.
70b88761
RP
4235
4236@table @code
4237@item info registers
4238@kindex info registers
b80282d5
RP
4239Print the names and values of all registers except floating-point
4240registers (in the selected stack frame).
4241
4242@item info all-registers
4243@kindex info all-registers
4244@cindex floating point registers
4245Print the names and values of all registers, including floating-point
4246registers.
70b88761
RP
4247
4248@item info registers @var{regname}
4249Print the relativized value of register @var{regname}. @var{regname}
4250may be any register name valid on the machine you are using, with
4251or without the initial @samp{$}.
4252@end table
4253
09267865 4254_GDBN__ has four ``standard'' register names that are available (in
29a2b744 4255expressions) on most machines---whenever they do not conflict with an
09267865
RP
4256architecture's canonical mnemonics for registers. The register names
4257@code{$pc} and @code{$sp} are used for the program counter register and
4258the stack pointer. @code{$fp} is used for a register that contains a
4259pointer to the current stack frame, and @code{$ps} is used for a
4260register that contains the processor status. For example,
70b88761 4261you could print the program counter in hex with
1041a570 4262
70b88761
RP
4263@example
4264p/x $pc
4265@end example
4266
4267@noindent
4268or print the instruction to be executed next with
1041a570 4269
70b88761
RP
4270@example
4271x/i $pc
4272@end example
4273
4274@noindent
29a2b744
RP
4275or add four to the stack pointer @footnote{This is a way of removing
4276one word from the stack, on machines where stacks grow downward in
4277memory (most machines, nowadays). This assumes that the innermost
4278stack frame is selected; setting @code{$sp} is not allowed when other
4279stack frames are selected. To pop entire frames off the stack,
4280regardless of machine architecture, use @code{return};
1041a570
RP
4281@pxref{Returning, ,Returning from a Function}.} with
4282
70b88761
RP
4283@example
4284set $sp += 4
4285@end example
4286
09267865
RP
4287Whenever possible, these four standard register names are available on
4288your machine even though the machine has different canonical mnemonics,
4289so long as there is no conflict. The @code{info registers} command
4290shows the canonical names. For example, on the SPARC, @code{info
70b88761
RP
4291registers} displays the processor status register as @code{$psr} but you
4292can also refer to it as @code{$ps}.
4293
4294_GDBN__ always considers the contents of an ordinary register as an
4295integer when the register is examined in this way. Some machines have
4296special registers which can hold nothing but floating point; these
4297registers are considered to have floating point values. There is no way
4298to refer to the contents of an ordinary register as floating point value
4299(although you can @emph{print} it as a floating point value with
4300@samp{print/f $@var{regname}}).
4301
4302Some registers have distinct ``raw'' and ``virtual'' data formats. This
4303means that the data format in which the register contents are saved by
4304the operating system is not the same one that your program normally
4305sees. For example, the registers of the 68881 floating point
4306coprocessor are always saved in ``extended'' (raw) format, but all C
4307programs expect to work with ``double'' (virtual) format. In such
4308cases, _GDBN__ normally works with the virtual format only (the format that
4309makes sense for your program), but the @code{info registers} command
4310prints the data in both formats.
4311
4312Normally, register values are relative to the selected stack frame
29a2b744
RP
4313(@pxref{Selection, ,Selecting a Frame}). This means that you get the
4314value that the register would contain if all stack frames farther in
4315were exited and their saved registers restored. In order to see the
4316true contents of hardware registers, you must select the innermost
4317frame (with @samp{frame 0}).
70b88761
RP
4318
4319However, _GDBN__ must deduce where registers are saved, from the machine
4320code generated by your compiler. If some registers are not saved, or if
4321_GDBN__ is unable to locate the saved registers, the selected stack
4322frame will make no difference.
4323
4324@node Floating Point Hardware, , Registers, Data
4325@section Floating Point Hardware
4326@cindex floating point
1041a570 4327
70b88761
RP
4328Depending on the host machine architecture, _GDBN__ may be able to give
4329you more information about the status of the floating point hardware.
4330
4331@table @code
4332@item info float
4333@kindex info float
4334If available, provides hardware-dependent information about the floating
4335point unit. The exact contents and layout vary depending on the
4336floating point chip.
4337@end table
4338@c FIXME: this is a cop-out. Try to get examples, explanations. Only
e251e767
RP
4339@c FIXME...supported currently on arm's and 386's. Mark properly with
4340@c FIXME... m4 macros to isolate general statements from hardware-dep,
70b88761
RP
4341@c FIXME... at that point.
4342
c2bbbb22
RP
4343@node Languages, Symbols, Data, Top
4344@chapter Using _GDBN__ with Different Languages
4345@cindex languages
4346
4347Although programming languages generally have common aspects, they are
4348rarely expressed in the same manner. For instance, in ANSI C,
4349dereferencing a pointer @code{p} is accomplished by @code{*p}, but in
4350Modula-2, it is accomplished by @code{p^}. Values can also be
4351represented (and displayed) differently. Hex numbers in C are written
4352like @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}.
4353
4354@cindex working language
4355Language-specific information is built into _GDBN__ for some languages,
29a2b744 4356allowing you to express operations like the above in your program's
c2bbbb22 4357native language, and allowing _GDBN__ to output values in a manner
29a2b744 4358consistent with the syntax of your program's native language. The
c2bbbb22
RP
4359language you use to build expressions, called the @dfn{working
4360language}, can be selected manually, or _GDBN__ can set it
4361automatically.
4362
4363@menu
4364* Setting:: Switching between source languages
4365* Show:: Displaying the language
4366* Checks:: Type and Range checks
4367* Support:: Supported languages
4368@end menu
4369
4370@node Setting, Show, Languages, Languages
4371@section Switching between source languages
4372
4373There are two ways to control the working language---either have _GDBN__
4374set it automatically, or select it manually yourself. You can use the
4375@code{set language} command for either purpose. On startup, _GDBN__
4376defaults to setting the language automatically.
4377
4378@menu
4379* Manually:: Setting the working language manually
4380* Automatically:: Having _GDBN__ infer the source language
4381@end menu
4382
4383@node Manually, Automatically, Setting, Setting
4384@subsection Setting the working language
4385
4386@kindex set language
4387To set the language, issue the command @samp{set language @var{lang}},
c338a2fd
RP
4388where @var{lang} is the name of a language: @code{c} or @code{modula-2}.
4389For a list of the supported languages, type @samp{set language}.
c2bbbb22
RP
4390
4391Setting the language manually prevents _GDBN__ from updating the working
4392language automatically. This can lead to confusion if you try
4393to debug a program when the working language is not the same as the
4394source language, when an expression is acceptable to both
4395languages---but means different things. For instance, if the current
4396source file were written in C, and _GDBN__ was parsing Modula-2, a
4397command such as:
4398
4399@example
4400print a = b + c
4401@end example
4402
4403@noindent
4404might not have the effect you intended. In C, this means to add
4405@code{b} and @code{c} and place the result in @code{a}. The result
4406printed would be the value of @code{a}. In Modula-2, this means to compare
4407@code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value.
4408
4409If you allow _GDBN__ to set the language automatically, then
4410you can count on expressions evaluating the same way in your debugging
4411session and in your program.
4412
4413@node Automatically, , Manually, Setting
4414@subsection Having _GDBN__ infer the source language
4415
4416To have _GDBN__ set the working language automatically, use @samp{set
4417language local} or @samp{set language auto}. _GDBN__ then infers the
4418language that a program was written in by looking at the name of its
4419source files, and examining their extensions:
4420
4421@table @file
4422@item *.mod
4423Modula-2 source file
4424
4425@item *.c
4426@itemx *.cc
4427C or C++ source file.
4428@end table
4429
4430This information is recorded for each function or procedure in a source
4431file. When your program stops in a frame (usually by encountering a
4432breakpoint), _GDBN__ sets the working language to the language recorded
4433for the function in that frame. If the language for a frame is unknown
4434(that is, if the function or block corresponding to the frame was
4435defined in a source file that does not have a recognized extension), the
4436current working language is not changed, and _GDBN__ issues a warning.
4437
4438This may not seem necessary for most programs, which are written
4439entirely in one source language. However, program modules and libraries
4440written in one source language can be used by a main program written in
4441a different source language. Using @samp{set language auto} in this
4442case frees you from having to set the working language manually.
4443
4444@node Show, Checks, Setting, Languages
4445@section Displaying the language
4446
4447The following commands will help you find out which language is the
4448working language, and also what language source files were written in.
4449
4450@kindex show language
4451@kindex info frame
4452@kindex info source
4453@table @code
4454@item show language
4455Display the current working language. This is the
4456language you can use with commands such as @code{print} to
29a2b744 4457build and compute expressions that may involve variables in your program.
c2bbbb22
RP
4458
4459@item info frame
1041a570 4460Among the other information listed here (@pxref{Frame Info, ,Information
c2bbbb22
RP
4461about a Frame}) is the source language for this frame. This is the
4462language that will become the working language if you ever use an
4463identifier that is in this frame.
4464
4465@item info source
1041a570 4466Among the other information listed here (@pxref{Symbols, ,Examining the
c2bbbb22 4467Symbol Table}) is the source language of this source file.
c2bbbb22
RP
4468@end table
4469
4470@node Checks, Support, Show, Languages
4471@section Type and range Checking
4472
4473@quotation
4474@emph{Warning:} In this release, the _GDBN__ commands for type and range
4475checking are included, but they do not yet have any effect. This
4476section documents the intended facilities.
4477@end quotation
4478@c FIXME remove warning when type/range code added
4479
4480Some languages are designed to guard you against making seemingly common
4481errors through a series of compile- and run-time checks. These include
4482checking the type of arguments to functions and operators, and making
4483sure mathematical overflows are caught at run time. Checks such as
4484these help to ensure a program's correctness once it has been compiled
4485by eliminating type mismatches, and providing active checks for range
29a2b744 4486errors when your program is running.
c2bbbb22 4487
1041a570
RP
4488_GDBN__ can check for conditions like the above if you wish.
4489Although _GDBN__ will not check the statements in your program, it
4490can check expressions entered directly into _GDBN__ for evaluation via
4491the @code{print} command, for example. As with the working language,
c2bbbb22 4492_GDBN__ can also decide whether or not to check automatically based on
1041a570
RP
4493your program's source language. @xref{Support, ,Supported Languages},
4494for the default settings of supported languages.
c2bbbb22
RP
4495
4496@menu
4497* Type Checking:: An overview of type checking
4498* Range Checking:: An overview of range checking
4499@end menu
4500
4501@cindex type checking
4502@cindex checks, type
4503@node Type Checking, Range Checking, Checks, Checks
4504@subsection An overview of type checking
4505
4506Some languages, such as Modula-2, are strongly typed, meaning that the
4507arguments to operators and functions have to be of the correct type,
4508otherwise an error occurs. These checks prevent type mismatch
4509errors from ever causing any run-time problems. For example,
4510
4511@example
45121 + 2 @result{} 3
1041a570 4513@exdent but
c2bbbb22
RP
4514@error{} 1 + 2.3
4515@end example
4516
4517The second example fails because the @code{CARDINAL} 1 is not
4518type-compatible with the @code{REAL} 2.3.
4519
4520For expressions you use in _GDBN__ commands, you can tell the _GDBN__
4521type checker to skip checking; to treat any mismatches as errors and
4522abandon the expression; or only issue warnings when type mismatches
4523occur, but evaluate the expression anyway. When you choose the last of
4524these, _GDBN__ evaluates expressions like the second example above, but
4525also issues a warning.
4526
4527Even though you may turn type checking off, other type-based reasons may
4528prevent _GDBN__ from evaluating an expression. For instance, _GDBN__ does not
4529know how to add an @code{int} and a @code{struct foo}. These particular
4530type errors have nothing to do with the language in use, and usually
4531arise from expressions, such as the one described above, which make
4532little sense to evaluate anyway.
4533
4534Each language defines to what degree it is strict about type. For
4535instance, both Modula-2 and C require the arguments to arithmetical
4536operators to be numbers. In C, enumerated types and pointers can be
4537represented as numbers, so that they are valid arguments to mathematical
1041a570 4538operators. @xref{Support, ,Supported Languages}, for further
c2bbbb22
RP
4539details on specific languages.
4540
4541_GDBN__ provides some additional commands for controlling the type checker:
4542
4543@kindex set check
4544@kindex set check type
4545@kindex show check type
4546@table @code
4547@item set check type auto
e251e767 4548Set type checking on or off based on the current working language.
1041a570 4549@xref{Support, ,Supported Languages}, for the default settings for
c2bbbb22
RP
4550each language.
4551
4552@item set check type on
4553@itemx set check type off
4554Set type checking on or off, overriding the default setting for the
4555current working language. Issue a warning if the setting does not
4556match the language's default. If any type mismatches occur in
4557evaluating an expression while typechecking is on, _GDBN__ prints a
4558message and aborts evaluation of the expression.
4559
4560@item set check type warn
4561Cause the type checker to issue warnings, but to always attempt to
4562evaluate the expression. Evaluating the expression may still
4563be impossible for other reasons. For example, _GDBN__ cannot add
4564numbers and structures.
4565
4566@item show type
e251e767 4567Show the current setting of the type checker, and whether or not _GDBN__ is
c2bbbb22
RP
4568setting it automatically.
4569@end table
4570
4571@cindex range checking
4572@cindex checks, range
4573@node Range Checking, , Type Checking, Checks
4574@subsection An overview of Range Checking
4575
4576In some languages (such as Modula-2), it is an error to exceed the
4577bounds of a type; this is enforced with run-time checks. Such range
4578checking is meant to ensure program correctness by making sure
4579computations do not overflow, or indices on an array element access do
4580not exceed the bounds of the array.
4581
4582For expressions you use in _GDBN__ commands, you can tell _GDBN__ to
4583ignore range errors; to always treat them as errors and abandon the
4584expression; or to issue warnings when a range error occurs but evaluate
4585the expression anyway.
4586
4587A range error can result from numerical overflow, from exceeding an
4588array index bound, or when you type in a constant that is not a member
4589of any type. Some languages, however, do not treat overflows as an
4590error. In many implementations of C, mathematical overflow causes the
4591result to ``wrap around'' to lower values---for example, if @var{m} is
4592the largest integer value, and @var{s} is the smallest, then
1041a570 4593
c2bbbb22
RP
4594@example
4595@var{m} + 1 @result{} @var{s}
4596@end example
4597
4598This, too, is specific to individual languages, and in some cases
1041a570 4599specific to individual compilers or machines. @xref{Support, ,
c2bbbb22
RP
4600Supported Languages}, for further details on specific languages.
4601
4602_GDBN__ provides some additional commands for controlling the range checker:
4603
4604@kindex set check
4605@kindex set check range
4606@kindex show check range
4607@table @code
4608@item set check range auto
e251e767 4609Set range checking on or off based on the current working language.
1041a570 4610@xref{Support, ,Supported Languages}, for the default settings for
c2bbbb22
RP
4611each language.
4612
4613@item set check range on
4614@itemx set check range off
4615Set range checking on or off, overriding the default setting for the
4616current working language. A warning is issued if the setting does not
4617match the language's default. If a range error occurs, then a message
4618is printed and evaluation of the expression is aborted.
4619
4620@item set check range warn
4621Output messages when the _GDBN__ range checker detects a range error,
4622but attempt to evaluate the expression anyway. Evaluating the
4623expression may still be impossible for other reasons, such as accessing
4624memory that the process does not own (a typical example from many UNIX
4625systems).
4626
4627@item show range
e251e767 4628Show the current setting of the range checker, and whether or not it is
c2bbbb22
RP
4629being set automatically by _GDBN__.
4630@end table
4631
4632@node Support, , Checks, Languages
4633@section Supported Languages
4634
1041a570
RP
4635_GDBN__ 4 supports C, C++, and Modula-2. The syntax for C and C++ is so
4636closely related that _GDBN__ does not distinguish the two. Some _GDBN__
4637features may be used in expressions regardless of the language you
4638use: the _GDBN__ @code{@@} and @code{::} operators, and the
4639@samp{@{type@}addr} construct (@pxref{Expressions, ,Expressions}) can be
4640used with the constructs of any of the supported languages.
c2bbbb22
RP
4641
4642The following sections detail to what degree each of these
4643source languages is supported by _GDBN__. These sections are
4644not meant to be language tutorials or references, but serve only as a
4645reference guide to what the _GDBN__ expression parser will accept, and
4646what input and output formats should look like for different languages.
4647There are many good books written on each of these languages; please
4648look to these for a language reference or tutorial.
4649
4650@menu
4651* C:: C and C++
4652* Modula-2:: Modula-2
4653@end menu
4654
4655@node C, Modula-2, Support, Support
4656@subsection C and C++
4657@cindex C and C++
4658
4659@cindex expressions in C or C++
4660Since C and C++ are so closely related, _GDBN__ does not distinguish
4661between them when interpreting the expressions recognized in _GDBN__
e251e767 4662commands.
b80282d5
RP
4663
4664@cindex C++
4665@kindex g++
4666@cindex GNU C++
c2bbbb22
RP
4667The C++ debugging facilities are jointly implemented by the GNU C++
4668compiler and _GDBN__. Therefore, to debug your C++ code effectively,
4669you must compile your C++ programs with the GNU C++ compiler,
4670@code{g++}.
4671
b80282d5 4672@menu
c2bbbb22
RP
4673* C Operators:: C and C++ Operators
4674* C Constants:: C and C++ Constants
4675* Cplusplus expressions:: C++ Expressions
4676* C Defaults:: Default settings for C and C++
4677* C Checks:: C and C++ Type and Range Checks
4678* Debugging C:: _GDBN__ and C
4679* Debugging C plus plus:: Special features for C++
b80282d5
RP
4680@end menu
4681
c2bbbb22
RP
4682@cindex C and C++ operators
4683@node C Operators, C Constants, C, C
4684@subsubsection C and C++ Operators
4685
4686Operators must be defined on values of specific types. For instance,
4687@code{+} is defined on numbers, but not on structures. Operators are
4688often defined on groups of types. For the purposes of C and C++, the
4689following definitions hold:
4690
4691@itemize @bullet
e251e767 4692@item
c2bbbb22
RP
4693@emph{Integral types} include @code{int} with any of its storage-class
4694specifiers, @code{char}, and @code{enum}s.
4695
4696@item
4697@emph{Floating-point types} include @code{float} and @code{double}.
4698
4699@item
4700@emph{Pointer types} include all types defined as @code{(@var{type}
4701*)}.
4702
e251e767 4703@item
c2bbbb22 4704@emph{Scalar types} include all of the above.
c2bbbb22
RP
4705@end itemize
4706
4707@noindent
4708The following operators are supported. They are listed here
4709in order of increasing precedence:
4710
4711@table @code
1041a570 4712_0__@item ,
c2bbbb22
RP
4713The comma or sequencing operator. Expressions in a comma-separated list
4714are evaluated from left to right, with the result of the entire
4715expression being the last expression evaluated.
4716
4717@item =
4718Assignment. The value of an assignment expression is the value
4719assigned. Defined on scalar types.
4720
4721@item @var{op}=
1041a570
RP
4722Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}},
4723and translated to @w{@code{@var{a} = @var{a op b}}}.
4724@w{@code{@var{op}=}} and @code{=} have the same precendence.
4725@var{op} is any one of the operators @code{|}, @code{^}, @code{&},
4726@code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}.
c2bbbb22
RP
4727
4728@item ?:
4729The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought
4730of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an
4731integral type.
4732
4733@item ||
1041a570 4734Logical @sc{or}. Defined on integral types.
c2bbbb22
RP
4735
4736@item &&
1041a570 4737Logical @sc{and}. Defined on integral types.
c2bbbb22
RP
4738
4739@item |
1041a570 4740Bitwise @sc{or}. Defined on integral types.
c2bbbb22
RP
4741
4742@item ^
1041a570 4743Bitwise exclusive-@sc{or}. Defined on integral types.
c2bbbb22
RP
4744
4745@item &
1041a570 4746Bitwise @sc{and}. Defined on integral types.
c2bbbb22
RP
4747
4748@item ==@r{, }!=
4749Equality and inequality. Defined on scalar types. The value of these
4750expressions is 0 for false and non-zero for true.
4751
4752@item <@r{, }>@r{, }<=@r{, }>=
4753Less than, greater than, less than or equal, greater than or equal.
4754Defined on scalar types. The value of these expressions is 0 for false
4755and non-zero for true.
4756
4757@item <<@r{, }>>
4758left shift, and right shift. Defined on integral types.
4759
e251e767 4760@item @@
1041a570 4761The _GDBN__ ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
c2bbbb22
RP
4762
4763@item +@r{, }-
4764Addition and subtraction. Defined on integral types, floating-point types and
e251e767 4765pointer types.
c2bbbb22
RP
4766
4767@item *@r{, }/@r{, }%
4768Multiplication, division, and modulus. Multiplication and division are
4769defined on integral and floating-point types. Modulus is defined on
4770integral types.
4771
4772@item ++@r{, }--
4773Increment and decrement. When appearing before a variable, the
4774operation is performed before the variable is used in an expression;
4775when appearing after it, the variable's value is used before the
4776operation takes place.
4777
4778@item *
4779Pointer dereferencing. Defined on pointer types. Same precedence as
4780@code{++}.
4781
4782@item &
4783Address operator. Defined on variables. Same precedence as @code{++}.
4784
6ca72cc6
RP
4785For debugging C++, _GDBN__ implements a use of @samp{&} beyond what's
4786allowed in the C++ language itself: you can use @samp{&(&@var{ref})}
4787(or, if you prefer, simply @samp{&&@var{ref}} to examine the address
4788where a C++ reference variable (declared with @samp{&@var{ref}}) is
4789stored.
4790
c2bbbb22
RP
4791@item -
4792Negative. Defined on integral and floating-point types. Same
4793precedence as @code{++}.
4794
4795@item !
4796Logical negation. Defined on integral types. Same precedence as
4797@code{++}.
4798
4799@item ~
4800Bitwise complement operator. Defined on integral types. Same precedence as
4801@code{++}.
4802
4803@item .@r{, }->
4804Structure member, and pointer-to-structure member. For convenience,
4805_GDBN__ regards the two as equivalent, choosing whether to dereference a
e251e767 4806pointer based on the stored type information.
c2bbbb22
RP
4807Defined on @code{struct}s and @code{union}s.
4808
4809@item []
4810Array indexing. @code{@var{a}[@var{i}]} is defined as
4811@code{*(@var{a}+@var{i})}. Same precedence as @code{->}.
4812
4813@item ()
4814Function parameter list. Same precedence as @code{->}.
4815
4816@item ::
4817C++ scope resolution operator. Defined on
4818@code{struct}, @code{union}, and @code{class} types.
4819
4820@item ::
1041a570
RP
4821The _GDBN__ scope operator (@pxref{Expressions, ,Expressions}). Same precedence as
4822@code{::}, above._1__
c2bbbb22
RP
4823@end table
4824
4825@cindex C and C++ constants
4826@node C Constants, Cplusplus expressions, C Operators, C
4827@subsubsection C and C++ Constants
4828
4829_GDBN__ allows you to express the constants of C and C++ in the
4830following ways:
4831
4832@itemize @bullet
c2bbbb22
RP
4833@item
4834Integer constants are a sequence of digits. Octal constants are
4835specified by a leading @samp{0} (ie. zero), and hexadecimal constants by
1041a570 4836a leading @samp{0x} or @samp{0X}. Constants may also end with a letter
c2bbbb22
RP
4837@samp{l}, specifying that the constant should be treated as a
4838@code{long} value.
4839
4840@item
4841Floating point constants are a sequence of digits, followed by a decimal
4842point, followed by a sequence of digits, and optionally followed by an
4843exponent. An exponent is of the form:
4844@samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another
4845sequence of digits. The @samp{+} is optional for positive exponents.
4846
4847@item
4848Enumerated constants consist of enumerated identifiers, or their
4849integral equivalents.
4850
4851@item
4852Character constants are a single character surrounded by single quotes
4853(@code{'}), or a number---the ordinal value of the corresponding character
4854(usually its @sc{ASCII} value). Within quotes, the single character may
4855be represented by a letter or by @dfn{escape sequences}, which are of
4856the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation
4857of the character's ordinal value; or of the form @samp{\@var{x}}, where
4858@samp{@var{x}} is a predefined special character---for example,
4859@samp{\n} for newline.
4860
4861@item
4862String constants are a sequence of character constants surrounded
4863by double quotes (@code{"}).
4864
4865@item
4866Pointer constants are an integral value.
c2bbbb22
RP
4867@end itemize
4868
c2bbbb22
RP
4869@node Cplusplus expressions, C Defaults, C Constants, C
4870@subsubsection C++ Expressions
b80282d5
RP
4871
4872@cindex expressions in C++
c2bbbb22
RP
4873_GDBN__'s expression handling has the following extensions to
4874interpret a significant subset of C++ expressions:
b80282d5
RP
4875
4876@enumerate
4877
4878@cindex member functions
e251e767 4879@item
b80282d5 4880Member function calls are allowed; you can use expressions like
1041a570 4881
b80282d5
RP
4882@example
4883count = aml->GetOriginal(x, y)
4884@end example
4885
4886@kindex this
4887@cindex namespace in C++
e251e767 4888@item
b80282d5
RP
4889While a member function is active (in the selected stack frame), your
4890expressions have the same namespace available as the member function;
4891that is, _GDBN__ allows implicit references to the class instance
4892pointer @code{this} following the same rules as C++.
4893
4894@cindex call overloaded functions
4895@cindex type conversions in C++
e251e767 4896@item
b80282d5
RP
4897You can call overloaded functions; _GDBN__ will resolve the function
4898call to the right definition, with one restriction---you must use
4899arguments of the type required by the function that you want to call.
4900_GDBN__ will not perform conversions requiring constructors or
4901user-defined type operators.
4902
4903@cindex reference declarations
4904@item
4905_GDBN__ understands variables declared as C++ references; you can use them in
4906expressions just as you do in C++ source---they are automatically
e251e767 4907dereferenced.
b80282d5
RP
4908
4909In the parameter list shown when _GDBN__ displays a frame, the values of
4910reference variables are not displayed (unlike other variables); this
4911avoids clutter, since references are often used for large structures.
4912The @emph{address} of a reference variable is always shown, unless
1041a570 4913you have specified @samp{set print address off}.
b80282d5
RP
4914
4915@item
4916_GDBN__ supports the C++ name resolution operator @code{::}---your
c2bbbb22
RP
4917expressions can use it just as expressions in your program do. Since
4918one scope may be defined in another, you can use @code{::} repeatedly if
4919necessary, for example in an expression like
4920@samp{@var{scope1}::@var{scope2}::@var{name}}. _GDBN__ also allows
4921resolving name scope by reference to source files, in both C and C++
1041a570 4922debugging (@pxref{Variables, ,Program Variables}).
b80282d5
RP
4923@end enumerate
4924
c2bbbb22
RP
4925@node C Defaults, C Checks, Cplusplus expressions, C
4926@subsubsection C and C++ Defaults
4927@cindex C and C++ defaults
4928
e251e767
RP
4929If you allow _GDBN__ to set type and range checking automatically, they
4930both default to @code{off} whenever the working language changes to
c2bbbb22
RP
4931C/C++. This happens regardless of whether you, or _GDBN__,
4932selected the working language.
4933
4934If you allow _GDBN__ to set the language automatically, it sets the
4935working language to C/C++ on entering code compiled from a source file
4936whose name ends with @file{.c} or @file{.cc}.
1041a570 4937@xref{Automatically, ,Having _GDBN__ infer the source language}, for
c2bbbb22
RP
4938further details.
4939
4940@node C Checks, Debugging C, C Defaults, C
4941@subsubsection C and C++ Type and Range Checks
4942@cindex C and C++ checks
4943
4944@quotation
4945@emph{Warning:} in this release, _GDBN__ does not yet perform type or
4946range checking.
4947@end quotation
4948@c FIXME remove warning when type/range checks added
4949
4950By default, when _GDBN__ parses C or C++ expressions, type checking
4951is not used. However, if you turn type checking on, _GDBN__ will
4952consider two variables type equivalent if:
4953
4954@itemize @bullet
4955@item
4956The two variables are structured and have the same structure, union, or
4957enumerated tag.
4958
e251e767 4959@item
c2bbbb22
RP
4960Two two variables have the same type name, or types that have been
4961declared equivalent through @code{typedef}.
4962
4963@ignore
4964@c leaving this out because neither J Gilmore nor R Pesch understand it.
4965@c FIXME--beers?
4966@item
4967The two @code{struct}, @code{union}, or @code{enum} variables are
4968declared in the same declaration. (Note: this may not be true for all C
4969compilers.)
4970@end ignore
c2bbbb22
RP
4971@end itemize
4972
4973Range checking, if turned on, is done on mathematical operations. Array
4974indices are not checked, since they are often used to index a pointer
4975that is not itself an array.
4976
4977@node Debugging C, Debugging C plus plus, C Checks, C
4978@subsubsection _GDBN__ and C
4979
4980The @code{set print union} and @code{show print union} commands apply to
4981the @code{union} type. When set to @samp{on}, any @code{union} that is
4982inside a @code{struct} or @code{class} will also be printed.
4983Otherwise, it will appear as @samp{@{...@}}.
4984
4985The @code{@@} operator aids in the debugging of dynamic arrays, formed
1041a570 4986with pointers and a memory allocation function. (@pxref{Expressions, ,Expressions})
c2bbbb22
RP
4987
4988@node Debugging C plus plus, , Debugging C, C
4989@subsubsection _GDBN__ Commands for C++
b80282d5
RP
4990
4991@cindex commands for C++
4992Some _GDBN__ commands are particularly useful with C++, and some are
4993designed specifically for use with C++. Here is a summary:
4994
4995@table @code
4996@cindex break in overloaded functions
4997@item @r{breakpoint menus}
4998When you want a breakpoint in a function whose name is overloaded,
4999_GDBN__'s breakpoint menus help you specify which function definition
5000you want. @xref{Breakpoint Menus}.
5001
5002@cindex overloading in C++
5003@item rbreak @var{regex}
5004Setting breakpoints using regular expressions is helpful for setting
5005breakpoints on overloaded functions that are not members of any special
e251e767 5006classes.
29a2b744 5007@xref{Set Breaks, ,Setting Breakpoints}.
b80282d5
RP
5008
5009@cindex C++ exception handling
5010@item catch @var{exceptions}
5011@itemx info catch
29a2b744 5012Debug C++ exception handling using these commands. @xref{Exception
1041a570 5013Handling, ,Breakpoints and Exceptions}.
b80282d5 5014
e251e767 5015@cindex inheritance
b80282d5
RP
5016@item ptype @var{typename}
5017Print inheritance relationships as well as other information for type
e251e767 5018@var{typename}.
1041a570 5019@xref{Symbols, ,Examining the Symbol Table}.
b80282d5
RP
5020
5021@cindex C++ symbol display
5022@item set print demangle
5023@itemx show print demangle
5024@itemx set print asm-demangle
5025@itemx show print asm-demangle
5026Control whether C++ symbols display in their source form, both when
5027displaying code as C++ source and when displaying disassemblies.
1041a570 5028@xref{Print Settings, ,Print Settings}.
b80282d5
RP
5029
5030@item set print object
5031@itemx show print object
e251e767 5032Choose whether to print derived (actual) or declared types of objects.
1041a570 5033@xref{Print Settings, ,Print Settings}.
b80282d5
RP
5034
5035@item set print vtbl
5036@itemx show print vtbl
5037Control the format for printing virtual function tables.
1041a570 5038@xref{Print Settings, ,Print Settings}.
b80282d5
RP
5039@end table
5040
c2bbbb22
RP
5041@node Modula-2, , C, Support
5042@subsection Modula-2
5043@cindex Modula-2
5044
5045The extensions made to _GDBN__ to support Modula-2 support output
5046from the GNU Modula-2 compiler (which is currently being developed).
5047Other Modula-2 compilers are not currently supported, and attempting to
5048debug executables produced by them will most likely result in an error
5049as _GDBN__ reads in the executable's symbol table.
5050
5051@cindex expressions in Modula-2
5052@menu
5053* M2 Operators:: Built-in operators
29a2b744 5054* Built-In Func/Proc:: Built-in Functions and Procedures
c2bbbb22
RP
5055* M2 Constants:: Modula-2 Constants
5056* M2 Defaults:: Default settings for Modula-2
5057* Deviations:: Deviations from standard Modula-2
5058* M2 Checks:: Modula-2 Type and Range Checks
5059* M2 Scope:: The scope operators @code{::} and @code{.}
5060* GDB/M2:: _GDBN__ and Modula-2
5061@end menu
5062
29a2b744 5063@node M2 Operators, Built-In Func/Proc, Modula-2, Modula-2
c2bbbb22
RP
5064@subsubsection Operators
5065@cindex Modula-2 operators
5066
5067Operators must be defined on values of specific types. For instance,
5068@code{+} is defined on numbers, but not on structures. Operators are
5069often defined on groups of types. For the purposes of Modula-2, the
5070following definitions hold:
5071
5072@itemize @bullet
5073
5074@item
5075@emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and
5076their subranges.
5077
5078@item
5079@emph{Character types} consist of @code{CHAR} and its subranges.
5080
5081@item
5082@emph{Floating-point types} consist of @code{REAL}.
5083
5084@item
5085@emph{Pointer types} consist of anything declared as @code{POINTER TO
5086@var{type}}.
5087
5088@item
5089@emph{Scalar types} consist of all of the above.
5090
5091@item
5092@emph{Set types} consist of @code{SET}s and @code{BITSET}s.
5093
5094@item
5095@emph{Boolean types} consist of @code{BOOLEAN}.
c2bbbb22
RP
5096@end itemize
5097
5098@noindent
5099The following operators are supported, and appear in order of
5100increasing precedence:
5101
5102@table @code
c2bbbb22
RP
5103@item ,
5104Function argument or array index separator.
1041a570 5105_0__
c2bbbb22
RP
5106@item :=
5107Assignment. The value of @var{var} @code{:=} @var{value} is
5108@var{value}.
5109
5110@item <@r{, }>
5111Less than, greater than on integral, floating-point, or enumerated
5112types.
5113
5114@item <=@r{, }>=
5115Less than, greater than, less than or equal to, greater than or equal to
5116on integral, floating-point and enumerated types, or set inclusion on
5117set types. Same precedence as @code{<}.
5118
5119@item =@r{, }<>@r{, }#
5120Equality and two ways of expressing inequality, valid on scalar types.
5121Same precedence as @code{<}. In _GDBN__ scripts, only @code{<>} is
5122available for inequality, since @code{#} conflicts with the script
5123comment character.
5124
5125@item IN
5126Set membership. Defined on set types and the types of their members.
5127Same precedence as @code{<}.
5128
5129@item OR
5130Boolean disjunction. Defined on boolean types.
5131
5132@item AND@r{, }&
5133Boolean conjuction. Defined on boolean types.
5134
5135@item @@
1041a570 5136The _GDBN__ ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
c2bbbb22
RP
5137
5138@item +@r{, }-
5139Addition and subtraction on integral and floating-point types, or union
5140and difference on set types.
5141
5142@item *
5143Multiplication on integral and floating-point types, or set intersection
5144on set types.
5145
5146@item /
5147Division on floating-point types, or symmetric set difference on set
5148types. Same precedence as @code{*}.
5149
5150@item DIV@r{, }MOD
5151Integer division and remainder. Defined on integral types. Same
5152precedence as @code{*}.
5153
5154@item -
5155Negative. Defined on @code{INTEGER}s and @code{REAL}s.
5156
5157@item ^
e251e767 5158Pointer dereferencing. Defined on pointer types.
c2bbbb22
RP
5159
5160@item NOT
5161Boolean negation. Defined on boolean types. Same precedence as
5162@code{^}.
5163
5164@item .
5165@code{RECORD} field selector. Defined on @code{RECORD}s. Same
5166precedence as @code{^}.
5167
5168@item []
5169Array indexing. Defined on @code{ARRAY}s. Same precedence as @code{^}.
5170
5171@item ()
5172Procedure argument list. Defined on @code{PROCEDURE}s. Same precedence
5173as @code{^}.
5174
5175@item ::@r{, }.
5176_GDBN__ and Modula-2 scope operators.
c2bbbb22
RP
5177@end table
5178
5179@quotation
5180@emph{Warning:} Sets and their operations are not yet supported, so _GDBN__
5181will treat the use of the operator @code{IN}, or the use of operators
5182@code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#},
5183@code{<=}, and @code{>=} on sets as an error.
5184@end quotation
5185_1__
29a2b744
RP
5186@cindex Modula-2 built-ins
5187@node Built-In Func/Proc, M2 Constants, M2 Operators, Modula-2
c2bbbb22
RP
5188@subsubsection Built-in Functions and Procedures
5189
5190Modula-2 also makes available several built-in procedures and functions.
5191In describing these, the following metavariables are used:
5192
5193@table @var
5194
5195@item a
5196represents an @code{ARRAY} variable.
5197
5198@item c
5199represents a @code{CHAR} constant or variable.
5200
5201@item i
5202represents a variable or constant of integral type.
5203
5204@item m
5205represents an identifier that belongs to a set. Generally used in the
5206same function with the metavariable @var{s}. The type of @var{s} should
5207be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}.
5208
5209@item n
5210represents a variable or constant of integral or floating-point type.
5211
5212@item r
5213represents a variable or constant of floating-point type.
5214
5215@item t
5216represents a type.
5217
5218@item v
5219represents a variable.
5220
5221@item x
5222represents a variable or constant of one of many types. See the
5223explanation of the function for details.
c2bbbb22
RP
5224@end table
5225
5226All Modula-2 built-in procedures also return a result, described below.
5227
5228@table @code
5229@item ABS(@var{n})
5230Returns the absolute value of @var{n}.
5231
5232@item CAP(@var{c})
5233If @var{c} is a lower case letter, it returns its upper case
5234equivalent, otherwise it returns its argument
5235
5236@item CHR(@var{i})
5237Returns the character whose ordinal value is @var{i}.
5238
5239@item DEC(@var{v})
5240Decrements the value in the variable @var{v}. Returns the new value.
5241
5242@item DEC(@var{v},@var{i})
5243Decrements the value in the variable @var{v} by @var{i}. Returns the
5244new value.
5245
5246@item EXCL(@var{m},@var{s})
5247Removes the element @var{m} from the set @var{s}. Returns the new
5248set.
5249
5250@item FLOAT(@var{i})
5251Returns the floating point equivalent of the integer @var{i}.
5252
5253@item HIGH(@var{a})
5254Returns the index of the last member of @var{a}.
5255
5256@item INC(@var{v})
5257Increments the value in the variable @var{v}. Returns the new value.
5258
5259@item INC(@var{v},@var{i})
5260Increments the value in the variable @var{v} by @var{i}. Returns the
5261new value.
5262
5263@item INCL(@var{m},@var{s})
5264Adds the element @var{m} to the set @var{s} if it is not already
5265there. Returns the new set.
5266
5267@item MAX(@var{t})
5268Returns the maximum value of the type @var{t}.
5269
5270@item MIN(@var{t})
5271Returns the minimum value of the type @var{t}.
5272
5273@item ODD(@var{i})
5274Returns boolean TRUE if @var{i} is an odd number.
5275
5276@item ORD(@var{x})
5277Returns the ordinal value of its argument. For example, the ordinal
5278value of a character is its ASCII value (on machines supporting the
5279ASCII character set). @var{x} must be of an ordered type, which include
5280integral, character and enumerated types.
5281
5282@item SIZE(@var{x})
5283Returns the size of its argument. @var{x} can be a variable or a type.
5284
5285@item TRUNC(@var{r})
5286Returns the integral part of @var{r}.
5287
5288@item VAL(@var{t},@var{i})
5289Returns the member of the type @var{t} whose ordinal value is @var{i}.
5290@end table
5291
5292@quotation
5293@emph{Warning:} Sets and their operations are not yet supported, so
5294_GDBN__ will treat the use of procedures @code{INCL} and @code{EXCL} as
5295an error.
5296@end quotation
5297
5298@cindex Modula-2 constants
29a2b744 5299@node M2 Constants, M2 Defaults, Built-In Func/Proc, Modula-2
c2bbbb22
RP
5300@subsubsection Constants
5301
5302_GDBN__ allows you to express the constants of Modula-2 in the following
5303ways:
5304
5305@itemize @bullet
5306
5307@item
5308Integer constants are simply a sequence of digits. When used in an
5309expression, a constant is interpreted to be type-compatible with the
5310rest of the expression. Hexadecimal integers are specified by a
5311trailing @samp{H}, and octal integers by a trailing @samp{B}.
5312
5313@item
5314Floating point constants appear as a sequence of digits, followed by a
5315decimal point and another sequence of digits. An optional exponent can
5316then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where
5317@samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the
5318digits of the floating point constant must be valid decimal (base 10)
5319digits.
5320
5321@item
5322Character constants consist of a single character enclosed by a pair of
5323like quotes, either single (@code{'}) or double (@code{"}). They may
5324also be expressed by their ordinal value (their ASCII value, usually)
5325followed by a @samp{C}.
5326
5327@item
1041a570
RP
5328String constants consist of a sequence of characters enclosed by a
5329pair of like quotes, either single (@code{'}) or double (@code{"}).
5330Escape sequences in the style of C are also allowed. @xref{C
5331Constants, ,C and C++ Constants}, for a brief explanation of escape
5332sequences.
c2bbbb22
RP
5333
5334@item
5335Enumerated constants consist of an enumerated identifier.
5336
5337@item
5338Boolean constants consist of the identifiers @code{TRUE} and
5339@code{FALSE}.
5340
5341@item
5342Pointer constants consist of integral values only.
5343
5344@item
5345Set constants are not yet supported.
c2bbbb22
RP
5346@end itemize
5347
5348@node M2 Defaults, Deviations, M2 Constants, Modula-2
5349@subsubsection Modula-2 Defaults
5350@cindex Modula-2 defaults
5351
e251e767
RP
5352If type and range checking are set automatically by _GDBN__, they
5353both default to @code{on} whenever the working language changes to
c2bbbb22
RP
5354Modula-2. This happens regardless of whether you, or _GDBN__,
5355selected the working language.
5356
5357If you allow _GDBN__ to set the language automatically, then entering
5358code compiled from a file whose name ends with @file{.mod} will set the
1041a570 5359working language to Modula-2. @xref{Automatically, ,Having _GDBN__ set
c2bbbb22
RP
5360the language automatically}, for further details.
5361
5362@node Deviations, M2 Checks, M2 Defaults, Modula-2
5363@subsubsection Deviations from Standard Modula-2
5364@cindex Modula-2, deviations from
5365
5366A few changes have been made to make Modula-2 programs easier to debug.
5367This is done primarily via loosening its type strictness:
5368
5369@itemize @bullet
e251e767 5370@item
c2bbbb22
RP
5371Unlike in standard Modula-2, pointer constants can be formed by
5372integers. This allows you to modify pointer variables during
5373debugging. (In standard Modula-2, the actual address contained in a
5374pointer variable is hidden from you; it can only be modified
5375through direct assignment to another pointer variable or expression that
5376returned a pointer.)
5377
e251e767 5378@item
c2bbbb22
RP
5379C escape sequences can be used in strings and characters to represent
5380non-printable characters. _GDBN__ will print out strings with these
5381escape sequences embedded. Single non-printable characters are
5382printed using the @samp{CHR(@var{nnn})} format.
5383
5384@item
5385The assignment operator (@code{:=}) returns the value of its right-hand
5386argument.
5387
5388@item
29a2b744 5389All built-in procedures both modify @emph{and} return their argument.
e251e767 5390@end itemize
c2bbbb22
RP
5391
5392@node M2 Checks, M2 Scope, Deviations, Modula-2
5393@subsubsection Modula-2 Type and Range Checks
5394@cindex Modula-2 checks
5395
5396@quotation
5397@emph{Warning:} in this release, _GDBN__ does not yet perform type or
5398range checking.
5399@end quotation
5400@c FIXME remove warning when type/range checks added
5401
5402_GDBN__ considers two Modula-2 variables type equivalent if:
5403
5404@itemize @bullet
5405@item
5406They are of types that have been declared equivalent via a @code{TYPE
5407@var{t1} = @var{t2}} statement
5408
5409@item
5410They have been declared on the same line. (Note: This is true of the
5411GNU Modula-2 compiler, but it may not be true of other compilers.)
c2bbbb22
RP
5412@end itemize
5413
5414As long as type checking is enabled, any attempt to combine variables
5415whose types are not equivalent is an error.
5416
5417Range checking is done on all mathematical operations, assignment, array
29a2b744 5418index bounds, and all built-in functions and procedures.
c2bbbb22
RP
5419
5420@node M2 Scope, GDB/M2, M2 Checks, Modula-2
5421@subsubsection The scope operators @code{::} and @code{.}
5422@cindex scope
5423@kindex .
e94b4a2b 5424@cindex colon, doubled as scope operator
1041a570
RP
5425@ifinfo
5426@kindex colon-colon
5427@c Info cannot handoe :: but TeX can.
5428@end ifinfo
5429@iftex
c2bbbb22 5430@kindex ::
1041a570 5431@end iftex
c2bbbb22
RP
5432
5433There are a few subtle differences between the Modula-2 scope operator
5434(@code{.}) and the _GDBN__ scope operator (@code{::}). The two have
5435similar syntax:
5436
5437@example
5438
5439@var{module} . @var{id}
5440@var{scope} :: @var{id}
c2bbbb22
RP
5441@end example
5442
5443@noindent
5444where @var{scope} is the name of a module or a procedure,
29a2b744
RP
5445@var{module} the name of a module, and @var{id} is any declared
5446identifier within your program, except another module.
c2bbbb22
RP
5447
5448Using the @code{::} operator makes _GDBN__ search the scope
5449specified by @var{scope} for the identifier @var{id}. If it is not
5450found in the specified scope, then _GDBN__ will search all scopes
5451enclosing the one specified by @var{scope}.
5452
5453Using the @code{.} operator makes _GDBN__ search the current scope for
5454the identifier specified by @var{id} that was imported from the
5455definition module specified by @var{module}. With this operator, it is
5456an error if the identifier @var{id} was not imported from definition
5457module @var{module}, or if @var{id} is not an identifier in
5458@var{module}.
5459
5460@node GDB/M2, , M2 Scope, Modula-2
5461@subsubsection _GDBN__ and Modula-2
5462
5463Some _GDBN__ commands have little use when debugging Modula-2 programs.
5464Five subcommands of @code{set print} and @code{show print} apply
5465specifically to C and C++: @samp{vtbl}, @samp{demangle},
5466@samp{asm-demangle}, @samp{object}, and @samp{union}. The first four
5467apply to C++, and the last to C's @code{union} type, which has no direct
5468analogue in Modula-2.
5469
1041a570 5470The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available
c2bbbb22
RP
5471while using any language, is not useful with Modula-2. Its
5472intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be
5473created in Modula-2 as they can in C or C++. However, because an
5474address can be specified by an integral constant, the construct
1041a570 5475@samp{@{@var{type}@}@var{adrexp}} is still useful. (@pxref{Expressions, ,Expressions})
c2bbbb22
RP
5476_0__
5477@cindex @code{#} in Modula-2
5478In _GDBN__ scripts, the Modula-2 inequality operator @code{#} is
5479interpreted as the beginning of a comment. Use @code{<>} instead.
5480_1__
c2bbbb22 5481@node Symbols, Altering, Languages, Top
70b88761
RP
5482@chapter Examining the Symbol Table
5483
5484The commands described in this section allow you to inquire about the
5485symbols (names of variables, functions and types) defined in your
5486program. This information is inherent in the text of your program and
29a2b744 5487does not change as your program executes. _GDBN__ finds it in your
e251e767 5488program's symbol table, in the file indicated when you started _GDBN__
1041a570
RP
5489(@pxref{File Options, ,Choosing Files}), or by one of the
5490file-management commands (@pxref{Files, ,Commands to Specify Files}).
70b88761
RP
5491
5492@table @code
5493@item info address @var{symbol}
5494@kindex info address
5495Describe where the data for @var{symbol} is stored. For a register
5496variable, this says which register it is kept in. For a non-register
5497local variable, this prints the stack-frame offset at which the variable
5498is always stored.
5499
5500Note the contrast with @samp{print &@var{symbol}}, which does not work
5501at all for a register variables, and for a stack local variable prints
5502the exact address of the current instantiation of the variable.
5503
5504@item whatis @var{exp}
5505@kindex whatis
5506Print the data type of expression @var{exp}. @var{exp} is not
5507actually evaluated, and any side-effecting operations (such as
5508assignments or function calls) inside it do not take place.
1041a570 5509@xref{Expressions, ,Expressions}.
70b88761
RP
5510
5511@item whatis
5512Print the data type of @code{$}, the last value in the value history.
5513
5514@item ptype @var{typename}
5515@kindex ptype
5516Print a description of data type @var{typename}. @var{typename} may be
5517the name of a type, or for C code it may have the form
5518@samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or
1041a570 5519@samp{enum @var{enum-tag}}.
70b88761
RP
5520
5521@item ptype @var{exp}
e0dacfd1 5522@itemx ptype
70b88761 5523Print a description of the type of expression @var{exp}. @code{ptype}
1041a570
RP
5524differs from @code{whatis} by printing a detailed description, instead
5525of just the name of the type. For example, if your program declares a
5526variable as
5527
70b88761
RP
5528@example
5529struct complex @{double real; double imag;@} v;
5530@end example
1041a570 5531
70b88761
RP
5532@noindent
5533compare the output of the two commands:
1041a570 5534
70b88761 5535@example
1041a570 5536@group
70b88761
RP
5537(_GDBP__) whatis v
5538type = struct complex
5539(_GDBP__) ptype v
5540type = struct complex @{
5541 double real;
5542 double imag;
5543@}
1041a570 5544@end group
70b88761 5545@end example
1041a570 5546
e0dacfd1
RP
5547@noindent
5548As with @code{whatis}, using @code{ptype} without an argument refers to
5549the type of @code{$}, the last value in the value history.
70b88761
RP
5550
5551@item info types @var{regexp}
5552@itemx info types
e251e767 5553@kindex info types
70b88761
RP
5554Print a brief description of all types whose name matches @var{regexp}
5555(or all types in your program, if you supply no argument). Each
5556complete typename is matched as though it were a complete line; thus,
5557@samp{i type value} gives information on all types in your program whose
5558name includes the string @code{value}, but @samp{i type ^value$} gives
5559information only on types whose complete name is @code{value}.
5560
5561This command differs from @code{ptype} in two ways: first, like
5562@code{whatis}, it does not print a detailed description; second, it
5563lists all source files where a type is defined.
5564
5565@item info source
5566@kindex info source
5567Show the name of the current source file---that is, the source file for
c2bbbb22
RP
5568the function containing the current point of execution---and the language
5569it was written in.
70b88761
RP
5570
5571@item info sources
5572@kindex info sources
29a2b744 5573Print the names of all source files in your program for which there is
b80282d5
RP
5574debugging information, organized into two lists: files whose symbols
5575have already been read, and files whose symbols will be read when needed.
70b88761
RP
5576
5577@item info functions
5578@kindex info functions
5579Print the names and data types of all defined functions.
5580
5581@item info functions @var{regexp}
5582Print the names and data types of all defined functions
5583whose names contain a match for regular expression @var{regexp}.
5584Thus, @samp{info fun step} finds all functions whose names
5585include @code{step}; @samp{info fun ^step} finds those whose names
5586start with @code{step}.
5587
5588@item info variables
5589@kindex info variables
5590Print the names and data types of all variables that are declared
5591outside of functions (i.e., excluding local variables).
5592
5593@item info variables @var{regexp}
5594Print the names and data types of all variables (except for local
5595variables) whose names contain a match for regular expression
5596@var{regexp}.
5597
70b88761
RP
5598@ignore
5599This was never implemented.
5600@item info methods
5601@itemx info methods @var{regexp}
5602@kindex info methods
5603The @code{info methods} command permits the user to examine all defined
5604methods within C++ program, or (with the @var{regexp} argument) a
5605specific set of methods found in the various C++ classes. Many
5606C++ classes provide a large number of methods. Thus, the output
5607from the @code{ptype} command can be overwhelming and hard to use. The
5608@code{info-methods} command filters the methods, printing only those
5609which match the regular-expression @var{regexp}.
5610@end ignore
5611
5612@item printsyms @var{filename}
440d9834 5613@itemx printpsyms @var{filename}
d24e0922 5614@itemx printmsyms @var{filename}
70b88761 5615@kindex printsyms
440d9834
RP
5616@cindex symbol dump
5617@kindex printsyms
5618@cindex partial symbol dump
5619Write a dump of debugging symbol data into the file @var{filename}.
e0dacfd1
RP
5620These commands are used to debug the _GDBN__ symbol-reading code. Only
5621symbols with debugging data are included. If you use @code{printsyms},
5622_GDBN__ includes all the symbols for which it has already collected full
5623details: that is, @var{filename} reflects symbols for only those files
5624whose symbols _GDBN__ has read. You can use the command @code{info
5625sources} to find out which files these are. If you use
d24e0922 5626@code{printpsyms} instead, the dump shows information about symbols that
e0dacfd1 5627_GDBN__ only knows partially---that is, symbols defined in files that
d24e0922 5628_GDBN__ has skimmed, but not yet read completely. Finally,
717b47f4 5629@code{printmsyms} dumps just the minimal symbol information required for
d24e0922
RP
5630each object file from which _GDBN__ has read some symbols. The description of
5631@code{symbol-file} explains how _GDBN__ reads symbols; both @code{info
5632source} and @code{symbol-file} are described in @ref{Files, ,Commands
5633to Specify Files}.
70b88761
RP
5634@end table
5635
5636@node Altering, _GDBN__ Files, Symbols, Top
5637@chapter Altering Execution
5638
29a2b744 5639Once you think you have found an error in your program, you might want to
70b88761
RP
5640find out for certain whether correcting the apparent error would lead to
5641correct results in the rest of the run. You can find the answer by
5642experiment, using the _GDBN__ features for altering execution of the
5643program.
5644
5645For example, you can store new values into variables or memory
29a2b744 5646locations, give your program a signal, restart it at a different address,
70b88761
RP
5647or even return prematurely from a function to its caller.
5648
5649@menu
b80282d5
RP
5650* Assignment:: Assignment to Variables
5651* Jumping:: Continuing at a Different Address
29a2b744 5652* Signaling:: Giving your program a Signal
b80282d5
RP
5653* Returning:: Returning from a Function
5654* Calling:: Calling your Program's Functions
c338a2fd 5655* Patching:: Patching your Program
70b88761
RP
5656@end menu
5657
5658@node Assignment, Jumping, Altering, Altering
5659@section Assignment to Variables
5660
5661@cindex assignment
5662@cindex setting variables
5663To alter the value of a variable, evaluate an assignment expression.
1041a570 5664@xref{Expressions, ,Expressions}. For example,
70b88761
RP
5665
5666@example
5667print x=4
5668@end example
5669
5670@noindent
1041a570
RP
5671stores the value 4 into the variable @code{x}, and then prints the
5672value of the assignment expression (which is 4). @xref{Languages,
5673,Using _GDBN__ with Different Languages}, for more information on
5674operators in supported languages.
70b88761 5675
70b88761
RP
5676@kindex set variable
5677@cindex variables, setting
5678If you are not interested in seeing the value of the assignment, use the
5679@code{set} command instead of the @code{print} command. @code{set} is
5680really the same as @code{print} except that the expression's value is not
1041a570 5681printed and is not put in the value history (@pxref{Value History, ,Value History}). The
70b88761
RP
5682expression is evaluated only for its effects.
5683
5684If the beginning of the argument string of the @code{set} command
5685appears identical to a @code{set} subcommand, use the @code{set
5686variable} command instead of just @code{set}. This command is identical
5687to @code{set} except for its lack of subcommands. For example, a
5688program might well have a variable @code{width}---which leads to
5689an error if we try to set a new value with just @samp{set width=13}, as
1041a570
RP
5690we might if @code{set width} did not happen to be a _GDBN__ command:
5691
70b88761
RP
5692@example
5693(_GDBP__) whatis width
5694type = double
5695(_GDBP__) p width
5696$4 = 13
5697(_GDBP__) set width=47
5698Invalid syntax in expression.
5699@end example
1041a570 5700
70b88761
RP
5701@noindent
5702The invalid expression, of course, is @samp{=47}. What we can do in
e251e767 5703order to actually set our program's variable @code{width} is
1041a570 5704
70b88761
RP
5705@example
5706(_GDBP__) set var width=47
5707@end example
5708
1041a570
RP
5709_GDBN__ allows more implicit conversions in assignments than C; you can
5710freely store an integer value into a pointer variable or vice versa,
5711and any structure can be converted to any other structure that is the
5712same length or shorter.
e251e767 5713@comment FIXME: how do structs align/pad in these conversions?
70b88761
RP
5714@comment /[email protected] 18dec1990
5715
5716To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
5717construct to generate a value of specified type at a specified address
1041a570 5718(@pxref{Expressions, ,Expressions}). For example, @code{@{int@}0x83040} refers
70b88761
RP
5719to memory location @code{0x83040} as an integer (which implies a certain size
5720and representation in memory), and
5721
5722@example
5723set @{int@}0x83040 = 4
5724@end example
5725
5726@noindent
5727stores the value 4 into that memory location.
5728
5729@node Jumping, Signaling, Assignment, Altering
5730@section Continuing at a Different Address
5731
29a2b744 5732Ordinarily, when you continue your program, you do so at the place where
70b88761
RP
5733it stopped, with the @code{continue} command. You can instead continue at
5734an address of your own choosing, with the following commands:
5735
5736@table @code
5737@item jump @var{linespec}
5738@kindex jump
5739Resume execution at line @var{linespec}. Execution will stop
29a2b744
RP
5740immediately if there is a breakpoint there. @xref{List, ,Printing
5741Source Lines}, for a description of the different forms of
5742@var{linespec}.
70b88761
RP
5743
5744The @code{jump} command does not change the current stack frame, or
5745the stack pointer, or the contents of any memory location or any
5746register other than the program counter. If line @var{linespec} is in
5747a different function from the one currently executing, the results may
5748be bizarre if the two functions expect different patterns of arguments or
5749of local variables. For this reason, the @code{jump} command requests
5750confirmation if the specified line is not in the function currently
5751executing. However, even bizarre results are predictable if you are
29a2b744 5752well acquainted with the machine-language code of your program.
70b88761
RP
5753
5754@item jump *@var{address}
5755Resume execution at the instruction at address @var{address}.
5756@end table
5757
5758You can get much the same effect as the @code{jump} command by storing a
5759new value into the register @code{$pc}. The difference is that this
29a2b744 5760does not start your program running; it only changes the address where it
70b88761
RP
5761@emph{will} run when it is continued. For example,
5762
5763@example
5764set $pc = 0x485
5765@end example
5766
5767@noindent
5768causes the next @code{continue} command or stepping command to execute at
1041a570
RP
5769address @code{0x485}, rather than at the address where your program stopped.
5770@xref{Continuing and Stepping, ,Continuing and Stepping}.
70b88761
RP
5771
5772The most common occasion to use the @code{jump} command is to back up,
5773perhaps with more breakpoints set, over a portion of a program that has
5774already executed, in order to examine its execution in more detail.
5775
5776@node Signaling, Returning, Jumping, Altering
5777@c @group
29a2b744 5778@section Giving your program a Signal
70b88761
RP
5779
5780@table @code
5781@item signal @var{signalnum}
5782@kindex signal
29a2b744 5783Resume execution where your program stopped, but give it immediately the
70b88761
RP
5784signal number @var{signalnum}.
5785
5786Alternatively, if @var{signalnum} is zero, continue execution without
29a2b744 5787giving a signal. This is useful when your program stopped on account of
70b88761
RP
5788a signal and would ordinary see the signal when resumed with the
5789@code{continue} command; @samp{signal 0} causes it to resume without a
5790signal.
5791
5792@code{signal} does not repeat when you press @key{RET} a second time
5793after executing the command.
5794@end table
5795@c @end group
5796
5797@node Returning, Calling, Signaling, Altering
5798@section Returning from a Function
5799
5800@table @code
5801@item return
5802@itemx return @var{expression}
5803@cindex returning from a function
5804@kindex return
5805You can cancel execution of a function call with the @code{return}
5806command. If you give an
5807@var{expression} argument, its value is used as the function's return
e251e767 5808value.
70b88761
RP
5809@end table
5810
5811When you use @code{return}, _GDBN__ discards the selected stack frame
5812(and all frames within it). You can think of this as making the
5813discarded frame return prematurely. If you wish to specify a value to
5814be returned, give that value as the argument to @code{return}.
5815
29a2b744
RP
5816This pops the selected stack frame (@pxref{Selection, ,Selecting a
5817Frame}), and any other frames inside of it, leaving its caller as the
5818innermost remaining frame. That frame becomes selected. The
5819specified value is stored in the registers used for returning values
5820of functions.
70b88761
RP
5821
5822The @code{return} command does not resume execution; it leaves the
5823program stopped in the state that would exist if the function had just
1041a570
RP
5824returned. In contrast, the @code{finish} command (@pxref{Continuing
5825and Stepping, ,Continuing and Stepping}) resumes execution until the
5826selected stack frame returns naturally.
70b88761 5827
c338a2fd 5828@node Calling, Patching, Returning, Altering
70b88761
RP
5829@section Calling your Program's Functions
5830
5831@cindex calling functions
5832@kindex call
5833@table @code
5834@item call @var{expr}
5835Evaluate the expression @var{expr} without displaying @code{void}
5836returned values.
5837@end table
5838
5839You can use this variant of the @code{print} command if you want to
5840execute a function from your program, but without cluttering the output
5841with @code{void} returned values. The result is printed and saved in
5842the value history, if it is not void.
5843
c338a2fd
RP
5844@node Patching, , Calling, Altering
5845@section Patching your Program
5846@cindex patching binaries
5847@cindex writing into executables
5848@cindex writing into corefiles
1041a570 5849
c338a2fd
RP
5850By default, _GDBN__ opens the file containing your program's executable
5851code (or the corefile) read-only. This prevents accidental alterations
5852to machine code; but it also prevents you from intentionally patching
5853your program's binary.
5854
5855If you'd like to be able to patch the binary, you can specify that
5856explicitly with the @code{set write} command. For example, you might
5857want to turn on internal debugging flags, or even to make emergency
e251e767 5858repairs.
c338a2fd
RP
5859
5860@table @code
5861@item set write on
5862@itemx set write off
5863@kindex set write
5864If you specify @samp{set write on}, _GDBN__ will open executable and
5865core files for both reading and writing; if you specify @samp{set write
5866off} (the default), _GDBN__ will open them read-only.
5867
1041a570 5868If you have already loaded a file, you must load it
c338a2fd
RP
5869again (using the @code{exec-file} or @code{core-file} command) after
5870changing @code{set write}, for your new setting to take effect.
5871
5872@item show write
7d7ff5f6 5873@kindex show write
c338a2fd
RP
5874Display whether executable files and core files will be opened for
5875writing as well as reading.
c338a2fd
RP
5876@end table
5877
70b88761
RP
5878@node _GDBN__ Files, Targets, Altering, Top
5879@chapter _GDBN__'s Files
5880
1041a570
RP
5881_GDBN__ needs to know the file name of the program to be debugged, both in
5882order to read its symbol table and in order to start your program. To
5883debug a core dump of a previous run, _GDBN__ must be told the file name of
5884the core dump.
5885
70b88761 5886@menu
b80282d5
RP
5887* Files:: Commands to Specify Files
5888* Symbol Errors:: Errors Reading Symbol Files
70b88761
RP
5889@end menu
5890
5891@node Files, Symbol Errors, _GDBN__ Files, _GDBN__ Files
5892@section Commands to Specify Files
5893@cindex core dump file
5894@cindex symbol table
70b88761 5895
1041a570
RP
5896The usual way to specify executable and core dump file names is with
5897the command arguments given when you start _GDBN__, (@pxref{Invocation,
5898,Getting In and Out of _GDBN__}.
70b88761
RP
5899
5900Occasionally it is necessary to change to a different file during a
5901_GDBN__ session. Or you may run _GDBN__ and forget to specify the files you
5902want to use. In these situations the _GDBN__ commands to specify new files
5903are useful.
5904
5905@table @code
5906@item file @var{filename}
5907@cindex executable file
5908@kindex file
5909Use @var{filename} as the program to be debugged. It is read for its
5910symbols and for the contents of pure memory. It is also the program
5911executed when you use the @code{run} command. If you do not specify a
1041a570
RP
5912directory and the file is not found in _GDBN__'s working directory, _GDBN__
5913uses the environment variable @code{PATH} as a list of directories to
5914search, just as the shell does when looking for a program to run. You
5915can change the value of this variable, for both _GDBN__ and your program,
5916using the @code{path} command.
70b88761 5917
14d01801
RP
5918On systems with memory-mapped files, an auxiliary symbol table file
5919@file{@var{filename}.syms} may be available for @var{filename}. If it
5920is, _GDBN__ will map in the symbol table from
5921@file{@var{filename}.syms}, starting up more quickly. See the
95d5ceb9 5922descriptions of the options @samp{-mapped} and @samp{-readnow} (available
77b46d13
JG
5923on the command line, and with the commands @code{file}, @code{symbol-file},
5924or @code{add-symbol-file}), for more information.
14d01801 5925
e0dacfd1 5926@item file
70b88761
RP
5927@code{file} with no argument makes _GDBN__ discard any information it
5928has on both executable file and the symbol table.
5929
e0dacfd1 5930@item exec-file @r{[} @var{filename} @r{]}
70b88761
RP
5931@kindex exec-file
5932Specify that the program to be run (but not the symbol table) is found
5933in @var{filename}. _GDBN__ will search the environment variable @code{PATH}
29a2b744 5934if necessary to locate your program. Omitting @var{filename} means to
e0dacfd1 5935discard information on the executable file.
70b88761 5936
e0dacfd1 5937@item symbol-file @r{[} @var{filename} @r{]}
70b88761
RP
5938@kindex symbol-file
5939Read symbol table information from file @var{filename}. @code{PATH} is
5940searched when necessary. Use the @code{file} command to get both symbol
5941table and program to run from the same file.
5942
5943@code{symbol-file} with no argument clears out _GDBN__'s information on your
5944program's symbol table.
5945
5946The @code{symbol-file} command causes _GDBN__ to forget the contents of its
5947convenience variables, the value history, and all breakpoints and
5948auto-display expressions. This is because they may contain pointers to
5949the internal data recording symbols and data types, which are part of
5950the old symbol table data being discarded inside _GDBN__.
5951
5952@code{symbol-file} will not repeat if you press @key{RET} again after
5953executing it once.
5954
14d01801
RP
5955When _GDBN__ is configured for a particular environment, it will
5956understand debugging information in whatever format is the standard
5957generated for that environment; you may use either a GNU compiler, or
5958other compilers that adhere to the local conventions. Best results are
5959usually obtained from GNU compilers; for example, using @code{_GCC__}
5960you can generate debugging information for optimized code.
5961
70b88761 5962On some kinds of object files, the @code{symbol-file} command does not
14d01801 5963normally read the symbol table in full right away. Instead, it scans
70b88761
RP
5964the symbol table quickly to find which source files and which symbols
5965are present. The details are read later, one source file at a time,
1041a570 5966as they are needed.
70b88761
RP
5967
5968The purpose of this two-stage reading strategy is to make _GDBN__ start up
1041a570
RP
5969faster. For the most part, it is invisible except for occasional
5970pauses while the symbol table details for a particular source file are
5971being read. (The @code{set verbose} command can turn these pauses
5972into messages if desired. @xref{Messages/Warnings, ,Optional Warnings
5973and Messages}.)
70b88761
RP
5974
5975When the symbol table is stored in COFF format, @code{symbol-file} does
1041a570 5976read the symbol table data in full right away. We have not implemented
70b88761
RP
5977the two-stage strategy for COFF yet.
5978
95d5ceb9
RP
5979@item symbol-file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
5980@itemx file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
14d01801
RP
5981@kindex readnow
5982@cindex reading symbols immediately
5983@cindex symbols, reading immediately
5984@kindex mapped
5985@cindex memory-mapped symbol file
38962738 5986@cindex saving symbol table
14d01801 5987You can override the _GDBN__ two-stage strategy for reading symbol
95d5ceb9 5988tables by using the @samp{-readnow} option with any of the commands that
14d01801
RP
5989load symbol table information, if you want to be sure _GDBN__ has the
5990entire symbol table available.
5991
5992If memory-mapped files are available on your system through the
95d5ceb9 5993@code{mmap} system call, you can use another option, @samp{-mapped}, to
77b46d13
JG
5994cause _GDBN__ to write the symbols for your program into a reusable
5995file. Future _GDBN__ debugging sessions will map in symbol information
5996from this auxiliary symbol file (if the program hasn't changed), rather
5997than spending time reading the symbol table from the executable
5998program. Using the @samp{-mapped} option has the same effect as
5999starting _GDBN__ with the @samp{-mapped} command-line option.
14d01801 6000
95d5ceb9 6001You can use both options together, to make sure the auxiliary symbol
14d01801
RP
6002file has all the symbol information for your program.
6003
77b46d13
JG
6004The @code{.syms} file is specific to the host machine on which GDB is run.
6005It holds an exact image of GDB's internal symbol table. It cannot be
6006shared across multiple host platforms.
6007
14d01801
RP
6008The auxiliary symbol file for a program called @var{myprog} is called
6009@samp{@var{myprog}.syms}. Once this file exists (so long as it is newer
6010than the corresponding executable), _GDBN__ will always attempt to use
6011it when you debug @var{myprog}; no special options or commands are
6012needed.
6013@c FIXME: for now no mention of directories, since this seems to be in
6014@c flux. 13mar1992 status is that in theory GDB would look either in
6015@c current dir or in same dir as myprog; but issues like competing
6016@c GDB's, or clutter in system dirs, mean that in practice right now
6017@c only current dir is used. FFish says maybe a special GDB hierarchy
6018@c (eg rooted in val of env var GDBSYMS) could exist for mappable symbol
6019@c files.
70b88761 6020
e0dacfd1 6021@item core-file @r{[} @var{filename} @r{]}
70b88761
RP
6022@kindex core
6023@kindex core-file
6024Specify the whereabouts of a core dump file to be used as the ``contents
6025of memory''. Traditionally, core files contain only some parts of the
6026address space of the process that generated them; _GDBN__ can access the
6027executable file itself for other parts.
6028
6029@code{core-file} with no argument specifies that no core file is
6030to be used.
6031
6032Note that the core file is ignored when your program is actually running
29a2b744 6033under _GDBN__. So, if you have been running your program and you wish to
70b88761
RP
6034debug a core file instead, you must kill the subprocess in which the
6035program is running. To do this, use the @code{kill} command
1041a570 6036(@pxref{Kill Process, ,Killing the Child Process}).
70b88761
RP
6037
6038@item load @var{filename}
6039@kindex load
6040_if__(_GENERIC__)
6041Depending on what remote debugging facilities are configured into
6042_GDBN__, the @code{load} command may be available. Where it exists, it
6043is meant to make @var{filename} (an executable) available for debugging
6044on the remote system---by downloading, or dynamic linking, for example.
6045@code{load} also records @var{filename}'s symbol table in _GDBN__, like
6046the @code{add-symbol-file} command.
6047
6048If @code{load} is not available on your _GDBN__, attempting to execute
6049it gets the error message ``@code{You can't do that when your target is
e251e767 6050@dots{}}''
70b88761
RP
6051_fi__(_GENERIC__)
6052
e251e767 6053_if__(_VXWORKS__)
70b88761
RP
6054On VxWorks, @code{load} will dynamically link @var{filename} on the
6055current target system as well as adding its symbols in _GDBN__.
6056_fi__(_VXWORKS__)
6057
6058_if__(_I960__)
6059@cindex download to Nindy-960
6060With the Nindy interface to an Intel 960 board, @code{load} will
6061download @var{filename} to the 960 as well as adding its symbols in
e251e767 6062_GDBN__.
70b88761
RP
6063_fi__(_I960__)
6064
c7cb8acb
RP
6065_if__(_H8__)
6066@cindex download to H8/300
6067@cindex H8/300 download
6068When you select remote debugging to a Hitachi H8/300 board (@pxref{Hitachi
6069H8/300 Remote,,_GDBN__ and the Hitachi H8/300}), the
6070@code{load} command downloads your program to the H8/300 and also opens
6071it as the current executable target for _GDBN__ on your host (like the
6072@code{file} command).
6073_fi__(_H8__)
6074
70b88761
RP
6075@code{load} will not repeat if you press @key{RET} again after using it.
6076
6077@item add-symbol-file @var{filename} @var{address}
95d5ceb9 6078@itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
70b88761
RP
6079@kindex add-symbol-file
6080@cindex dynamic linking
6081The @code{add-symbol-file} command reads additional symbol table information
b80282d5 6082from the file @var{filename}. You would use this command when @var{filename}
70b88761
RP
6083has been dynamically loaded (by some other means) into the program that
6084is running. @var{address} should be the memory address at which the
6085file has been loaded; _GDBN__ cannot figure this out for itself.
6086
6087The symbol table of the file @var{filename} is added to the symbol table
6088originally read with the @code{symbol-file} command. You can use the
6089@code{add-symbol-file} command any number of times; the new symbol data thus
6090read keeps adding to the old. To discard all old symbol data instead,
e251e767 6091use the @code{symbol-file} command.
70b88761
RP
6092
6093@code{add-symbol-file} will not repeat if you press @key{RET} after using it.
6094
95d5ceb9
RP
6095You can use the @samp{-mapped} and @samp{-readnow} options just as with
6096the @code{symbol-file} command, to change how _GDBN__ manages the symbol
6097tabl einformation for @var{filename}.
6098
70b88761
RP
6099@item info files
6100@itemx info target
6101@kindex info files
6102@kindex info target
1041a570
RP
6103@code{info files} and @code{info target} are synonymous; both print
6104the current targets (@pxref{Targets, ,Specifying a Debugging Target}),
6105including the names of the executable and core dump files currently in
6106use by _GDBN__, and the files from which symbols were loaded. The command
6107@code{help targets} lists all possible targets rather than current
6108ones.
70b88761
RP
6109
6110@end table
6111
6112All file-specifying commands allow both absolute and relative file names
6113as arguments. _GDBN__ always converts the file name to an absolute path
6114name and remembers it that way.
6115
70b88761
RP
6116@cindex shared libraries
6117
77b46d13
JG
6118_GDBN__ supports SunOS, SVR4, and IBM RS/6000 shared libraries.
6119_GDBN__ automatically loads symbol definitions from shared libraries
6120when you use the @code{run} command, or when you examine a core file.
6121(Before you issue the @code{run} command, _GDBN__ will not understand
6122references to a function in a shared library, however---unless you are
6123debugging a core file).
c338a2fd 6124@c FIXME: next _GDBN__ release should permit some refs to undef
1041a570 6125@c FIXME...symbols---eg in a break cmd---assuming they are from a shared lib
70b88761
RP
6126
6127@table @code
70b88761
RP
6128@item info share
6129@itemx info sharedlibrary
6130@kindex info sharedlibrary
6131@kindex info share
c338a2fd 6132Print the names of the shared libraries which are currently loaded.
70b88761 6133
c338a2fd
RP
6134@item sharedlibrary @var{regex}
6135@itemx share @var{regex}
6136@kindex sharedlibrary
6137@kindex share
6138This is an obsolescent command; you can use it to explicitly
6139load shared object library symbols for files matching a UNIX regular
6140expression, but as with files loaded automatically, it will only load
6141shared libraries required by your program for a core file or after
6142typing @code{run}. If @var{regex} is omitted all shared libraries
6143required by your program are loaded.
6144@end table
70b88761
RP
6145
6146@node Symbol Errors, , Files, _GDBN__ Files
6147@section Errors Reading Symbol Files
1041a570
RP
6148
6149While reading a symbol file, _GDBN__ will occasionally encounter problems,
6150such as symbol types it does not recognize, or known bugs in compiler
6151output. By default, _GDBN__ does not notify you of such problems, since
6152they are relatively common and primarily of interest to people
6153debugging compilers. If you are interested in seeing information
b80282d5
RP
6154about ill-constructed symbol tables, you can either ask _GDBN__ to print
6155only one message about each such type of problem, no matter how many
6156times the problem occurs; or you can ask _GDBN__ to print more messages,
1041a570
RP
6157to see how many times the problems occur, with the @code{set
6158complaints} command (@pxref{Messages/Warnings, ,Optional Warnings and
6159Messages}).
70b88761
RP
6160
6161The messages currently printed, and their meanings, are:
6162
6163@table @code
6164@item inner block not inside outer block in @var{symbol}
6165
6166The symbol information shows where symbol scopes begin and end
6167(such as at the start of a function or a block of statements). This
6168error indicates that an inner scope block is not fully contained
e251e767 6169in its outer scope blocks.
70b88761
RP
6170
6171_GDBN__ circumvents the problem by treating the inner block as if it had
6172the same scope as the outer block. In the error message, @var{symbol}
6173may be shown as ``@code{(don't know)}'' if the outer block is not a
6174function.
6175
6176@item block at @var{address} out of order
6177
e251e767 6178The symbol information for symbol scope blocks should occur in
70b88761 6179order of increasing addresses. This error indicates that it does not
e251e767 6180do so.
70b88761
RP
6181
6182_GDBN__ does not circumvent this problem, and will have trouble locating
6183symbols in the source file whose symbols being read. (You can often
6184determine what source file is affected by specifying @code{set verbose
29a2b744 6185on}. @xref{Messages/Warnings, ,Optional Warnings and Messages}.)
70b88761
RP
6186
6187@item bad block start address patched
6188
6189The symbol information for a symbol scope block has a start address
6190smaller than the address of the preceding source line. This is known
e251e767 6191to occur in the SunOS 4.1.1 (and earlier) C compiler.
70b88761
RP
6192
6193_GDBN__ circumvents the problem by treating the symbol scope block as
6194starting on the previous source line.
6195
70b88761
RP
6196@item bad string table offset in symbol @var{n}
6197
6198@cindex foo
6199Symbol number @var{n} contains a pointer into the string table which is
e251e767 6200larger than the size of the string table.
70b88761
RP
6201
6202_GDBN__ circumvents the problem by considering the symbol to have the
6203name @code{foo}, which may cause other problems if many symbols end up
6204with this name.
6205
6206@item unknown symbol type @code{0x@var{nn}}
6207
6208The symbol information contains new data types that _GDBN__ does not yet
6209know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood
e251e767 6210information, in hexadecimal.
70b88761
RP
6211
6212_GDBN__ circumvents the error by ignoring this symbol information. This
29a2b744 6213will usually allow your program to be debugged, though certain symbols
70b88761
RP
6214will not be accessible. If you encounter such a problem and feel like
6215debugging it, you can debug @code{_GDBP__} with itself, breakpoint on
6216@code{complain}, then go up to the function @code{read_dbx_symtab} and
6217examine @code{*bufp} to see the symbol.
6218
6219@item stub type has NULL name
e251e767 6220_GDBN__ could not find the full definition for a struct or class.
70b88761 6221
440d9834 6222@item const/volatile indicator missing (ok if using g++ v1.x), got@dots{}
70b88761
RP
6223
6224The symbol information for a C++ member function is missing some
440d9834
RP
6225information that recent versions of the compiler should have output
6226for it.
70b88761 6227
440d9834 6228@item info mismatch between compiler and debugger
70b88761 6229
440d9834 6230_GDBN__ could not parse a type specification output by the compiler.
70b88761
RP
6231@end table
6232
6233@node Targets, Controlling _GDBN__, _GDBN__ Files, Top
e251e767 6234@chapter Specifying a Debugging Target
70b88761
RP
6235@cindex debugging target
6236@kindex target
1041a570 6237
cedaf8bc 6238A @dfn{target} is the execution environment occupied by your program.
1041a570
RP
6239Often, _GDBN__ runs in the same host environment as your program; in
6240that case, the debugging target is specified as a side effect when you
6241use the @code{file} or @code{core} commands. When you need more
6242flexibility---for example, running _GDBN__ on a physically separate
6243host, or controlling a standalone system over a serial port or a
6244realtime system over a TCP/IP connection---you can use the @code{target}
6245command to specify one of the target types configured for _GDBN__
6246(@pxref{Target Commands, ,Commands for Managing Targets}).
70b88761
RP
6247
6248@menu
b80282d5
RP
6249* Active Targets:: Active Targets
6250* Target Commands:: Commands for Managing Targets
6251* Remote:: Remote Debugging
70b88761
RP
6252@end menu
6253
6254@node Active Targets, Target Commands, Targets, Targets
6255@section Active Targets
6256@cindex stacking targets
6257@cindex active targets
6258@cindex multiple targets
6259
cedaf8bc
RP
6260There are three classes of targets: processes, core files, and
6261executable files. _GDBN__ can work concurrently on up to three active
6262targets, one in each class. This allows you to (for example) start a
6263process and inspect its activity without abandoning your work on a core
6264file.
70b88761 6265
cedaf8bc
RP
6266If, for example, you execute @samp{gdb a.out}, then the executable file
6267@code{a.out} is the only active target. If you designate a core file as
6268well---presumably from a prior run that crashed and coredumped---then
6269_GDBN__ has two active targets and will use them in tandem, looking
6270first in the corefile target, then in the executable file, to satisfy
6271requests for memory addresses. (Typically, these two classes of target
29a2b744 6272are complementary, since core files contain only a program's
cedaf8bc
RP
6273read-write memory---variables and so on---plus machine status, while
6274executable files contain only the program text and initialized data.)
6275
6276When you type @code{run}, your executable file becomes an active process
6277target as well. When a process target is active, all _GDBN__ commands
6278requesting memory addresses refer to that target; addresses in an active
6279core file or executable file target are obscured while the process
6280target is active.
6281
1041a570
RP
6282Use the @code{core-file} and @code{exec-file} commands to select a
6283new core file or executable target (@pxref{Files, ,Commands to Specify
6284Files}). To specify as a target a process that is already running, use
6285the @code{attach} command (@pxref{Attach, ,Debugging an
6286Already-Running Process}.).
70b88761
RP
6287
6288@node Target Commands, Remote, Active Targets, Targets
6289@section Commands for Managing Targets
6290
6291@table @code
6292@item target @var{type} @var{parameters}
6293Connects the _GDBN__ host environment to a target machine or process. A
6294target is typically a protocol for talking to debugging facilities. You
6295use the argument @var{type} to specify the type or protocol of the
6296target machine.
6297
6298Further @var{parameters} are interpreted by the target protocol, but
6299typically include things like device names or host names to connect
e251e767 6300with, process numbers, and baud rates.
70b88761
RP
6301
6302The @code{target} command will not repeat if you press @key{RET} again
6303after executing the command.
6304
6305@item help target
6306@kindex help target
6307Displays the names of all targets available. To display targets
6308currently selected, use either @code{info target} or @code{info files}
29a2b744 6309(@pxref{Files, ,Commands to Specify Files}).
70b88761
RP
6310
6311@item help target @var{name}
6312Describe a particular target, including any parameters necessary to
6313select it.
6314@end table
6315
c7cb8acb 6316Here are some common targets (available, or not, depending on the GDB
70b88761
RP
6317configuration):
6318
6319@table @code
6320@item target exec @var{prog}
6321@kindex target exec
6322An executable file. @samp{target exec @var{prog}} is the same as
6323@samp{exec-file @var{prog}}.
6324
6325@item target core @var{filename}
6326@kindex target core
6327A core dump file. @samp{target core @var{filename}} is the same as
6328@samp{core-file @var{filename}}.
6329
6330@item target remote @var{dev}
6331@kindex target remote
c7cb8acb 6332Remote serial target in GDB-specific protocol. The argument @var{dev}
70b88761 6333specifies what serial device to use for the connection (e.g.
1041a570 6334@file{/dev/ttya}). @xref{Remote, ,Remote Debugging}.
70b88761
RP
6335
6336_if__(_AMD29K__)
6337@item target amd-eb @var{dev} @var{speed} @var{PROG}
6338@kindex target amd-eb
6339@cindex AMD EB29K
6340Remote PC-resident AMD EB29K board, attached over serial lines.
6341@var{dev} is the serial device, as for @code{target remote};
6342@var{speed} allows you to specify the linespeed; and @var{PROG} is the
6343name of the program to be debugged, as it appears to DOS on the PC.
1041a570 6344@xref{EB29K Remote, ,GDB with a Remote EB29K}.
70b88761
RP
6345
6346_fi__(_AMD29K__)
c7cb8acb
RP
6347_if__(_H8__)
6348@item target hms
6349@kindex target hms
6350A Hitachi H8/300 board, attached via serial line to your host. Use
6351special commands @code{device} and @code{speed} to control the serial
6352line and the communications speed used. @xref{Hitachi H8/300
6353Remote,,_GDBN__ and the Hitachi H8/300}.
6354
6355_fi__(_H8__)
70b88761
RP
6356_if__(_I960__)
6357@item target nindy @var{devicename}
6358@kindex target nindy
6359An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is
6360the name of the serial device to use for the connection, e.g.
1041a570 6361@file{/dev/ttya}. @xref{i960-Nindy Remote, ,_GDBN__ with a Remote i960 (Nindy)}.
70b88761
RP
6362
6363_fi__(_I960__)
6364_if__(_VXWORKS__)
6365@item target vxworks @var{machinename}
6366@kindex target vxworks
6367A VxWorks system, attached via TCP/IP. The argument @var{machinename}
6368is the target system's machine name or IP address.
1041a570 6369@xref{VxWorks Remote, ,_GDBN__ and VxWorks}.
70b88761
RP
6370_fi__(_VXWORKS__)
6371@end table
6372
6373_if__(_GENERIC__)
6374Different targets are available on different configurations of _GDBN__; your
6375configuration may have more or fewer targets.
6376_fi__(_GENERIC__)
6377
6378@node Remote, , Target Commands, Targets
6379@section Remote Debugging
6380@cindex remote debugging
6381
29a2b744 6382If you are trying to debug a program running on a machine that cannot run
c7cb8acb 6383GDB in the usual way, it is often useful to use remote debugging. For
70b88761
RP
6384example, you might use remote debugging on an operating system kernel, or on
6385a small system which does not have a general purpose operating system
e251e767 6386powerful enough to run a full-featured debugger.
70b88761 6387
c7cb8acb 6388Some configurations of GDB have special serial or TCP/IP interfaces
70b88761 6389to make this work with particular debugging targets. In addition,
c7cb8acb 6390GDB comes with a generic serial protocol (specific to GDB, but
70b88761
RP
6391not specific to any particular target system) which you can use if you
6392write the remote stubs---the code that will run on the remote system to
c7cb8acb 6393communicate with GDB.
70b88761 6394
c7cb8acb 6395To use the GDB remote serial protocol, the program to be debugged on
70b88761 6396the remote machine needs to contain a debugging stub which talks to
c7cb8acb
RP
6397GDB over the serial line. Several working remote stubs are
6398distributed with GDB; see the @file{README} file in the GDB
70b88761
RP
6399distribution for more information.
6400
6401For details of this communication protocol, see the comments in the
c7cb8acb 6402GDB source file @file{remote.c}.
70b88761 6403
c7cb8acb
RP
6404To start remote debugging, first run GDB and specify as an executable file
6405the program that is running in the remote machine. This tells GDB how
29a2b744 6406to find your program's symbols and the contents of its pure text. Then
70b88761
RP
6407establish communication using the @code{target remote} command with a device
6408name as an argument. For example:
6409
6410@example
6411target remote /dev/ttyb
6412@end example
6413
6414@noindent
6415if the serial line is connected to the device named @file{/dev/ttyb}. This
6416will stop the remote machine if it is not already stopped.
6417
6418Now you can use all the usual commands to examine and change data and to
6419step and continue the remote program.
6420
6421To resume the remote program and stop debugging it, use the @code{detach}
6422command.
6423
6424Other remote targets may be available in your
c7cb8acb 6425configuration of GDB; use @code{help targets} to list them.
70b88761
RP
6426
6427_if__(_GENERIC__)
1041a570
RP
6428_dnl__ Text on starting up GDB in various specific cases; it goes up front
6429_dnl__ in manuals configured for any of those particular situations, here
6430_dnl__ otherwise.
6431@menu
6432_include__(gdbinv-m.m4)<>_dnl__
6433@end menu
70b88761
RP
6434_include__(gdbinv-s.m4)
6435_fi__(_GENERIC__)
6436
6437@node Controlling _GDBN__, Sequences, Targets, Top
6438@chapter Controlling _GDBN__
6439
6440You can alter many aspects of _GDBN__'s interaction with you by using
6441the @code{set} command. For commands controlling how _GDBN__ displays
1041a570 6442data, @pxref{Print Settings, ,Print Settings}; other settings are described here.
70b88761
RP
6443
6444@menu
b80282d5
RP
6445* Prompt:: Prompt
6446* Editing:: Command Editing
6447* History:: Command History
6448* Screen Size:: Screen Size
6449* Numbers:: Numbers
6450* Messages/Warnings:: Optional Warnings and Messages
70b88761
RP
6451@end menu
6452
6453@node Prompt, Editing, Controlling _GDBN__, Controlling _GDBN__
6454@section Prompt
6455@cindex prompt
1041a570 6456
70b88761
RP
6457_GDBN__ indicates its readiness to read a command by printing a string
6458called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You
6459can change the prompt string with the @code{set prompt} command. For
6460instance, when debugging _GDBN__ with _GDBN__, it is useful to change
6461the prompt in one of the _GDBN__<>s so that you can always tell which
6462one you are talking to.
6463
6464@table @code
6465@item set prompt @var{newprompt}
6466@kindex set prompt
6467Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth.
6468@kindex show prompt
6469@item show prompt
6470Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
6471@end table
6472
6473@node Editing, History, Prompt, Controlling _GDBN__
6474@section Command Editing
6475@cindex readline
6476@cindex command line editing
1041a570 6477
70b88761
RP
6478_GDBN__ reads its input commands via the @dfn{readline} interface. This
6479GNU library provides consistent behavior for programs which provide a
6480command line interface to the user. Advantages are @code{emacs}-style
6481or @code{vi}-style inline editing of commands, @code{csh}-like history
6482substitution, and a storage and recall of command history across
6483debugging sessions.
6484
6485You may control the behavior of command line editing in _GDBN__ with the
e251e767 6486command @code{set}.
70b88761
RP
6487
6488@table @code
6489@kindex set editing
6490@cindex editing
6491@item set editing
6492@itemx set editing on
6493Enable command line editing (enabled by default).
6494
6495@item set editing off
6496Disable command line editing.
6497
6498@kindex show editing
6499@item show editing
6500Show whether command line editing is enabled.
6501@end table
6502
6503@node History, Screen Size, Editing, Controlling _GDBN__
6504@section Command History
1041a570 6505
70b88761
RP
6506@table @code
6507@cindex history substitution
6508@cindex history file
6509@kindex set history filename
6510@item set history filename @var{fname}
6511Set the name of the _GDBN__ command history file to @var{fname}. This is
6512the file from which _GDBN__ will read an initial command history
6513list or to which it will write this list when it exits. This list is
6514accessed through history expansion or through the history
6515command editing characters listed below. This file defaults to the
6516value of the environment variable @code{GDBHISTFILE}, or to
6517@file{./.gdb_history} if this variable is not set.
6518
6519@cindex history save
6520@kindex set history save
6521@item set history save
6522@itemx set history save on
6523Record command history in a file, whose name may be specified with the
6524@code{set history filename} command. By default, this option is disabled.
6525
6526@item set history save off
6527Stop recording command history in a file.
6528
6529@cindex history size
6530@kindex set history size
6531@item set history size @var{size}
6532Set the number of commands which _GDBN__ will keep in its history list.
6533This defaults to the value of the environment variable
6534@code{HISTSIZE}, or to 256 if this variable is not set.
6535@end table
6536
6537@cindex history expansion
6538History expansion assigns special meaning to the character @kbd{!}.
6539@iftex
1041a570 6540@xref{Event Designators}.
70b88761
RP
6541@end iftex
6542Since @kbd{!} is also the logical not operator in C, history expansion
6543is off by default. If you decide to enable history expansion with the
6544@code{set history expansion on} command, you may sometimes need to
6545follow @kbd{!} (when it is used as logical not, in an expression) with
6546a space or a tab to prevent it from being expanded. The readline
6547history facilities will not attempt substitution on the strings
6548@kbd{!=} and @kbd{!(}, even when history expansion is enabled.
6549
6550The commands to control history expansion are:
6551
6552@table @code
6553
6554@kindex set history expansion
6555@item set history expansion on
6556@itemx set history expansion
6557Enable history expansion. History expansion is off by default.
6558
6559@item set history expansion off
6560Disable history expansion.
6561
6562The readline code comes with more complete documentation of
6563editing and history expansion features. Users unfamiliar with @code{emacs}
e251e767 6564or @code{vi} may wish to read it.
70b88761
RP
6565@iftex
6566@xref{Command Line Editing}.
6567@end iftex
6568
6569@c @group
6570@kindex show history
6571@item show history
6572@itemx show history filename
6573@itemx show history save
6574@itemx show history size
6575@itemx show history expansion
6576These commands display the state of the _GDBN__ history parameters.
6577@code{show history} by itself displays all four states.
6578@c @end group
70b88761
RP
6579@end table
6580
6581@table @code
6582@kindex show commands
6583@item show commands
6584Display the last ten commands in the command history.
6585
6586@item show commands @var{n}
6587Print ten commands centered on command number @var{n}.
6588
6589@item show commands +
6590Print ten commands just after the commands last printed.
70b88761
RP
6591@end table
6592
6593@node Screen Size, Numbers, History, Controlling _GDBN__
6594@section Screen Size
6595@cindex size of screen
6596@cindex pauses in output
1041a570 6597
70b88761
RP
6598Certain commands to _GDBN__ may produce large amounts of information
6599output to the screen. To help you read all of it, _GDBN__ pauses and
6600asks you for input at the end of each page of output. Type @key{RET}
6601when you want to continue the output. _GDBN__ also uses the screen
6602width setting to determine when to wrap lines of output. Depending on
6603what is being printed, it tries to break the line at a readable place,
6604rather than simply letting it overflow onto the following line.
6605
6606Normally _GDBN__ knows the size of the screen from the termcap data base
6607together with the value of the @code{TERM} environment variable and the
6608@code{stty rows} and @code{stty cols} settings. If this is not correct,
6609you can override it with the @code{set height} and @code{set
6610width} commands:
6611
6612@table @code
6613@item set height @var{lpp}
6614@itemx show height
6615@itemx set width @var{cpl}
6616@itemx show width
6617@kindex set height
6618@kindex set width
6619@kindex show width
6620@kindex show height
6621These @code{set} commands specify a screen height of @var{lpp} lines and
6622a screen width of @var{cpl} characters. The associated @code{show}
6623commands display the current settings.
6624
6625If you specify a height of zero lines, _GDBN__ will not pause during output
6626no matter how long the output is. This is useful if output is to a file
6627or to an editor buffer.
6628@end table
6629
6630@node Numbers, Messages/Warnings, Screen Size, Controlling _GDBN__
6631@section Numbers
6632@cindex number representation
6633@cindex entering numbers
1041a570 6634
70b88761
RP
6635You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by
6636the usual conventions: octal numbers begin with @samp{0}, decimal
6637numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}.
6638Numbers that begin with none of these are, by default, entered in base
663910; likewise, the default display for numbers---when no particular
6640format is specified---is base 10. You can change the default base for
6641both input and output with the @code{set radix} command.
6642
6643@table @code
6644@kindex set radix
6645@item set radix @var{base}
6646Set the default base for numeric input and display. Supported choices
c2bbbb22 6647for @var{base} are decimal 2, 8, 10, 16. @var{base} must itself be
70b88761
RP
6648specified either unambiguously or using the current default radix; for
6649example, any of
6650
6651@example
c2bbbb22 6652set radix 1010
70b88761
RP
6653set radix 012
6654set radix 10.
6655set radix 0xa
6656@end example
6657
6658@noindent
6659will set the base to decimal. On the other hand, @samp{set radix 10}
6660will leave the radix unchanged no matter what it was.
6661
6662@kindex show radix
6663@item show radix
6664Display the current default base for numeric input and display.
70b88761
RP
6665@end table
6666
c2bbbb22 6667@node Messages/Warnings, , Numbers, Controlling _GDBN__
70b88761 6668@section Optional Warnings and Messages
1041a570 6669
70b88761
RP
6670By default, _GDBN__ is silent about its inner workings. If you are running
6671on a slow machine, you may want to use the @code{set verbose} command.
6672It will make _GDBN__ tell you when it does a lengthy internal operation, so
1041a570 6673you will not think it has crashed.
70b88761 6674
1041a570
RP
6675Currently, the messages controlled by @code{set verbose} are those
6676which announce that the symbol table for a source file is being read
6677(@pxref{Files, ,Commands to Specify Files}, in the description of the
6678command @code{symbol-file}).
29a2b744 6679@c The following is the right way to do it, but emacs 18.55 does not support
70b88761 6680@c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo
e251e767 6681@c is released.
70b88761 6682@ignore
29a2b744 6683see @code{symbol-file} in @ref{Files, ,Commands to Specify Files}).
70b88761
RP
6684@end ignore
6685
6686@table @code
6687@kindex set verbose
6688@item set verbose on
6689Enables _GDBN__'s output of certain informational messages.
6690
6691@item set verbose off
6692Disables _GDBN__'s output of certain informational messages.
6693
6694@kindex show verbose
6695@item show verbose
6696Displays whether @code{set verbose} is on or off.
6697@end table
6698
b80282d5
RP
6699By default, if _GDBN__ encounters bugs in the symbol table of an object
6700file, it is silent; but if you are debugging a compiler, you may find
1041a570 6701this information useful (@pxref{Symbol Errors, ,Errors Reading Symbol Files}).
70b88761
RP
6702
6703@table @code
6704@kindex set complaints
6705@item set complaints @var{limit}
6706Permits _GDBN__ to output @var{limit} complaints about each type of unusual
6707symbols before becoming silent about the problem. Set @var{limit} to
6708zero to suppress all complaints; set it to a large number to prevent
6709complaints from being suppressed.
6710
6711@kindex show complaints
6712@item show complaints
6713Displays how many symbol complaints _GDBN__ is permitted to produce.
6714@end table
6715
6716By default, _GDBN__ is cautious, and asks what sometimes seem to be a
6717lot of stupid questions to confirm certain commands. For example, if
6718you try to run a program which is already running:
1041a570 6719
70b88761
RP
6720@example
6721(_GDBP__) run
6722The program being debugged has been started already.
e251e767 6723Start it from the beginning? (y or n)
70b88761
RP
6724@end example
6725
29a2b744 6726If you are willing to unflinchingly face the consequences of your own
70b88761
RP
6727commands, you can disable this ``feature'':
6728
6729@table @code
6730@kindex set confirm
6731@cindex flinching
6732@cindex confirmation
6733@cindex stupid questions
6734@item set confirm off
6735Disables confirmation requests.
6736
6737@item set confirm on
6738Enables confirmation requests (the default).
6739
6740@item show confirm
6741@kindex show confirm
6742Displays state of confirmation requests.
6743@end table
6744
29a2b744 6745@c FIXME this does not really belong here. But where *does* it belong?
b80282d5
RP
6746@cindex reloading symbols
6747Some systems allow individual object files that make up your program to
6748be replaced without stopping and restarting your program.
6749_if__(_VXWORKS__)
6750For example, in VxWorks you can simply recompile a defective object file
6751and keep on running.
6752_fi__(_VXWORKS__)
29a2b744 6753If you are running on one of these systems, you can allow _GDBN__ to
1041a570
RP
6754reload the symbols for automatically relinked modules:
6755
b80282d5
RP
6756@table @code
6757@kindex set symbol-reloading
6758@item set symbol-reloading on
6759Replace symbol definitions for the corresponding source file when an
6760object file with a particular name is seen again.
6761
6762@item set symbol-reloading off
1041a570 6763Do not replace symbol definitions when re-encountering object files of
29a2b744 6764the same name. This is the default state; if you are not running on a
b80282d5
RP
6765system that permits automatically relinking modules, you should leave
6766@code{symbol-reloading} off, since otherwise _GDBN__ may discard symbols
6767when linking large programs, that may contain several modules (from
6768different directories or libraries) with the same name.
6769
6770@item show symbol-reloading
6771Show the current @code{on} or @code{off} setting.
6772@end table
6773
70b88761
RP
6774@node Sequences, Emacs, Controlling _GDBN__, Top
6775@chapter Canned Sequences of Commands
6776
29a2b744 6777Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint
1041a570
RP
6778Command Lists}), _GDBN__ provides two ways to store sequences of commands
6779for execution as a unit: user-defined commands and command files.
70b88761
RP
6780
6781@menu
b80282d5
RP
6782* Define:: User-Defined Commands
6783* Command Files:: Command Files
6784* Output:: Commands for Controlled Output
70b88761
RP
6785@end menu
6786
6787@node Define, Command Files, Sequences, Sequences
6788@section User-Defined Commands
6789
6790@cindex user-defined command
6791A @dfn{user-defined command} is a sequence of _GDBN__ commands to which you
6792assign a new name as a command. This is done with the @code{define}
6793command.
6794
6795@table @code
6796@item define @var{commandname}
6797@kindex define
6798Define a command named @var{commandname}. If there is already a command
6799by that name, you are asked to confirm that you want to redefine it.
6800
6801The definition of the command is made up of other _GDBN__ command lines,
6802which are given following the @code{define} command. The end of these
6803commands is marked by a line containing @code{end}.
6804
6805@item document @var{commandname}
6806@kindex document
6807Give documentation to the user-defined command @var{commandname}. The
6808command @var{commandname} must already be defined. This command reads
6809lines of documentation just as @code{define} reads the lines of the
6810command definition, ending with @code{end}. After the @code{document}
6811command is finished, @code{help} on command @var{commandname} will print
6812the documentation you have specified.
6813
6814You may use the @code{document} command again to change the
6815documentation of a command. Redefining the command with @code{define}
6816does not change the documentation.
6817
6818@item help user-defined
6819@kindex help user-defined
6820List all user-defined commands, with the first line of the documentation
6821(if any) for each.
6822
4768ba62
JG
6823@item show user
6824@itemx show user @var{commandname}
6825@kindex show user
70b88761
RP
6826Display the _GDBN__ commands used to define @var{commandname} (but not its
6827documentation). If no @var{commandname} is given, display the
6828definitions for all user-defined commands.
6829@end table
6830
6831User-defined commands do not take arguments. When they are executed, the
6832commands of the definition are not printed. An error in any command
6833stops execution of the user-defined command.
6834
6835Commands that would ask for confirmation if used interactively proceed
6836without asking when used inside a user-defined command. Many _GDBN__ commands
6837that normally print messages to say what they are doing omit the messages
6838when used in a user-defined command.
6839
6840@node Command Files, Output, Define, Sequences
6841@section Command Files
6842
6843@cindex command files
6844A command file for _GDBN__ is a file of lines that are _GDBN__ commands. Comments
6845(lines starting with @kbd{#}) may also be included. An empty line in a
6846command file does nothing; it does not mean to repeat the last command, as
6847it would from the terminal.
6848
6849@cindex init file
6850@cindex @file{_GDBINIT__}
6851When you start _GDBN__, it automatically executes commands from its
1041a570
RP
6852@dfn{init files}. These are files named @file{_GDBINIT__}. _GDBN__ reads
6853the init file (if any) in your home directory and then the init file
6854(if any) in the current working directory. (The init files are not
6855executed if you use the @samp{-nx} option; @pxref{Mode Options,
6856,Choosing Modes}.) You can also request the execution of a command
6857file with the @code{source} command:
70b88761
RP
6858
6859@table @code
6860@item source @var{filename}
6861@kindex source
6862Execute the command file @var{filename}.
6863@end table
6864
6865The lines in a command file are executed sequentially. They are not
6866printed as they are executed. An error in any command terminates execution
6867of the command file.
6868
6869Commands that would ask for confirmation if used interactively proceed
6870without asking when used in a command file. Many _GDBN__ commands that
6871normally print messages to say what they are doing omit the messages
6872when called from command files.
6873
6874@node Output, , Command Files, Sequences
6875@section Commands for Controlled Output
6876
6877During the execution of a command file or a user-defined command, normal
6878_GDBN__ output is suppressed; the only output that appears is what is
6879explicitly printed by the commands in the definition. This section
6880describes three commands useful for generating exactly the output you
6881want.
6882
6883@table @code
6884@item echo @var{text}
6885@kindex echo
29a2b744
RP
6886@c I do not consider backslash-space a standard C escape sequence
6887@c because it is not in ANSI.
1041a570
RP
6888Print @var{text}. Nonprinting characters can be included in
6889@var{text} using C escape sequences, such as @samp{\n} to print a
6890newline. @strong{No newline will be printed unless you specify one.}
6891In addition to the standard C escape sequences, a backslash followed
6892by a space stands for a space. This is useful for outputting a
6893string with spaces at the beginning or the end, since leading and
6894trailing spaces are otherwise trimmed from all arguments.
6895To print @samp{@w{ }and foo =@w{ }}, use the command
6896@samp{echo \@w{ }and foo = \@w{ }}.
70b88761
RP
6897
6898A backslash at the end of @var{text} can be used, as in C, to continue
6899the command onto subsequent lines. For example,
6900
6901@example
6902echo This is some text\n\
6903which is continued\n\
6904onto several lines.\n
6905@end example
6906
6907produces the same output as
6908
6909@example
6910echo This is some text\n
6911echo which is continued\n
6912echo onto several lines.\n
6913@end example
6914
6915@item output @var{expression}
6916@kindex output
6917Print the value of @var{expression} and nothing but that value: no
6918newlines, no @samp{$@var{nn} = }. The value is not entered in the
1041a570 6919value history either. @xref{Expressions, ,Expressions}, for more information on
e251e767 6920expressions.
70b88761
RP
6921
6922@item output/@var{fmt} @var{expression}
6923Print the value of @var{expression} in format @var{fmt}. You can use
6924the same formats as for @code{print}; @pxref{Output formats}, for more
6925information.
6926
6927@item printf @var{string}, @var{expressions}@dots{}
6928@kindex printf
6929Print the values of the @var{expressions} under the control of
6930@var{string}. The @var{expressions} are separated by commas and may
6931be either numbers or pointers. Their values are printed as specified
29a2b744 6932by @var{string}, exactly as if your program were to execute
70b88761
RP
6933
6934@example
6935printf (@var{string}, @var{expressions}@dots{});
6936@end example
6937
6938For example, you can print two values in hex like this:
6939
6940@example
6941printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
6942@end example
6943
6944The only backslash-escape sequences that you can use in the format
6945string are the simple ones that consist of backslash followed by a
6946letter.
6947@end table
6948
6ca72cc6
RP
6949_if__(_LUCID__)
6950@node Emacs, Energize, Sequences, Top
6951_fi__(_LUCID__)
6952_if__(!_LUCID__)
70b88761 6953@node Emacs, _GDBN__ Bugs, Sequences, Top
6ca72cc6 6954_fi__(!_LUCID__)
70b88761
RP
6955@chapter Using _GDBN__ under GNU Emacs
6956
6957@cindex emacs
6958A special interface allows you to use GNU Emacs to view (and
6959edit) the source files for the program you are debugging with
6960_GDBN__.
6961
6962To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
6963executable file you want to debug as an argument. This command starts
6964_GDBN__ as a subprocess of Emacs, with input and output through a newly
6965created Emacs buffer.
6966
6967Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two
6968things:
6969
6970@itemize @bullet
6971@item
e251e767 6972All ``terminal'' input and output goes through the Emacs buffer.
70b88761
RP
6973@end itemize
6974
6975This applies both to _GDBN__ commands and their output, and to the input
6976and output done by the program you are debugging.
6977
6978This is useful because it means that you can copy the text of previous
6979commands and input them again; you can even use parts of the output
6980in this way.
6981
3d3ab540
RP
6982All the facilities of Emacs' Shell mode are available for interacting
6983with your program. In particular, you can send signals the usual
6984way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a
6985stop.
70b88761
RP
6986
6987@itemize @bullet
6988@item
e251e767 6989_GDBN__ displays source code through Emacs.
70b88761
RP
6990@end itemize
6991
6992Each time _GDBN__ displays a stack frame, Emacs automatically finds the
6993source file for that frame and puts an arrow (_0__@samp{=>}_1__) at the
6994left margin of the current line. Emacs uses a separate buffer for
6995source display, and splits the window to show both your _GDBN__ session
6996and the source.
6997
6998Explicit _GDBN__ @code{list} or search commands still produce output as
6999usual, but you probably will have no reason to use them.
7000
7001@quotation
7002@emph{Warning:} If the directory where your program resides is not your
7003current directory, it can be easy to confuse Emacs about the location of
7004the source files, in which case the auxiliary display buffer will not
7005appear to show your source. _GDBN__ can find programs by searching your
7006environment's @code{PATH} variable, so the _GDBN__ input and output
29a2b744 7007session will proceed normally; but Emacs does not get enough information
70b88761
RP
7008back from _GDBN__ to locate the source files in this situation. To
7009avoid this problem, either start _GDBN__ mode from the directory where
7010your program resides, or specify a full path name when prompted for the
7011@kbd{M-x gdb} argument.
7012
7013A similar confusion can result if you use the _GDBN__ @code{file} command to
7014switch to debugging a program in some other location, from an existing
7015_GDBN__ buffer in Emacs.
7016@end quotation
7017
7018By default, @kbd{M-x gdb} calls the program called @file{gdb}. If
7019you need to call _GDBN__ by a different name (for example, if you keep
7020several configurations around, with different names) you can set the
7021Emacs variable @code{gdb-command-name}; for example,
1041a570 7022
70b88761
RP
7023@example
7024(setq gdb-command-name "mygdb")
7025@end example
1041a570 7026
70b88761
RP
7027@noindent
7028(preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or
7029in your @file{.emacs} file) will make Emacs call the program named
7030``@code{mygdb}'' instead.
7031
7032In the _GDBN__ I/O buffer, you can use these special Emacs commands in
7033addition to the standard Shell mode commands:
7034
7035@table @kbd
7036@item C-h m
7037Describe the features of Emacs' _GDBN__ Mode.
7038
7039@item M-s
7040Execute to another source line, like the _GDBN__ @code{step} command; also
7041update the display window to show the current file and location.
7042
7043@item M-n
7044Execute to next source line in this function, skipping all function
7045calls, like the _GDBN__ @code{next} command. Then update the display window
7046to show the current file and location.
7047
7048@item M-i
7049Execute one instruction, like the _GDBN__ @code{stepi} command; update
7050display window accordingly.
7051
7052@item M-x gdb-nexti
7053Execute to next instruction, using the _GDBN__ @code{nexti} command; update
7054display window accordingly.
7055
7056@item C-c C-f
7057Execute until exit from the selected stack frame, like the _GDBN__
7058@code{finish} command.
7059
7060@item M-c
29a2b744 7061Continue execution of your program, like the _GDBN__ @code{continue}
1041a570 7062command.
203eea5d
RP
7063
7064@emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}.
70b88761
RP
7065
7066@item M-u
7067Go up the number of frames indicated by the numeric argument
7068(@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}),
1041a570 7069like the _GDBN__ @code{up} command.
203eea5d 7070
1041a570 7071@emph{Warning:} In Emacs v19, this command is @kbd{C-c C-u}.
70b88761
RP
7072
7073@item M-d
7074Go down the number of frames indicated by the numeric argument, like the
1041a570 7075_GDBN__ @code{down} command.
203eea5d
RP
7076
7077@emph{Warning:} In Emacs v19, this command is @kbd{C-c C-d}.
70b88761
RP
7078
7079@item C-x &
7080Read the number where the cursor is positioned, and insert it at the end
7081of the _GDBN__ I/O buffer. For example, if you wish to disassemble code
7082around an address that was displayed earlier, type @kbd{disassemble};
7083then move the cursor to the address display, and pick up the
e251e767 7084argument for @code{disassemble} by typing @kbd{C-x &}.
70b88761
RP
7085
7086You can customize this further on the fly by defining elements of the list
7087@code{gdb-print-command}; once it is defined, you can format or
7088otherwise process numbers picked up by @kbd{C-x &} before they are
c2bbbb22 7089inserted. A numeric argument to @kbd{C-x &} will both indicate that you
70b88761
RP
7090wish special formatting, and act as an index to pick an element of the
7091list. If the list element is a string, the number to be inserted is
7092formatted using the Emacs function @code{format}; otherwise the number
7093is passed as an argument to the corresponding list element.
70b88761
RP
7094@end table
7095
7096In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break})
7097tells _GDBN__ to set a breakpoint on the source line point is on.
7098
7099If you accidentally delete the source-display buffer, an easy way to get
7100it back is to type the command @code{f} in the _GDBN__ buffer, to
7101request a frame display; when you run under Emacs, this will recreate
7102the source buffer if necessary to show you the context of the current
7103frame.
7104
7105The source files displayed in Emacs are in ordinary Emacs buffers
7106which are visiting the source files in the usual way. You can edit
7107the files with these buffers if you wish; but keep in mind that _GDBN__
7108communicates with Emacs in terms of line numbers. If you add or
7109delete lines from the text, the line numbers that _GDBN__ knows will cease
7110to correspond properly to the code.
7111
7112@c The following dropped because Epoch is nonstandard. Reactivate
7113@c if/when v19 does something similar. [email protected] 19dec1990
7114@ignore
e251e767 7115@kindex emacs epoch environment
70b88761
RP
7116@kindex epoch
7117@kindex inspect
7118
7119Version 18 of Emacs has a built-in window system called the @code{epoch}
7120environment. Users of this environment can use a new command,
7121@code{inspect} which performs identically to @code{print} except that
7122each value is printed in its own window.
7123@end ignore
7124
6ca72cc6
RP
7125_if__(_LUCID__)
7126@node Energize, _GDBN__ Bugs, Emacs, Top
7127@chapter Using _GDBN__ with Energize
7128
7129@cindex Energize
7130The Energize Programming System is an integrated development environment
7131that includes a point-and-click interface to many programming tools.
7132When you use _GDBN__ in this environment, you can use the standard
7133Energize graphical interface to drive _GDBN__; you can also, if you
7134choose, type _GDBN__ commands as usual in a debugging window. Even if
7135you use the graphical interface, the debugging window (which uses Emacs,
7136and resembles the standard Emacs interface to _GDBN__) displays the
7137equivalent commands, so that the history of your debugging session is
7138properly reflected.
7139
7140When Energize starts up a _GDBN__ session, it uses one of the
7141command-line options @samp{-energize} or @samp{-cadillac} (``cadillac''
7142is the name of the communications protocol used by the Energize system).
7143This option makes _GDBN__ run as one of the tools in the Energize Tool
7144Set: it sends all output to the Energize kernel, and accept input from
7145it as well.
7146
7147See the user manual for the Energize Programming System for
7148information on how to use the Energize graphical interface and the other
7149development tools that Energize integrates with _GDBN__.
7150
7151@node _GDBN__ Bugs, Renamed Commands, Energize, Top
7152_fi__(_LUCID__)
7153_if__(!_LUCID__)
70b88761 7154@node _GDBN__ Bugs, Renamed Commands, Emacs, Top
6ca72cc6 7155_fi__(!_LUCID__)
70b88761
RP
7156@chapter Reporting Bugs in _GDBN__
7157@cindex Bugs in _GDBN__
7158@cindex Reporting Bugs in _GDBN__
7159
7160Your bug reports play an essential role in making _GDBN__ reliable.
7161
7162Reporting a bug may help you by bringing a solution to your problem, or it
7163may not. But in any case the principal function of a bug report is to help
7164the entire community by making the next version of _GDBN__ work better. Bug
7165reports are your contribution to the maintenance of _GDBN__.
7166
7167In order for a bug report to serve its purpose, you must include the
7168information that enables us to fix the bug.
7169
7170@menu
b80282d5
RP
7171* Bug Criteria:: Have You Found a Bug?
7172* Bug Reporting:: How to Report Bugs
70b88761
RP
7173@end menu
7174
7175@node Bug Criteria, Bug Reporting, _GDBN__ Bugs, _GDBN__ Bugs
7176@section Have You Found a Bug?
7177@cindex Bug Criteria
7178
7179If you are not sure whether you have found a bug, here are some guidelines:
7180
7181@itemize @bullet
7182@item
7183@cindex Fatal Signal
7184@cindex Core Dump
7185If the debugger gets a fatal signal, for any input whatever, that is a
7186_GDBN__ bug. Reliable debuggers never crash.
7187
7188@item
7189@cindex error on Valid Input
7190If _GDBN__ produces an error message for valid input, that is a bug.
7191
7192@item
7193@cindex Invalid Input
7194If _GDBN__ does not produce an error message for invalid input,
7195that is a bug. However, you should note that your idea of
7196``invalid input'' might be our idea of ``an extension'' or ``support
7197for traditional practice''.
7198
7199@item
7200If you are an experienced user of debugging tools, your suggestions
7201for improvement of _GDBN__ are welcome in any case.
7202@end itemize
7203
7204@node Bug Reporting, , Bug Criteria, _GDBN__ Bugs
7205@section How to Report Bugs
7206@cindex Bug Reports
3d3ab540 7207@cindex _GDBN__ Bugs, Reporting
70b88761
RP
7208
7209A number of companies and individuals offer support for GNU products.
7210If you obtained _GDBN__ from a support organization, we recommend you
e251e767 7211contact that organization first.
70b88761
RP
7212
7213Contact information for many support companies and individuals is
7214available in the file @file{etc/SERVICE} in the GNU Emacs distribution.
7215
7216In any event, we also recommend that you send bug reports for _GDBN__ to one
7217of these addresses:
7218
7219@example
7220bug-gdb@@prep.ai.mit.edu
7221@{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb
7222@end example
7223
7224@strong{Do not send bug reports to @samp{info-gdb}, or to
7225@samp{help-gdb}, or to any newsgroups.} Most users of _GDBN__ do not want to
7226receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}.
7227
3d3ab540
RP
7228The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which
7229serves as a repeater. The mailing list and the newsgroup carry exactly
7230the same messages. Often people think of posting bug reports to the
7231newsgroup instead of mailing them. This appears to work, but it has one
7232problem which can be crucial: a newsgroup posting often lacks a mail
7233path back to the sender. Thus, if we need to ask for more information,
7234we may be unable to reach you. For this reason, it is better to send
7235bug reports to the mailing list.
70b88761
RP
7236
7237As a last resort, send bug reports on paper to:
7238
7239@example
7240GNU Debugger Bugs
3d3ab540 7241Free Software Foundation
70b88761
RP
7242545 Tech Square
7243Cambridge, MA 02139
7244@end example
7245
7246The fundamental principle of reporting bugs usefully is this:
7247@strong{report all the facts}. If you are not sure whether to state a
7248fact or leave it out, state it!
7249
7250Often people omit facts because they think they know what causes the
29a2b744 7251problem and assume that some details do not matter. Thus, you might
70b88761 7252assume that the name of the variable you use in an example does not matter.
29a2b744 7253Well, probably it does not, but one cannot be sure. Perhaps the bug is a
70b88761
RP
7254stray memory reference which happens to fetch from the location where that
7255name is stored in memory; perhaps, if the name were different, the contents
7256of that location would fool the debugger into doing the right thing despite
7257the bug. Play it safe and give a specific, complete example. That is the
7258easiest thing for you to do, and the most helpful.
7259
7260Keep in mind that the purpose of a bug report is to enable us to fix
1041a570 7261the bug if it is new to us. It is not as important as what happens if
70b88761
RP
7262the bug is already known. Therefore, always write your bug reports on
7263the assumption that the bug has not been reported previously.
7264
7265Sometimes people give a few sketchy facts and ask, ``Does this ring a
7266bell?'' Those bug reports are useless, and we urge everyone to
7267@emph{refuse to respond to them} except to chide the sender to report
7268bugs properly.
7269
7270To enable us to fix the bug, you should include all these things:
7271
7272@itemize @bullet
7273@item
7274The version of _GDBN__. _GDBN__ announces it if you start with no
7275arguments; you can also print it at any time using @code{show version}.
7276
1041a570 7277Without this, we will not know whether there is any point in looking for
70b88761
RP
7278the bug in the current version of _GDBN__.
7279
7280@item
ddf21240
JG
7281The type of machine you are using, and the operating system name and
7282version number.
70b88761
RP
7283
7284@item
7285What compiler (and its version) was used to compile _GDBN__---e.g.
c7cb8acb 7286``_GCC__-2.0''.
70b88761 7287
ddf21240
JG
7288@item
7289What compiler (and its version) was used to compile the program you
c7cb8acb 7290are debugging---e.g. ``_GCC__-2.0''.
ddf21240 7291
70b88761
RP
7292@item
7293The command arguments you gave the compiler to compile your example and
7294observe the bug. For example, did you use @samp{-O}? To guarantee
1041a570 7295you will not omit something important, list them all. A copy of the
ddf21240 7296Makefile (or the output from make) is sufficient.
70b88761
RP
7297
7298If we were to try to guess the arguments, we would probably guess wrong
7299and then we might not encounter the bug.
7300
7301@item
ddf21240
JG
7302A complete input script, and all necessary source files, that will
7303reproduce the bug.
70b88761
RP
7304
7305@item
7306A description of what behavior you observe that you believe is
7307incorrect. For example, ``It gets a fatal signal.''
7308
7309Of course, if the bug is that _GDBN__ gets a fatal signal, then we will
7310certainly notice it. But if the bug is incorrect output, we might not
7311notice unless it is glaringly wrong. We are human, after all. You
7312might as well not give us a chance to make a mistake.
7313
7314Even if the problem you experience is a fatal signal, you should still
7315say so explicitly. Suppose something strange is going on, such as,
7316your copy of _GDBN__ is out of synch, or you have encountered a
7317bug in the C library on your system. (This has happened!) Your copy
7318might crash and ours would not. If you told us to expect a crash,
7319then when ours fails to crash, we would know that the bug was not
7320happening for us. If you had not told us to expect a crash, then we
7321would not be able to draw any conclusion from our observations.
7322
7323@item
7324If you wish to suggest changes to the _GDBN__ source, send us context
7325diffs. If you even discuss something in the _GDBN__ source, refer to
7326it by context, not by line number.
7327
1041a570 7328The line numbers in our development sources will not match those in your
70b88761 7329sources. Your line numbers would convey no useful information to us.
70b88761
RP
7330@end itemize
7331
7332Here are some things that are not necessary:
7333
7334@itemize @bullet
7335@item
7336A description of the envelope of the bug.
7337
7338Often people who encounter a bug spend a lot of time investigating
7339which changes to the input file will make the bug go away and which
7340changes will not affect it.
7341
7342This is often time consuming and not very useful, because the way we
7343will find the bug is by running a single example under the debugger
7344with breakpoints, not by pure deduction from a series of examples.
7345We recommend that you save your time for something else.
7346
7347Of course, if you can find a simpler example to report @emph{instead}
7348of the original one, that is a convenience for us. Errors in the
7349output will be easier to spot, running under the debugger will take
e251e767 7350less time, etc.
70b88761 7351
29a2b744 7352However, simplification is not vital; if you do not want to do this,
70b88761
RP
7353report the bug anyway and send us the entire test case you used.
7354
7355@item
7356A patch for the bug.
7357
29a2b744 7358A patch for the bug does help us if it is a good one. But do not omit
70b88761
RP
7359the necessary information, such as the test case, on the assumption that
7360a patch is all we need. We might see problems with your patch and decide
7361to fix the problem another way, or we might not understand it at all.
7362
7363Sometimes with a program as complicated as _GDBN__ it is very hard to
7364construct an example that will make the program follow a certain path
1041a570
RP
7365through the code. If you do not send us the example, we will not be able
7366to construct one, so we will not be able to verify that the bug is fixed.
70b88761 7367
29a2b744 7368And if we cannot understand what bug you are trying to fix, or why your
1041a570 7369patch should be an improvement, we will not install it. A test case will
70b88761
RP
7370help us to understand.
7371
7372@item
7373A guess about what the bug is or what it depends on.
7374
29a2b744 7375Such guesses are usually wrong. Even we cannot guess right about such
70b88761
RP
7376things without first using the debugger to find the facts.
7377@end itemize
7378
1041a570
RP
7379@c Note: no need to update nodes for rdl-apps.texi since it appears
7380@c *only* in the TeX version of the manual.
7381@c Note: eventually, make a cross reference to the readline Info nodes.
70b88761 7382@iftex
cacf5942
RP
7383@c appendices describing GNU readline. Distributed with readline code.
7384@include rluser.texinfo
7385@include inc-hist.texi
70b88761
RP
7386@end iftex
7387
77b46d13 7388@node Renamed Commands, Formatting Documentation, _GDBN__ Bugs, Top
70b88761
RP
7389@appendix Renamed Commands
7390
c7cb8acb 7391The following commands were renamed in GDB 4, in order to make the
70b88761
RP
7392command set as a whole more consistent and easier to use and remember:
7393
e251e767
RP
7394@kindex add-syms
7395@kindex delete environment
7396@kindex info copying
7397@kindex info convenience
7398@kindex info directories
7399@kindex info editing
7400@kindex info history
7401@kindex info targets
7402@kindex info values
7403@kindex info version
7404@kindex info warranty
7405@kindex set addressprint
7406@kindex set arrayprint
7407@kindex set prettyprint
7408@kindex set screen-height
7409@kindex set screen-width
7410@kindex set unionprint
7411@kindex set vtblprint
7412@kindex set demangle
7413@kindex set asm-demangle
7414@kindex set sevenbit-strings
7415@kindex set array-max
7416@kindex set caution
7417@kindex set history write
7418@kindex show addressprint
7419@kindex show arrayprint
7420@kindex show prettyprint
7421@kindex show screen-height
7422@kindex show screen-width
7423@kindex show unionprint
7424@kindex show vtblprint
7425@kindex show demangle
7426@kindex show asm-demangle
7427@kindex show sevenbit-strings
7428@kindex show array-max
7429@kindex show caution
7430@kindex show history write
7431@kindex unset
70b88761 7432
92b73793 7433@c TEXI2ROFF-KILL
70b88761 7434@ifinfo
92b73793 7435@c END TEXI2ROFF-KILL
cf496415
RP
7436@example
7437OLD COMMAND NEW COMMAND
92b73793 7438@c TEXI2ROFF-KILL
cf496415 7439--------------- -------------------------------
92b73793 7440@c END TEXI2ROFF-KILL
cf496415
RP
7441add-syms add-symbol-file
7442delete environment unset environment
7443info convenience show convenience
7444info copying show copying
e251e767 7445info directories show directories
cf496415
RP
7446info editing show commands
7447info history show values
7448info targets help target
7449info values show values
7450info version show version
7451info warranty show warranty
7452set/show addressprint set/show print address
7453set/show array-max set/show print elements
7454set/show arrayprint set/show print array
7455set/show asm-demangle set/show print asm-demangle
7456set/show caution set/show confirm
7457set/show demangle set/show print demangle
7458set/show history write set/show history save
7459set/show prettyprint set/show print pretty
7460set/show screen-height set/show height
7461set/show screen-width set/show width
7462set/show sevenbit-strings set/show print sevenbit-strings
7463set/show unionprint set/show print union
7464set/show vtblprint set/show print vtbl
7465
7466unset [No longer an alias for delete]
7467@end example
92b73793 7468@c TEXI2ROFF-KILL
70b88761
RP
7469@end ifinfo
7470
7471@tex
7472\vskip \parskip\vskip \baselineskip
7473\halign{\tt #\hfil &\qquad#&\tt #\hfil\cr
7474{\bf Old Command} &&{\bf New Command}\cr
7475add-syms &&add-symbol-file\cr
7476delete environment &&unset environment\cr
7477info convenience &&show convenience\cr
7478info copying &&show copying\cr
7479info directories &&show directories \cr
7480info editing &&show commands\cr
7481info history &&show values\cr
7482info targets &&help target\cr
7483info values &&show values\cr
7484info version &&show version\cr
7485info warranty &&show warranty\cr
7486set{\rm / }show addressprint &&set{\rm / }show print address\cr
7487set{\rm / }show array-max &&set{\rm / }show print elements\cr
7488set{\rm / }show arrayprint &&set{\rm / }show print array\cr
7489set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr
7490set{\rm / }show caution &&set{\rm / }show confirm\cr
7491set{\rm / }show demangle &&set{\rm / }show print demangle\cr
7492set{\rm / }show history write &&set{\rm / }show history save\cr
7493set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr
7494set{\rm / }show screen-height &&set{\rm / }show height\cr
7495set{\rm / }show screen-width &&set{\rm / }show width\cr
7496set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr
7497set{\rm / }show unionprint &&set{\rm / }show print union\cr
7498set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr
7499\cr
7500unset &&\rm(No longer an alias for delete)\cr
7501}
7502@end tex
92b73793 7503@c END TEXI2ROFF-KILL
70b88761 7504
77b46d13
JG
7505@node Formatting Documentation, Installing GDB, Renamed Commands, Top
7506@appendix Formatting the Documentation
7507
7508@cindex GDB reference card
7509@cindex reference card
7510The GDB 4 release includes an already-formatted reference card, ready
7511for printing on a PostScript or GhostScript printer, in the @file{gdb}
7512subdirectory of the main source directory---in
7513@file{gdb-_GDB_VN__/gdb/refcard.ps} of the version _GDB_VN__ release. If you have
7514a PostScript or GhostScript printer, you can print the reference card
7515by just sending @file{refcard.ps} to the printer.
7516
7517The release also includes the source for the reference card. You
7518can format it, using @TeX{}, by typing:
7519
7520@example
7521make refcard.dvi
7522@end example
7523
7524The GDB reference card is designed to print in landscape mode on US
7525``letter'' size paper; that is, on a sheet 11 inches wide by 8.5 inches
7526high. You will need to specify this form of printing as an option to
7527your @sc{dvi} output program.
7528
7529@cindex documentation
7530
7531All the documentation for GDB comes as part of the machine-readable
7532distribution. The documentation is written in Texinfo format, which is
7533a documentation system that uses a single source file to produce both
7534on-line information and a printed manual. You can use one of the Info
7535formatting commands to create the on-line version of the documentation
7536and @TeX{} (or @code{texi2roff}) to typeset the printed version.
7537
7538GDB includes an already formatted copy of the on-line Info version of
7539this manual in the @file{gdb} subdirectory. The main Info file is
7540@file{gdb-@var{version-number}/gdb/gdb.info}, and it refers to
a89f94c2
RP
7541subordinate files matching @samp{gdb.info*} in the same directory. If
7542necessary, you can print out these files, or read them with any editor;
7543but they are easier to read using the @code{info} subsystem in GNU Emacs
7544or the standalone @code{info} program, available as part of the GNU
7545Texinfo distribution.
77b46d13
JG
7546
7547If you want to format these Info files yourself, you need one of the
7548Info formatting programs, such as @code{texinfo-format-buffer} or
7549@code{makeinfo}.
7550
7551If you have @code{makeinfo} installed, and are in the top level GDB
7552source directory (@file{gdb-_GDB_VN__}, in the case of version _GDB_VN__), you can
7553make the Info file by typing:
7554
7555@example
7556cd gdb
7557make gdb.info
7558@end example
7559
7560If you want to typeset and print copies of this manual, you need
7561@TeX{}, a printing program such as @code{lpr}, and @file{texinfo.tex},
7562the Texinfo definitions file.
7563
7564@TeX{} is typesetting program; it does not print files directly, but
7565produces output files called @sc{dvi} files. To print a typeset
7566document, you need a program to print @sc{dvi} files. If your system
7567has @TeX{} installed, chances are it has such a program. The precise
7568command to use depends on your system; @kbd{lpr -d} is common; another
7569is @kbd{dvips}. The @sc{dvi} print command may require a file name
7570without any extension or a @samp{.dvi} extension.
7571
7572@TeX{} also requires a macro definitions file called
7573@file{texinfo.tex}. This file tells @TeX{} how to typeset a document
7574written in Texinfo format. On its own, @TeX{} cannot read, much less
7575typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB
7576and is located in the @file{gdb-@var{version-number}/texinfo}
7577directory.
7578
7579If you have @TeX{} and a @sc{dvi} printer program installed, you can
7580typeset and print this manual. First switch to the the @file{gdb}
7581subdirectory of the main source directory (for example, to
7582@file{gdb-_GDB_VN__/gdb}) and then type:
7583
7584@example
7585make gdb.dvi
7586@end example
7587
7588@node Installing GDB, Copying, Formatting Documentation, Top
c7cb8acb
RP
7589@appendix Installing GDB
7590@cindex configuring GDB
70b88761
RP
7591@cindex installation
7592
f672bb7f
RP
7593@iftex
7594@c irrelevant in info file; it's as current as the code it lives with.
7595@quotation
7596@emph{Warning:} These installation instructions are current as of
c7cb8acb
RP
7597GDB version _GDB_VN__. If you're installing a more recent release
7598of GDB, we may have improved the installation procedures since
f672bb7f
RP
7599printing this manual; see the @file{README} file included in your
7600release for the most recent instructions.
7601@end quotation
7602@end iftex
7603
c7cb8acb
RP
7604GDB comes with a @code{configure} script that automates the process
7605of preparing GDB for installation; you can then use @code{make} to
7606build the program.
b80282d5 7607
c7cb8acb 7608The GDB distribution includes all the source code you need for GDB in
1041a570
RP
7609a single directory, whose name is usually composed by appending the
7610version number to @samp{gdb}.
7611
c7cb8acb 7612For example, the GDB version _GDB_VN__ distribution is in the @file{gdb-_GDB_VN__}
1041a570 7613directory. That directory contains:
b80282d5 7614
3d3ab540 7615@table @code
c7637ea6 7616@item gdb-_GDB_VN__/configure @r{(and supporting files)}
c7cb8acb 7617script for configuring GDB and all its supporting libraries.
b80282d5 7618
3e0d0a27 7619@item gdb-_GDB_VN__/gdb
c7cb8acb 7620the source specific to GDB itself
3d3ab540 7621
3e0d0a27 7622@item gdb-_GDB_VN__/bfd
77b46d13 7623source for the Binary File Descriptor library
3d3ab540 7624
3e0d0a27 7625@item gdb-_GDB_VN__/include
b80282d5 7626GNU include files
3d3ab540 7627
3e0d0a27 7628@item gdb-_GDB_VN__/libiberty
3d3ab540
RP
7629source for the @samp{-liberty} free software library
7630
3e0d0a27 7631@item gdb-_GDB_VN__/readline
b80282d5 7632source for the GNU command-line interface
77b46d13
JG
7633
7634@item gdb-_GDB_VN__/glob
7635source for the GNU filename pattern-matching subroutine
7636
7637@item gdb-_GDB_VN__/mmalloc
7638source for the GNU memory-mapped malloc package
3d3ab540 7639@end table
1041a570 7640
c7cb8acb 7641The simplest way to configure and build GDB is to run @code{configure}
1041a570
RP
7642from the @file{gdb-@var{version-number}} source directory, which in
7643this example is the @file{gdb-_GDB_VN__} directory.
7644
7645First switch to the @file{gdb-@var{version-number}} source directory
7646if you are not already in it; then run @code{configure}. Pass the
c7cb8acb 7647identifier for the platform on which GDB will run as an
1041a570
RP
7648argument.
7649
7650For example:
7651
7463aadd 7652@example
3e0d0a27 7653cd gdb-_GDB_VN__
3d3ab540 7654./configure @var{host}
7463aadd
RP
7655make
7656@end example
1041a570 7657
7463aadd 7658@noindent
1041a570 7659where @var{host} is an identifier such as @samp{sun4} or
c7cb8acb 7660@samp{decstation}, that identifies the platform where GDB will run.
1041a570 7661
38962738
RP
7662Running @samp{configure @var{host}} followed by @code{make} builds the
7663@file{bfd}, @file{readline}, @file{mmalloc}, and @file{libiberty}
7664libraries, then @code{gdb} itself. The configured source files, and the
7665binaries, are left in the corresponding source directories.
3d3ab540 7666
e251e767 7667@code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your
29a2b744 7668system does not recognize this automatically when you run a different
1041a570
RP
7669shell, you may need to run @code{sh} on it explicitly:
7670
7671@example
7672sh configure @var{host}
7673@end example
e251e767 7674
f672bb7f
RP
7675If you run @code{configure} from a directory that contains source
7676directories for multiple libraries or programs, such as the
7677@file{gdb-_GDB_VN__} source directory for version _GDB_VN__, @code{configure}
7678creates configuration files for every directory level underneath (unless
98349959 7679you tell it not to, with the @samp{--norecursion} option).
f672bb7f
RP
7680
7681You can run the @code{configure} script from any of the
c7cb8acb 7682subordinate directories in the GDB distribution, if you only want to
1041a570
RP
7683configure that subdirectory; but be sure to specify a path to it.
7684
7685For example, with version _GDB_VN__, type the following to configure only
7686the @code{bfd} subdirectory:
7687
e251e767 7688@example
203eea5d 7689@group
e251e767
RP
7690cd gdb-_GDB_VN__/bfd
7691../configure @var{host}
203eea5d 7692@end group
e251e767
RP
7693@end example
7694
1041a570
RP
7695You can install @code{_GDBP__} anywhere; it has no hardwired paths.
7696However, you should make sure that the shell on your path (named by
7697the @samp{SHELL} environment variable) is publicly readable. Remember
c7cb8acb
RP
7698that GDB uses the shell to start your program---some systems refuse to
7699let GDB debug child processes whose programs are not readable.
3d3ab540
RP
7700
7701@menu
c7cb8acb 7702* Separate Objdir:: Compiling GDB in another directory
b80282d5
RP
7703* Config Names:: Specifying names for hosts and targets
7704* configure Options:: Summary of options for configure
3d3ab540
RP
7705@end menu
7706
c7cb8acb
RP
7707@node Separate Objdir, Config Names, Installing GDB, Installing GDB
7708@section Compiling GDB in Another Directory
1041a570 7709
c7cb8acb
RP
7710If you want to run GDB versions for several host or target machines,
7711you'll need a different @code{gdb} compiled for each combination of
1041a570 7712host and target. @code{configure} is designed to make this easy by
f672bb7f
RP
7713allowing you to generate each configuration in a separate subdirectory,
7714rather than in the source directory. If your @code{make} program
7715handles the @samp{VPATH} feature (GNU @code{make} does), running
c7cb8acb 7716@code{make} in each of these directories then builds the @code{gdb}
f672bb7f 7717program specified there.
b80282d5 7718
c7cb8acb 7719To build @code{gdb} in a separate directory, run @code{configure}
f672bb7f 7720with the @samp{--srcdir} option to specify where to find the source.
77b46d13
JG
7721(You'll also need to specify a path to find @code{configure}
7722itself from your working directory. If the path to @code{configure}
7723would be the same as the argument to @samp{--srcdir}, you can leave out
7724the @samp{--srcdir} option; it will be assumed.)
1041a570 7725
c7cb8acb 7726For example, with version _GDB_VN__, you can build GDB in a separate
f672bb7f 7727directory for a Sun 4 like this:
70b88761
RP
7728
7729@example
3d3ab540 7730@group
3e0d0a27 7731cd gdb-_GDB_VN__
f672bb7f
RP
7732mkdir ../gdb-sun4
7733cd ../gdb-sun4
77b46d13 7734../gdb-_GDB_VN__/configure sun4
70b88761 7735make
3d3ab540 7736@end group
70b88761
RP
7737@end example
7738
f672bb7f
RP
7739When @code{configure} builds a configuration using a remote source
7740directory, it creates a tree for the binaries with the same structure
7741(and using the same names) as the tree under the source directory. In
7742the example, you'd find the Sun 4 library @file{libiberty.a} in the
c7cb8acb 7743directory @file{gdb-sun4/libiberty}, and GDB itself in
f672bb7f 7744@file{gdb-sun4/gdb}.
1041a570 7745
38962738 7746One popular reason to build several GDB configurations in separate
c7cb8acb 7747directories is to configure GDB for cross-compiling (where GDB
f672bb7f
RP
7748runs on one machine---the host---while debugging programs that run on
7749another machine---the target). You specify a cross-debugging target by
7750giving the @samp{--target=@var{target}} option to @code{configure}.
c7637ea6 7751
1041a570 7752When you run @code{make} to build a program or library, you must run
f672bb7f
RP
7753it in a configured directory---whatever directory you were in when you
7754called @code{configure} (or one of its subdirectories).
c7637ea6
RP
7755
7756The @code{Makefile} generated by @code{configure} for each source
f672bb7f
RP
7757directory also runs recursively. If you type @code{make} in a source
7758directory such as @file{gdb-_GDB_VN__} (or in a separate configured
7759directory configured with @samp{--srcdir=@var{path}/gdb-_GDB_VN__}), you
c7cb8acb 7760will build all the required libraries, then build GDB.
3d3ab540 7761
f672bb7f
RP
7762When you have multiple hosts or targets configured in separate
7763directories, you can run @code{make} on them in parallel (for example,
7764if they are NFS-mounted on each of the hosts); they will not interfere
7765with each other.
3d3ab540 7766
c7cb8acb 7767@node Config Names, configure Options, Separate Objdir, Installing GDB
b80282d5
RP
7768@section Specifying Names for Hosts and Targets
7769
7770The specifications used for hosts and targets in the @code{configure}
7771script are based on a three-part naming scheme, but some short predefined
7772aliases are also supported. The full naming scheme encodes three pieces
e251e767 7773of information in the following pattern:
1041a570 7774
b80282d5
RP
7775@example
7776@var{architecture}-@var{vendor}-@var{os}
7777@end example
7778
7779For example, you can use the alias @code{sun4} as a @var{host} argument
5e3186ab 7780or in a @code{--target=@var{target}} option, but the equivalent full name
e251e767 7781is @samp{sparc-sun-sunos4}.
b80282d5 7782
38962738
RP
7783@c @group would be better, if it worked
7784@page
1041a570 7785The following table shows all the architectures, hosts, and OS
c7cb8acb 7786prefixes that @code{configure} recognizes in GDB version _GDB_VN__. Entries
1041a570
RP
7787in the ``OS prefix'' column ending in a @samp{*} may be followed by a
7788release number.
b80282d5 7789
38962738 7790@c FIXME! Update for most recent gdb
92b73793 7791@c TEXI2ROFF-KILL
b80282d5 7792@ifinfo
92b73793 7793@c END TEXI2ROFF-KILL
b80282d5
RP
7794@example
7795
203eea5d 7796ARCHITECTURE VENDOR OS prefix
92b73793 7797@c TEXI2ROFF-KILL
203eea5d 7798------------+--------------------------+---------------------------
92b73793 7799@c END TEXI2ROFF-KILL
203eea5d
RP
7800 | |
7801 580 | altos hp | aix* msdos*
7802 a29k | amd ibm | amigados newsos*
7803 alliant | amdahl intel | aout nindy*
7804 arm | aout isi | bout osf*
7805 c1 | apollo little | bsd* sco*
7806 c2 | att mips | coff sunos*
7807 cray2 | bcs motorola | ctix* svr4
7808 h8300 | bout ncr | dgux* sym*
7809 i386 | bull next | dynix* sysv*
7810 i860 | cbm nyu | ebmon ultrix*
7811 i960 | coff sco | esix* unicos*
7812 m68000 | convergent sequent | hds unos*
7813 m68k | convex sgi | hpux* uts
7814 m88k | cray sony | irix* v88r*
7815 mips | dec sun | isc* vms*
7816 ns32k | encore unicom | kern vxworks*
7817 pyramid | gould utek | mach*
7818 romp | hitachi wrs |
7819 rs6000 | |
7820 sparc | |
7821 tahoe | |
7822 tron | |
7823 vax | |
7824 xmp | |
7825 ymp | |
b80282d5 7826@end example
1041a570 7827
92b73793 7828@c TEXI2ROFF-KILL
b80282d5
RP
7829@end ifinfo
7830@tex
c338a2fd
RP
7831%\vskip\parskip
7832\vskip \baselineskip
203eea5d
RP
7833\hfil\vbox{\offinterlineskip
7834\halign{\strut\tt #\hfil\ &\vrule#&\strut\ \tt #\hfil\ &\strut\ \tt #\hfil
7835\ &\vrule#&\strut\ \tt #\hfil\ &\strut\ \tt #\hfil \cr
7836{\bf Architecture} &&{\bf Vendor} &&&{\bf OS prefix}\cr
7837\multispan7\hrulefill\cr
7838 580 && altos & hp && aix* & msdos* \cr
7839 a29k && amd & ibm && amigados & newsos* \cr
7840 alliant && amdahl & intel && aout & nindy* \cr
7841 arm && aout & isi && bout & osf* \cr
7842 c1 && apollo & little && bsd* & sco* \cr
7843 c2 && att & mips && coff & sunos* \cr
7844 cray2 && bcs & motorola && ctix* & svr4 \cr
7845 h8300 && bout & ncr && dgux* & sym* \cr
7846 i386 && bull & next && dynix* & sysv* \cr
7847 i860 && cbm & nyu && ebmon & ultrix* \cr
7848 i960 && coff & sco && esix* & unicos* \cr
7849 m68000 && convergent& sequent && hds & unos* \cr
7850 m68k && convex & sgi && hpux* & uts \cr
7851 m88k && cray & sony && irix* & v88r* \cr
7852 mips && dec & sun && isc* & vms* \cr
7853 ns32k && encore & unicom && kern & vxworks* \cr
7854 pyramid && gould & utek && mach* & \cr
7855 romp && hitachi & wrs && & \cr
7856 rs6000 && & && & \cr
7857 sparc && & && & \cr
7858 tahoe && & && & \cr
7859 tron && & && & \cr
7860 vax && & && & \cr
7861 xmp && & && & \cr
7862 ymp && & && & \cr
7863}\hfil}
1041a570 7864@end tex
92b73793 7865@c END TEXI2ROFF-KILL
1041a570 7866
203eea5d 7867@quotation
a6d0b6d3
RP
7868@emph{Warning:} @code{configure} can represent a very large number of
7869combinations of architecture, vendor, and OS. There is by no means
7870support available for all possible combinations!
203eea5d 7871@end quotation
b80282d5 7872
c7cb8acb 7873The @code{configure} script accompanying GDB does not provide
b80282d5
RP
7874any query facility to list all supported host and target names or
7875aliases. @code{configure} calls the Bourne shell script
7876@code{config.sub} to map abbreviations to full names; you can read the
7877script, if you wish, or you can use it to test your guesses on
7878abbreviations---for example:
1041a570 7879
b80282d5
RP
7880@example
7881% sh config.sub sun4
7882sparc-sun-sunos4
7883% sh config.sub sun3
7884m68k-sun-sunos4
7885% sh config.sub decstation
7886mips-dec-ultrix
7887% sh config.sub hp300bsd
7888m68k-hp-bsd
7889% sh config.sub i386v
7890i386-none-sysv
e94b4a2b
RP
7891% sh config.sub i786v
7892*** Configuration "i786v" not recognized
b80282d5 7893@end example
1041a570 7894
c7637ea6 7895@noindent
1041a570
RP
7896@code{config.sub} is also distributed in the GDB source
7897directory (@file{gdb-_GDB_VN__}, for version _GDB_VN__).
b80282d5 7898
77b46d13 7899@node configure Options, , Config Names, Installing GDB
3d3ab540 7900@section @code{configure} Options
7463aadd
RP
7901
7902Here is a summary of all the @code{configure} options and arguments that
c7cb8acb 7903you might use for building GDB:
7463aadd
RP
7904
7905@example
77b46d13 7906configure @r{[}--srcdir=@var{path}@r{]}
f672bb7f
RP
7907 @r{[}--norecursion@r{]} @r{[}--rm@r{]}
7908 @r{[}--target=@var{target}@r{]} @var{host}
7463aadd 7909@end example
1041a570 7910
3d3ab540 7911@noindent
f672bb7f
RP
7912You may introduce options with a single @samp{-} rather than
7913@samp{--} if you prefer; but you may abbreviate option names if you use
7914@samp{--}.
70b88761
RP
7915
7916@table @code
f672bb7f 7917@item --srcdir=@var{path}
6ca72cc6
RP
7918@strong{Warning: using this option requires GNU @code{make}, or another
7919@code{make} that implements the @code{VPATH} feature.}@*
f672bb7f 7920Use this option to make configurations in directories separate from the
c7cb8acb 7921GDB source directories. Among other things, you can use this to
f672bb7f
RP
7922build (or maintain) several configurations simultaneously, in separate
7923directories. @code{configure} writes configuration specific files in
7924the current directory, but arranges for them to use the source in the
7925directory @var{path}. @code{configure} will create directories under
7926the working directory in parallel to the source directories below
7927@var{path}.
7928
7929@item --norecursion
7930Configure only the directory level where @code{configure} is executed; do not
7463aadd
RP
7931propagate configuration to subdirectories.
7932
f672bb7f 7933@item --rm
b80282d5 7934Remove the configuration that the other arguments specify.
7463aadd 7935
29a2b744 7936@c This does not work (yet if ever). FIXME.
f672bb7f 7937@c @item --parse=@var{lang} @dots{}
c7cb8acb
RP
7938@c Configure the GDB expression parser to parse the listed languages.
7939@c @samp{all} configures GDB for all supported languages. To get a
d7b569d5 7940@c list of all supported languages, omit the argument. Without this
c7cb8acb 7941@c option, GDB is configured to parse all supported languages.
c2bbbb22 7942
f672bb7f 7943@item --target=@var{target}
c7cb8acb
RP
7944Configure GDB for cross-debugging programs running on the specified
7945@var{target}. Without this option, GDB is configured to debug
7946programs that run on the same machine (@var{host}) as GDB itself.
b80282d5
RP
7947
7948There is no convenient way to generate a list of all available targets.
7463aadd
RP
7949
7950@item @var{host} @dots{}
c7cb8acb 7951Configure GDB to run on the specified @var{host}.
b80282d5
RP
7952
7953There is no convenient way to generate a list of all available hosts.
70b88761
RP
7954@end table
7955
3d3ab540
RP
7956@noindent
7957@code{configure} accepts other options, for compatibility with
b80282d5 7958configuring other GNU tools recursively; but these are the only
c7cb8acb 7959options that affect GDB or its supporting libraries.
3d3ab540 7960
c7cb8acb 7961@node Copying, Index, Installing GDB, Top
70b88761 7962@unnumbered GNU GENERAL PUBLIC LICENSE
7463aadd 7963@center Version 2, June 1991
70b88761
RP
7964
7965@display
7463aadd 7966Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
70b88761
RP
7967675 Mass Ave, Cambridge, MA 02139, USA
7968
7969Everyone is permitted to copy and distribute verbatim copies
7970of this license document, but changing it is not allowed.
7971@end display
7972
7973@unnumberedsec Preamble
7974
7463aadd
RP
7975 The licenses for most software are designed to take away your
7976freedom to share and change it. By contrast, the GNU General Public
70b88761 7977License is intended to guarantee your freedom to share and change free
7463aadd
RP
7978software---to make sure the software is free for all its users. This
7979General Public License applies to most of the Free Software
7980Foundation's software and to any other program whose authors commit to
7981using it. (Some other Free Software Foundation software is covered by
7982the GNU Library General Public License instead.) You can apply it to
7983your programs, too.
70b88761
RP
7984
7985 When we speak of free software, we are referring to freedom, not
7463aadd
RP
7986price. Our General Public Licenses are designed to make sure that you
7987have the freedom to distribute copies of free software (and charge for
7988this service if you wish), that you receive source code or can get it
7989if you want it, that you can change the software or use pieces of it
7990in new free programs; and that you know you can do these things.
70b88761
RP
7991
7992 To protect your rights, we need to make restrictions that forbid
7993anyone to deny you these rights or to ask you to surrender the rights.
7994These restrictions translate to certain responsibilities for you if you
7995distribute copies of the software, or if you modify it.
7996
7463aadd 7997 For example, if you distribute copies of such a program, whether
70b88761
RP
7998gratis or for a fee, you must give the recipients all the rights that
7999you have. You must make sure that they, too, receive or can get the
7463aadd
RP
8000source code. And you must show them these terms so they know their
8001rights.
70b88761
RP
8002
8003 We protect your rights with two steps: (1) copyright the software, and
8004(2) offer you this license which gives you legal permission to copy,
8005distribute and/or modify the software.
8006
8007 Also, for each author's protection and ours, we want to make certain
8008that everyone understands that there is no warranty for this free
8009software. If the software is modified by someone else and passed on, we
8010want its recipients to know that what they have is not the original, so
8011that any problems introduced by others will not reflect on the original
8012authors' reputations.
8013
7463aadd
RP
8014 Finally, any free program is threatened constantly by software
8015patents. We wish to avoid the danger that redistributors of a free
8016program will individually obtain patent licenses, in effect making the
8017program proprietary. To prevent this, we have made it clear that any
8018patent must be licensed for everyone's free use or not licensed at all.
8019
70b88761
RP
8020 The precise terms and conditions for copying, distribution and
8021modification follow.
8022
8023@iftex
7463aadd 8024@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
70b88761
RP
8025@end iftex
8026@ifinfo
7463aadd 8027@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
70b88761
RP
8028@end ifinfo
8029
8030@enumerate
8031@item
7463aadd
RP
8032This License applies to any program or other work which contains
8033a notice placed by the copyright holder saying it may be distributed
8034under the terms of this General Public License. The ``Program'', below,
8035refers to any such program or work, and a ``work based on the Program''
8036means either the Program or any derivative work under copyright law:
8037that is to say, a work containing the Program or a portion of it,
8038either verbatim or with modifications and/or translated into another
8039language. (Hereinafter, translation is included without limitation in
8040the term ``modification''.) Each licensee is addressed as ``you''.
8041
8042Activities other than copying, distribution and modification are not
8043covered by this License; they are outside its scope. The act of
8044running the Program is not restricted, and the output from the Program
8045is covered only if its contents constitute a work based on the
8046Program (independent of having been made by running the Program).
8047Whether that is true depends on what the Program does.
70b88761
RP
8048
8049@item
7463aadd
RP
8050You may copy and distribute verbatim copies of the Program's
8051source code as you receive it, in any medium, provided that you
8052conspicuously and appropriately publish on each copy an appropriate
8053copyright notice and disclaimer of warranty; keep intact all the
8054notices that refer to this License and to the absence of any warranty;
8055and give any other recipients of the Program a copy of this License
8056along with the Program.
70b88761 8057
7463aadd
RP
8058You may charge a fee for the physical act of transferring a copy, and
8059you may at your option offer warranty protection in exchange for a fee.
70b88761 8060
70b88761 8061@item
7463aadd
RP
8062You may modify your copy or copies of the Program or any portion
8063of it, thus forming a work based on the Program, and copy and
8064distribute such modifications or work under the terms of Section 1
8065above, provided that you also meet all of these conditions:
70b88761 8066
1041a570 8067@enumerate a
70b88761 8068@item
7463aadd
RP
8069You must cause the modified files to carry prominent notices
8070stating that you changed the files and the date of any change.
70b88761
RP
8071
8072@item
7463aadd
RP
8073You must cause any work that you distribute or publish, that in
8074whole or in part contains or is derived from the Program or any
8075part thereof, to be licensed as a whole at no charge to all third
8076parties under the terms of this License.
70b88761
RP
8077
8078@item
7463aadd
RP
8079If the modified program normally reads commands interactively
8080when run, you must cause it, when started running for such
8081interactive use in the most ordinary way, to print or display an
8082announcement including an appropriate copyright notice and a
8083notice that there is no warranty (or else, saying that you provide
8084a warranty) and that users may redistribute the program under
8085these conditions, and telling the user how to view a copy of this
8086License. (Exception: if the Program itself is interactive but
8087does not normally print such an announcement, your work based on
8088the Program is not required to print an announcement.)
1041a570 8089@end enumerate
7463aadd
RP
8090
8091These requirements apply to the modified work as a whole. If
8092identifiable sections of that work are not derived from the Program,
8093and can be reasonably considered independent and separate works in
8094themselves, then this License, and its terms, do not apply to those
8095sections when you distribute them as separate works. But when you
8096distribute the same sections as part of a whole which is a work based
8097on the Program, the distribution of the whole must be on the terms of
8098this License, whose permissions for other licensees extend to the
8099entire whole, and thus to each and every part regardless of who wrote it.
8100
8101Thus, it is not the intent of this section to claim rights or contest
8102your rights to work written entirely by you; rather, the intent is to
8103exercise the right to control the distribution of derivative or
8104collective works based on the Program.
8105
8106In addition, mere aggregation of another work not based on the Program
8107with the Program (or with a work based on the Program) on a volume of
8108a storage or distribution medium does not bring the other work under
8109the scope of this License.
70b88761
RP
8110
8111@item
7463aadd
RP
8112You may copy and distribute the Program (or a work based on it,
8113under Section 2) in object code or executable form under the terms of
8114Sections 1 and 2 above provided that you also do one of the following:
70b88761 8115
1041a570 8116@enumerate a
70b88761 8117@item
7463aadd
RP
8118Accompany it with the complete corresponding machine-readable
8119source code, which must be distributed under the terms of Sections
81201 and 2 above on a medium customarily used for software interchange; or,
70b88761
RP
8121
8122@item
7463aadd
RP
8123Accompany it with a written offer, valid for at least three
8124years, to give any third party, for a charge no more than your
8125cost of physically performing source distribution, a complete
8126machine-readable copy of the corresponding source code, to be
8127distributed under the terms of Sections 1 and 2 above on a medium
8128customarily used for software interchange; or,
70b88761
RP
8129
8130@item
7463aadd
RP
8131Accompany it with the information you received as to the offer
8132to distribute corresponding source code. (This alternative is
70b88761 8133allowed only for noncommercial distribution and only if you
7463aadd
RP
8134received the program in object code or executable form with such
8135an offer, in accord with Subsection b above.)
1041a570 8136@end enumerate
7463aadd
RP
8137
8138The source code for a work means the preferred form of the work for
8139making modifications to it. For an executable work, complete source
8140code means all the source code for all modules it contains, plus any
8141associated interface definition files, plus the scripts used to
8142control compilation and installation of the executable. However, as a
8143special exception, the source code distributed need not include
8144anything that is normally distributed (in either source or binary
8145form) with the major components (compiler, kernel, and so on) of the
8146operating system on which the executable runs, unless that component
8147itself accompanies the executable.
8148
8149If distribution of executable or object code is made by offering
8150access to copy from a designated place, then offering equivalent
8151access to copy the source code from the same place counts as
8152distribution of the source code, even though third parties are not
8153compelled to copy the source along with the object code.
70b88761
RP
8154
8155@item
7463aadd
RP
8156You may not copy, modify, sublicense, or distribute the Program
8157except as expressly provided under this License. Any attempt
8158otherwise to copy, modify, sublicense or distribute the Program is
8159void, and will automatically terminate your rights under this License.
8160However, parties who have received copies, or rights, from you under
8161this License will not have their licenses terminated so long as such
8162parties remain in full compliance.
70b88761
RP
8163
8164@item
7463aadd
RP
8165You are not required to accept this License, since you have not
8166signed it. However, nothing else grants you permission to modify or
8167distribute the Program or its derivative works. These actions are
8168prohibited by law if you do not accept this License. Therefore, by
8169modifying or distributing the Program (or any work based on the
8170Program), you indicate your acceptance of this License to do so, and
8171all its terms and conditions for copying, distributing or modifying
8172the Program or works based on it.
70b88761
RP
8173
8174@item
8175Each time you redistribute the Program (or any work based on the
7463aadd
RP
8176Program), the recipient automatically receives a license from the
8177original licensor to copy, distribute or modify the Program subject to
8178these terms and conditions. You may not impose any further
8179restrictions on the recipients' exercise of the rights granted herein.
8180You are not responsible for enforcing compliance by third parties to
8181this License.
8182
8183@item
8184If, as a consequence of a court judgment or allegation of patent
8185infringement or for any other reason (not limited to patent issues),
8186conditions are imposed on you (whether by court order, agreement or
8187otherwise) that contradict the conditions of this License, they do not
8188excuse you from the conditions of this License. If you cannot
8189distribute so as to satisfy simultaneously your obligations under this
8190License and any other pertinent obligations, then as a consequence you
8191may not distribute the Program at all. For example, if a patent
8192license would not permit royalty-free redistribution of the Program by
8193all those who receive copies directly or indirectly through you, then
8194the only way you could satisfy both it and this License would be to
8195refrain entirely from distribution of the Program.
8196
8197If any portion of this section is held invalid or unenforceable under
8198any particular circumstance, the balance of the section is intended to
8199apply and the section as a whole is intended to apply in other
8200circumstances.
8201
8202It is not the purpose of this section to induce you to infringe any
8203patents or other property right claims or to contest validity of any
8204such claims; this section has the sole purpose of protecting the
8205integrity of the free software distribution system, which is
8206implemented by public license practices. Many people have made
8207generous contributions to the wide range of software distributed
8208through that system in reliance on consistent application of that
8209system; it is up to the author/donor to decide if he or she is willing
8210to distribute software through any other system and a licensee cannot
8211impose that choice.
8212
8213This section is intended to make thoroughly clear what is believed to
8214be a consequence of the rest of this License.
8215
8216@item
8217If the distribution and/or use of the Program is restricted in
8218certain countries either by patents or by copyrighted interfaces, the
8219original copyright holder who places the Program under this License
8220may add an explicit geographical distribution limitation excluding
8221those countries, so that distribution is permitted only in or among
8222countries not thus excluded. In such case, this License incorporates
8223the limitation as if written in the body of this License.
70b88761
RP
8224
8225@item
8226The Free Software Foundation may publish revised and/or new versions
8227of the General Public License from time to time. Such new versions will
8228be similar in spirit to the present version, but may differ in detail to
8229address new problems or concerns.
8230
8231Each version is given a distinguishing version number. If the Program
7463aadd 8232specifies a version number of this License which applies to it and ``any
70b88761
RP
8233later version'', you have the option of following the terms and conditions
8234either of that version or of any later version published by the Free
8235Software Foundation. If the Program does not specify a version number of
7463aadd 8236this License, you may choose any version ever published by the Free Software
70b88761
RP
8237Foundation.
8238
8239@item
8240If you wish to incorporate parts of the Program into other free
8241programs whose distribution conditions are different, write to the author
8242to ask for permission. For software which is copyrighted by the Free
8243Software Foundation, write to the Free Software Foundation; we sometimes
8244make exceptions for this. Our decision will be guided by the two goals
8245of preserving the free status of all derivatives of our free software and
8246of promoting the sharing and reuse of software generally.
8247
8248@iftex
8249@heading NO WARRANTY
8250@end iftex
8251@ifinfo
8252@center NO WARRANTY
8253@end ifinfo
8254
8255@item
8256BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
8257FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
8258OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
8259PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
8260OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
8261MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
8262TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
8263PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
8264REPAIR OR CORRECTION.
8265
8266@item
7463aadd
RP
8267IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
8268WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
70b88761 8269REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
7463aadd
RP
8270INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
8271OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
8272TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
8273YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
8274PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
8275POSSIBILITY OF SUCH DAMAGES.
70b88761
RP
8276@end enumerate
8277
8278@iftex
8279@heading END OF TERMS AND CONDITIONS
8280@end iftex
8281@ifinfo
8282@center END OF TERMS AND CONDITIONS
8283@end ifinfo
8284
8285@page
54e6b3c3 8286@unnumberedsec Applying These Terms to Your New Programs
70b88761
RP
8287
8288 If you develop a new program, and you want it to be of the greatest
7463aadd
RP
8289possible use to the public, the best way to achieve this is to make it
8290free software which everyone can redistribute and change under these terms.
70b88761 8291
7463aadd
RP
8292 To do so, attach the following notices to the program. It is safest
8293to attach them to the start of each source file to most effectively
8294convey the exclusion of warranty; and each file should have at least
8295the ``copyright'' line and a pointer to where the full notice is found.
70b88761
RP
8296
8297@smallexample
203eea5d 8298@var{one line to give the program's name and an idea of what it does.}
70b88761
RP
8299Copyright (C) 19@var{yy} @var{name of author}
8300
203eea5d
RP
8301This program is free software; you can redistribute it and/or
8302modify it under the terms of the GNU General Public License
8303as published by the Free Software Foundation; either version 2
8304of the License, or (at your option) any later version.
70b88761
RP
8305
8306This program is distributed in the hope that it will be useful,
8307but WITHOUT ANY WARRANTY; without even the implied warranty of
8308MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8309GNU General Public License for more details.
8310
8311You should have received a copy of the GNU General Public License
203eea5d
RP
8312along with this program; if not, write to the
8313Free Software Foundation, Inc., 675 Mass Ave,
8314Cambridge, MA 02139, USA.
70b88761
RP
8315@end smallexample
8316
8317Also add information on how to contact you by electronic and paper mail.
8318
8319If the program is interactive, make it output a short notice like this
8320when it starts in an interactive mode:
8321
8322@smallexample
8323Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
203eea5d
RP
8324Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
8325type `show w'. This is free software, and you are welcome
8326to redistribute it under certain conditions; type `show c'
8327for details.
70b88761
RP
8328@end smallexample
8329
7463aadd
RP
8330The hypothetical commands @samp{show w} and @samp{show c} should show
8331the appropriate parts of the General Public License. Of course, the
8332commands you use may be called something other than @samp{show w} and
8333@samp{show c}; they could even be mouse-clicks or menu items---whatever
8334suits your program.
70b88761
RP
8335
8336You should also get your employer (if you work as a programmer) or your
8337school, if any, to sign a ``copyright disclaimer'' for the program, if
8338necessary. Here is a sample; alter the names:
8339
1041a570
RP
8340@example
8341Yoyodyne, Inc., hereby disclaims all copyright
8342interest in the program `Gnomovision'
8343(which makes passes at compilers) written
8344by James Hacker.
70b88761
RP
8345
8346@var{signature of Ty Coon}, 1 April 1989
8347Ty Coon, President of Vice
1041a570 8348@end example
7463aadd
RP
8349
8350This General Public License does not permit incorporating your program into
8351proprietary programs. If your program is a subroutine library, you may
8352consider it more useful to permit linking proprietary applications with the
8353library. If this is what you want to do, use the GNU Library General
8354Public License instead of this License.
70b88761 8355
9c3ad547 8356@node Index, , Copying, Top
d2e08421 8357@unnumbered Index
e91b87a3 8358
8359@printindex cp
8360
fe3f5fc8
RP
8361@tex
8362% I think something like @colophon should be in texinfo. In the
8363% meantime:
8364\long\def\colophon{\hbox to0pt{}\vfill
8365\centerline{The body of this manual is set in}
8366\centerline{\fontname\tenrm,}
8367\centerline{with headings in {\bf\fontname\tenbf}}
8368\centerline{and examples in {\tt\fontname\tentt}.}
a6d0b6d3
RP
8369\centerline{{\it\fontname\tenit\/},}
8370\centerline{{\bf\fontname\tenbf}, and}
fe3f5fc8
RP
8371\centerline{{\sl\fontname\tensl\/}}
8372\centerline{are used for emphasis.}\vfill}
8373\page\colophon
a6d0b6d3 8374% Blame: [email protected], 1991.
fe3f5fc8
RP
8375@end tex
8376
e91b87a3 8377@contents
8378@bye
This page took 1.288435 seconds and 4 git commands to generate.