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