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