]>
Commit | Line | Data |
---|---|---|
b80282d5 | 1 | _dnl__ -*-Texinfo-*- |
1041a570 | 2 | _dnl__ Copyright (c) 1988 1989 1990 1991 1992 Free Software Foundation, Inc. |
29a2b744 RP |
3 | _dnl__ $Id$ |
4 | \input texinfo @c -*-texinfo-*- | |
1041a570 | 5 | @c Copyright (c) 1988 1989 1990 1991 1992 Free Software Foundation, Inc. |
29a2b744 | 6 | @c %**start of header |
5a131cc7 | 7 | @setfilename _GDBP__.info |
29a2b744 | 8 | _if__(_GENERIC__) |
95d5ceb9 | 9 | @settitle _GDB__, The GNU Debugger |
29a2b744 RP |
10 | _fi__(_GENERIC__) |
11 | _if__(!_GENERIC__) | |
95d5ceb9 | 12 | @settitle _GDB__, The GNU Debugger (_HOST__) |
29a2b744 RP |
13 | _fi__(!_GENERIC__) |
14 | @setchapternewpage odd | |
73e44aaf RP |
15 | @c @smallbook |
16 | @c @cropmarks | |
29a2b744 RP |
17 | @c %**end of header |
18 | ||
19 | @finalout | |
20 | @syncodeindex ky cp | |
21 | ||
22 | _0__@c ===> NOTE! <==_1__ | |
23 | @c Determine the edition number in *three* places by hand: | |
24 | @c 1. First ifinfo section 2. title page 3. top node | |
25 | @c To find the locations, search for !!set | |
26 | ||
27 | @c The following is for Pesch for his RCS system. | |
28 | @c This revision number *not* the same as the Edition number. | |
29 | @tex | |
30 | \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ | |
31 | \xdef\manvers{\$Revision$} % For use in headers, footers too | |
32 | @end tex | |
33 | ||
d24e0922 | 34 | @c GDB CHANGELOG CONSULTED BETWEEN: |
29a2b744 RP |
35 | @c Fri Oct 11 23:27:06 1991 John Gilmore (gnu at cygnus.com) |
36 | @c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint) | |
37 | ||
9c3ad547 | 38 | @c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly. |
29a2b744 | 39 | |
b7becc8f RP |
40 | @ifinfo |
41 | @format | |
42 | START-INFO-DIR-ENTRY | |
29a2b744 | 43 | * Gdb: (gdb). The GNU debugger. |
b7becc8f RP |
44 | END-INFO-DIR-ENTRY |
45 | @end format | |
46 | @end ifinfo | |
5a131cc7 RP |
47 | _if__(0) |
48 | ||
a6d0b6d3 RP |
49 | NOTE: this manual is marked up for preprocessing with a collection |
50 | of m4 macros called "pretex.m4". | |
51 | ||
9bcc06ef RP |
52 | THIS IS THE SOURCE PRIOR TO PREPROCESSING. The full source needs to |
53 | be run through m4 before either tex- or info- formatting: for example, | |
08665207 | 54 | _0__ |
3e0d0a27 | 55 | m4 pretex.m4 none.m4 all.m4 gdb.texinfo >gdb-all.texinfo |
70b88761 | 56 | will produce (assuming your path finds either GNU m4 >= 0.84, or SysV |
1041a570 | 57 | m4; Berkeley will not do) a file suitable for formatting. See the text in |
70b88761 | 58 | "pretex.m4" for a fuller explanation (and the macro definitions). |
29a2b744 | 59 | _1__ |
e91b87a3 | 60 | |
9bcc06ef | 61 | _fi__(0) |
70b88761 | 62 | @c |
70b88761 RP |
63 | @ifinfo |
64 | This file documents the GNU debugger _GDBN__. | |
65 | ||
29a2b744 | 66 | @c !!set edition, date, version |
d24e0922 | 67 | This is Edition 4.04, March 1992, |
29a2b744 RP |
68 | of @cite{Using GDB: A Guide to the GNU Source-Level Debugger} |
69 | for GDB Version _GDB_VN__. | |
70 | ||
95d5ceb9 | 71 | Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. |
70b88761 RP |
72 | |
73 | Permission is granted to make and distribute verbatim copies of | |
74 | this manual provided the copyright notice and this permission notice | |
75 | are preserved on all copies. | |
76 | ||
77 | @ignore | |
78 | Permission is granted to process this file through TeX and print the | |
79 | results, provided the printed document carries copying permission | |
80 | notice identical to this one except for the removal of this paragraph | |
81 | (this paragraph not being relevant to the printed manual). | |
82 | ||
83 | @end ignore | |
84 | Permission is granted to copy and distribute modified versions of this | |
85 | manual under the conditions for verbatim copying, provided also that the | |
86 | section entitled ``GNU General Public License'' is included exactly as | |
87 | in the original, and provided that the entire resulting derived work is | |
88 | distributed under the terms of a permission notice identical to this | |
89 | one. | |
90 | ||
91 | Permission is granted to copy and distribute translations of this manual | |
92 | into another language, under the above conditions for modified versions, | |
93 | except that the section entitled ``GNU General Public License'' may be | |
94 | included in a translation approved by the Free Software Foundation | |
95 | instead of in the original English. | |
96 | @end ifinfo | |
1041a570 | 97 | |
70b88761 | 98 | @titlepage |
92b73793 | 99 | @title Using _GDBN__ |
95d5ceb9 | 100 | @subtitle The GNU Source-Level Debugger |
70b88761 | 101 | _if__(!_GENERIC__) |
c7cb8acb | 102 | @subtitle on _HOST__ Systems |
70b88761 RP |
103 | _fi__(!_GENERIC__) |
104 | @sp 1 | |
29a2b744 | 105 | @c !!set edition, date, version |
d24e0922 RP |
106 | @subtitle Edition 4.04, for _GDBN__ version _GDB_VN__ |
107 | @subtitle March 1992 | |
29a2b744 | 108 | @author by Richard M. Stallman and Roland H. Pesch |
70b88761 RP |
109 | @page |
110 | @tex | |
111 | {\parskip=0pt | |
112 | \hfill rms\@ai.mit.edu, pesch\@cygnus.com\par | |
113 | \hfill {\it Using _GDBN__}, \manvers\par | |
114 | \hfill \TeX{}info \texinfoversion\par | |
115 | } | |
116 | @end tex | |
117 | ||
118 | @vskip 0pt plus 1filll | |
1041a570 | 119 | Copyright @copyright{} 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. |
70b88761 RP |
120 | |
121 | Permission is granted to make and distribute verbatim copies of | |
122 | this manual provided the copyright notice and this permission notice | |
123 | are preserved on all copies. | |
124 | ||
125 | Permission is granted to copy and distribute modified versions of this | |
126 | manual under the conditions for verbatim copying, provided also that the | |
127 | section entitled ``GNU General Public License'' is included exactly as | |
128 | in the original, and provided that the entire resulting derived work is | |
129 | distributed under the terms of a permission notice identical to this | |
130 | one. | |
131 | ||
132 | Permission is granted to copy and distribute translations of this manual | |
133 | into another language, under the above conditions for modified versions, | |
134 | except that the section entitled ``GNU General Public License'' may be | |
135 | included in a translation approved by the Free Software Foundation | |
136 | instead of in the original English. | |
137 | @end titlepage | |
138 | @page | |
139 | ||
70b88761 | 140 | @ifinfo |
29a2b744 RP |
141 | @node Top, Summary, (dir), (dir) |
142 | @top _GDBN__, the GNU symbolic debugger | |
143 | ||
144 | This file describes _GDBN__, the GNU symbolic debugger. | |
145 | ||
146 | @c !!set edition, date, version | |
d24e0922 | 147 | This is Edition 4.04, March 1992, for GDB Version _GDB_VN__. |
70b88761 RP |
148 | @end ifinfo |
149 | ||
150 | @menu | |
b80282d5 | 151 | * Summary:: Summary of _GDBN__ |
c7cb8acb | 152 | * New Features:: New features since GDB version 3.5 |
95d5ceb9 | 153 | * Sample Session:: A sample _GDBN__ session |
29a2b744 RP |
154 | * Invocation:: Getting in and out of _GDBN__ |
155 | * Commands:: _GDBN__ commands | |
156 | * Running:: Running programs under _GDBN__ | |
157 | * Stopping:: Stopping and continuing | |
158 | * Stack:: Examining the stack | |
159 | * Source:: Examining source files | |
160 | * Data:: Examining data | |
161 | * Languages:: Using _GDBN__ with different languages | |
162 | * Symbols:: Examining the symbol table | |
163 | * Altering:: Altering execution | |
164 | * _GDBN__ Files:: _GDBN__'s files | |
165 | * Targets:: Specifying a debugging target | |
c2bbbb22 | 166 | * Controlling _GDBN__:: Controlling _GDBN__ |
29a2b744 | 167 | * Sequences:: Canned sequences of commands |
b80282d5 | 168 | * Emacs:: Using _GDBN__ under GNU Emacs |
29a2b744 | 169 | * _GDBN__ Bugs:: Reporting bugs in _GDBN__ |
e251e767 | 170 | * Renamed Commands:: |
c7cb8acb | 171 | * Installing GDB:: Installing GDB |
b80282d5 RP |
172 | * Copying:: GNU GENERAL PUBLIC LICENSE |
173 | * Index:: Index | |
c2bbbb22 | 174 | |
70b88761 RP |
175 | --- The Detailed Node Listing --- |
176 | ||
177 | Summary of _GDBN__ | |
178 | ||
95d5ceb9 | 179 | * Free Software:: Freely redistributable software |
b80282d5 | 180 | * Contributors:: Contributors to _GDBN__ |
70b88761 RP |
181 | |
182 | Getting In and Out of _GDBN__ | |
183 | ||
95d5ceb9 RP |
184 | * Invoking _GDBN__:: How to start _GDBN__ |
185 | * Leaving _GDBN__:: How to quit _GDBN__ | |
186 | * Shell Commands:: How to use shell commands inside _GDBN__ | |
70b88761 RP |
187 | |
188 | Starting _GDBN__ | |
189 | ||
b80282d5 RP |
190 | * File Options:: Choosing Files |
191 | * Mode Options:: Choosing Modes | |
70b88761 RP |
192 | |
193 | _GDBN__ Commands | |
194 | ||
b80282d5 RP |
195 | * Command Syntax:: Command Syntax |
196 | * Help:: Getting Help | |
70b88761 RP |
197 | |
198 | Running Programs Under _GDBN__ | |
199 | ||
b80282d5 RP |
200 | * Compilation:: Compiling for Debugging |
201 | * Starting:: Starting your Program | |
202 | * Arguments:: Your Program's Arguments | |
203 | * Environment:: Your Program's Environment | |
204 | * Working Directory:: Your Program's Working Directory | |
205 | * Input/Output:: Your Program's Input and Output | |
206 | * Attach:: Debugging an Already-Running Process | |
207 | * Kill Process:: Killing the Child Process | |
d24e0922 | 208 | * Process Information:: Additional Process Information |
70b88761 RP |
209 | |
210 | Stopping and Continuing | |
211 | ||
b80282d5 RP |
212 | * Breakpoints:: Breakpoints, Watchpoints, and Exceptions |
213 | * Continuing and Stepping:: Resuming Execution | |
214 | * Signals:: Signals | |
70b88761 RP |
215 | |
216 | Breakpoints, Watchpoints, and Exceptions | |
217 | ||
b80282d5 RP |
218 | * Set Breaks:: Setting Breakpoints |
219 | * Set Watchpoints:: Setting Watchpoints | |
220 | * Exception Handling:: Breakpoints and Exceptions | |
221 | * Delete Breaks:: Deleting Breakpoints | |
222 | * Disabling:: Disabling Breakpoints | |
223 | * Conditions:: Break Conditions | |
224 | * Break Commands:: Breakpoint Command Lists | |
225 | * Breakpoint Menus:: Breakpoint Menus | |
c2bbbb22 | 226 | * Error in Breakpoints:: ``Cannot insert breakpoints'' |
70b88761 RP |
227 | |
228 | Examining the Stack | |
229 | ||
b80282d5 RP |
230 | * Frames:: Stack Frames |
231 | * Backtrace:: Backtraces | |
232 | * Selection:: Selecting a Frame | |
233 | * Frame Info:: Information on a Frame | |
70b88761 RP |
234 | |
235 | Examining Source Files | |
236 | ||
b80282d5 RP |
237 | * List:: Printing Source Lines |
238 | * Search:: Searching Source Files | |
239 | * Source Path:: Specifying Source Directories | |
240 | * Machine Code:: Source and Machine Code | |
70b88761 RP |
241 | |
242 | Examining Data | |
243 | ||
b80282d5 RP |
244 | * Expressions:: Expressions |
245 | * Variables:: Program Variables | |
246 | * Arrays:: Artificial Arrays | |
247 | * Output formats:: Output formats | |
248 | * Memory:: Examining Memory | |
249 | * Auto Display:: Automatic Display | |
250 | * Print Settings:: Print Settings | |
251 | * Value History:: Value History | |
252 | * Convenience Vars:: Convenience Variables | |
253 | * Registers:: Registers | |
254 | * Floating Point Hardware:: Floating Point Hardware | |
70b88761 | 255 | |
c2bbbb22 RP |
256 | Using GDB with Different Languages |
257 | ||
258 | * Setting:: Switching between source languages | |
259 | * Show:: Displaying the language | |
260 | * Checks:: Type and Range checks | |
261 | * Support:: Supported languages | |
262 | ||
263 | Switching between source languages | |
264 | ||
265 | * Manually:: Setting the working language manually | |
266 | * Automatically:: Having GDB infer the source language | |
267 | ||
268 | Type and range Checking | |
269 | ||
270 | * Type Checking:: An overview of type checking | |
271 | * Range Checking:: An overview of range checking | |
272 | ||
273 | Supported Languages | |
274 | ||
275 | * C:: C and C++ | |
276 | * Modula-2:: Modula-2 | |
277 | ||
278 | C and C++ | |
279 | ||
280 | * C Operators:: C and C++ Operators | |
281 | * C Constants:: C and C++ Constants | |
282 | * Cplusplus expressions:: C++ Expressions | |
283 | * C Defaults:: Default settings for C and C++ | |
284 | * C Checks:: C and C++ Type and Range Checks | |
285 | * Debugging C:: _GDBN__ and C | |
286 | * Debugging C plus plus:: Special features for C++ | |
287 | ||
288 | Modula-2 | |
289 | ||
290 | * M2 Operators:: Built-in operators | |
29a2b744 | 291 | * Built-In Func/Proc:: Built-in Functions and Procedures |
c2bbbb22 RP |
292 | * M2 Constants:: Modula-2 Constants |
293 | * M2 Defaults:: Default settings for Modula-2 | |
294 | * Deviations:: Deviations from standard Modula-2 | |
295 | * M2 Checks:: Modula-2 Type and Range Checks | |
296 | * M2 Scope:: The scope operators @code{::} and @code{.} | |
297 | * GDB/M2:: GDB and Modula-2 | |
298 | ||
70b88761 RP |
299 | Altering Execution |
300 | ||
b80282d5 RP |
301 | * Assignment:: Assignment to Variables |
302 | * Jumping:: Continuing at a Different Address | |
29a2b744 | 303 | * Signaling:: Giving your program a Signal |
b80282d5 RP |
304 | * Returning:: Returning from a Function |
305 | * Calling:: Calling your Program's Functions | |
c338a2fd | 306 | * Patching:: Patching your Program |
70b88761 RP |
307 | |
308 | _GDBN__'s Files | |
309 | ||
b80282d5 RP |
310 | * Files:: Commands to Specify Files |
311 | * Symbol Errors:: Errors Reading Symbol Files | |
70b88761 | 312 | |
e251e767 | 313 | Specifying a Debugging Target |
70b88761 | 314 | |
b80282d5 RP |
315 | * Active Targets:: Active Targets |
316 | * Target Commands:: Commands for Managing Targets | |
317 | * Remote:: Remote Debugging | |
70b88761 RP |
318 | |
319 | Remote Debugging | |
320 | ||
c2bbbb22 RP |
321 | * i960-Nindy Remote:: _GDBN__ with a Remote i960 (Nindy) |
322 | * EB29K Remote:: _GDBN__ with a Remote EB29K | |
323 | * VxWorks Remote:: _GDBN__ and VxWorks | |
70b88761 RP |
324 | |
325 | _GDBN__ with a Remote i960 (Nindy) | |
326 | ||
b80282d5 RP |
327 | * Nindy Startup:: Startup with Nindy |
328 | * Nindy Options:: Options for Nindy | |
329 | * Nindy reset:: Nindy Reset Command | |
70b88761 RP |
330 | |
331 | _GDBN__ with a Remote EB29K | |
332 | ||
b80282d5 RP |
333 | * Comms (EB29K):: Communications Setup |
334 | * gdb-EB29K:: EB29K cross-debugging | |
335 | * Remote Log:: Remote Log | |
70b88761 RP |
336 | |
337 | _GDBN__ and VxWorks | |
338 | ||
b80282d5 RP |
339 | * VxWorks connection:: Connecting to VxWorks |
340 | * VxWorks download:: VxWorks Download | |
341 | * VxWorks attach:: Running Tasks | |
70b88761 RP |
342 | |
343 | Controlling _GDBN__ | |
344 | ||
b80282d5 RP |
345 | * Prompt:: Prompt |
346 | * Editing:: Command Editing | |
347 | * History:: Command History | |
348 | * Screen Size:: Screen Size | |
349 | * Numbers:: Numbers | |
350 | * Messages/Warnings:: Optional Warnings and Messages | |
70b88761 RP |
351 | |
352 | Canned Sequences of Commands | |
353 | ||
b80282d5 RP |
354 | * Define:: User-Defined Commands |
355 | * Command Files:: Command Files | |
356 | * Output:: Commands for Controlled Output | |
70b88761 RP |
357 | |
358 | Reporting Bugs in _GDBN__ | |
359 | ||
b80282d5 RP |
360 | * Bug Criteria:: Have You Found a Bug? |
361 | * Bug Reporting:: How to Report Bugs | |
c2bbbb22 RP |
362 | |
363 | Installing GDB | |
364 | ||
f672bb7f | 365 | * Separate Objdir:: Compiling _GDBN__ in another directory |
c2bbbb22 RP |
366 | * Config Names:: Specifying names for hosts and targets |
367 | * configure Options:: Summary of options for configure | |
d7b569d5 | 368 | * Formatting Documentation:: How to format and print GDB documentation |
70b88761 RP |
369 | @end menu |
370 | ||
371 | @node Summary, New Features, Top, Top | |
372 | @unnumbered Summary of _GDBN__ | |
373 | ||
374 | The purpose of a debugger such as _GDBN__ is to allow you to see what is | |
375 | going on ``inside'' another program while it executes---or what another | |
1041a570 | 376 | program was doing at the moment it crashed. |
70b88761 RP |
377 | |
378 | _GDBN__ can do four main kinds of things (plus other things in support of | |
1041a570 | 379 | these) to help you catch bugs in the act: |
70b88761 RP |
380 | |
381 | @itemize @bullet | |
382 | @item | |
383 | Start your program, specifying anything that might affect its behavior. | |
384 | ||
385 | @item | |
386 | Make your program stop on specified conditions. | |
387 | ||
388 | @item | |
389 | Examine what has happened, when your program has stopped. | |
390 | ||
391 | @item | |
392 | Change things in your program, so you can experiment with correcting the | |
393 | effects of one bug and go on to learn about another. | |
394 | @end itemize | |
395 | ||
c2bbbb22 RP |
396 | You can use _GDBN__ to debug programs written in C, C++, and Modula-2. |
397 | Fortran support will be added when a GNU Fortran compiler is ready. | |
70b88761 RP |
398 | |
399 | @menu | |
b80282d5 RP |
400 | * Free Software:: Free Software |
401 | * Contributors:: Contributors to GDB | |
70b88761 RP |
402 | @end menu |
403 | ||
404 | @node Free Software, Contributors, Summary, Summary | |
405 | @unnumberedsec Free Software | |
1041a570 RP |
406 | |
407 | _GDBN__ is @dfn{free software}, protected by the GNU General Public License | |
408 | (GPL). The GPL gives you the freedom to copy or adapt a licensed | |
70b88761 RP |
409 | program---but every person getting a copy also gets with it the |
410 | freedom to modify that copy (which means that they must get access to | |
411 | the source code), and the freedom to distribute further copies. | |
412 | Typical software companies use copyrights to limit your freedoms; the | |
413 | Free Software Foundation uses the GPL to preserve these freedoms. | |
414 | ||
415 | Fundamentally, the General Public License is a license which says that | |
29a2b744 | 416 | you have these freedoms and that you cannot take these freedoms away |
70b88761 RP |
417 | from anyone else. |
418 | ||
29a2b744 | 419 | For full details, @pxref{Copying, ,GNU GENERAL PUBLIC LICENSE}. |
1041a570 | 420 | |
70b88761 RP |
421 | @node Contributors, , Free Software, Summary |
422 | @unnumberedsec Contributors to GDB | |
423 | ||
424 | Richard Stallman was the original author of GDB, and of many other GNU | |
425 | programs. Many others have contributed to its development. This | |
426 | section attempts to credit major contributors. One of the virtues of | |
427 | free software is that everyone is free to contribute to it; with | |
428 | regret, we cannot actually acknowledge everyone here. The file | |
429 | @file{ChangeLog} in the GDB distribution approximates a blow-by-blow | |
430 | account. | |
431 | ||
432 | Changes much prior to version 2.0 are lost in the mists of time. | |
433 | ||
434 | @quotation | |
435 | @emph{Plea:} Additions to this section are particularly welcome. If you | |
436 | or your friends (or enemies; let's be evenhanded) have been unfairly | |
437 | omitted from this list, we would like to add your names! | |
438 | @end quotation | |
439 | ||
440 | So that they may not regard their long labor as thankless, we | |
69bbcf05 | 441 | particularly thank those who shepherded GDB through major releases: Stu |
14d01801 | 442 | Grossman and John Gilmore (releases 4.5, 4.4), John Gilmore (releases 4.3, 4.2, |
69bbcf05 RP |
443 | 4.1, 4.0, and 3.9); Jim Kingdon (releases 3.5, 3.4, 3.3); and Randy |
444 | Smith (releases 3.2, 3.1, 3.0). As major maintainer of GDB for some | |
445 | period, each contributed significantly to the structure, stability, and | |
446 | capabilities of the entire debugger. | |
70b88761 RP |
447 | |
448 | Richard Stallman, assisted at various times by Pete TerMaat, Chris | |
449 | Hanson, and Richard Mlynarik, handled releases through 2.8. | |
450 | ||
451 | Michael Tiemann is the author of most of the GNU C++ support in GDB, | |
452 | with significant additional contributions from Per Bothner. James | |
453 | Clark wrote the GNU C++ demangler. Early work on C++ was by Peter | |
454 | TerMaat (who also did much general update work leading to release 3.0). | |
455 | ||
1041a570 RP |
456 | GDB 4 uses the BFD subroutine library to examine multiple |
457 | object-file formats; BFD was a joint project of David V. | |
458 | Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore. | |
70b88761 | 459 | |
1041a570 RP |
460 | David Johnson wrote the original COFF support; Pace Willison did |
461 | the original support for encapsulated COFF. | |
70b88761 RP |
462 | |
463 | Adam de Boor and Bradley Davis contributed the ISI Optimum V support. | |
464 | Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS | |
1041a570 RP |
465 | support. Jean-Daniel Fekete contributed Sun 386i support. Chris |
466 | Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki | |
467 | Hasei contributed Sony/News OS 3 support. David Johnson contributed | |
468 | Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. | |
469 | Keith Packard contributed NS32K support. Doug Rabson contributed | |
470 | Acorn Risc Machine support. Chris Smith contributed Convex support | |
471 | (and Fortran debugging). Jonathan Stone contributed Pyramid support. | |
472 | Michael Tiemann contributed SPARC support. Tim Tucker contributed | |
473 | support for the Gould NP1 and Gould Powernode. Pace Willison | |
474 | contributed Intel 386 support. Jay Vosburgh contributed Symmetry | |
475 | support. | |
70b88761 | 476 | |
c338a2fd RP |
477 | Rich Schaefer and Peter Schauer helped with support of SunOS shared |
478 | libraries. | |
70b88761 RP |
479 | |
480 | Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about | |
481 | several machine instruction sets. | |
482 | ||
1041a570 RP |
483 | Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped |
484 | develop remote debugging. Intel Corporation and Wind River Systems | |
485 | contributed remote debugging modules for their products. | |
70b88761 | 486 | |
1041a570 RP |
487 | Brian Fox is the author of the readline libraries providing |
488 | command-line editing and command history. | |
70b88761 | 489 | |
1041a570 RP |
490 | Andrew Beers of SUNY Buffalo wrote the language-switching code and |
491 | the Modula-2 support, and contributed the Languages chapter of this | |
492 | manual. | |
c2bbbb22 | 493 | |
14d01801 RP |
494 | Fred Fish wrote most of the support for Unix System Vr4. |
495 | ||
70b88761 | 496 | @node New Features, Sample Session, Summary, Top |
c7cb8acb | 497 | @unnumbered New Features since GDB version 3.5 |
70b88761 RP |
498 | |
499 | @table @emph | |
500 | @item Targets | |
501 | Using the new command @code{target}, you can select at runtime whether | |
502 | you are debugging local files, local processes, standalone systems over | |
b80282d5 RP |
503 | a serial port, realtime systems over a TCP/IP connection, etc. The |
504 | command @code{load} can download programs into a remote system. Serial | |
505 | stubs are available for Motorola 680x0 and Intel 80386 remote systems; | |
c7cb8acb | 506 | GDB also supports debugging realtime processes running under |
b80282d5 | 507 | VxWorks, using SunRPC Remote Procedure Calls over TCP/IP to talk to a |
c7cb8acb | 508 | debugger stub on the target system. Internally, GDB now uses a |
b80282d5 RP |
509 | function vector to mediate access to different targets; if you need to |
510 | add your own support for a remote protocol, this makes it much easier. | |
70b88761 RP |
511 | |
512 | @item Watchpoints | |
c7cb8acb | 513 | GDB now sports watchpoints as well as breakpoints. You can use a |
70b88761 RP |
514 | watchpoint to stop execution whenever the value of an expression |
515 | changes, without having to predict a particular place in your program | |
516 | where this may happen. | |
517 | ||
b80282d5 RP |
518 | @item Wide Output |
519 | Commands that issue wide output now insert newlines at places designed | |
520 | to make the output more readable. | |
521 | ||
70b88761 | 522 | @item Object Code Formats |
c7cb8acb | 523 | GDB uses a new library called the Binary File Descriptor (BFD) |
3d3ab540 RP |
524 | Library to permit it to switch dynamically, without reconfiguration or |
525 | recompilation, between different object-file formats. Formats currently | |
526 | supported are COFF, a.out, and the Intel 960 b.out; files may be read as | |
527 | .o's, archive libraries, or core dumps. BFD is available as a | |
528 | subroutine library so that other programs may take advantage of it, and | |
529 | the other GNU binary utilities are being converted to use it. | |
70b88761 | 530 | |
b80282d5 | 531 | @item Configuration and Ports |
70b88761 | 532 | Compile-time configuration (to select a particular architecture and |
7463aadd | 533 | operating system) is much easier. The script @code{configure} now |
c7cb8acb RP |
534 | allows you to configure GDB as either a native debugger or a |
535 | cross-debugger. @xref{Installing GDB}, for details on how to | |
b80282d5 | 536 | configure and on what architectures are now available. |
70b88761 RP |
537 | |
538 | @item Interaction | |
c7cb8acb | 539 | The user interface to GDB's control variables has been simplified |
70b88761 RP |
540 | and consolidated in two commands, @code{set} and @code{show}. Output |
541 | lines are now broken at readable places, rather than overflowing onto | |
542 | the next line. You can suppress output of machine-level addresses, | |
543 | displaying only source language information. | |
544 | ||
b80282d5 | 545 | @item C++ |
c7cb8acb | 546 | GDB now supports C++ multiple inheritance (if used with a GCC |
b80282d5 | 547 | version 2 compiler), and also has limited support for C++ exception |
c7cb8acb | 548 | handling, with the commands @code{catch} and @code{info catch}: GDB |
b80282d5 RP |
549 | can break when an exception is raised, before the stack is peeled back |
550 | to the exception handler's context. | |
70b88761 | 551 | |
c2bbbb22 | 552 | @item Modula-2 |
c7cb8acb | 553 | GDB now has preliminary support for the GNU Modula-2 compiler, |
c2bbbb22 | 554 | currently under development at the State University of New York at |
c7cb8acb | 555 | Buffalo. Coordinated development of both GDB and the GNU Modula-2 |
5b0fdf7b RP |
556 | compiler will continue into 1992. Other Modula-2 compilers are |
557 | currently not supported, and attempting to debug programs compiled with | |
558 | them will likely result in an error as the symbol table of the | |
559 | executable is read in. | |
c2bbbb22 | 560 | |
70b88761 | 561 | @item Command Rationalization |
c7cb8acb | 562 | Many GDB commands have been renamed to make them easier to remember |
70b88761 RP |
563 | and use. In particular, the subcommands of @code{info} and |
564 | @code{show}/@code{set} are grouped to make the former refer to the state | |
c7cb8acb | 565 | of your program, and the latter refer to the state of GDB itself. |
70b88761 RP |
566 | @xref{Renamed Commands}, for details on what commands were renamed. |
567 | ||
70b88761 | 568 | @item Shared Libraries |
c7cb8acb | 569 | GDB 4 can debug programs and core files that use SunOS shared |
e251e767 | 570 | libraries. |
b80282d5 RP |
571 | |
572 | @item Reference Card | |
c7cb8acb | 573 | GDB 4 has a reference card. @xref{Formatting Documentation} for |
b80282d5 | 574 | instructions on printing it. |
70b88761 RP |
575 | |
576 | @item Work in Progress | |
577 | Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture | |
578 | support. | |
70b88761 RP |
579 | @end table |
580 | ||
581 | @node Sample Session, Invocation, New Features, Top | |
582 | @chapter A Sample _GDBN__ Session | |
583 | ||
584 | You can use this manual at your leisure to read all about _GDBN__. | |
585 | However, a handful of commands are enough to get started using the | |
586 | debugger. This chapter illustrates these commands. | |
587 | ||
588 | @iftex | |
6ca72cc6 | 589 | In this sample session, we emphasize user input like this: @b{input}, |
70b88761 RP |
590 | to make it easier to pick out from the surrounding output. |
591 | @end iftex | |
592 | ||
593 | @c FIXME: this example may not be appropriate for some configs, where | |
594 | @c FIXME...primary interest is in remote use. | |
595 | _0__ | |
596 | One of the preliminary versions of GNU @code{m4} (a generic macro | |
597 | processor) exhibits the following bug: sometimes, when we change its | |
598 | quote strings from the default, the commands used to capture one macro's | |
599 | definition in another stop working. In the following short @code{m4} | |
600 | session, we define a macro @code{foo} which expands to @code{0000}; we | |
29a2b744 | 601 | then use the @code{m4} built-in @code{defn} to define @code{bar} as the |
70b88761 RP |
602 | same thing. However, when we change the open quote string to |
603 | @code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same | |
604 | procedure fails to define a new synonym @code{baz}: | |
605 | ||
606 | @smallexample | |
6ca72cc6 RP |
607 | $ @b{cd gnu/m4} |
608 | $ @b{./m4} | |
609 | @b{define(foo,0000)} | |
70b88761 | 610 | |
6ca72cc6 | 611 | @b{foo} |
70b88761 | 612 | 0000 |
6ca72cc6 | 613 | @b{define(bar,defn(`foo'))} |
70b88761 | 614 | |
6ca72cc6 | 615 | @b{bar} |
70b88761 | 616 | 0000 |
6ca72cc6 | 617 | @b{changequote(<QUOTE>,<UNQUOTE>)} |
70b88761 | 618 | |
6ca72cc6 RP |
619 | @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))} |
620 | @b{baz} | |
621 | @b{C-d} | |
70b88761 RP |
622 | m4: End of input: 0: fatal error: EOF in string |
623 | @end smallexample | |
624 | ||
625 | @noindent | |
626 | Let's use _GDBN__ to try to see what's going on. | |
627 | ||
628 | @smallexample | |
6ca72cc6 | 629 | $ @b{_GDBP__ m4} |
203eea5d RP |
630 | @c FIXME: this falsifies the exact text played out, to permit smallbook |
631 | @c FIXME... format to come out better. | |
632 | GDB is free software and you are welcome to distribute copies | |
633 | of it under certain conditions; type "show copying" to see | |
634 | the conditions. | |
635 | There is absolutely no warranty for GDB; type "show warranty" | |
636 | for details. | |
5b0fdf7b | 637 | GDB _GDB_VN__, Copyright 1992 Free Software Foundation, Inc... |
e251e767 | 638 | (_GDBP__) |
70b88761 RP |
639 | @end smallexample |
640 | ||
641 | @noindent | |
1041a570 RP |
642 | _GDBN__ reads only enough symbol data to know where to find the rest when |
643 | needed; as a result, the first prompt comes up very quickly. We now | |
644 | tell _GDBN__ to use a narrower display width than usual, so that examples | |
645 | will fit in this manual. | |
70b88761 RP |
646 | |
647 | @smallexample | |
6ca72cc6 | 648 | (_GDBP__) @b{set width 70} |
70b88761 RP |
649 | @end smallexample |
650 | ||
e251e767 | 651 | @noindent |
29a2b744 | 652 | Let's see how the @code{m4} built-in @code{changequote} works. |
70b88761 RP |
653 | Having looked at the source, we know the relevant subroutine is |
654 | @code{m4_changequote}, so we set a breakpoint there with _GDBN__'s | |
655 | @code{break} command. | |
656 | ||
657 | @smallexample | |
6ca72cc6 | 658 | (_GDBP__) @b{break m4_changequote} |
70b88761 RP |
659 | Breakpoint 1 at 0x62f4: file builtin.c, line 879. |
660 | @end smallexample | |
661 | ||
662 | @noindent | |
663 | Using the @code{run} command, we start @code{m4} running under _GDBN__ | |
664 | control; as long as control does not reach the @code{m4_changequote} | |
665 | subroutine, the program runs as usual: | |
666 | ||
667 | @smallexample | |
6ca72cc6 | 668 | (_GDBP__) @b{run} |
e251e767 | 669 | Starting program: /work/Editorial/gdb/gnu/m4/m4 |
6ca72cc6 | 670 | @b{define(foo,0000)} |
70b88761 | 671 | |
6ca72cc6 | 672 | @b{foo} |
70b88761 RP |
673 | 0000 |
674 | @end smallexample | |
675 | ||
676 | @noindent | |
677 | To trigger the breakpoint, we call @code{changequote}. _GDBN__ | |
678 | suspends execution of @code{m4}, displaying information about the | |
679 | context where it stops. | |
680 | ||
681 | @smallexample | |
6ca72cc6 | 682 | @b{changequote(<QUOTE>,<UNQUOTE>)} |
70b88761 | 683 | |
203eea5d RP |
684 | Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) |
685 | at builtin.c:879 | |
70b88761 RP |
686 | 879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3)) |
687 | @end smallexample | |
688 | ||
689 | @noindent | |
690 | Now we use the command @code{n} (@code{next}) to advance execution to | |
691 | the next line of the current function. | |
692 | ||
693 | @smallexample | |
6ca72cc6 | 694 | (_GDBP__) @b{n} |
203eea5d RP |
695 | 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\ |
696 | : nil, | |
70b88761 RP |
697 | @end smallexample |
698 | ||
699 | @noindent | |
700 | @code{set_quotes} looks like a promising subroutine. We can go into it | |
701 | by using the command @code{s} (@code{step}) instead of @code{next}. | |
702 | @code{step} goes to the next line to be executed in @emph{any} | |
e251e767 | 703 | subroutine, so it steps into @code{set_quotes}. |
70b88761 RP |
704 | |
705 | @smallexample | |
6ca72cc6 | 706 | (_GDBP__) @b{s} |
70b88761 RP |
707 | set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>") |
708 | at input.c:530 | |
709 | 530 if (lquote != def_lquote) | |
710 | @end smallexample | |
711 | ||
712 | @noindent | |
29a2b744 RP |
713 | The display that shows the subroutine where @code{m4} is now |
714 | suspended (and its arguments) is called a stack frame display. It | |
715 | shows a summary of the stack. We can use the @code{backtrace} | |
716 | command (which can also be spelled @code{bt}), to see where we are | |
717 | in the stack as a whole: the @code{backtrace} command displays a | |
718 | stack frame for each active subroutine. | |
70b88761 RP |
719 | |
720 | @smallexample | |
6ca72cc6 | 721 | (_GDBP__) @b{bt} |
70b88761 RP |
722 | #0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>") |
723 | at input.c:530 | |
203eea5d RP |
724 | #1 0x6344 in m4_changequote (argc=3, argv=0x33c70) |
725 | at builtin.c:882 | |
70b88761 RP |
726 | #2 0x8174 in expand_macro (sym=0x33320) at macro.c:242 |
727 | #3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30) | |
728 | at macro.c:71 | |
729 | #4 0x79dc in expand_input () at macro.c:40 | |
730 | #5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195 | |
731 | @end smallexample | |
732 | ||
733 | @noindent | |
734 | Let's step through a few more lines to see what happens. The first two | |
735 | times, we can use @samp{s}; the next two times we use @code{n} to avoid | |
736 | falling into the @code{xstrdup} subroutine. | |
1041a570 | 737 | |
70b88761 | 738 | @smallexample |
6ca72cc6 | 739 | (_GDBP__) @b{s} |
70b88761 | 740 | 0x3b5c 532 if (rquote != def_rquote) |
6ca72cc6 | 741 | (_GDBP__) @b{s} |
203eea5d RP |
742 | 0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \ |
743 | def_lquote : xstrdup(lq); | |
6ca72cc6 | 744 | (_GDBP__) @b{n} |
203eea5d RP |
745 | 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ |
746 | : xstrdup(rq); | |
6ca72cc6 | 747 | (_GDBP__) @b{n} |
70b88761 RP |
748 | 538 len_lquote = strlen(rquote); |
749 | @end smallexample | |
750 | ||
751 | @noindent | |
752 | The last line displayed looks a little odd; let's examine the variables | |
753 | @code{lquote} and @code{rquote} to see if they are in fact the new left | |
754 | and right quotes we specified. We can use the command @code{p} | |
755 | (@code{print}) to see their values. | |
756 | ||
757 | @smallexample | |
6ca72cc6 | 758 | (_GDBP__) @b{p lquote} |
70b88761 | 759 | $1 = 0x35d40 "<QUOTE>" |
6ca72cc6 | 760 | (_GDBP__) @b{p rquote} |
70b88761 RP |
761 | $2 = 0x35d50 "<UNQUOTE>" |
762 | @end smallexample | |
763 | ||
764 | @noindent | |
765 | @code{lquote} and @code{rquote} are indeed the new left and right quotes. | |
766 | Let's look at some context; we can display ten lines of source | |
767 | surrounding the current line, with the @code{l} (@code{list}) command. | |
768 | ||
769 | @smallexample | |
6ca72cc6 | 770 | (_GDBP__) @b{l} |
70b88761 | 771 | 533 xfree(rquote); |
e251e767 | 772 | 534 |
203eea5d RP |
773 | 535 lquote = (lq == nil || *lq == '\0') ? def_lquote\ |
774 | : xstrdup (lq); | |
775 | 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ | |
776 | : xstrdup (rq); | |
e251e767 | 777 | 537 |
70b88761 RP |
778 | 538 len_lquote = strlen(rquote); |
779 | 539 len_rquote = strlen(lquote); | |
780 | 540 @} | |
e251e767 | 781 | 541 |
70b88761 RP |
782 | 542 void |
783 | @end smallexample | |
784 | ||
785 | @noindent | |
786 | Let's step past the two lines that set @code{len_lquote} and | |
787 | @code{len_rquote}, and then examine the values of those variables. | |
788 | ||
789 | @smallexample | |
6ca72cc6 | 790 | (_GDBP__) @b{n} |
70b88761 | 791 | 539 len_rquote = strlen(lquote); |
6ca72cc6 | 792 | (_GDBP__) @b{n} |
70b88761 | 793 | 540 @} |
6ca72cc6 | 794 | (_GDBP__) @b{p len_lquote} |
70b88761 | 795 | $3 = 9 |
6ca72cc6 | 796 | (_GDBP__) @b{p len_rquote} |
70b88761 RP |
797 | $4 = 7 |
798 | @end smallexample | |
799 | ||
800 | @noindent | |
801 | That certainly looks wrong, assuming @code{len_lquote} and | |
802 | @code{len_rquote} are meant to be the lengths of @code{lquote} and | |
803 | @code{rquote} respectively. Let's try setting them to better values. | |
804 | We can use the @code{p} command for this, since it'll print the value of | |
805 | any expression---and that expression can include subroutine calls and | |
e251e767 | 806 | assignments. |
70b88761 RP |
807 | |
808 | @smallexample | |
6ca72cc6 | 809 | (_GDBP__) @b{p len_lquote=strlen(lquote)} |
70b88761 | 810 | $5 = 7 |
6ca72cc6 | 811 | (_GDBP__) @b{p len_rquote=strlen(rquote)} |
70b88761 RP |
812 | $6 = 9 |
813 | @end smallexample | |
814 | ||
815 | @noindent | |
816 | Let's see if that fixes the problem of using the new quotes with the | |
817 | @code{m4} built-in @code{defn}. We can allow @code{m4} to continue | |
818 | executing with the @code{c} (@code{continue}) command, and then try the | |
819 | example that caused trouble initially: | |
820 | ||
821 | @smallexample | |
6ca72cc6 | 822 | (_GDBP__) @b{c} |
70b88761 RP |
823 | Continuing. |
824 | ||
6ca72cc6 | 825 | @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))} |
70b88761 RP |
826 | |
827 | baz | |
828 | 0000 | |
829 | @end smallexample | |
830 | ||
831 | @noindent | |
832 | Success! The new quotes now work just as well as the default ones. The | |
833 | problem seems to have been just the two typos defining the wrong | |
834 | lengths. We'll let @code{m4} exit by giving it an EOF as input. | |
835 | ||
836 | @smallexample | |
6ca72cc6 | 837 | @b{C-d} |
70b88761 RP |
838 | Program exited normally. |
839 | @end smallexample | |
840 | ||
e251e767 | 841 | @noindent |
70b88761 RP |
842 | The message @samp{Program exited normally.} is from _GDBN__; it |
843 | indicates @code{m4} has finished executing. We can end our _GDBN__ | |
844 | session with the _GDBN__ @code{quit} command. | |
845 | ||
846 | @smallexample | |
6ca72cc6 | 847 | (_GDBP__) @b{quit} |
70b88761 RP |
848 | _1__@end smallexample |
849 | ||
850 | @node Invocation, Commands, Sample Session, Top | |
851 | @chapter Getting In and Out of _GDBN__ | |
852 | ||
c7cb8acb RP |
853 | This chapter discusses how to start _GDBN__, and how to get out of it. |
854 | (The essentials: type @samp{_GDBP__} to start GDB, and type @kbd{quit} | |
855 | or @kbd{C-d} to exit.) | |
29a2b744 | 856 | |
70b88761 | 857 | @menu |
29a2b744 | 858 | * Invoking _GDBN__:: Starting _GDBN__ |
c2bbbb22 | 859 | * Leaving _GDBN__:: Leaving _GDBN__ |
b80282d5 | 860 | * Shell Commands:: Shell Commands |
70b88761 RP |
861 | @end menu |
862 | ||
29a2b744 | 863 | @node Invoking _GDBN__, Leaving _GDBN__, Invocation, Invocation |
70b88761 RP |
864 | @section Starting _GDBN__ |
865 | ||
1041a570 RP |
866 | Start _GDBN__ with the shell command @code{_GDBP__}. Once it's running, |
867 | _GDBN__ reads commands from the terminal until you tell it to exit. | |
70b88761 | 868 | |
c7cb8acb RP |
869 | You can also run @code{_GDBP__} with a variety of arguments and options, |
870 | to specify more of your debugging environment at the outset. | |
871 | ||
872 | The command-line options described here are designed | |
873 | to cover a variety of situations; in some environments, some of these | |
874 | options may effectively be unavailable. | |
875 | ||
876 | _if__(_H8__) | |
877 | For details on starting up _GDBP__ as a | |
878 | remote debugger attached to a Hitachi H8/300 board, see @ref{Hitachi | |
879 | H8/300 Remote,,_GDBN__ and the Hitachi H8/300}. | |
880 | _fi__(_H8__) | |
881 | ||
882 | The most usual way to start _GDBN__ is with one argument or two, | |
883 | specifying an executable program as the argument: | |
1041a570 | 884 | |
70b88761 | 885 | @example |
29a2b744 | 886 | _GDBP__ @var{program} |
70b88761 | 887 | @end example |
1041a570 | 888 | |
70b88761 | 889 | @noindent |
29a2b744 RP |
890 | You can also start with both an executable program and a core file |
891 | specified: | |
1041a570 | 892 | |
70b88761 | 893 | @example |
29a2b744 | 894 | _GDBP__ @var{program} @var{core} |
70b88761 RP |
895 | @end example |
896 | ||
b80282d5 RP |
897 | You can, instead, specify a process ID as a second argument, if you want |
898 | to debug a running process: | |
1041a570 | 899 | |
b80282d5 | 900 | @example |
29a2b744 | 901 | _GDBP__ @var{program} 1234 |
b80282d5 | 902 | @end example |
1041a570 | 903 | |
b80282d5 RP |
904 | @noindent |
905 | would attach _GDBN__ to process @code{1234} (unless you also have a file | |
906 | named @file{1234}; _GDBN__ does check for a core file first). | |
907 | ||
c7cb8acb RP |
908 | Taking advantage of the second command-line argument requires a fairly |
909 | complete operating system; when you use _GDBN__ as a remote debugger | |
910 | attached to a bare board, there may not be any notion of ``process'', | |
911 | and there is often no way to get a core dump. | |
912 | ||
70b88761 RP |
913 | @noindent |
914 | You can further control how _GDBN__ starts up by using command-line | |
29a2b744 RP |
915 | options. _GDBN__ itself can remind you of the options available. |
916 | ||
917 | @noindent | |
918 | Type | |
919 | ||
70b88761 RP |
920 | @example |
921 | _GDBP__ -help | |
922 | @end example | |
29a2b744 | 923 | |
70b88761 | 924 | @noindent |
29a2b744 | 925 | to display all available options and briefly describe their use |
70b88761 RP |
926 | (@samp{_GDBP__ -h} is a shorter equivalent). |
927 | ||
928 | All options and command line arguments you give are processed | |
929 | in sequential order. The order makes a difference when the | |
e251e767 | 930 | @samp{-x} option is used. |
70b88761 RP |
931 | |
932 | @menu | |
b80282d5 RP |
933 | * File Options:: Choosing Files |
934 | * Mode Options:: Choosing Modes | |
70b88761 RP |
935 | _if__(!_GENERIC__) |
936 | _include__(gdbinv-m.m4)_dnl__ | |
937 | _fi__(!_GENERIC__) | |
938 | @end menu | |
939 | ||
29a2b744 | 940 | @node File Options, Mode Options, Invoking _GDBN__, Invoking _GDBN__ |
70b88761 RP |
941 | @subsection Choosing Files |
942 | ||
29a2b744 RP |
943 | When _GDBN__ starts, it reads any arguments other than options as |
944 | specifying an executable file and core file (or process ID). This is | |
945 | the same as if the arguments were specified by the @samp{-se} and | |
946 | @samp{-c} options respectively. (_GDBN__ reads the first argument | |
947 | that does not have an associated option flag as equivalent to the | |
948 | @samp{-se} option followed by that argument; and the second argument | |
949 | that does not have an associated option flag, if any, as equivalent to | |
950 | the @samp{-c} option followed by that argument.) | |
951 | ||
952 | Many options have both long and short forms; both are shown in the | |
953 | following list. _GDBN__ also recognizes the long forms if you truncate | |
954 | them, so long as enough of the option is present to be unambiguous. | |
955 | (If you prefer, you can flag option arguments with @samp{--} rather | |
956 | than @samp{-}, though we illustrate the more usual convention.) | |
70b88761 RP |
957 | |
958 | @table @code | |
959 | @item -symbols=@var{file} | |
960 | @itemx -s @var{file} | |
961 | Read symbol table from file @var{file}. | |
962 | ||
963 | @item -exec=@var{file} | |
964 | @itemx -e @var{file} | |
965 | Use file @var{file} as the executable file to execute when | |
966 | appropriate, and for examining pure data in conjunction with a core | |
967 | dump. | |
968 | ||
3d3ab540 | 969 | @item -se=@var{file} |
70b88761 RP |
970 | Read symbol table from file @var{file} and use it as the executable |
971 | file. | |
972 | ||
973 | @item -core=@var{file} | |
974 | @itemx -c @var{file} | |
975 | Use file @var{file} as a core dump to examine. | |
976 | ||
977 | @item -command=@var{file} | |
978 | @itemx -x @var{file} | |
979 | Execute _GDBN__ commands from file @var{file}. @xref{Command Files}. | |
980 | ||
981 | @item -directory=@var{directory} | |
982 | @itemx -d @var{directory} | |
983 | Add @var{directory} to the path to search for source files. | |
14d01801 RP |
984 | |
985 | @item -m | |
986 | @itemx -mapped | |
987 | @emph{Warning: this option depends on operating system facilities that are not | |
988 | supported on all systems.}@* | |
989 | If memory-mapped files are available through the @code{mmap} system | |
990 | call, you can use this option to get _GDBN__ to write out the symbols | |
991 | for your program in a reusable file. Next time _GDBN__ starts up (if the | |
992 | program hasn't changed), it will map in symbol information from this | |
993 | auxiliary symbol file, rather than spending time reading the symbol | |
994 | table from the executable program. | |
70b88761 RP |
995 | @end table |
996 | ||
997 | _if__(!_GENERIC__) | |
29a2b744 | 998 | @node Mode Options, Mode Options, File Options, Invoking _GDBN__ |
70b88761 RP |
999 | _fi__(!_GENERIC__) |
1000 | _if__(_GENERIC__) | |
29a2b744 RP |
1001 | @node Mode Options, , File Options, Invoking _GDBN__ |
1002 | _fi__(_GENERIC__) | |
1041a570 RP |
1003 | @subsection Choosing Modes |
1004 | ||
29a2b744 RP |
1005 | You can run _GDBN__ in various alternative modes---for example, in |
1006 | batch mode or quiet mode. | |
70b88761 RP |
1007 | |
1008 | @table @code | |
1009 | @item -nx | |
1010 | @itemx -n | |
1011 | Do not execute commands from any @file{_GDBINIT__} initialization files. | |
1012 | Normally, the commands in these files are executed after all the | |
e251e767 | 1013 | command options and arguments have been processed. |
c728f1f0 | 1014 | @xref{Command Files}. |
70b88761 RP |
1015 | |
1016 | @item -quiet | |
1017 | @itemx -q | |
1018 | ``Quiet''. Do not print the introductory and copyright messages. These | |
c338a2fd | 1019 | messages are also suppressed in batch mode. |
70b88761 RP |
1020 | |
1021 | @item -batch | |
1022 | Run in batch mode. Exit with status @code{0} after processing all the command | |
1023 | files specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited). | |
1024 | Exit with nonzero status if an error occurs in executing the _GDBN__ | |
e251e767 | 1025 | commands in the command files. |
70b88761 RP |
1026 | |
1027 | Batch mode may be useful for running _GDBN__ as a filter, for example to | |
1028 | download and run a program on another computer; in order to make this | |
e251e767 | 1029 | more useful, the message |
1041a570 | 1030 | |
70b88761 RP |
1031 | @example |
1032 | Program exited normally. | |
1033 | @end example | |
1041a570 | 1034 | |
70b88761 RP |
1035 | @noindent |
1036 | (which is ordinarily issued whenever a program running under _GDBN__ control | |
1037 | terminates) is not issued when running in batch mode. | |
1038 | ||
3d3ab540 | 1039 | @item -cd=@var{directory} |
70b88761 RP |
1040 | Run _GDBN__ using @var{directory} as its working directory, |
1041 | instead of the current directory. | |
1042 | ||
6ca72cc6 RP |
1043 | _if__(_LUCID__) |
1044 | @item -energize @var{authentication} | |
1045 | @itemx -cadillac @var{authentication} | |
1046 | When the Energize programming system starts up _GDBN__, it uses this | |
1047 | option to trigger an alternate mode of interaction. | |
1048 | @var{authentication} is a pair of numeric codes that identify _GDBN__ | |
1049 | as a client in the Energize environment. Avoid this option when you run | |
1050 | _GDBN__ directly from the command line. See @ref{Energize,,Using | |
1051 | _GDBN__ with Energize} for more discussion of using _GDBN__ with Energize. | |
1052 | _fi__(_LUCID__) | |
1053 | ||
70b88761 RP |
1054 | @item -fullname |
1055 | @itemx -f | |
1056 | Emacs sets this option when it runs _GDBN__ as a subprocess. It tells _GDBN__ | |
1057 | to output the full file name and line number in a standard, | |
1058 | recognizable fashion each time a stack frame is displayed (which | |
29a2b744 | 1059 | includes each time your program stops). This recognizable format looks |
70b88761 RP |
1060 | like two @samp{\032} characters, followed by the file name, line number |
1061 | and character position separated by colons, and a newline. The | |
1062 | Emacs-to-_GDBN__ interface program uses the two @samp{\032} characters as | |
1063 | a signal to display the source code for the frame. | |
1064 | ||
1065 | @item -b @var{bps} | |
1066 | Set the line speed (baud rate or bits per second) of any serial | |
1067 | interface used by _GDBN__ for remote debugging. | |
1068 | ||
3d3ab540 | 1069 | @item -tty=@var{device} |
70b88761 | 1070 | Run using @var{device} for your program's standard input and output. |
29a2b744 | 1071 | @c FIXME: kingdon thinks there is more to -tty. Investigate. |
70b88761 RP |
1072 | @end table |
1073 | ||
1074 | _if__(!_GENERIC__) | |
1075 | _include__(gdbinv-s.m4) | |
1076 | _fi__(!_GENERIC__) | |
29a2b744 | 1077 | @node Leaving _GDBN__, Shell Commands, Invoking _GDBN__, Invocation |
70b88761 RP |
1078 | @section Leaving _GDBN__ |
1079 | @cindex exiting _GDBN__ | |
1041a570 | 1080 | |
70b88761 RP |
1081 | @table @code |
1082 | @item quit | |
1083 | @kindex quit | |
1084 | @kindex q | |
1085 | To exit _GDBN__, use the @code{quit} command (abbreviated @code{q}), or type | |
e251e767 | 1086 | an end-of-file character (usually @kbd{C-d}). |
70b88761 RP |
1087 | @end table |
1088 | ||
1089 | @cindex interrupt | |
1090 | An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather | |
1091 | will terminate the action of any _GDBN__ command that is in progress and | |
1092 | return to _GDBN__ command level. It is safe to type the interrupt | |
1093 | character at any time because _GDBN__ does not allow it to take effect | |
1094 | until a time when it is safe. | |
1095 | ||
1041a570 RP |
1096 | If you have been using _GDBN__ to control an attached process or device, you |
1097 | can release it with the @code{detach} command; @pxref{Attach, | |
1098 | ,Debugging an Already-Running Process}.. | |
70b88761 RP |
1099 | |
1100 | @node Shell Commands, , Leaving _GDBN__, Invocation | |
1101 | @section Shell Commands | |
1041a570 | 1102 | |
70b88761 | 1103 | If you need to execute occasional shell commands during your |
29a2b744 | 1104 | debugging session, there is no need to leave or suspend _GDBN__; you can |
70b88761 RP |
1105 | just use the @code{shell} command. |
1106 | ||
1107 | @table @code | |
1108 | @item shell @var{command string} | |
1109 | @kindex shell | |
1110 | @cindex shell escape | |
1111 | Directs _GDBN__ to invoke an inferior shell to execute @var{command | |
1112 | string}. If it exists, the environment variable @code{SHELL} is used | |
1113 | for the name of the shell to run. Otherwise _GDBN__ uses | |
1114 | @code{/bin/sh}. | |
1115 | @end table | |
1116 | ||
1117 | The utility @code{make} is often needed in development environments. | |
29a2b744 | 1118 | You do not have to use the @code{shell} command for this purpose in _GDBN__: |
70b88761 RP |
1119 | |
1120 | @table @code | |
1121 | @item make @var{make-args} | |
1122 | @kindex make | |
1123 | @cindex calling make | |
1124 | Causes _GDBN__ to execute an inferior @code{make} program with the specified | |
1125 | arguments. This is equivalent to @samp{shell make @var{make-args}}. | |
1126 | @end table | |
1127 | ||
1128 | @node Commands, Running, Invocation, Top | |
1129 | @chapter _GDBN__ Commands | |
1130 | ||
29a2b744 RP |
1131 | You can abbreviate GDB command if that abbreviation is unambiguous; |
1132 | and you can repeat certain GDB commands by typing just @key{RET}. | |
1133 | ||
70b88761 | 1134 | @menu |
b80282d5 RP |
1135 | * Command Syntax:: Command Syntax |
1136 | * Help:: Getting Help | |
70b88761 RP |
1137 | @end menu |
1138 | ||
1139 | @node Command Syntax, Help, Commands, Commands | |
1140 | @section Command Syntax | |
1041a570 | 1141 | |
70b88761 RP |
1142 | A _GDBN__ command is a single line of input. There is no limit on how long |
1143 | it can be. It starts with a command name, which is followed by arguments | |
1144 | whose meaning depends on the command name. For example, the command | |
1145 | @code{step} accepts an argument which is the number of times to step, | |
1146 | as in @samp{step 5}. You can also use the @code{step} command with | |
1147 | no arguments. Some command names do not allow any arguments. | |
1148 | ||
1149 | @cindex abbreviation | |
1150 | _GDBN__ command names may always be truncated if that abbreviation is | |
1151 | unambiguous. Other possible command abbreviations are listed in the | |
1152 | documentation for individual commands. In some cases, even ambiguous | |
1153 | abbreviations are allowed; for example, @code{s} is specially defined as | |
1154 | equivalent to @code{step} even though there are other commands whose | |
1155 | names start with @code{s}. You can test abbreviations by using them as | |
7463aadd | 1156 | arguments to the @code{help} command. |
70b88761 | 1157 | |
e251e767 | 1158 | @cindex repeating commands |
70b88761 RP |
1159 | @kindex RET |
1160 | A blank line as input to _GDBN__ (typing just @key{RET}) means to | |
1161 | repeat the previous command. Certain commands (for example, @code{run}) | |
1162 | will not repeat this way; these are commands for which unintentional | |
1163 | repetition might cause trouble and which you are unlikely to want to | |
1164 | repeat. | |
1165 | ||
1166 | The @code{list} and @code{x} commands, when you repeat them with | |
1167 | @key{RET}, construct new arguments rather than repeating | |
1168 | exactly as typed. This permits easy scanning of source or memory. | |
1169 | ||
b80282d5 RP |
1170 | _GDBN__ can also use @key{RET} in another way: to partition lengthy |
1171 | output, in a way similar to the common utility @code{more} | |
29a2b744 | 1172 | (@pxref{Screen Size}). Since it is easy to press one @key{RET} too many |
b80282d5 RP |
1173 | in this situation, _GDBN__ disables command repetition after any command |
1174 | that generates this sort of display. | |
1175 | ||
70b88761 RP |
1176 | @kindex # |
1177 | @cindex comment | |
1178 | A line of input starting with @kbd{#} is a comment; it does nothing. | |
29a2b744 | 1179 | This is useful mainly in command files (@pxref{Command Files}). |
70b88761 RP |
1180 | |
1181 | @node Help, , Command Syntax, Commands | |
1182 | @section Getting Help | |
1183 | @cindex online documentation | |
1184 | @kindex help | |
1041a570 | 1185 | |
70b88761 | 1186 | You can always ask _GDBN__ itself for information on its commands, using the |
e251e767 | 1187 | command @code{help}. |
70b88761 RP |
1188 | |
1189 | @table @code | |
1190 | @item help | |
1191 | @itemx h | |
1192 | @kindex h | |
1193 | You can use @code{help} (abbreviated @code{h}) with no arguments to | |
1194 | display a short list of named classes of commands: | |
1041a570 | 1195 | |
70b88761 RP |
1196 | @smallexample |
1197 | (_GDBP__) help | |
1198 | List of classes of commands: | |
1199 | ||
1200 | running -- Running the program | |
1201 | stack -- Examining the stack | |
1202 | data -- Examining data | |
1203 | breakpoints -- Making program stop at certain points | |
1204 | files -- Specifying and examining files | |
1205 | status -- Status inquiries | |
1206 | support -- Support facilities | |
1207 | user-defined -- User-defined commands | |
1208 | aliases -- Aliases of other commands | |
1209 | obscure -- Obscure features | |
1210 | ||
203eea5d RP |
1211 | Type "help" followed by a class name for a list of |
1212 | commands in that class. | |
1213 | Type "help" followed by command name for full | |
1214 | documentation. | |
70b88761 | 1215 | Command name abbreviations are allowed if unambiguous. |
e251e767 | 1216 | (_GDBP__) |
70b88761 RP |
1217 | @end smallexample |
1218 | ||
1219 | @item help @var{class} | |
1220 | Using one of the general help classes as an argument, you can get a | |
1221 | list of the individual commands in that class. For example, here is the | |
1222 | help display for the class @code{status}: | |
1041a570 | 1223 | |
70b88761 RP |
1224 | @smallexample |
1225 | (_GDBP__) help status | |
1226 | Status inquiries. | |
1227 | ||
1228 | List of commands: | |
1229 | ||
1230 | show -- Generic command for showing things set with "set" | |
1231 | info -- Generic command for printing status | |
1232 | ||
203eea5d RP |
1233 | Type "help" followed by command name for full |
1234 | documentation. | |
70b88761 | 1235 | Command name abbreviations are allowed if unambiguous. |
e251e767 | 1236 | (_GDBP__) |
70b88761 RP |
1237 | @end smallexample |
1238 | ||
1239 | @item help @var{command} | |
1240 | With a command name as @code{help} argument, _GDBN__ will display a | |
e251e767 | 1241 | short paragraph on how to use that command. |
70b88761 RP |
1242 | @end table |
1243 | ||
1244 | In addition to @code{help}, you can use the _GDBN__ commands @code{info} | |
1245 | and @code{show} to inquire about the state of your program, or the state | |
1246 | of _GDBN__ itself. Each command supports many topics of inquiry; this | |
1247 | manual introduces each of them in the appropriate context. The listings | |
1248 | under @code{info} and under @code{show} in the Index point to | |
29a2b744 | 1249 | all the sub-commands. @xref{Index}. |
70b88761 RP |
1250 | |
1251 | @c @group | |
1252 | @table @code | |
1253 | @item info | |
1254 | @kindex info | |
1255 | @kindex i | |
1256 | This command (abbreviated @code{i}) is for describing the state of your | |
1257 | program; for example, it can list the arguments given to your program | |
1258 | (@code{info args}), the registers currently in use (@code{info | |
1041a570 | 1259 | registers}), or the breakpoints you have set (@code{info breakpoints}). |
70b88761 RP |
1260 | You can get a complete list of the @code{info} sub-commands with |
1261 | @w{@code{help info}}. | |
1262 | ||
1263 | @kindex show | |
1264 | @item show | |
1265 | In contrast, @code{show} is for describing the state of _GDBN__ itself. | |
1266 | You can change most of the things you can @code{show}, by using the | |
1267 | related command @code{set}; for example, you can control what number | |
1268 | system is used for displays with @code{set radix}, or simply inquire | |
e251e767 | 1269 | which is currently in use with @code{show radix}. |
70b88761 RP |
1270 | |
1271 | @kindex info set | |
1272 | To display all the settable parameters and their current | |
1273 | values, you can use @code{show} with no arguments; you may also use | |
1274 | @code{info set}. Both commands produce the same display. | |
1275 | @c FIXME: "info set" violates the rule that "info" is for state of | |
1276 | @c FIXME...program. Ck w/ GNU: "info set" to be called something else, | |
1277 | @c FIXME...or change desc of rule---eg "state of prog and debugging session"? | |
1278 | @end table | |
1279 | @c @end group | |
1280 | ||
1281 | Here are three miscellaneous @code{show} subcommands, all of which are | |
1282 | exceptional in lacking corresponding @code{set} commands: | |
1283 | ||
1284 | @table @code | |
1285 | @kindex show version | |
3d3ab540 | 1286 | @cindex version number |
70b88761 RP |
1287 | @item show version |
1288 | Show what version of _GDBN__ is running. You should include this | |
1041a570 RP |
1289 | information in _GDBN__ bug-reports. If multiple versions of _GDBN__ are in |
1290 | use at your site, you may occasionally want to make sure what version | |
1291 | of _GDBN__ you are running; as _GDBN__ evolves, new commands are introduced, | |
1292 | and old ones may wither away. The version number is also announced | |
1293 | when you start _GDBN__ with no arguments. | |
70b88761 RP |
1294 | |
1295 | @kindex show copying | |
1296 | @item show copying | |
1297 | Display information about permission for copying _GDBN__. | |
1298 | ||
1299 | @kindex show warranty | |
1300 | @item show warranty | |
1301 | Display the GNU ``NO WARRANTY'' statement. | |
1302 | @end table | |
1303 | ||
1304 | @node Running, Stopping, Commands, Top | |
1305 | @chapter Running Programs Under _GDBN__ | |
1306 | ||
1041a570 RP |
1307 | To debug a program, you must run it under _GDBN__. |
1308 | ||
70b88761 | 1309 | @menu |
b80282d5 RP |
1310 | * Compilation:: Compiling for Debugging |
1311 | * Starting:: Starting your Program | |
1312 | * Arguments:: Your Program's Arguments | |
1313 | * Environment:: Your Program's Environment | |
1314 | * Working Directory:: Your Program's Working Directory | |
1315 | * Input/Output:: Your Program's Input and Output | |
1316 | * Attach:: Debugging an Already-Running Process | |
1317 | * Kill Process:: Killing the Child Process | |
d24e0922 | 1318 | * Process Information:: Additional Process Information |
70b88761 RP |
1319 | @end menu |
1320 | ||
1321 | @node Compilation, Starting, Running, Running | |
1322 | @section Compiling for Debugging | |
1323 | ||
1324 | In order to debug a program effectively, you need to generate | |
1325 | debugging information when you compile it. This debugging information | |
1326 | is stored in the object file; it describes the data type of each | |
1327 | variable or function and the correspondence between source line numbers | |
1328 | and addresses in the executable code. | |
1329 | ||
1330 | To request debugging information, specify the @samp{-g} option when you run | |
1331 | the compiler. | |
1332 | ||
1333 | Many C compilers are unable to handle the @samp{-g} and @samp{-O} | |
1334 | options together. Using those compilers, you cannot generate optimized | |
1335 | executables containing debugging information. | |
1336 | ||
c7cb8acb RP |
1337 | _GCC__, the GNU C compiler, supports @samp{-g} with or without |
1338 | @samp{-O}, making it possible to debug optimized code. We recommend | |
1339 | that you @emph{always} use @samp{-g} whenever you compile a program. | |
1340 | You may think your program is correct, but there is no sense in pushing | |
1341 | your luck. | |
70b88761 | 1342 | |
6ca72cc6 RP |
1343 | @cindex optimized code, debugging |
1344 | @cindex debugging optimized code | |
1345 | When you debug a program compiled with @samp{-g -O}, remember that the | |
1346 | optimizer is rearranging your code; the debugger will show you what's | |
1347 | really there. Don't be too surprised when the execution path doesn't | |
1348 | exactly match your source file! An extreme example: if you define a | |
1349 | variable, but never use it, _GDBN__ will never see that | |
1350 | variable---because the compiler optimizes it out of existence. | |
1351 | ||
70b88761 RP |
1352 | Some things do not work as well with @samp{-g -O} as with just |
1353 | @samp{-g}, particularly on machines with instruction scheduling. If in | |
1354 | doubt, recompile with @samp{-g} alone, and if this fixes the problem, | |
1355 | please report it as a bug (including a test case!). | |
1356 | ||
1357 | Older versions of the GNU C compiler permitted a variant option | |
c7cb8acb | 1358 | @w{@samp{-gg}} for debugging information. _GDBN__ no longer supports this |
70b88761 RP |
1359 | format; if your GNU C compiler has this option, do not use it. |
1360 | ||
1361 | @ignore | |
1362 | @comment As far as I know, there are no cases in which _GDBN__ will | |
1363 | @comment produce strange output in this case. (but no promises). | |
1364 | If your program includes archives made with the @code{ar} program, and | |
1365 | if the object files used as input to @code{ar} were compiled without the | |
1366 | @samp{-g} option and have names longer than 15 characters, _GDBN__ will get | |
29a2b744 | 1367 | confused reading your program's symbol table. No error message will be |
70b88761 RP |
1368 | given, but _GDBN__ may behave strangely. The reason for this problem is a |
1369 | deficiency in the Unix archive file format, which cannot represent file | |
1370 | names longer than 15 characters. | |
1371 | ||
1372 | To avoid this problem, compile the archive members with the @samp{-g} | |
1373 | option or use shorter file names. Alternatively, use a version of GNU | |
1374 | @code{ar} dated more recently than August 1989. | |
1375 | @end ignore | |
1376 | ||
70b88761 RP |
1377 | @node Starting, Arguments, Compilation, Running |
1378 | @section Starting your Program | |
1379 | @cindex starting | |
1380 | @cindex running | |
1041a570 | 1381 | |
70b88761 RP |
1382 | @table @code |
1383 | @item run | |
1384 | @itemx r | |
1385 | @kindex run | |
1041a570 RP |
1386 | Use the @code{run} command to start your program under _GDBN__. You must |
1387 | first specify the program name | |
e251e767 | 1388 | _if__(_VXWORKS__) |
7463aadd | 1389 | (except on VxWorks) |
70b88761 | 1390 | _fi__(_VXWORKS__) |
1041a570 RP |
1391 | with an argument to |
1392 | _GDBN__ (@pxref{Invocation, ,Getting In and Out of _GDBN__}), or by using the | |
1393 | @code{file} or @code{exec-file} command (@pxref{Files, ,Commands to | |
1394 | Specify Files}). | |
1395 | ||
70b88761 RP |
1396 | @end table |
1397 | ||
29a2b744 RP |
1398 | If you are running your program in an execution environment that |
1399 | supports processes, @code{run} creates an inferior process and makes | |
1400 | that process run your program. (In environments without processes, | |
1401 | @code{run} jumps to the start of your program.) | |
70b88761 RP |
1402 | |
1403 | The execution of a program is affected by certain information it | |
1404 | receives from its superior. _GDBN__ provides ways to specify this | |
6ca72cc6 | 1405 | information, which you must do @emph{before} starting your program. (You |
29a2b744 RP |
1406 | can change it after starting your program, but such changes will only affect |
1407 | your program the next time you start it.) This information may be | |
70b88761 RP |
1408 | divided into four categories: |
1409 | ||
1410 | @table @asis | |
6ca72cc6 | 1411 | @item The @emph{arguments.} |
29a2b744 | 1412 | Specify the arguments to give your program as the arguments of the |
1041a570 RP |
1413 | @code{run} command. If a shell is available on your target, the shell |
1414 | is used to pass the arguments, so that you may use normal conventions | |
1415 | (such as wildcard expansion or variable substitution) in describing | |
1416 | the arguments. In Unix systems, you can control which shell is used | |
1417 | with the @code{SHELL} environment variable. @xref{Arguments, ,Your | |
1418 | Program's Arguments}. | |
70b88761 | 1419 | |
6ca72cc6 | 1420 | @item The @emph{environment.} |
70b88761 RP |
1421 | Your program normally inherits its environment from _GDBN__, but you can |
1422 | use the _GDBN__ commands @code{set environment} and @code{unset | |
1423 | environment} to change parts of the environment that will be given to | |
1041a570 | 1424 | your program. @xref{Environment, ,Your Program's Environment}. |
70b88761 | 1425 | |
6ca72cc6 | 1426 | @item The @emph{working directory.} |
70b88761 RP |
1427 | Your program inherits its working directory from _GDBN__. You can set |
1428 | _GDBN__'s working directory with the @code{cd} command in _GDBN__. | |
29a2b744 | 1429 | @xref{Working Directory, ,Your Program's Working Directory}. |
70b88761 | 1430 | |
6ca72cc6 | 1431 | @item The @emph{standard input and output.} |
70b88761 RP |
1432 | Your program normally uses the same device for standard input and |
1433 | standard output as _GDBN__ is using. You can redirect input and output | |
1434 | in the @code{run} command line, or you can use the @code{tty} command to | |
1435 | set a different device for your program. | |
1041a570 | 1436 | @xref{Input/Output, ,Your Program's Input and Output}. |
3d3ab540 RP |
1437 | |
1438 | @cindex pipes | |
29a2b744 RP |
1439 | @emph{Warning:} While input and output redirection work, you cannot use |
1440 | pipes to pass the output of the program you are debugging to another | |
3d3ab540 RP |
1441 | program; if you attempt this, _GDBN__ is likely to wind up debugging the |
1442 | wrong program. | |
70b88761 RP |
1443 | @end table |
1444 | ||
29a2b744 | 1445 | @c FIXME: Rewrite following paragraph, especially its third sentence. |
1041a570 RP |
1446 | When you issue the @code{run} command, your program begins to execute |
1447 | immediately. @xref{Stopping, ,Stopping and Continuing}, for | |
29a2b744 RP |
1448 | discussion of how to arrange for your program to stop. Once your |
1449 | program has been started by the @code{run} command (and then stopped), | |
1041a570 RP |
1450 | you may evaluate expressions that involve calls to functions in your |
1451 | program, using the @code{print} or @code{call} commands. @xref{Data, | |
1452 | ,Examining Data}. | |
70b88761 | 1453 | |
29a2b744 | 1454 | If the modification time of your symbol file has changed since the |
1041a570 RP |
1455 | last time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and |
1456 | re-read it. When it does this, _GDBN__ tries to retain your current | |
1457 | breakpoints. | |
70b88761 RP |
1458 | |
1459 | @node Arguments, Environment, Starting, Running | |
1460 | @section Your Program's Arguments | |
1461 | ||
1462 | @cindex arguments (to your program) | |
1463 | The arguments to your program can be specified by the arguments of the | |
1464 | @code{run} command. They are passed to a shell, which expands wildcard | |
29a2b744 | 1465 | characters and performs redirection of I/O, and thence to your program. |
70b88761 RP |
1466 | _GDBN__ uses the shell indicated by your environment variable |
1467 | @code{SHELL} if it exists; otherwise, _GDBN__ uses @code{/bin/sh}. | |
1468 | ||
1469 | @code{run} with no arguments uses the same arguments used by the previous | |
1470 | @code{run}, or those set by the @code{set args} command. | |
1471 | ||
1472 | @kindex set args | |
1473 | @table @code | |
1474 | @item set args | |
1475 | Specify the arguments to be used the next time your program is run. If | |
1476 | @code{set args} has no arguments, @code{run} will execute your program | |
e251e767 | 1477 | with no arguments. Once you have run your program with arguments, |
70b88761 RP |
1478 | using @code{set args} before the next @code{run} is the only way to run |
1479 | it again without arguments. | |
1480 | ||
1481 | @item show args | |
1482 | @kindex show args | |
1483 | Show the arguments to give your program when it is started. | |
1484 | @end table | |
1485 | ||
1486 | @node Environment, Working Directory, Arguments, Running | |
1487 | @section Your Program's Environment | |
1488 | ||
1489 | @cindex environment (of your program) | |
1490 | The @dfn{environment} consists of a set of environment variables and | |
1491 | their values. Environment variables conventionally record such things as | |
1492 | your user name, your home directory, your terminal type, and your search | |
1493 | path for programs to run. Usually you set up environment variables with | |
1494 | the shell and they are inherited by all the other programs you run. When | |
29a2b744 | 1495 | debugging, it can be useful to try running your program with a modified |
70b88761 RP |
1496 | environment without having to start _GDBN__ over again. |
1497 | ||
1498 | @table @code | |
1499 | @item path @var{directory} | |
1500 | @kindex path | |
1501 | Add @var{directory} to the front of the @code{PATH} environment variable | |
1502 | (the search path for executables), for both _GDBN__ and your program. | |
1503 | You may specify several directory names, separated by @samp{:} or | |
1504 | whitespace. If @var{directory} is already in the path, it is moved to | |
e251e767 | 1505 | the front, so it will be searched sooner. |
7463aadd RP |
1506 | |
1507 | You can use the string @samp{$cwd} to refer to whatever is the current | |
1508 | working directory at the time _GDBN__ searches the path. If you use | |
1509 | @samp{.} instead, it refers to the directory where you executed the | |
1510 | @code{path} command. _GDBN__ fills in the current path where needed in | |
1511 | the @var{directory} argument, before adding it to the search path. | |
29a2b744 | 1512 | @c 'path' is explicitly nonrepeatable, but RMS points out it is silly to |
70b88761 RP |
1513 | @c document that, since repeating it would be a no-op. |
1514 | ||
1515 | @item show paths | |
1516 | @kindex show paths | |
1517 | Display the list of search paths for executables (the @code{PATH} | |
1518 | environment variable). | |
1519 | ||
1520 | @item show environment @r{[}@var{varname}@r{]} | |
1521 | @kindex show environment | |
1522 | Print the value of environment variable @var{varname} to be given to | |
29a2b744 | 1523 | your program when it starts. If you do not supply @var{varname}, |
70b88761 RP |
1524 | print the names and values of all environment variables to be given to |
1525 | your program. You can abbreviate @code{environment} as @code{env}. | |
1526 | ||
7463aadd | 1527 | @item set environment @var{varname} @r{[}=@r{]} @var{value} |
70b88761 RP |
1528 | @kindex set environment |
1529 | Sets environment variable @var{varname} to @var{value}. The value | |
1530 | changes for your program only, not for _GDBN__ itself. @var{value} may | |
1531 | be any string; the values of environment variables are just strings, and | |
1532 | any interpretation is supplied by your program itself. The @var{value} | |
1533 | parameter is optional; if it is eliminated, the variable is set to a | |
1534 | null value. | |
29a2b744 | 1535 | @c "any string" here does not include leading, trailing |
70b88761 RP |
1536 | @c blanks. Gnu asks: does anyone care? |
1537 | ||
1538 | For example, this command: | |
1539 | ||
1540 | @example | |
1541 | set env USER = foo | |
1542 | @end example | |
1543 | ||
1544 | @noindent | |
1545 | tells a Unix program, when subsequently run, that its user is named | |
1546 | @samp{foo}. (The spaces around @samp{=} are used for clarity here; they | |
1547 | are not actually required.) | |
1548 | ||
1549 | @item unset environment @var{varname} | |
1550 | @kindex unset environment | |
1551 | Remove variable @var{varname} from the environment to be passed to your | |
1552 | program. This is different from @samp{set env @var{varname} =}; | |
1553 | @code{unset environment} removes the variable from the environment, | |
e251e767 | 1554 | rather than assigning it an empty value. |
70b88761 RP |
1555 | @end table |
1556 | ||
1557 | @node Working Directory, Input/Output, Environment, Running | |
1558 | @section Your Program's Working Directory | |
1559 | ||
1560 | @cindex working directory (of your program) | |
1561 | Each time you start your program with @code{run}, it inherits its | |
1562 | working directory from the current working directory of _GDBN__. _GDBN__'s | |
1563 | working directory is initially whatever it inherited from its parent | |
1564 | process (typically the shell), but you can specify a new working | |
1565 | directory in _GDBN__ with the @code{cd} command. | |
1566 | ||
1567 | The _GDBN__ working directory also serves as a default for the commands | |
1041a570 RP |
1568 | that specify files for _GDBN__ to operate on. @xref{Files, ,Commands to |
1569 | Specify Files}. | |
70b88761 RP |
1570 | |
1571 | @table @code | |
1572 | @item cd @var{directory} | |
1573 | @kindex cd | |
1574 | Set _GDBN__'s working directory to @var{directory}. | |
1575 | ||
1576 | @item pwd | |
1577 | @kindex pwd | |
1578 | Print _GDBN__'s working directory. | |
1579 | @end table | |
1580 | ||
1581 | @node Input/Output, Attach, Working Directory, Running | |
1582 | @section Your Program's Input and Output | |
1583 | ||
1584 | @cindex redirection | |
1585 | @cindex i/o | |
1586 | @cindex terminal | |
1587 | By default, the program you run under _GDBN__ does input and output to | |
1588 | the same terminal that _GDBN__ uses. _GDBN__ switches the terminal to | |
1589 | its own terminal modes to interact with you, but it records the terminal | |
1590 | modes your program was using and switches back to them when you continue | |
1591 | running your program. | |
1592 | ||
1593 | @table @code | |
1594 | @item info terminal | |
1595 | @kindex info terminal | |
1596 | Displays _GDBN__'s recorded information about the terminal modes your | |
1597 | program is using. | |
1598 | @end table | |
1599 | ||
29a2b744 | 1600 | You can redirect your program's input and/or output using shell |
70b88761 RP |
1601 | redirection with the @code{run} command. For example, |
1602 | ||
1603 | _0__@example | |
1604 | run > outfile | |
1605 | _1__@end example | |
1606 | ||
1607 | @noindent | |
29a2b744 | 1608 | starts your program, diverting its output to the file @file{outfile}. |
70b88761 RP |
1609 | |
1610 | @kindex tty | |
1611 | @cindex controlling terminal | |
29a2b744 | 1612 | Another way to specify where your program should do input and output is |
70b88761 RP |
1613 | with the @code{tty} command. This command accepts a file name as |
1614 | argument, and causes this file to be the default for future @code{run} | |
1615 | commands. It also resets the controlling terminal for the child | |
1616 | process, for future @code{run} commands. For example, | |
1617 | ||
1618 | @example | |
1619 | tty /dev/ttyb | |
1620 | @end example | |
1621 | ||
1622 | @noindent | |
1623 | directs that processes started with subsequent @code{run} commands | |
1624 | default to do input and output on the terminal @file{/dev/ttyb} and have | |
1625 | that as their controlling terminal. | |
1626 | ||
1627 | An explicit redirection in @code{run} overrides the @code{tty} command's | |
1628 | effect on the input/output device, but not its effect on the controlling | |
1629 | terminal. | |
1630 | ||
1631 | When you use the @code{tty} command or redirect input in the @code{run} | |
1632 | command, only the input @emph{for your program} is affected. The input | |
1633 | for _GDBN__ still comes from your terminal. | |
1634 | ||
1635 | @node Attach, Kill Process, Input/Output, Running | |
1636 | @section Debugging an Already-Running Process | |
1637 | @kindex attach | |
1638 | @cindex attach | |
1639 | ||
1640 | @table @code | |
1641 | @item attach @var{process-id} | |
1642 | This command | |
1643 | attaches to a running process---one that was started outside _GDBN__. | |
1644 | (@code{info files} will show your active targets.) The command takes as | |
1645 | argument a process ID. The usual way to find out the process-id of | |
1646 | a Unix process is with the @code{ps} utility, or with the @samp{jobs -l} | |
e251e767 | 1647 | shell command. |
70b88761 RP |
1648 | |
1649 | @code{attach} will not repeat if you press @key{RET} a second time after | |
1650 | executing the command. | |
1651 | @end table | |
1652 | ||
1653 | To use @code{attach}, you must be debugging in an environment which | |
1654 | supports processes. You must also have permission to send the process a | |
1655 | signal, and it must have the same effective user ID as the _GDBN__ | |
1656 | process. | |
1657 | ||
1658 | When using @code{attach}, you should first use the @code{file} command | |
1659 | to specify the program running in the process and load its symbol table. | |
29a2b744 | 1660 | @xref{Files, ,Commands to Specify Files}. |
70b88761 RP |
1661 | |
1662 | The first thing _GDBN__ does after arranging to debug the specified | |
1663 | process is to stop it. You can examine and modify an attached process | |
1664 | with all the _GDBN__ commands that are ordinarily available when you start | |
1665 | processes with @code{run}. You can insert breakpoints; you can step and | |
1666 | continue; you can modify storage. If you would rather the process | |
1667 | continue running, you may use the @code{continue} command after | |
1668 | attaching _GDBN__ to the process. | |
1669 | ||
1670 | @table @code | |
1671 | @item detach | |
1672 | @kindex detach | |
1673 | When you have finished debugging the attached process, you can use the | |
1674 | @code{detach} command to release it from _GDBN__'s control. Detaching | |
1675 | the process continues its execution. After the @code{detach} command, | |
1676 | that process and _GDBN__ become completely independent once more, and you | |
1677 | are ready to @code{attach} another process or start one with @code{run}. | |
1678 | @code{detach} will not repeat if you press @key{RET} again after | |
1679 | executing the command. | |
1680 | @end table | |
1681 | ||
1682 | If you exit _GDBN__ or use the @code{run} command while you have an attached | |
1683 | process, you kill that process. By default, you will be asked for | |
1684 | confirmation if you try to do either of these things; you can control | |
1685 | whether or not you need to confirm by using the @code{set confirm} command | |
29a2b744 | 1686 | (@pxref{Messages/Warnings, ,Optional Warnings and Messages}). |
70b88761 | 1687 | |
d24e0922 | 1688 | @node Kill Process, Process Information, Attach, Running |
70b88761 RP |
1689 | @c @group |
1690 | @section Killing the Child Process | |
1691 | ||
1692 | @table @code | |
1693 | @item kill | |
1694 | @kindex kill | |
1695 | Kill the child process in which your program is running under _GDBN__. | |
1696 | @end table | |
1697 | ||
1698 | This command is useful if you wish to debug a core dump instead of a | |
1699 | running process. _GDBN__ ignores any core dump file while your program | |
1700 | is running. | |
1701 | @c @end group | |
1702 | ||
29a2b744 | 1703 | On some operating systems, a program cannot be executed outside _GDBN__ |
70b88761 | 1704 | while you have breakpoints set on it inside _GDBN__. You can use the |
29a2b744 | 1705 | @code{kill} command in this situation to permit running your program |
70b88761 RP |
1706 | outside the debugger. |
1707 | ||
1708 | The @code{kill} command is also useful if you wish to recompile and | |
29a2b744 | 1709 | relink your program, since on many systems it is impossible to modify an |
70b88761 RP |
1710 | executable file while it is running in a process. In this case, when you |
1711 | next type @code{run}, _GDBN__ will notice that the file has changed, and | |
1712 | will re-read the symbol table (while trying to preserve your current | |
1713 | breakpoint settings). | |
1714 | ||
d24e0922 RP |
1715 | @node Process Information, , Kill Process, Running |
1716 | @section Additional Process Information | |
1717 | ||
1718 | @kindex /proc | |
1719 | @cindex process image | |
1720 | Some operating systems provide a facility called @samp{/proc} that can | |
cc9bc574 RP |
1721 | be used to examine the image of a running process using file-system |
1722 | subroutines. If _GDBN__ is configured for an operating system with this | |
1723 | facility, the command @code{info proc} is available to report on several | |
1724 | kinds of information about the process running your program. | |
d24e0922 RP |
1725 | |
1726 | @table @code | |
1727 | @item info proc | |
1728 | @kindex info proc | |
1729 | Summarize available information about the process. | |
1730 | ||
1731 | @item info proc mappings | |
1732 | @kindex info proc mappings | |
1733 | Report on the address ranges accessible in the program, with information | |
1734 | on whether your program may read, write, or execute each range. | |
1735 | ||
1736 | @item info proc times | |
1737 | @kindex info proc times | |
1738 | Starting time, user CPU time, and system CPU time for your program and | |
1739 | its children. | |
1740 | ||
1741 | @item info proc id | |
1742 | @kindex info proc id | |
1743 | Report on the process ID's related to your program: its own process id, | |
1744 | the id of its parent, the process group id, and the session id. | |
1745 | ||
1746 | @item info proc status | |
1747 | @kindex info proc status | |
1748 | General information on the state of the process. If the process is | |
1749 | stopped, this report includes the reason for stopping, and any signal | |
1750 | received. | |
cc9bc574 RP |
1751 | |
1752 | @item info proc all | |
1753 | Show all the above information about the process. | |
d24e0922 RP |
1754 | @end table |
1755 | ||
70b88761 RP |
1756 | @node Stopping, Stack, Running, Top |
1757 | @chapter Stopping and Continuing | |
1758 | ||
1759 | The principal purpose of using a debugger is so that you can stop your | |
29a2b744 | 1760 | program before it terminates; or so that, if your program runs into |
70b88761 RP |
1761 | trouble, you can investigate and find out why. |
1762 | ||
1763 | Inside _GDBN__, your program may stop for any of several reasons, such | |
1764 | as a signal, a breakpoint, or reaching a new line after a _GDBN__ | |
1765 | command such as @code{step}. You may then examine and change | |
1766 | variables, set new breakpoints or remove old ones, and then continue | |
1767 | execution. Usually, the messages shown by _GDBN__ provide ample | |
1768 | explanation of the status of your program---but you can also explicitly | |
1769 | request this information at any time. | |
1770 | ||
1771 | @table @code | |
1772 | @item info program | |
1773 | @kindex info program | |
1774 | Display information about the status of your program: whether it is | |
1775 | running or not, what process it is, and why it stopped. | |
1776 | @end table | |
1777 | ||
1778 | @menu | |
b80282d5 RP |
1779 | * Breakpoints:: Breakpoints, Watchpoints, and Exceptions |
1780 | * Continuing and Stepping:: Resuming Execution | |
1781 | * Signals:: Signals | |
70b88761 RP |
1782 | @end menu |
1783 | ||
3d3ab540 | 1784 | @node Breakpoints, Continuing and Stepping, Stopping, Stopping |
70b88761 RP |
1785 | @section Breakpoints, Watchpoints, and Exceptions |
1786 | ||
1787 | @cindex breakpoints | |
1788 | A @dfn{breakpoint} makes your program stop whenever a certain point in | |
1041a570 | 1789 | the program is reached. For each breakpoint, you can add various |
29a2b744 | 1790 | conditions to control in finer detail whether your program will stop. |
70b88761 | 1791 | You can set breakpoints with the @code{break} command and its variants |
29a2b744 RP |
1792 | (@pxref{Set Breaks, ,Setting Breakpoints}), to specify the place where |
1793 | your program should stop by line number, function name or exact address | |
1041a570 | 1794 | in the program. In languages with exception handling (such as GNU |
29a2b744 | 1795 | C++), you can also set breakpoints where an exception is raised |
1041a570 | 1796 | (@pxref{Exception Handling, ,Breakpoints and Exceptions}). |
70b88761 RP |
1797 | |
1798 | @cindex watchpoints | |
6ca72cc6 RP |
1799 | @cindex memory tracing |
1800 | @cindex breakpoint on memory address | |
1801 | @cindex breakpoint on variable modification | |
29a2b744 RP |
1802 | A @dfn{watchpoint} is a special breakpoint that stops your program |
1803 | when the value of an expression changes. You must use a different | |
1804 | command to set watchpoints (@pxref{Set Watchpoints, ,Setting | |
1805 | Watchpoints}), but aside from that, you can manage a watchpoint like | |
1806 | any other breakpoint: you enable, disable, and delete both breakpoints | |
1041a570 | 1807 | and watchpoints using the same commands. |
70b88761 | 1808 | |
6ca72cc6 RP |
1809 | @cindex breakpoint numbers |
1810 | @cindex numbers for breakpoints | |
1811 | _GDBN__ assigns a number to each breakpoint or watchpoint when you | |
1812 | create it; these numbers are successive integers starting with one. In | |
1813 | many of the commands for controlling various features of breakpoints you | |
1814 | use the breakpoint number to say which breakpoint you want to change. | |
1815 | Each breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has | |
29a2b744 | 1816 | no effect on your program until you enable it again. |
70b88761 RP |
1817 | |
1818 | @menu | |
b80282d5 RP |
1819 | * Set Breaks:: Setting Breakpoints |
1820 | * Set Watchpoints:: Setting Watchpoints | |
1821 | * Exception Handling:: Breakpoints and Exceptions | |
1822 | * Delete Breaks:: Deleting Breakpoints | |
1823 | * Disabling:: Disabling Breakpoints | |
1824 | * Conditions:: Break Conditions | |
1825 | * Break Commands:: Breakpoint Command Lists | |
1826 | * Breakpoint Menus:: Breakpoint Menus | |
e251e767 | 1827 | * Error in Breakpoints:: |
70b88761 RP |
1828 | @end menu |
1829 | ||
1830 | @node Set Breaks, Set Watchpoints, Breakpoints, Breakpoints | |
1831 | @subsection Setting Breakpoints | |
1832 | ||
4906534f RP |
1833 | @c FIXME LMB what does GDB do if no code on line of breakpt? |
1834 | @c consider in particular declaration with/without initialization. | |
1835 | @c | |
1836 | @c FIXME 2 is there stuff on this already? break at fun start, already init? | |
1837 | ||
70b88761 RP |
1838 | @kindex break |
1839 | @kindex b | |
6ca72cc6 RP |
1840 | @kindex $bpnum |
1841 | @cindex latest breakpoint | |
1842 | Breakpoints are set with the @code{break} command (abbreviated | |
1843 | @code{b}). The debugger convenience variable @samp{$bpnum} records the | |
1844 | number of the beakpoint you've set most recently; see @ref{Convenience | |
d24e0922 | 1845 | Vars,, Convenience Variables}, for a discussion of what you can do with |
6ca72cc6 | 1846 | convenience variables. |
70b88761 RP |
1847 | |
1848 | You have several ways to say where the breakpoint should go. | |
1849 | ||
1850 | @table @code | |
1851 | @item break @var{function} | |
1852 | Set a breakpoint at entry to function @var{function}. When using source | |
1853 | languages that permit overloading of symbols, such as C++, | |
1854 | @var{function} may refer to more than one possible place to break. | |
1855 | @xref{Breakpoint Menus}, for a discussion of that situation. | |
1856 | ||
1857 | @item break +@var{offset} | |
1858 | @itemx break -@var{offset} | |
1859 | Set a breakpoint some number of lines forward or back from the position | |
1860 | at which execution stopped in the currently selected frame. | |
1861 | ||
1862 | @item break @var{linenum} | |
1863 | Set a breakpoint at line @var{linenum} in the current source file. | |
1864 | That file is the last file whose source text was printed. This | |
29a2b744 | 1865 | breakpoint will stop your program just before it executes any of the |
70b88761 RP |
1866 | code on that line. |
1867 | ||
1868 | @item break @var{filename}:@var{linenum} | |
1869 | Set a breakpoint at line @var{linenum} in source file @var{filename}. | |
1870 | ||
1871 | @item break @var{filename}:@var{function} | |
1872 | Set a breakpoint at entry to function @var{function} found in file | |
1873 | @var{filename}. Specifying a file name as well as a function name is | |
1874 | superfluous except when multiple files contain similarly named | |
1875 | functions. | |
1876 | ||
1877 | @item break *@var{address} | |
1878 | Set a breakpoint at address @var{address}. You can use this to set | |
29a2b744 | 1879 | breakpoints in parts of your program which do not have debugging |
70b88761 RP |
1880 | information or source files. |
1881 | ||
1882 | @item break | |
29a2b744 RP |
1883 | When called without any arguments, @code{break} sets a breakpoint at |
1884 | the next instruction to be executed in the selected stack frame | |
1885 | (@pxref{Stack, ,Examining the Stack}). In any selected frame but the | |
1886 | innermost, this will cause your program to stop as soon as control | |
1887 | returns to that frame. This is similar to the effect of a | |
1888 | @code{finish} command in the frame inside the selected frame---except | |
1889 | that @code{finish} does not leave an active breakpoint. If you use | |
1041a570 RP |
1890 | @code{break} without an argument in the innermost frame, _GDBN__ will stop |
1891 | the next time it reaches the current location; this may be useful | |
1892 | inside loops. | |
70b88761 RP |
1893 | |
1894 | _GDBN__ normally ignores breakpoints when it resumes execution, until at | |
1895 | least one instruction has been executed. If it did not do this, you | |
1896 | would be unable to proceed past a breakpoint without first disabling the | |
1897 | breakpoint. This rule applies whether or not the breakpoint already | |
29a2b744 | 1898 | existed when your program stopped. |
70b88761 RP |
1899 | |
1900 | @item break @dots{} if @var{cond} | |
1901 | Set a breakpoint with condition @var{cond}; evaluate the expression | |
1902 | @var{cond} each time the breakpoint is reached, and stop only if the | |
3d3ab540 | 1903 | value is nonzero---that is, if @var{cond} evaluates as true. |
1041a570 RP |
1904 | @samp{@dots{}} stands for one of the possible arguments described |
1905 | above (or no argument) specifying where to break. @xref{Conditions, | |
1906 | ,Break Conditions}, for more information on breakpoint conditions. | |
70b88761 RP |
1907 | |
1908 | @item tbreak @var{args} | |
1909 | @kindex tbreak | |
1910 | Set a breakpoint enabled only for one stop. @var{args} are the | |
1911 | same as for the @code{break} command, and the breakpoint is set in the same | |
29a2b744 RP |
1912 | way, but the breakpoint is automatically disabled after the first time your |
1913 | program stops there. @xref{Disabling, ,Disabling Breakpoints}. | |
70b88761 RP |
1914 | |
1915 | @item rbreak @var{regex} | |
1916 | @kindex rbreak | |
1917 | @cindex regular expression | |
4906534f | 1918 | @c FIXME what kind of regexp? |
70b88761 | 1919 | Set breakpoints on all functions matching the regular expression |
b80282d5 | 1920 | @var{regex}. This command |
70b88761 RP |
1921 | sets an unconditional breakpoint on all matches, printing a list of all |
1922 | breakpoints it set. Once these breakpoints are set, they are treated | |
1923 | just like the breakpoints set with the @code{break} command. They can | |
1924 | be deleted, disabled, made conditional, etc., in the standard ways. | |
1925 | ||
b80282d5 RP |
1926 | When debugging C++ programs, @code{rbreak} is useful for setting |
1927 | breakpoints on overloaded functions that are not members of any special | |
1928 | classes. | |
1929 | ||
70b88761 | 1930 | @kindex info breakpoints |
c338a2fd | 1931 | @cindex @code{$_} and @code{info breakpoints} |
70b88761 | 1932 | @item info breakpoints @r{[}@var{n}@r{]} |
6ca72cc6 RP |
1933 | @itemx info break @r{[}@var{n}@r{]} |
1934 | @itemx info watchpoints @r{[}@var{n}@r{]} | |
1935 | Print a table of all breakpoints and watchpoints set and not | |
1936 | deleted, with the following columns for each breakpoint: | |
1937 | ||
1938 | @table @emph | |
1939 | @item Breakpoint Numbers | |
1940 | @item Type | |
1941 | Breakpoint or watchpoint. | |
1942 | @item Disposition | |
1943 | Whether the breakpoint is marked to be disabled or deleted when hit. | |
1944 | @item Enabled or Disabled | |
d24e0922 | 1945 | Enabled breakpoints are marked with @samp{y}. @samp{n} marks breakpoints |
6ca72cc6 RP |
1946 | that are not enabled. |
1947 | @item Address | |
1948 | Where the breakpoint is in your program, as a memory address | |
1949 | @item What | |
1950 | Where the breakpoint is in the source for your program, as a file and | |
1951 | line number. | |
1952 | @end table | |
1953 | ||
1954 | @noindent | |
1955 | Breakpoint commands, if any, are listed after the line for the | |
1956 | corresponding breakpoint. | |
1957 | ||
1958 | @noindent | |
1959 | @code{info break} with a breakpoint | |
29a2b744 RP |
1960 | number @var{n} as argument lists only that breakpoint. The |
1961 | convenience variable @code{$_} and the default examining-address for | |
1962 | the @code{x} command are set to the address of the last breakpoint | |
6ca72cc6 | 1963 | listed (@pxref{Memory, ,Examining Memory}). |
1041a570 | 1964 | @end table |
70b88761 | 1965 | |
1041a570 RP |
1966 | _GDBN__ allows you to set any number of breakpoints at the same place in |
1967 | your program. There is nothing silly or meaningless about this. When | |
1968 | the breakpoints are conditional, this is even useful | |
29a2b744 | 1969 | (@pxref{Conditions, ,Break Conditions}). |
70b88761 | 1970 | |
6ca72cc6 RP |
1971 | @cindex negative breakpoint numbers |
1972 | @cindex internal _GDBN__ breakpoints | |
1973 | _GDBN__ itself sometimes sets breakpoints in your program for special | |
1974 | purposes, such as proper handling of @code{longjmp} (in C programs). | |
1975 | These internal breakpoints are assigned negative numbers, starting with | |
1976 | @code{-1}; @samp{info breakpoints} does not display them, but the | |
1977 | similar command @samp{info all-breakpoints} does. | |
1978 | ||
1979 | @table @code | |
1980 | @kindex all-breakpoints | |
1981 | @item info all-breakpoints | |
1982 | Using the same format as @samp{info breakpoints}, display both the | |
1983 | breakpoints you've set explicitly, and those _GDBN__ is using for | |
1984 | internal purposes. Internal breakpoints are shown with negative | |
1985 | breakpoint numbers. The type column identifies what kind of breakpoint | |
1986 | is shown: | |
1987 | ||
1988 | @table @code | |
1989 | @item breakpoint | |
1990 | Normal, explicitly set breakpoint. | |
1991 | ||
1992 | @item watchpoint | |
1993 | Normal, explicitly set watchpoint. | |
1994 | ||
1995 | @item longjmp | |
1996 | Internal breakpoint, used to handle correctly stepping through | |
1997 | @code{longjmp} calls. | |
1998 | ||
1999 | @item longjmp resume | |
2000 | Internal breakpoint at the target of a @code{longjmp}. | |
2001 | ||
2002 | @item until | |
2003 | Temporary internal breakpoint used by the _GDBN__ @code{until} command. | |
2004 | ||
2005 | @item finish | |
2006 | Temporary internal breakpoint used by the _GDBN__ @code{finish} command. | |
2007 | @end table | |
2008 | ||
2009 | @end table | |
2010 | ||
2011 | ||
70b88761 RP |
2012 | @node Set Watchpoints, Exception Handling, Set Breaks, Breakpoints |
2013 | @subsection Setting Watchpoints | |
2014 | @cindex setting watchpoints | |
1041a570 | 2015 | |
70b88761 | 2016 | You can use a watchpoint to stop execution whenever the value of an |
e251e767 | 2017 | expression changes, without having to predict a particular place |
70b88761 RP |
2018 | where this may happen. |
2019 | ||
2020 | Watchpoints currently execute two orders of magnitude more slowly than | |
2021 | other breakpoints, but this can well be worth it to catch errors where | |
2022 | you have no clue what part of your program is the culprit. Some | |
2023 | processors provide special hardware to support watchpoint evaluation; future | |
2024 | releases of _GDBN__ will use such hardware if it is available. | |
2025 | ||
2026 | @table @code | |
e251e767 | 2027 | @kindex watch |
70b88761 RP |
2028 | @item watch @var{expr} |
2029 | Set a watchpoint for an expression. | |
2030 | ||
2031 | @kindex info watchpoints | |
2032 | @item info watchpoints | |
6ca72cc6 RP |
2033 | This command prints a list of watchpoints and breakpoints; it is the |
2034 | same as @code{info break}. | |
70b88761 RP |
2035 | @end table |
2036 | ||
2037 | @node Exception Handling, Delete Breaks, Set Watchpoints, Breakpoints | |
2038 | @subsection Breakpoints and Exceptions | |
2039 | @cindex exception handlers | |
2040 | ||
b80282d5 | 2041 | Some languages, such as GNU C++, implement exception handling. You can |
29a2b744 RP |
2042 | use _GDBN__ to examine what caused your program to raise an exception, |
2043 | and to list the exceptions your program is prepared to handle at a | |
70b88761 RP |
2044 | given point in time. |
2045 | ||
2046 | @table @code | |
2047 | @item catch @var{exceptions} | |
2048 | @kindex catch | |
2049 | You can set breakpoints at active exception handlers by using the | |
2050 | @code{catch} command. @var{exceptions} is a list of names of exceptions | |
2051 | to catch. | |
2052 | @end table | |
2053 | ||
29a2b744 RP |
2054 | You can use @code{info catch} to list active exception handlers. |
2055 | @xref{Frame Info, ,Information About a Frame}. | |
70b88761 RP |
2056 | |
2057 | There are currently some limitations to exception handling in _GDBN__. | |
2058 | These will be corrected in a future release. | |
2059 | ||
2060 | @itemize @bullet | |
2061 | @item | |
2062 | If you call a function interactively, _GDBN__ normally returns | |
2063 | control to you when the function has finished executing. If the call | |
2064 | raises an exception, however, the call may bypass the mechanism that | |
29a2b744 | 2065 | returns control to you and cause your program to simply continue |
70b88761 RP |
2066 | running until it hits a breakpoint, catches a signal that _GDBN__ is |
2067 | listening for, or exits. | |
2068 | @item | |
2069 | You cannot raise an exception interactively. | |
2070 | @item | |
2071 | You cannot interactively install an exception handler. | |
2072 | @end itemize | |
2073 | ||
2074 | @cindex raise exceptions | |
2075 | Sometimes @code{catch} is not the best way to debug exception handling: | |
29a2b744 | 2076 | if you need to know exactly where an exception is raised, it is better to |
70b88761 RP |
2077 | stop @emph{before} the exception handler is called, since that way you |
2078 | can see the stack before any unwinding takes place. If you set a | |
2079 | breakpoint in an exception handler instead, it may not be easy to find | |
2080 | out where the exception was raised. | |
2081 | ||
2082 | To stop just before an exception handler is called, you need some | |
b80282d5 | 2083 | knowledge of the implementation. In the case of GNU C++, exceptions are |
70b88761 RP |
2084 | raised by calling a library function named @code{__raise_exception} |
2085 | which has the following ANSI C interface: | |
2086 | ||
2087 | @example | |
b80282d5 | 2088 | /* @var{addr} is where the exception identifier is stored. |
70b88761 RP |
2089 | ID is the exception identifier. */ |
2090 | void __raise_exception (void **@var{addr}, void *@var{id}); | |
2091 | @end example | |
2092 | ||
2093 | @noindent | |
2094 | To make the debugger catch all exceptions before any stack | |
2095 | unwinding takes place, set a breakpoint on @code{__raise_exception} | |
29a2b744 | 2096 | (@pxref{Breakpoints, ,Breakpoints Watchpoints and Exceptions}). |
70b88761 | 2097 | |
29a2b744 RP |
2098 | With a conditional breakpoint (@pxref{Conditions, ,Break Conditions}) |
2099 | that depends on the value of @var{id}, you can stop your program when | |
2100 | a specific exception is raised. You can use multiple conditional | |
2101 | breakpoints to stop your program when any of a number of exceptions are | |
2102 | raised. | |
70b88761 RP |
2103 | |
2104 | @node Delete Breaks, Disabling, Exception Handling, Breakpoints | |
2105 | @subsection Deleting Breakpoints | |
2106 | ||
2107 | @cindex clearing breakpoints, watchpoints | |
2108 | @cindex deleting breakpoints, watchpoints | |
2109 | It is often necessary to eliminate a breakpoint or watchpoint once it | |
29a2b744 | 2110 | has done its job and you no longer want your program to stop there. This |
70b88761 RP |
2111 | is called @dfn{deleting} the breakpoint. A breakpoint that has been |
2112 | deleted no longer exists; it is forgotten. | |
2113 | ||
2114 | With the @code{clear} command you can delete breakpoints according to | |
29a2b744 | 2115 | where they are in your program. With the @code{delete} command you can |
70b88761 RP |
2116 | delete individual breakpoints or watchpoints by specifying their |
2117 | breakpoint numbers. | |
2118 | ||
2119 | It is not necessary to delete a breakpoint to proceed past it. _GDBN__ | |
2120 | automatically ignores breakpoints on the first instruction to be executed | |
2121 | when you continue execution without changing the execution address. | |
2122 | ||
2123 | @table @code | |
2124 | @item clear | |
2125 | @kindex clear | |
2126 | Delete any breakpoints at the next instruction to be executed in the | |
29a2b744 RP |
2127 | selected stack frame (@pxref{Selection, ,Selecting a Frame}). When |
2128 | the innermost frame is selected, this is a good way to delete a | |
2129 | breakpoint where your program just stopped. | |
70b88761 RP |
2130 | |
2131 | @item clear @var{function} | |
2132 | @itemx clear @var{filename}:@var{function} | |
2133 | Delete any breakpoints set at entry to the function @var{function}. | |
2134 | ||
2135 | @item clear @var{linenum} | |
2136 | @itemx clear @var{filename}:@var{linenum} | |
2137 | Delete any breakpoints set at or within the code of the specified line. | |
2138 | ||
2139 | @item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} | |
2140 | @cindex delete breakpoints | |
2141 | @kindex delete | |
2142 | @kindex d | |
2143 | Delete the breakpoints or watchpoints of the numbers specified as | |
2144 | arguments. If no argument is specified, delete all breakpoints (_GDBN__ | |
1041a570 | 2145 | asks confirmation, unless you have @code{set confirm off}). You |
70b88761 RP |
2146 | can abbreviate this command as @code{d}. |
2147 | @end table | |
2148 | ||
2149 | @node Disabling, Conditions, Delete Breaks, Breakpoints | |
2150 | @subsection Disabling Breakpoints | |
2151 | ||
2152 | @cindex disabled breakpoints | |
2153 | @cindex enabled breakpoints | |
2154 | Rather than deleting a breakpoint or watchpoint, you might prefer to | |
2155 | @dfn{disable} it. This makes the breakpoint inoperative as if it had | |
2156 | been deleted, but remembers the information on the breakpoint so that | |
2157 | you can @dfn{enable} it again later. | |
2158 | ||
2159 | You disable and enable breakpoints and watchpoints with the | |
2160 | @code{enable} and @code{disable} commands, optionally specifying one or | |
2161 | more breakpoint numbers as arguments. Use @code{info break} or | |
2162 | @code{info watch} to print a list of breakpoints or watchpoints if you | |
29a2b744 | 2163 | do not know which numbers to use. |
70b88761 RP |
2164 | |
2165 | A breakpoint or watchpoint can have any of four different states of | |
2166 | enablement: | |
2167 | ||
2168 | @itemize @bullet | |
2169 | @item | |
29a2b744 | 2170 | Enabled. The breakpoint will stop your program. A breakpoint set |
70b88761 RP |
2171 | with the @code{break} command starts out in this state. |
2172 | @item | |
29a2b744 | 2173 | Disabled. The breakpoint has no effect on your program. |
70b88761 | 2174 | @item |
29a2b744 | 2175 | Enabled once. The breakpoint will stop your program, but |
70b88761 RP |
2176 | when it does so it will become disabled. A breakpoint set |
2177 | with the @code{tbreak} command starts out in this state. | |
2178 | @item | |
29a2b744 | 2179 | Enabled for deletion. The breakpoint will stop your program, but |
70b88761 RP |
2180 | immediately after it does so it will be deleted permanently. |
2181 | @end itemize | |
2182 | ||
2183 | You can use the following commands to enable or disable breakpoints and | |
2184 | watchpoints: | |
2185 | ||
2186 | @table @code | |
2187 | @item disable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} | |
2188 | @kindex disable breakpoints | |
2189 | @kindex disable | |
2190 | @kindex dis | |
2191 | Disable the specified breakpoints---or all breakpoints, if none are | |
2192 | listed. A disabled breakpoint has no effect but is not forgotten. All | |
2193 | options such as ignore-counts, conditions and commands are remembered in | |
2194 | case the breakpoint is enabled again later. You may abbreviate | |
2195 | @code{disable} as @code{dis}. | |
2196 | ||
2197 | @item enable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} | |
2198 | @kindex enable breakpoints | |
2199 | @kindex enable | |
2200 | Enable the specified breakpoints (or all defined breakpoints). They | |
29a2b744 | 2201 | become effective once again in stopping your program. |
70b88761 RP |
2202 | |
2203 | @item enable @r{[}breakpoints@r{]} once @var{bnums}@dots{} | |
2204 | Enable the specified breakpoints temporarily. Each will be disabled | |
29a2b744 | 2205 | again the next time it stops your program. |
70b88761 RP |
2206 | |
2207 | @item enable @r{[}breakpoints@r{]} delete @var{bnums}@dots{} | |
2208 | Enable the specified breakpoints to work once and then die. Each of | |
29a2b744 | 2209 | the breakpoints will be deleted the next time it stops your program. |
70b88761 RP |
2210 | @end table |
2211 | ||
29a2b744 RP |
2212 | Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks, |
2213 | ,Setting Breakpoints}), breakpoints that you set are initially | |
2214 | enabled; subsequently, they become disabled or enabled only when you | |
2215 | use one of the commands above. (The command @code{until} can set and | |
2216 | delete a breakpoint of its own, but it will not change the state of | |
98fe4566 | 2217 | your other breakpoints; see @ref{Continuing and Stepping, ,Continuing and Stepping}.) |
70b88761 RP |
2218 | |
2219 | @node Conditions, Break Commands, Disabling, Breakpoints | |
2220 | @subsection Break Conditions | |
2221 | @cindex conditional breakpoints | |
2222 | @cindex breakpoint conditions | |
2223 | ||
4906534f RP |
2224 | @c FIXME what is scope of break condition expr? Context where wanted? |
2225 | @c in particular for a watchpoint? | |
29a2b744 | 2226 | The simplest sort of breakpoint breaks every time your program reaches a |
70b88761 RP |
2227 | specified place. You can also specify a @dfn{condition} for a |
2228 | breakpoint. A condition is just a Boolean expression in your | |
1041a570 RP |
2229 | programming language (@pxref{Expressions, ,Expressions}). A breakpoint with |
2230 | a condition evaluates the expression each time your program reaches it, | |
2231 | and your program stops only if the condition is @emph{true}. | |
3d3ab540 RP |
2232 | |
2233 | This is the converse of using assertions for program validation; in that | |
2234 | situation, you want to stop when the assertion is violated---that is, | |
2235 | when the condition is false. In C, if you want to test an assertion expressed | |
e251e767 | 2236 | by the condition @var{assert}, you should set the condition |
3d3ab540 | 2237 | @samp{! @var{assert}} on the appropriate breakpoint. |
70b88761 RP |
2238 | |
2239 | Conditions are also accepted for watchpoints; you may not need them, | |
2240 | since a watchpoint is inspecting the value of an expression anyhow---but | |
2241 | it might be simpler, say, to just set a watchpoint on a variable name, | |
2242 | and specify a condition that tests whether the new value is an interesting | |
e251e767 | 2243 | one. |
70b88761 | 2244 | |
29a2b744 | 2245 | Break conditions can have side effects, and may even call functions in |
70b88761 | 2246 | your program. This can be useful, for example, to activate functions |
29a2b744 RP |
2247 | that log program progress, or to use your own print functions to |
2248 | format special data structures. The effects are completely predictable | |
2249 | unless there is another enabled breakpoint at the same address. (In | |
2250 | that case, _GDBN__ might see the other breakpoint first and stop your | |
2251 | program without checking the condition of this one.) Note that | |
2252 | breakpoint commands are usually more convenient and flexible for the | |
2253 | purpose of performing side effects when a breakpoint is reached | |
2254 | (@pxref{Break Commands, ,Breakpoint Command Lists}). | |
70b88761 RP |
2255 | |
2256 | Break conditions can be specified when a breakpoint is set, by using | |
29a2b744 RP |
2257 | @samp{if} in the arguments to the @code{break} command. @xref{Set |
2258 | Breaks, ,Setting Breakpoints}. They can also be changed at any time | |
2259 | with the @code{condition} command. The @code{watch} command does not | |
2260 | recognize the @code{if} keyword; @code{condition} is the only way to | |
2261 | impose a further condition on a watchpoint. | |
70b88761 | 2262 | |
e251e767 RP |
2263 | @table @code |
2264 | @item condition @var{bnum} @var{expression} | |
2265 | @kindex condition | |
70b88761 RP |
2266 | Specify @var{expression} as the break condition for breakpoint or |
2267 | watchpoint number @var{bnum}. From now on, this breakpoint will stop | |
29a2b744 | 2268 | your program only if the value of @var{expression} is true (nonzero, in |
70b88761 RP |
2269 | C). When you use @code{condition}, _GDBN__ checks @var{expression} |
2270 | immediately for syntactic correctness, and to determine whether symbols | |
1041a570 | 2271 | in it have referents in the context of your breakpoint. |
29a2b744 | 2272 | @c FIXME so what does GDB do if there is no referent? Moreover, what |
4906534f RP |
2273 | @c about watchpoints? |
2274 | _GDBN__ does | |
70b88761 | 2275 | not actually evaluate @var{expression} at the time the @code{condition} |
1041a570 | 2276 | command is given, however. @xref{Expressions, ,Expressions}. |
70b88761 RP |
2277 | |
2278 | @item condition @var{bnum} | |
2279 | Remove the condition from breakpoint number @var{bnum}. It becomes | |
2280 | an ordinary unconditional breakpoint. | |
2281 | @end table | |
2282 | ||
2283 | @cindex ignore count (of breakpoint) | |
2284 | A special case of a breakpoint condition is to stop only when the | |
2285 | breakpoint has been reached a certain number of times. This is so | |
2286 | useful that there is a special way to do it, using the @dfn{ignore | |
2287 | count} of the breakpoint. Every breakpoint has an ignore count, which | |
2288 | is an integer. Most of the time, the ignore count is zero, and | |
29a2b744 | 2289 | therefore has no effect. But if your program reaches a breakpoint whose |
70b88761 RP |
2290 | ignore count is positive, then instead of stopping, it just decrements |
2291 | the ignore count by one and continues. As a result, if the ignore count | |
2292 | value is @var{n}, the breakpoint will not stop the next @var{n} times it | |
2293 | is reached. | |
2294 | ||
2295 | @table @code | |
2296 | @item ignore @var{bnum} @var{count} | |
2297 | @kindex ignore | |
2298 | Set the ignore count of breakpoint number @var{bnum} to @var{count}. | |
2299 | The next @var{count} times the breakpoint is reached, your program's | |
2300 | execution will not stop; other than to decrement the ignore count, _GDBN__ | |
2301 | takes no action. | |
2302 | ||
2303 | To make the breakpoint stop the next time it is reached, specify | |
2304 | a count of zero. | |
2305 | ||
2306 | @item continue @var{count} | |
2307 | @itemx c @var{count} | |
2308 | @itemx fg @var{count} | |
2309 | @kindex continue @var{count} | |
29a2b744 RP |
2310 | Continue execution of your program, setting the ignore count of the |
2311 | breakpoint where your program stopped to @var{count} minus one. | |
2312 | Thus, your program will not stop at this breakpoint until the | |
70b88761 RP |
2313 | @var{count}'th time it is reached. |
2314 | ||
29a2b744 | 2315 | An argument to this command is meaningful only when your program stopped |
70b88761 RP |
2316 | due to a breakpoint. At other times, the argument to @code{continue} is |
2317 | ignored. | |
2318 | ||
2319 | The synonym @code{fg} is provided purely for convenience, and has | |
2320 | exactly the same behavior as other forms of the command. | |
2321 | @end table | |
2322 | ||
2323 | If a breakpoint has a positive ignore count and a condition, the condition | |
2324 | is not checked. Once the ignore count reaches zero, the condition will | |
2325 | be checked. | |
2326 | ||
29a2b744 | 2327 | You could achieve the effect of the ignore count with a condition such |
1041a570 RP |
2328 | as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience variable that |
2329 | is decremented each time. @xref{Convenience Vars, ,Convenience | |
2330 | Variables}. | |
70b88761 RP |
2331 | |
2332 | @node Break Commands, Breakpoint Menus, Conditions, Breakpoints | |
2333 | @subsection Breakpoint Command Lists | |
2334 | ||
2335 | @cindex breakpoint commands | |
2336 | You can give any breakpoint (or watchpoint) a series of commands to | |
29a2b744 | 2337 | execute when your program stops due to that breakpoint. For example, you |
70b88761 RP |
2338 | might want to print the values of certain expressions, or enable other |
2339 | breakpoints. | |
2340 | ||
2341 | @table @code | |
2342 | @item commands @r{[}@var{bnum}@r{]} | |
2343 | @itemx @dots{} @var{command-list} @dots{} | |
2344 | @itemx end | |
2345 | @kindex commands | |
2346 | @kindex end | |
2347 | Specify a list of commands for breakpoint number @var{bnum}. The commands | |
2348 | themselves appear on the following lines. Type a line containing just | |
2349 | @code{end} to terminate the commands. | |
2350 | ||
203eea5d RP |
2351 | To remove all commands from a breakpoint, type @code{commands} and |
2352 | follow it immediately with @code{end}; that is, give no commands. | |
70b88761 RP |
2353 | |
2354 | With no @var{bnum} argument, @code{commands} refers to the last | |
2355 | breakpoint or watchpoint set (not to the breakpoint most recently | |
2356 | encountered). | |
2357 | @end table | |
2358 | ||
2359 | Pressing @key{RET} as a means of repeating the last _GDBN__ command is | |
2360 | disabled within a @var{command-list}. | |
2361 | ||
29a2b744 | 2362 | You can use breakpoint commands to start your program up again. Simply |
70b88761 RP |
2363 | use the @code{continue} command, or @code{step}, or any other command |
2364 | that resumes execution. Subsequent commands in the command list are | |
2365 | ignored. | |
2366 | ||
2367 | @kindex silent | |
2368 | If the first command specified is @code{silent}, the usual message about | |
2369 | stopping at a breakpoint is not printed. This may be desirable for | |
2370 | breakpoints that are to print a specific message and then continue. | |
2371 | If the remaining commands too print nothing, you will see no sign that | |
e251e767 | 2372 | the breakpoint was reached at all. @code{silent} is meaningful only |
70b88761 RP |
2373 | at the beginning of a breakpoint command list. |
2374 | ||
29a2b744 RP |
2375 | The commands @code{echo} and @code{output} that allow you to print |
2376 | precisely controlled output are often useful in silent breakpoints. | |
2377 | @xref{Output, ,Commands for Controlled Output}. | |
70b88761 RP |
2378 | |
2379 | For example, here is how you could use breakpoint commands to print the | |
2380 | value of @code{x} at entry to @code{foo} whenever @code{x} is positive. | |
2381 | ||
2382 | _0__@example | |
2383 | break foo if x>0 | |
2384 | commands | |
2385 | silent | |
2386 | echo x is\040 | |
2387 | output x | |
2388 | echo \n | |
2389 | cont | |
2390 | end | |
2391 | _1__@end example | |
2392 | ||
2393 | One application for breakpoint commands is to compensate for one bug so | |
2394 | you can test for another. Put a breakpoint just after the erroneous line | |
2395 | of code, give it a condition to detect the case in which something | |
2396 | erroneous has been done, and give it commands to assign correct values | |
2397 | to any variables that need them. End with the @code{continue} command | |
29a2b744 | 2398 | so that your program does not stop, and start with the @code{silent} |
70b88761 RP |
2399 | command so that no output is produced. Here is an example: |
2400 | ||
2401 | @example | |
2402 | break 403 | |
2403 | commands | |
2404 | silent | |
2405 | set x = y + 4 | |
2406 | cont | |
2407 | end | |
2408 | @end example | |
2409 | ||
2410 | @cindex lost output | |
2411 | One deficiency in the operation of automatically continuing breakpoints | |
2412 | under Unix appears when your program uses raw mode for the terminal. | |
2413 | _GDBN__ switches back to its own terminal modes (not raw) before executing | |
2414 | commands, and then must switch back to raw mode when your program is | |
e251e767 | 2415 | continued. This causes any pending terminal input to be lost. |
70b88761 RP |
2416 | @c FIXME: revisit below when GNU sys avail. |
2417 | @c In the GNU system, this will be fixed by changing the behavior of | |
2418 | @c terminal modes. | |
2419 | ||
2420 | Under Unix, you can get around this problem by writing actions into | |
2421 | the breakpoint condition rather than in commands. For example | |
2422 | ||
2423 | @example | |
2424 | condition 5 (x = y + 4), 0 | |
2425 | @end example | |
2426 | ||
2427 | @noindent | |
1041a570 RP |
2428 | specifies a condition expression (@pxref{Expressions, ,Expressions}) that will |
2429 | change @code{x} as needed, then always have the value zero so your | |
2430 | program will not stop. No input is lost here, because _GDBN__ evaluates | |
2431 | break conditions without changing the terminal modes. When you want | |
2432 | to have nontrivial conditions for performing the side effects, the | |
2433 | operators @samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful. | |
70b88761 RP |
2434 | |
2435 | @node Breakpoint Menus, Error in Breakpoints, Break Commands, Breakpoints | |
2436 | @subsection Breakpoint Menus | |
b80282d5 | 2437 | @cindex overloading |
e251e767 | 2438 | @cindex symbol overloading |
70b88761 RP |
2439 | |
2440 | Some programming languages (notably C++) permit a single function name | |
2441 | to be defined several times, for application in different contexts. | |
2442 | This is called @dfn{overloading}. When a function name is overloaded, | |
2443 | @samp{break @var{function}} is not enough to tell _GDBN__ where you | |
2444 | want a breakpoint. _GDBN__ offers you a menu of numbered choices for | |
2445 | different possible breakpoints, and waits for your selection with the | |
2446 | prompt @samp{>}. The first two options are always @samp{[0] cancel} | |
2447 | and @samp{[1] all}. Typing @kbd{1} sets a breakpoint at each | |
2448 | definition of @var{function}, and typing @kbd{0} aborts the | |
2449 | @code{break} command without setting any new breakpoints. | |
2450 | ||
2451 | For example, the following session excerpt shows an attempt to set a | |
e251e767 | 2452 | breakpoint at the overloaded symbol @code{String::after}. |
70b88761 RP |
2453 | We choose three particular definitions of that function name: |
2454 | ||
2455 | @example | |
2456 | (_GDBP__) b String::after | |
2457 | [0] cancel | |
2458 | [1] all | |
2459 | [2] file:String.cc; line number:867 | |
2460 | [3] file:String.cc; line number:860 | |
2461 | [4] file:String.cc; line number:875 | |
2462 | [5] file:String.cc; line number:853 | |
2463 | [6] file:String.cc; line number:846 | |
2464 | [7] file:String.cc; line number:735 | |
2465 | > 2 4 6 | |
2466 | Breakpoint 1 at 0xb26c: file String.cc, line 867. | |
2467 | Breakpoint 2 at 0xb344: file String.cc, line 875. | |
2468 | Breakpoint 3 at 0xafcc: file String.cc, line 846. | |
2469 | Multiple breakpoints were set. | |
2470 | Use the "delete" command to delete unwanted breakpoints. | |
e251e767 | 2471 | (_GDBP__) |
70b88761 RP |
2472 | @end example |
2473 | ||
70b88761 RP |
2474 | @node Error in Breakpoints, , Breakpoint Menus, Breakpoints |
2475 | @subsection ``Cannot Insert Breakpoints'' | |
2476 | ||
e251e767 | 2477 | @c FIXME: "cannot insert breakpoints" error, v unclear. |
70b88761 | 2478 | @c Q in pending mail to Gilmore. [email protected], 26mar91 |
e251e767 | 2479 | @c some light may be shed by looking at instances of |
d24e0922 | 2480 | @c ONE_PROCESS_WRITETEXT. But error message seems possible otherwise |
c338a2fd | 2481 | @c too. pesch, 20sep91 |
70b88761 RP |
2482 | Under some operating systems, breakpoints cannot be used in a program if |
2483 | any other process is running that program. In this situation, | |
2484 | attempting to run or continue a program with a breakpoint causes _GDBN__ | |
2485 | to stop the other process. | |
2486 | ||
2487 | When this happens, you have three ways to proceed: | |
2488 | ||
2489 | @enumerate | |
2490 | @item | |
2491 | Remove or disable the breakpoints, then continue. | |
2492 | ||
2493 | @item | |
29a2b744 | 2494 | Suspend _GDBN__, and copy the file containing your program to a new name. |
70b88761 | 2495 | Resume _GDBN__ and use the @code{exec-file} command to specify that _GDBN__ |
29a2b744 | 2496 | should run your program under that name. Then start your program again. |
70b88761 RP |
2497 | |
2498 | @c FIXME: RMS commented here "Show example". Maybe when someone | |
2499 | @c explains the first FIXME: in this section... | |
2500 | ||
2501 | @item | |
29a2b744 | 2502 | Relink your program so that the text segment is nonsharable, using the |
70b88761 RP |
2503 | linker option @samp{-N}. The operating system limitation may not apply |
2504 | to nonsharable executables. | |
2505 | @end enumerate | |
2506 | ||
3d3ab540 RP |
2507 | @node Continuing and Stepping, Signals, Breakpoints, Stopping |
2508 | @section Continuing and Stepping | |
70b88761 RP |
2509 | |
2510 | @cindex stepping | |
7463aadd RP |
2511 | @cindex continuing |
2512 | @cindex resuming execution | |
3d3ab540 | 2513 | @dfn{Continuing} means resuming program execution until your program |
cedaf8bc RP |
2514 | completes normally. In contrast, @dfn{stepping} means executing just |
2515 | one more ``step'' of your program, where ``step'' may mean either one | |
2516 | line of source code, or one machine instruction (depending on what | |
2517 | particular command you use). Either when continuing | |
29a2b744 | 2518 | or when stepping, your program may stop even sooner, due to a breakpoint |
cedaf8bc | 2519 | or to a signal. (If due to a signal, you may want to use @code{handle}, |
1041a570 | 2520 | or use @samp{signal 0} to resume execution. @xref{Signals, ,Signals}.) |
3d3ab540 RP |
2521 | |
2522 | @table @code | |
2523 | @item continue @r{[}@var{ignore-count}@r{]} | |
2524 | @kindex continue | |
29a2b744 | 2525 | Resume program execution, at the address where your program last stopped; |
3d3ab540 RP |
2526 | any breakpoints set at that address are bypassed. The optional argument |
2527 | @var{ignore-count} allows you to specify a further number of times to | |
2528 | ignore a breakpoint at this location; its effect is like that of | |
29a2b744 | 2529 | @code{ignore} (@pxref{Conditions, ,Break Conditions}). |
3d3ab540 RP |
2530 | |
2531 | To resume execution at a different place, you can use @code{return} | |
29a2b744 RP |
2532 | (@pxref{Returning, ,Returning from a Function}) to go back to the |
2533 | calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a | |
1041a570 | 2534 | Different Address}) to go to an arbitrary location in your program. |
3d3ab540 | 2535 | @end table |
7463aadd RP |
2536 | |
2537 | A typical technique for using stepping is to set a breakpoint | |
29a2b744 RP |
2538 | (@pxref{Breakpoints, ,Breakpoints Watchpoints and Exceptions}) at the |
2539 | beginning of the function or the section of your program where a | |
2540 | problem is believed to lie, run your program until it stops at that | |
2541 | breakpoint, and then step through the suspect area, examining the | |
2542 | variables that are interesting, until you see the problem happen. | |
70b88761 RP |
2543 | |
2544 | @table @code | |
2545 | @item step | |
2546 | @kindex step | |
2547 | @kindex s | |
29a2b744 | 2548 | Continue running your program until control reaches a different source |
7463aadd | 2549 | line, then stop it and return control to _GDBN__. This command is |
70b88761 RP |
2550 | abbreviated @code{s}. |
2551 | ||
3d3ab540 RP |
2552 | @quotation |
2553 | @emph{Warning:} If you use the @code{step} command while control is | |
2554 | within a function that was compiled without debugging information, | |
2555 | execution will proceed until control reaches another function. | |
2556 | @end quotation | |
70b88761 RP |
2557 | |
2558 | @item step @var{count} | |
2559 | Continue running as in @code{step}, but do so @var{count} times. If a | |
2560 | breakpoint is reached or a signal not related to stepping occurs before | |
2561 | @var{count} steps, stepping stops right away. | |
2562 | ||
7463aadd | 2563 | @item next @r{[}@var{count}@r{]} |
70b88761 RP |
2564 | @kindex next |
2565 | @kindex n | |
7463aadd RP |
2566 | Continue to the next source line in the current (innermost) stack frame. |
2567 | Similar to @code{step}, but any function calls appearing within the line | |
2568 | of code are executed without stopping. Execution stops when control | |
2569 | reaches a different line of code at the stack level which was executing | |
2570 | when the @code{next} command was given. This command is abbreviated | |
2571 | @code{n}. | |
70b88761 | 2572 | |
7463aadd | 2573 | An argument @var{count} is a repeat count, as for @code{step}. |
70b88761 RP |
2574 | |
2575 | @code{next} within a function that lacks debugging information acts like | |
2576 | @code{step}, but any function calls appearing within the code of the | |
2577 | function are executed without stopping. | |
2578 | ||
2579 | @item finish | |
2580 | @kindex finish | |
7463aadd RP |
2581 | Continue running until just after function in the selected stack frame |
2582 | returns. Print the returned value (if any). | |
70b88761 | 2583 | |
29a2b744 | 2584 | Contrast this with the @code{return} command (@pxref{Returning, |
1041a570 | 2585 | ,Returning from a Function}). |
70b88761 RP |
2586 | |
2587 | @item until | |
2588 | @kindex until | |
2589 | @item u | |
2590 | @kindex u | |
2591 | Continue running until a source line past the current line, in the | |
2592 | current stack frame, is reached. This command is used to avoid single | |
2593 | stepping through a loop more than once. It is like the @code{next} | |
2594 | command, except that when @code{until} encounters a jump, it | |
2595 | automatically continues execution until the program counter is greater | |
2596 | than the address of the jump. | |
2597 | ||
2598 | This means that when you reach the end of a loop after single stepping | |
29a2b744 | 2599 | though it, @code{until} will cause your program to continue execution |
70b88761 RP |
2600 | until the loop is exited. In contrast, a @code{next} command at the end |
2601 | of a loop will simply step back to the beginning of the loop, which | |
2602 | would force you to step through the next iteration. | |
2603 | ||
29a2b744 | 2604 | @code{until} always stops your program if it attempts to exit the current |
70b88761 RP |
2605 | stack frame. |
2606 | ||
2607 | @code{until} may produce somewhat counterintuitive results if the order | |
7463aadd | 2608 | of machine code does not match the order of the source lines. For |
70b88761 RP |
2609 | example, in the following excerpt from a debugging session, the @code{f} |
2610 | (@code{frame}) command shows that execution is stopped at line | |
2611 | @code{206}; yet when we use @code{until}, we get to line @code{195}: | |
2612 | ||
2613 | @example | |
2614 | (_GDBP__) f | |
2615 | #0 main (argc=4, argv=0xf7fffae8) at m4.c:206 | |
b80282d5 | 2616 | 206 expand_input(); |
70b88761 | 2617 | (_GDBP__) until |
b80282d5 | 2618 | 195 for ( ; argc > 0; NEXTARG) @{ |
70b88761 RP |
2619 | @end example |
2620 | ||
7463aadd RP |
2621 | This happened because, for execution efficiency, the compiler had |
2622 | generated code for the loop closure test at the end, rather than the | |
2623 | start, of the loop---even though the test in a C @code{for}-loop is | |
2624 | written before the body of the loop. The @code{until} command appeared | |
2625 | to step back to the beginning of the loop when it advanced to this | |
2626 | expression; however, it has not really gone to an earlier | |
2627 | statement---not in terms of the actual machine code. | |
70b88761 RP |
2628 | |
2629 | @code{until} with no argument works by means of single | |
2630 | instruction stepping, and hence is slower than @code{until} with an | |
2631 | argument. | |
2632 | ||
2633 | @item until @var{location} | |
2634 | @item u @var{location} | |
29a2b744 RP |
2635 | Continue running your program until either the specified location is |
2636 | reached, or the current stack frame returns. @var{location} is any of | |
2637 | the forms of argument acceptable to @code{break} (@pxref{Set Breaks, | |
2638 | ,Setting Breakpoints}). This form of the command uses breakpoints, | |
1041a570 | 2639 | and hence is quicker than @code{until} without an argument. |
70b88761 RP |
2640 | |
2641 | @item stepi | |
2642 | @itemx si | |
2643 | @kindex stepi | |
2644 | @kindex si | |
2645 | Execute one machine instruction, then stop and return to the debugger. | |
2646 | ||
2647 | It is often useful to do @samp{display/i $pc} when stepping by machine | |
2648 | instructions. This will cause the next instruction to be executed to | |
29a2b744 RP |
2649 | be displayed automatically at each stop. @xref{Auto Display, |
2650 | ,Automatic Display}. | |
70b88761 RP |
2651 | |
2652 | An argument is a repeat count, as in @code{step}. | |
2653 | ||
2654 | @item nexti | |
2655 | @itemx ni | |
2656 | @kindex nexti | |
2657 | @kindex ni | |
2658 | Execute one machine instruction, but if it is a function call, | |
2659 | proceed until the function returns. | |
2660 | ||
2661 | An argument is a repeat count, as in @code{next}. | |
70b88761 RP |
2662 | @end table |
2663 | ||
3d3ab540 | 2664 | @node Signals, , Continuing and Stepping, Stopping |
70b88761 RP |
2665 | @section Signals |
2666 | @cindex signals | |
2667 | ||
2668 | A signal is an asynchronous event that can happen in a program. The | |
2669 | operating system defines the possible kinds of signals, and gives each | |
2670 | kind a name and a number. For example, in Unix @code{SIGINT} is the | |
2671 | signal a program gets when you type an interrupt (often @kbd{C-c}); | |
2672 | @code{SIGSEGV} is the signal a program gets from referencing a place in | |
2673 | memory far away from all the areas in use; @code{SIGALRM} occurs when | |
29a2b744 | 2674 | the alarm clock timer goes off (which happens only if your program has |
70b88761 RP |
2675 | requested an alarm). |
2676 | ||
2677 | @cindex fatal signals | |
2678 | Some signals, including @code{SIGALRM}, are a normal part of the | |
29a2b744 RP |
2679 | functioning of your program. Others, such as @code{SIGSEGV}, indicate |
2680 | errors; these signals are @dfn{fatal} (kill your program immediately) if the | |
70b88761 | 2681 | program has not specified in advance some other way to handle the signal. |
29a2b744 | 2682 | @code{SIGINT} does not indicate an error in your program, but it is normally |
70b88761 RP |
2683 | fatal so it can carry out the purpose of the interrupt: to kill the program. |
2684 | ||
29a2b744 RP |
2685 | _GDBN__ has the ability to detect any occurrence of a signal in your |
2686 | program. You can tell _GDBN__ in advance what to do for each kind of | |
2687 | signal. | |
70b88761 RP |
2688 | |
2689 | @cindex handling signals | |
2690 | Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM} | |
29a2b744 RP |
2691 | (so as not to interfere with their role in the functioning of your program) |
2692 | but to stop your program immediately whenever an error signal happens. | |
70b88761 RP |
2693 | You can change these settings with the @code{handle} command. |
2694 | ||
2695 | @table @code | |
2696 | @item info signals | |
2697 | @kindex info signals | |
2698 | Print a table of all the kinds of signals and how _GDBN__ has been told to | |
2699 | handle each one. You can use this to see the signal numbers of all | |
2700 | the defined types of signals. | |
2701 | ||
2702 | @item handle @var{signal} @var{keywords}@dots{} | |
2703 | @kindex handle | |
2704 | Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the | |
2705 | number of a signal or its name (with or without the @samp{SIG} at the | |
2706 | beginning). The @var{keywords} say what change to make. | |
2707 | @end table | |
2708 | ||
2709 | @c @group | |
2710 | The keywords allowed by the @code{handle} command can be abbreviated. | |
2711 | Their full names are: | |
2712 | ||
2713 | @table @code | |
2714 | @item nostop | |
29a2b744 | 2715 | _GDBN__ should not stop your program when this signal happens. It may |
70b88761 RP |
2716 | still print a message telling you that the signal has come in. |
2717 | ||
2718 | @item stop | |
29a2b744 | 2719 | _GDBN__ should stop your program when this signal happens. This implies |
70b88761 RP |
2720 | the @code{print} keyword as well. |
2721 | ||
2722 | @item print | |
2723 | _GDBN__ should print a message when this signal happens. | |
2724 | ||
2725 | @item noprint | |
2726 | _GDBN__ should not mention the occurrence of the signal at all. This | |
2727 | implies the @code{nostop} keyword as well. | |
2728 | ||
2729 | @item pass | |
29a2b744 | 2730 | _GDBN__ should allow your program to see this signal; your program will be |
70b88761 RP |
2731 | able to handle the signal, or may be terminated if the signal is fatal |
2732 | and not handled. | |
2733 | ||
2734 | @item nopass | |
29a2b744 | 2735 | _GDBN__ should not allow your program to see this signal. |
70b88761 RP |
2736 | @end table |
2737 | @c @end group | |
2738 | ||
29a2b744 | 2739 | When a signal has been set to stop your program, your program cannot see the |
70b88761 | 2740 | signal until you continue. It will see the signal then, if @code{pass} is |
6ca72cc6 | 2741 | in effect for the signal in question @emph{at that time}. In other words, |
70b88761 RP |
2742 | after _GDBN__ reports a signal, you can use the @code{handle} command with |
2743 | @code{pass} or @code{nopass} to control whether that signal will be seen by | |
29a2b744 | 2744 | your program when you later continue it. |
70b88761 | 2745 | |
29a2b744 | 2746 | You can also use the @code{signal} command to prevent your program from |
70b88761 | 2747 | seeing a signal, or cause it to see a signal it normally would not see, |
29a2b744 | 2748 | or to give it any signal at any time. For example, if your program stopped |
7463aadd RP |
2749 | due to some sort of memory reference error, you might store correct |
2750 | values into the erroneous variables and continue, hoping to see more | |
29a2b744 RP |
2751 | execution; but your program would probably terminate immediately as |
2752 | a result of the fatal signal once it saw the signal. To prevent this, | |
2753 | you can continue with @samp{signal 0}. @xref{Signaling, ,Giving your | |
2754 | Program a Signal}. | |
70b88761 RP |
2755 | |
2756 | @node Stack, Source, Stopping, Top | |
2757 | @chapter Examining the Stack | |
2758 | ||
2759 | When your program has stopped, the first thing you need to know is where it | |
2760 | stopped and how it got there. | |
2761 | ||
2762 | @cindex call stack | |
2763 | Each time your program performs a function call, the information about | |
29a2b744 | 2764 | where in your program the call was made from is saved in a block of data |
70b88761 RP |
2765 | called a @dfn{stack frame}. The frame also contains the arguments of the |
2766 | call and the local variables of the function that was called. All the | |
2767 | stack frames are allocated in a region of memory called the @dfn{call | |
2768 | stack}. | |
2769 | ||
2770 | When your program stops, the _GDBN__ commands for examining the stack allow you | |
2771 | to see all of this information. | |
2772 | ||
2773 | @cindex selected frame | |
2774 | One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands | |
2775 | refer implicitly to the selected frame. In particular, whenever you ask | |
29a2b744 | 2776 | _GDBN__ for the value of a variable in your program, the value is found in the |
70b88761 RP |
2777 | selected frame. There are special _GDBN__ commands to select whichever frame |
2778 | you are interested in. | |
2779 | ||
29a2b744 | 2780 | When your program stops, _GDBN__ automatically selects the currently executing |
70b88761 | 2781 | frame and describes it briefly as the @code{frame} command does |
29a2b744 | 2782 | (@pxref{Frame Info, ,Information About a Frame}). |
70b88761 RP |
2783 | |
2784 | @menu | |
b80282d5 RP |
2785 | * Frames:: Stack Frames |
2786 | * Backtrace:: Backtraces | |
2787 | * Selection:: Selecting a Frame | |
2788 | * Frame Info:: Information on a Frame | |
70b88761 RP |
2789 | @end menu |
2790 | ||
2791 | @node Frames, Backtrace, Stack, Stack | |
2792 | @section Stack Frames | |
2793 | ||
2794 | @cindex frame | |
2795 | @cindex stack frame | |
2796 | The call stack is divided up into contiguous pieces called @dfn{stack | |
2797 | frames}, or @dfn{frames} for short; each frame is the data associated | |
2798 | with one call to one function. The frame contains the arguments given | |
2799 | to the function, the function's local variables, and the address at | |
2800 | which the function is executing. | |
2801 | ||
2802 | @cindex initial frame | |
2803 | @cindex outermost frame | |
2804 | @cindex innermost frame | |
2805 | When your program is started, the stack has only one frame, that of the | |
2806 | function @code{main}. This is called the @dfn{initial} frame or the | |
2807 | @dfn{outermost} frame. Each time a function is called, a new frame is | |
2808 | made. Each time a function returns, the frame for that function invocation | |
2809 | is eliminated. If a function is recursive, there can be many frames for | |
2810 | the same function. The frame for the function in which execution is | |
2811 | actually occurring is called the @dfn{innermost} frame. This is the most | |
2812 | recently created of all the stack frames that still exist. | |
2813 | ||
2814 | @cindex frame pointer | |
2815 | Inside your program, stack frames are identified by their addresses. A | |
2816 | stack frame consists of many bytes, each of which has its own address; each | |
2817 | kind of computer has a convention for choosing one of those bytes whose | |
2818 | address serves as the address of the frame. Usually this address is kept | |
2819 | in a register called the @dfn{frame pointer register} while execution is | |
2820 | going on in that frame. | |
2821 | ||
2822 | @cindex frame number | |
2823 | _GDBN__ assigns numbers to all existing stack frames, starting with | |
2824 | zero for the innermost frame, one for the frame that called it, | |
2825 | and so on upward. These numbers do not really exist in your program; | |
2826 | they are assigned by _GDBN__ to give you a way of designating stack | |
2827 | frames in _GDBN__ commands. | |
2828 | ||
2829 | @cindex frameless execution | |
2830 | Some compilers allow functions to be compiled so that they operate | |
2831 | without stack frames. (For example, the @code{_GCC__} option | |
2832 | @samp{-fomit-frame-pointer} will generate functions without a frame.) | |
2833 | This is occasionally done with heavily used library functions to save | |
2834 | the frame setup time. _GDBN__ has limited facilities for dealing with | |
2835 | these function invocations. If the innermost function invocation has no | |
2836 | stack frame, _GDBN__ will nevertheless regard it as though it had a | |
2837 | separate frame, which is numbered zero as usual, allowing correct | |
2838 | tracing of the function call chain. However, _GDBN__ has no provision | |
2839 | for frameless functions elsewhere in the stack. | |
2840 | ||
2841 | @node Backtrace, Selection, Frames, Stack | |
2842 | @section Backtraces | |
2843 | ||
29a2b744 | 2844 | A backtrace is a summary of how your program got where it is. It shows one |
70b88761 RP |
2845 | line per frame, for many frames, starting with the currently executing |
2846 | frame (frame zero), followed by its caller (frame one), and on up the | |
2847 | stack. | |
2848 | ||
2849 | @table @code | |
2850 | @item backtrace | |
2851 | @itemx bt | |
2852 | @kindex backtrace | |
2853 | @kindex bt | |
2854 | Print a backtrace of the entire stack: one line per frame for all | |
2855 | frames in the stack. | |
2856 | ||
2857 | You can stop the backtrace at any time by typing the system interrupt | |
2858 | character, normally @kbd{C-c}. | |
2859 | ||
2860 | @item backtrace @var{n} | |
2861 | @itemx bt @var{n} | |
2862 | Similar, but print only the innermost @var{n} frames. | |
2863 | ||
2864 | @item backtrace -@var{n} | |
2865 | @itemx bt -@var{n} | |
2866 | Similar, but print only the outermost @var{n} frames. | |
2867 | @end table | |
2868 | ||
2869 | @kindex where | |
2870 | @kindex info stack | |
2871 | @kindex info s | |
2872 | The names @code{where} and @code{info stack} (abbreviated @code{info s}) | |
2873 | are additional aliases for @code{backtrace}. | |
2874 | ||
2875 | Each line in the backtrace shows the frame number and the function name. | |
2876 | The program counter value is also shown---unless you use @code{set | |
2877 | print address off}. The backtrace also shows the source file name and | |
2878 | line number, as well as the arguments to the function. The program | |
2879 | counter value is omitted if it is at the beginning of the code for that | |
2880 | line number. | |
2881 | ||
2882 | Here is an example of a backtrace. It was made with the command | |
2883 | @samp{bt 3}, so it shows the innermost three frames. | |
2884 | ||
2885 | @smallexample | |
2886 | @group | |
203eea5d RP |
2887 | #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) |
2888 | at builtin.c:993 | |
70b88761 RP |
2889 | #1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242 |
2890 | #2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08) | |
2891 | at macro.c:71 | |
2892 | (More stack frames follow...) | |
2893 | @end group | |
2894 | @end smallexample | |
2895 | ||
2896 | @noindent | |
29a2b744 RP |
2897 | The display for frame zero does not begin with a program counter |
2898 | value, indicating that your program has stopped at the beginning of the | |
70b88761 RP |
2899 | code for line @code{993} of @code{builtin.c}. |
2900 | ||
2901 | @node Selection, Frame Info, Backtrace, Stack | |
2902 | @section Selecting a Frame | |
2903 | ||
29a2b744 | 2904 | Most commands for examining the stack and other data in your program work on |
70b88761 RP |
2905 | whichever stack frame is selected at the moment. Here are the commands for |
2906 | selecting a stack frame; all of them finish by printing a brief description | |
2907 | of the stack frame just selected. | |
2908 | ||
2909 | @table @code | |
2910 | @item frame @var{n} | |
2911 | @itemx f @var{n} | |
2912 | @kindex frame | |
2913 | @kindex f | |
2914 | Select frame number @var{n}. Recall that frame zero is the innermost | |
2915 | (currently executing) frame, frame one is the frame that called the | |
2916 | innermost one, and so on. The highest-numbered frame is @code{main}'s | |
2917 | frame. | |
2918 | ||
2919 | @item frame @var{addr} | |
2920 | @itemx f @var{addr} | |
2921 | Select the frame at address @var{addr}. This is useful mainly if the | |
2922 | chaining of stack frames has been damaged by a bug, making it | |
2923 | impossible for _GDBN__ to assign numbers properly to all frames. In | |
29a2b744 | 2924 | addition, this can be useful when your program has multiple stacks and |
70b88761 RP |
2925 | switches between them. |
2926 | ||
c728f1f0 | 2927 | _if__(_SPARC__) |
70b88761 | 2928 | On the SPARC architecture, @code{frame} needs two addresses to |
e251e767 | 2929 | select an arbitrary frame: a frame pointer and a stack pointer. |
70b88761 RP |
2930 | @c note to future updaters: this is conditioned on a flag |
2931 | @c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used | |
2932 | @c by SPARC, hence the specific attribution. Generalize or list all | |
2933 | @c possibilities if more supported machines start doing this. | |
c728f1f0 | 2934 | _fi__(_SPARC__) |
70b88761 RP |
2935 | |
2936 | @item up @var{n} | |
2937 | @kindex up | |
2938 | Move @var{n} frames up the stack. For positive numbers @var{n}, this | |
2939 | advances toward the outermost frame, to higher frame numbers, to frames | |
2940 | that have existed longer. @var{n} defaults to one. | |
2941 | ||
2942 | @item down @var{n} | |
2943 | @kindex down | |
2944 | @kindex do | |
2945 | Move @var{n} frames down the stack. For positive numbers @var{n}, this | |
2946 | advances toward the innermost frame, to lower frame numbers, to frames | |
2947 | that were created more recently. @var{n} defaults to one. You may | |
2948 | abbreviate @code{down} as @code{do}. | |
2949 | @end table | |
2950 | ||
2951 | All of these commands end by printing two lines of output describing the | |
2952 | frame. The first line shows the frame number, the function name, the | |
2953 | arguments, and the source file and line number of execution in that | |
2954 | frame. The second line shows the text of that source line. For | |
2955 | example: | |
2956 | ||
2957 | @smallexample | |
29a2b744 | 2958 | @group |
70b88761 | 2959 | (_GDBP__) up |
203eea5d RP |
2960 | #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) |
2961 | at env.c:10 | |
70b88761 | 2962 | 10 read_input_file (argv[i]); |
29a2b744 | 2963 | @end group |
70b88761 RP |
2964 | @end smallexample |
2965 | ||
29a2b744 RP |
2966 | After such a printout, the @code{list} command with no arguments will |
2967 | print ten lines centered on the point of execution in the frame. | |
2968 | @xref{List, ,Printing Source Lines}. | |
70b88761 RP |
2969 | |
2970 | @table @code | |
2971 | @item up-silently @var{n} | |
2972 | @itemx down-silently @var{n} | |
2973 | @kindex down-silently | |
2974 | @kindex up-silently | |
2975 | These two commands are variants of @code{up} and @code{down}, | |
2976 | respectively; they differ in that they do their work silently, without | |
2977 | causing display of the new frame. They are intended primarily for use | |
2978 | in _GDBN__ command scripts, where the output might be unnecessary and | |
e251e767 | 2979 | distracting. |
70b88761 RP |
2980 | @end table |
2981 | ||
2982 | @node Frame Info, , Selection, Stack | |
2983 | @section Information About a Frame | |
2984 | ||
2985 | There are several other commands to print information about the selected | |
2986 | stack frame. | |
2987 | ||
2988 | @table @code | |
2989 | @item frame | |
2990 | @itemx f | |
29a2b744 RP |
2991 | When used without any argument, this command does not change which |
2992 | frame is selected, but prints a brief description of the currently | |
70b88761 | 2993 | selected stack frame. It can be abbreviated @code{f}. With an |
29a2b744 RP |
2994 | argument, this command is used to select a stack frame |
2995 | (@pxref{Selection, ,Selecting a Frame}). | |
70b88761 RP |
2996 | |
2997 | @item info frame | |
70b88761 | 2998 | @itemx info f |
29a2b744 | 2999 | @kindex info frame |
70b88761 RP |
3000 | @kindex info f |
3001 | This command prints a verbose description of the selected stack frame, | |
3002 | including the address of the frame, the addresses of the next frame down | |
c2bbbb22 RP |
3003 | (called by this frame) and the next frame up (caller of this frame), the |
3004 | language that the source code corresponding to this frame was written in, | |
70b88761 RP |
3005 | the address of the frame's arguments, the program counter saved in it |
3006 | (the address of execution in the caller frame), and which registers | |
3007 | were saved in the frame. The verbose description is useful when | |
3008 | something has gone wrong that has made the stack format fail to fit | |
3009 | the usual conventions. | |
3010 | ||
3011 | @item info frame @var{addr} | |
3012 | @itemx info f @var{addr} | |
3013 | Print a verbose description of the frame at address @var{addr}, | |
3014 | without selecting that frame. The selected frame remains unchanged by | |
3015 | this command. | |
3016 | ||
3017 | @item info args | |
3018 | @kindex info args | |
3019 | Print the arguments of the selected frame, each on a separate line. | |
3020 | ||
3021 | @item info locals | |
3022 | @kindex info locals | |
3023 | Print the local variables of the selected frame, each on a separate | |
3024 | line. These are all variables declared static or automatic within all | |
3025 | program blocks that execution in this frame is currently inside of. | |
3026 | ||
3027 | @item info catch | |
3028 | @kindex info catch | |
3029 | @cindex catch exceptions | |
3030 | @cindex exception handlers | |
3031 | Print a list of all the exception handlers that are active in the | |
3032 | current stack frame at the current point of execution. To see other | |
3033 | exception handlers, visit the associated frame (using the @code{up}, | |
3034 | @code{down}, or @code{frame} commands); then type @code{info catch}. | |
1041a570 | 3035 | @xref{Exception Handling, ,Breakpoints and Exceptions}. |
70b88761 RP |
3036 | @end table |
3037 | ||
3038 | @node Source, Data, Stack, Top | |
3039 | @chapter Examining Source Files | |
3040 | ||
3041 | _GDBN__ can print parts of your program's source, since the debugging | |
1041a570 RP |
3042 | information recorded in your program tells _GDBN__ what source files were |
3043 | used to build it. When your program stops, _GDBN__ spontaneously prints | |
3044 | the line where it stopped. Likewise, when you select a stack frame | |
3045 | (@pxref{Selection, ,Selecting a Frame}), _GDBN__ prints the line where | |
3046 | execution in that frame has stopped. You can print other portions of | |
3047 | source files by explicit command. | |
70b88761 | 3048 | |
1041a570 RP |
3049 | If you use _GDBN__ through its GNU Emacs interface, you may prefer to use |
3050 | Emacs facilities to view source; @pxref{Emacs, ,Using _GDBN__ under GNU | |
3051 | Emacs}. | |
70b88761 RP |
3052 | |
3053 | @menu | |
b80282d5 RP |
3054 | * List:: Printing Source Lines |
3055 | * Search:: Searching Source Files | |
3056 | * Source Path:: Specifying Source Directories | |
3057 | * Machine Code:: Source and Machine Code | |
70b88761 RP |
3058 | @end menu |
3059 | ||
3060 | @node List, Search, Source, Source | |
3061 | @section Printing Source Lines | |
3062 | ||
3063 | @kindex list | |
3064 | @kindex l | |
3065 | To print lines from a source file, use the @code{list} command | |
3066 | (abbreviated @code{l}). There are several ways to specify what part | |
3067 | of the file you want to print. | |
3068 | ||
3069 | Here are the forms of the @code{list} command most commonly used: | |
3070 | ||
3071 | @table @code | |
3072 | @item list @var{linenum} | |
c338a2fd | 3073 | Print lines centered around line number @var{linenum} in the |
70b88761 RP |
3074 | current source file. |
3075 | ||
3076 | @item list @var{function} | |
c338a2fd | 3077 | Print lines centered around the beginning of function |
70b88761 RP |
3078 | @var{function}. |
3079 | ||
3080 | @item list | |
c338a2fd RP |
3081 | Print more lines. If the last lines printed were printed with a |
3082 | @code{list} command, this prints lines following the last lines | |
70b88761 | 3083 | printed; however, if the last line printed was a solitary line printed |
29a2b744 | 3084 | as part of displaying a stack frame (@pxref{Stack, ,Examining the |
1041a570 | 3085 | Stack}), this prints lines centered around that line. |
70b88761 RP |
3086 | |
3087 | @item list - | |
c338a2fd RP |
3088 | Print lines just before the lines last printed. |
3089 | @end table | |
3090 | ||
3091 | By default, _GDBN__ prints ten source lines with any of these forms of | |
3092 | the @code{list} command. You can change this using @code{set listsize}: | |
3093 | ||
3094 | @table @code | |
3095 | @item set listsize @var{count} | |
3096 | @kindex set listsize | |
3097 | Make the @code{list} command display @var{count} source lines (unless | |
3098 | the @code{list} argument explicitly specifies some other number). | |
3099 | ||
3100 | @item show listsize | |
3101 | @kindex show listsize | |
3102 | Display the number of lines that @code{list} will currently display by | |
e251e767 | 3103 | default. |
70b88761 RP |
3104 | @end table |
3105 | ||
3106 | Repeating a @code{list} command with @key{RET} discards the argument, | |
3107 | so it is equivalent to typing just @code{list}. This is more useful | |
3108 | than listing the same lines again. An exception is made for an | |
3109 | argument of @samp{-}; that argument is preserved in repetition so that | |
3110 | each repetition moves up in the source file. | |
3111 | ||
3112 | @cindex linespec | |
3113 | In general, the @code{list} command expects you to supply zero, one or two | |
3114 | @dfn{linespecs}. Linespecs specify source lines; there are several ways | |
3115 | of writing them but the effect is always to specify some source line. | |
3116 | Here is a complete description of the possible arguments for @code{list}: | |
3117 | ||
3118 | @table @code | |
3119 | @item list @var{linespec} | |
c338a2fd | 3120 | Print lines centered around the line specified by @var{linespec}. |
70b88761 RP |
3121 | |
3122 | @item list @var{first},@var{last} | |
3123 | Print lines from @var{first} to @var{last}. Both arguments are | |
3124 | linespecs. | |
3125 | ||
3126 | @item list ,@var{last} | |
c338a2fd | 3127 | Print lines ending with @var{last}. |
70b88761 RP |
3128 | |
3129 | @item list @var{first}, | |
c338a2fd | 3130 | Print lines starting with @var{first}. |
70b88761 RP |
3131 | |
3132 | @item list + | |
c338a2fd | 3133 | Print lines just after the lines last printed. |
70b88761 RP |
3134 | |
3135 | @item list - | |
c338a2fd | 3136 | Print lines just before the lines last printed. |
70b88761 RP |
3137 | |
3138 | @item list | |
3139 | As described in the preceding table. | |
3140 | @end table | |
3141 | ||
3142 | Here are the ways of specifying a single source line---all the | |
3143 | kinds of linespec. | |
3144 | ||
3145 | @table @code | |
3146 | @item @var{number} | |
3147 | Specifies line @var{number} of the current source file. | |
3148 | When a @code{list} command has two linespecs, this refers to | |
3149 | the same source file as the first linespec. | |
3150 | ||
3151 | @item +@var{offset} | |
3152 | Specifies the line @var{offset} lines after the last line printed. | |
3153 | When used as the second linespec in a @code{list} command that has | |
3154 | two, this specifies the line @var{offset} lines down from the | |
3155 | first linespec. | |
3156 | ||
3157 | @item -@var{offset} | |
3158 | Specifies the line @var{offset} lines before the last line printed. | |
3159 | ||
3160 | @item @var{filename}:@var{number} | |
3161 | Specifies line @var{number} in the source file @var{filename}. | |
3162 | ||
3163 | @item @var{function} | |
3164 | @c FIXME: "of the open-brace" is C-centric. When we add other langs... | |
3165 | Specifies the line of the open-brace that begins the body of the | |
3166 | function @var{function}. | |
3167 | ||
3168 | @item @var{filename}:@var{function} | |
3169 | Specifies the line of the open-brace that begins the body of the | |
3170 | function @var{function} in the file @var{filename}. You only need the | |
3171 | file name with a function name to avoid ambiguity when there are | |
3172 | identically named functions in different source files. | |
3173 | ||
3174 | @item *@var{address} | |
3175 | Specifies the line containing the program address @var{address}. | |
3176 | @var{address} may be any expression. | |
3177 | @end table | |
3178 | ||
3179 | @node Search, Source Path, List, Source | |
3180 | @section Searching Source Files | |
3181 | @cindex searching | |
3182 | @kindex reverse-search | |
3183 | ||
3184 | There are two commands for searching through the current source file for a | |
3185 | regular expression. | |
3186 | ||
3187 | @table @code | |
3188 | @item forward-search @var{regexp} | |
3189 | @itemx search @var{regexp} | |
3190 | @kindex search | |
3191 | @kindex forward-search | |
1041a570 RP |
3192 | The command @samp{forward-search @var{regexp}} checks each line, |
3193 | starting with the one following the last line listed, for a match for | |
3194 | @var{regexp}. It lists the line that is found. You can use | |
3195 | synonym @samp{search @var{regexp}} or abbreviate the command name as | |
3196 | @code{fo}. | |
70b88761 RP |
3197 | |
3198 | @item reverse-search @var{regexp} | |
3199 | The command @samp{reverse-search @var{regexp}} checks each line, starting | |
3200 | with the one before the last line listed and going backward, for a match | |
3201 | for @var{regexp}. It lists the line that is found. You can abbreviate | |
3202 | this command as @code{rev}. | |
3203 | @end table | |
3204 | ||
3205 | @node Source Path, Machine Code, Search, Source | |
3206 | @section Specifying Source Directories | |
3207 | ||
3208 | @cindex source path | |
3209 | @cindex directories for source files | |
3210 | Executable programs sometimes do not record the directories of the source | |
3211 | files from which they were compiled, just the names. Even when they do, | |
3212 | the directories could be moved between the compilation and your debugging | |
3213 | session. _GDBN__ has a list of directories to search for source files; | |
3214 | this is called the @dfn{source path}. Each time _GDBN__ wants a source file, | |
3215 | it tries all the directories in the list, in the order they are present | |
3216 | in the list, until it finds a file with the desired name. Note that | |
3217 | the executable search path is @emph{not} used for this purpose. Neither is | |
3218 | the current working directory, unless it happens to be in the source | |
3219 | path. | |
3220 | ||
29a2b744 | 3221 | If _GDBN__ cannot find a source file in the source path, and the object |
70b88761 RP |
3222 | program records a directory, _GDBN__ tries that directory too. If the |
3223 | source path is empty, and there is no record of the compilation | |
3224 | directory, _GDBN__ will, as a last resort, look in the current | |
3225 | directory. | |
3226 | ||
3227 | Whenever you reset or rearrange the source path, _GDBN__ will clear out | |
3228 | any information it has cached about where source files are found, where | |
3229 | each line is in the file, etc. | |
3230 | ||
3231 | @kindex directory | |
3232 | When you start _GDBN__, its source path is empty. | |
3233 | To add other directories, use the @code{directory} command. | |
3234 | ||
3235 | @table @code | |
3236 | @item directory @var{dirname} @dots{} | |
3237 | Add directory @var{dirname} to the front of the source path. Several | |
3238 | directory names may be given to this command, separated by @samp{:} or | |
3239 | whitespace. You may specify a directory that is already in the source | |
e251e767 | 3240 | path; this moves it forward, so it will be searched sooner. |
7463aadd RP |
3241 | |
3242 | You can use the string @samp{$cdir} to refer to the compilation | |
3243 | directory (if one is recorded), and @samp{$cwd} to refer to the current | |
3244 | working directory. @samp{$cwd} is not the same as @samp{.}---the former | |
3245 | tracks the current working directory as it changes during your _GDBN__ | |
3246 | session, while the latter is immediately expanded to the current | |
3247 | directory at the time you add an entry to the source path. | |
70b88761 RP |
3248 | |
3249 | @item directory | |
3250 | Reset the source path to empty again. This requires confirmation. | |
3251 | ||
3252 | @c RET-repeat for @code{directory} is explicitly disabled, but since | |
29a2b744 | 3253 | @c repeating it would be a no-op we do not say that. (thanks to RMS) |
70b88761 RP |
3254 | |
3255 | @item show directories | |
3256 | @kindex show directories | |
3257 | Print the source path: show which directories it contains. | |
3258 | @end table | |
3259 | ||
3260 | If your source path is cluttered with directories that are no longer of | |
3261 | interest, _GDBN__ may sometimes cause confusion by finding the wrong | |
3262 | versions of source. You can correct the situation as follows: | |
3263 | ||
3264 | @enumerate | |
3265 | @item | |
3266 | Use @code{directory} with no argument to reset the source path to empty. | |
3267 | ||
3268 | @item | |
3269 | Use @code{directory} with suitable arguments to reinstall the | |
3270 | directories you want in the source path. You can add all the | |
3271 | directories in one command. | |
3272 | @end enumerate | |
3273 | ||
3274 | @node Machine Code, , Source Path, Source | |
3275 | @section Source and Machine Code | |
1041a570 | 3276 | |
70b88761 RP |
3277 | You can use the command @code{info line} to map source lines to program |
3278 | addresses (and viceversa), and the command @code{disassemble} to display | |
3279 | a range of addresses as machine instructions. | |
3280 | ||
3281 | @table @code | |
3282 | @item info line @var{linespec} | |
3283 | @kindex info line | |
3284 | Print the starting and ending addresses of the compiled code for | |
1041a570 RP |
3285 | source line @var{linespec}. You can specify source lines in any of |
3286 | the ways understood by the @code{list} command (@pxref{List, ,Printing | |
3287 | Source Lines}). | |
70b88761 RP |
3288 | @end table |
3289 | ||
1041a570 RP |
3290 | For example, we can use @code{info line} to discover the location of |
3291 | the object code for the first line of function | |
3292 | @code{m4_changequote}: | |
3293 | ||
70b88761 RP |
3294 | @smallexample |
3295 | (_GDBP__) info line m4_changecom | |
3296 | Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350. | |
3297 | @end smallexample | |
3298 | ||
3299 | @noindent | |
3300 | We can also inquire (using @code{*@var{addr}} as the form for | |
3301 | @var{linespec}) what source line covers a particular address: | |
3302 | @smallexample | |
3303 | (_GDBP__) info line *0x63ff | |
3304 | Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404. | |
3305 | @end smallexample | |
3306 | ||
c338a2fd | 3307 | @cindex @code{$_} and @code{info line} |
29a2b744 RP |
3308 | After @code{info line}, the default address for the @code{x} command |
3309 | is changed to the starting address of the line, so that @samp{x/i} is | |
3310 | sufficient to begin examining the machine code (@pxref{Memory, | |
3311 | ,Examining Memory}). Also, this address is saved as the value of the | |
3312 | convenience variable @code{$_} (@pxref{Convenience Vars, ,Convenience | |
3313 | Variables}). | |
70b88761 RP |
3314 | |
3315 | @table @code | |
3316 | @kindex disassemble | |
3317 | @item disassemble | |
e94b4a2b RP |
3318 | This specialized command dumps a range of memory as machine |
3319 | instructions. The default memory range is the function surrounding the | |
3320 | program counter of the selected frame. A single argument to this | |
3321 | command is a program counter value; the function surrounding this value | |
3322 | will be dumped. Two arguments specify a range of addresses (first | |
3323 | inclusive, second exclusive) to dump. | |
70b88761 RP |
3324 | @end table |
3325 | ||
3326 | We can use @code{disassemble} to inspect the object code | |
3327 | range shown in the last @code{info line} example: | |
3328 | ||
3329 | @smallexample | |
3330 | (_GDBP__) disas 0x63e4 0x6404 | |
3331 | Dump of assembler code from 0x63e4 to 0x6404: | |
b80282d5 RP |
3332 | 0x63e4 <builtin_init+5340>: ble 0x63f8 <builtin_init+5360> |
3333 | 0x63e8 <builtin_init+5344>: sethi %hi(0x4c00), %o0 | |
3334 | 0x63ec <builtin_init+5348>: ld [%i1+4], %o0 | |
3335 | 0x63f0 <builtin_init+5352>: b 0x63fc <builtin_init+5364> | |
3336 | 0x63f4 <builtin_init+5356>: ld [%o0+4], %o0 | |
3337 | 0x63f8 <builtin_init+5360>: or %o0, 0x1a4, %o0 | |
3338 | 0x63fc <builtin_init+5364>: call 0x9288 <path_search> | |
e251e767 | 3339 | 0x6400 <builtin_init+5368>: nop |
70b88761 | 3340 | End of assembler dump. |
70b88761 RP |
3341 | @end smallexample |
3342 | ||
c2bbbb22 | 3343 | @node Data, Languages, Source, Top |
70b88761 RP |
3344 | @chapter Examining Data |
3345 | ||
3346 | @cindex printing data | |
3347 | @cindex examining data | |
3348 | @kindex print | |
3349 | @kindex inspect | |
1041a570 | 3350 | @c "inspect" is not quite a synonym if you are using Epoch, which we do not |
29a2b744 | 3351 | @c document because it is nonstandard... Under Epoch it displays in a |
70b88761 RP |
3352 | @c different window or something like that. |
3353 | The usual way to examine data in your program is with the @code{print} | |
3354 | command (abbreviated @code{p}), or its synonym @code{inspect}. It | |
b80282d5 | 3355 | evaluates and prints the value of an expression of the language your |
1041a570 RP |
3356 | program is written in (@pxref{Languages, ,Using _GDBN__ with Different |
3357 | Languages}). | |
70b88761 | 3358 | |
e0dacfd1 RP |
3359 | @table @code |
3360 | @item print @var{exp} | |
3361 | @itemx print /@var{f} @var{exp} | |
3362 | @var{exp} is an expression (in the source language). By default | |
70b88761 | 3363 | the value of @var{exp} is printed in a format appropriate to its data |
e0dacfd1 RP |
3364 | type; you can choose a different format by specifying @samp{/@var{f}}, |
3365 | where @var{f} is a letter specifying the format; @pxref{Output formats}. | |
3366 | ||
3367 | @item print | |
3368 | @itemx print /@var{f} | |
3369 | If you omit @var{exp}, _GDBN__ displays the last value again (from the | |
1041a570 | 3370 | @dfn{value history}; @pxref{Value History, ,Value History}). This allows you to |
e0dacfd1 RP |
3371 | conveniently inspect the same value in an alternative format. |
3372 | @end table | |
70b88761 RP |
3373 | |
3374 | A more low-level way of examining data is with the @code{x} command. | |
3375 | It examines data in memory at a specified address and prints it in a | |
29a2b744 | 3376 | specified format. @xref{Memory, ,Examining Memory}. |
70b88761 | 3377 | |
29a2b744 | 3378 | If you are interested in information about types, or about how the fields |
b80282d5 | 3379 | of a struct or class are declared, use the @code{ptype @var{exp}} |
1041a570 | 3380 | command rather than @code{print}. @xref{Symbols, ,Examining the Symbol Table}. |
b80282d5 | 3381 | |
70b88761 | 3382 | @menu |
b80282d5 RP |
3383 | * Expressions:: Expressions |
3384 | * Variables:: Program Variables | |
3385 | * Arrays:: Artificial Arrays | |
3386 | * Output formats:: Output formats | |
3387 | * Memory:: Examining Memory | |
3388 | * Auto Display:: Automatic Display | |
3389 | * Print Settings:: Print Settings | |
3390 | * Value History:: Value History | |
3391 | * Convenience Vars:: Convenience Variables | |
3392 | * Registers:: Registers | |
3393 | * Floating Point Hardware:: Floating Point Hardware | |
70b88761 RP |
3394 | @end menu |
3395 | ||
3396 | @node Expressions, Variables, Data, Data | |
3397 | @section Expressions | |
3398 | ||
3399 | @cindex expressions | |
3400 | @code{print} and many other _GDBN__ commands accept an expression and | |
3401 | compute its value. Any kind of constant, variable or operator defined | |
3402 | by the programming language you are using is legal in an expression in | |
3403 | _GDBN__. This includes conditional expressions, function calls, casts | |
3404 | and string constants. It unfortunately does not include symbols defined | |
b80282d5 | 3405 | by preprocessor @code{#define} commands. |
70b88761 | 3406 | |
c2bbbb22 | 3407 | Because C is so widespread, most of the expressions shown in examples in |
1041a570 | 3408 | this manual are in C. @xref{Languages, , Using _GDBN__ with Different |
c2bbbb22 | 3409 | Languages}, for information on how to use expressions in other |
e251e767 | 3410 | languages. |
c2bbbb22 RP |
3411 | |
3412 | In this section, we discuss operators that you can use in _GDBN__ | |
e251e767 | 3413 | expressions regardless of your programming language. |
c2bbbb22 | 3414 | |
70b88761 RP |
3415 | Casts are supported in all languages, not just in C, because it is so |
3416 | useful to cast a number into a pointer so as to examine a structure | |
3417 | at that address in memory. | |
c2bbbb22 | 3418 | @c FIXME: casts supported---Mod2 true? |
70b88761 | 3419 | |
c2bbbb22 | 3420 | _GDBN__ supports these operators in addition to those of programming |
70b88761 RP |
3421 | languages: |
3422 | ||
3423 | @table @code | |
3424 | @item @@ | |
3425 | @samp{@@} is a binary operator for treating parts of memory as arrays. | |
1041a570 | 3426 | @xref{Arrays, ,Artificial Arrays}, for more information. |
70b88761 RP |
3427 | |
3428 | @item :: | |
3429 | @samp{::} allows you to specify a variable in terms of the file or | |
1041a570 | 3430 | function where it is defined. @xref{Variables, ,Program Variables}. |
70b88761 RP |
3431 | |
3432 | @item @{@var{type}@} @var{addr} | |
3433 | Refers to an object of type @var{type} stored at address @var{addr} in | |
3434 | memory. @var{addr} may be any expression whose value is an integer or | |
3435 | pointer (but parentheses are required around binary operators, just as in | |
3436 | a cast). This construct is allowed regardless of what kind of data is | |
1041a570 | 3437 | normally supposed to reside at @var{addr}. |
70b88761 RP |
3438 | @end table |
3439 | ||
3440 | @node Variables, Arrays, Expressions, Data | |
3441 | @section Program Variables | |
3442 | ||
3443 | The most common kind of expression to use is the name of a variable | |
3444 | in your program. | |
3445 | ||
3446 | Variables in expressions are understood in the selected stack frame | |
29a2b744 RP |
3447 | (@pxref{Selection, ,Selecting a Frame}); they must either be global |
3448 | (or static) or be visible according to the scope rules of the | |
3449 | programming language from the point of execution in that frame. This | |
3450 | means that in the function | |
70b88761 RP |
3451 | |
3452 | @example | |
3453 | foo (a) | |
3454 | int a; | |
3455 | @{ | |
3456 | bar (a); | |
3457 | @{ | |
3458 | int b = test (); | |
3459 | bar (b); | |
3460 | @} | |
3461 | @} | |
3462 | @end example | |
3463 | ||
3464 | @noindent | |
29a2b744 | 3465 | the variable @code{a} is usable whenever your program is executing |
70b88761 | 3466 | within the function @code{foo}, but the variable @code{b} is visible |
29a2b744 | 3467 | only while your program is executing inside the block in which @code{b} |
70b88761 RP |
3468 | is declared. |
3469 | ||
3470 | @cindex variable name conflict | |
3471 | There is an exception: you can refer to a variable or function whose | |
3472 | scope is a single source file even if the current execution point is not | |
3473 | in this file. But it is possible to have more than one such variable or | |
6ca72cc6 RP |
3474 | function with the same name (in different source files). If that |
3475 | happens, referring to that name has unpredictable effects. If you wish, | |
3476 | you can specify a static variable in a particular function or file, | |
3477 | using the colon-colon notation: | |
70b88761 RP |
3478 | |
3479 | @cindex colon-colon | |
a6d0b6d3 | 3480 | @iftex |
29a2b744 | 3481 | @c info cannot cope with a :: index entry, but why deprive hard copy readers? |
70b88761 | 3482 | @kindex :: |
a6d0b6d3 | 3483 | @end iftex |
70b88761 RP |
3484 | @example |
3485 | @var{file}::@var{variable} | |
6ca72cc6 | 3486 | @var{function}::@var{variable} |
70b88761 RP |
3487 | @end example |
3488 | ||
3489 | @noindent | |
6ca72cc6 RP |
3490 | Here @var{file} or @var{function} is the name of the context for the |
3491 | static @var{variable}. | |
70b88761 | 3492 | |
c2bbbb22 | 3493 | @cindex C++ scope resolution |
70b88761 RP |
3494 | This use of @samp{::} is very rarely in conflict with the very similar |
3495 | use of the same notation in C++. _GDBN__ also supports use of the C++ | |
c2bbbb22 | 3496 | scope resolution operator in _GDBN__ expressions. |
70b88761 | 3497 | |
3d3ab540 RP |
3498 | @cindex wrong values |
3499 | @cindex variable values, wrong | |
3500 | @quotation | |
3501 | @emph{Warning:} Occasionally, a local variable may appear to have the | |
3502 | wrong value at certain points in a function---just after entry to the | |
29a2b744 | 3503 | function, and just before exit. You may see this problem when you are |
3d3ab540 RP |
3504 | stepping by machine instructions. This is because on most machines, it |
3505 | takes more than one instruction to set up a stack frame (including local | |
29a2b744 | 3506 | variable definitions); if you are stepping by machine instructions, |
3d3ab540 RP |
3507 | variables may appear to have the wrong values until the stack frame is |
3508 | completely built. On function exit, it usually also takes more than one | |
3509 | machine instruction to destroy a stack frame; after you begin stepping | |
3510 | through that group of instructions, local variable definitions may be | |
3511 | gone. | |
3512 | @end quotation | |
3513 | ||
70b88761 RP |
3514 | @node Arrays, Output formats, Variables, Data |
3515 | @section Artificial Arrays | |
3516 | ||
3517 | @cindex artificial array | |
3518 | @kindex @@ | |
3519 | It is often useful to print out several successive objects of the | |
3520 | same type in memory; a section of an array, or an array of | |
3521 | dynamically determined size for which only a pointer exists in the | |
3522 | program. | |
3523 | ||
3524 | This can be done by constructing an @dfn{artificial array} with the | |
3525 | binary operator @samp{@@}. The left operand of @samp{@@} should be | |
3526 | the first element of the desired array, as an individual object. | |
3527 | The right operand should be the desired length of the array. The result is | |
3528 | an array value whose elements are all of the type of the left argument. | |
3529 | The first element is actually the left argument; the second element | |
3530 | comes from bytes of memory immediately following those that hold the | |
3531 | first element, and so on. Here is an example. If a program says | |
3532 | ||
3533 | @example | |
3534 | int *array = (int *) malloc (len * sizeof (int)); | |
3535 | @end example | |
3536 | ||
3537 | @noindent | |
3538 | you can print the contents of @code{array} with | |
3539 | ||
3540 | @example | |
3541 | p *array@@len | |
3542 | @end example | |
3543 | ||
3544 | The left operand of @samp{@@} must reside in memory. Array values made | |
3545 | with @samp{@@} in this way behave just like other arrays in terms of | |
3546 | subscripting, and are coerced to pointers when used in expressions. | |
3547 | Artificial arrays most often appear in expressions via the value history | |
1041a570 | 3548 | (@pxref{Value History, ,Value History}), after printing one out.) |
70b88761 | 3549 | |
1041a570 | 3550 | Sometimes the artificial array mechanism is not quite enough; in |
3d3ab540 | 3551 | moderately complex data structures, the elements of interest may not |
1041a570 RP |
3552 | actually be adjacent---for example, if you are interested in the values |
3553 | of pointers in an array. One useful work-around in this situation is | |
3554 | to use a convenience variable (@pxref{Convenience Vars, ,Convenience | |
3555 | Variables}) as a counter in an expression that prints the first | |
3556 | interesting value, and then repeat that expression via @key{RET}. For | |
3557 | instance, suppose you have an array @code{dtab} of pointers to | |
3558 | structures, and you are interested in the values of a field @code{fv} | |
3559 | in each structure. Here is an example of what you might type: | |
3560 | ||
3d3ab540 RP |
3561 | @example |
3562 | set $i = 0 | |
3563 | p dtab[$i++]->fv | |
3564 | @key{RET} | |
3565 | @key{RET} | |
3566 | @dots{} | |
3567 | @end example | |
3568 | ||
70b88761 RP |
3569 | @node Output formats, Memory, Arrays, Data |
3570 | @section Output formats | |
3571 | ||
3572 | @cindex formatted output | |
3573 | @cindex output formats | |
3574 | By default, _GDBN__ prints a value according to its data type. Sometimes | |
3575 | this is not what you want. For example, you might want to print a number | |
3576 | in hex, or a pointer in decimal. Or you might want to view data in memory | |
3577 | at a certain address as a character string or as an instruction. To do | |
3578 | these things, specify an @dfn{output format} when you print a value. | |
3579 | ||
3580 | The simplest use of output formats is to say how to print a value | |
3581 | already computed. This is done by starting the arguments of the | |
3582 | @code{print} command with a slash and a format letter. The format | |
3583 | letters supported are: | |
3584 | ||
3585 | @table @code | |
3586 | @item x | |
3587 | Regard the bits of the value as an integer, and print the integer in | |
3588 | hexadecimal. | |
3589 | ||
3590 | @item d | |
3591 | Print as integer in signed decimal. | |
3592 | ||
3593 | @item u | |
3594 | Print as integer in unsigned decimal. | |
3595 | ||
3596 | @item o | |
3597 | Print as integer in octal. | |
3598 | ||
3599 | @item t | |
3600 | Print as integer in binary. The letter @samp{t} stands for ``two''. | |
3601 | ||
3602 | @item a | |
3603 | Print as an address, both absolute in hex and as an offset from the | |
3604 | nearest preceding symbol. This format can be used to discover where (in | |
3605 | what function) an unknown address is located: | |
1041a570 | 3606 | |
70b88761 RP |
3607 | @example |
3608 | (_GDBP__) p/a 0x54320 | |
3609 | _0__$3 = 0x54320 <_initialize_vx+396>_1__ | |
3610 | @end example | |
3611 | ||
70b88761 RP |
3612 | @item c |
3613 | Regard as an integer and print it as a character constant. | |
3614 | ||
3615 | @item f | |
3616 | Regard the bits of the value as a floating point number and print | |
3617 | using typical floating point syntax. | |
3618 | @end table | |
3619 | ||
3620 | For example, to print the program counter in hex (@pxref{Registers}), type | |
3621 | ||
3622 | @example | |
3623 | p/x $pc | |
3624 | @end example | |
3625 | ||
3626 | @noindent | |
3627 | Note that no space is required before the slash; this is because command | |
3628 | names in _GDBN__ cannot contain a slash. | |
3629 | ||
3630 | To reprint the last value in the value history with a different format, | |
3631 | you can use the @code{print} command with just a format and no | |
3632 | expression. For example, @samp{p/x} reprints the last value in hex. | |
3633 | ||
3634 | @node Memory, Auto Display, Output formats, Data | |
3635 | @section Examining Memory | |
3636 | ||
1041a570 RP |
3637 | You can use the command @code{x} (for ``examine'') to examine memory in |
3638 | any of several formats, independently of your program's data types. | |
3639 | ||
70b88761 RP |
3640 | @cindex examining memory |
3641 | @table @code | |
3642 | @kindex x | |
cedaf8bc RP |
3643 | @item x/@var{nfu} @var{addr} |
3644 | @itemx x @var{addr} | |
3645 | @itemx x | |
1041a570 RP |
3646 | Use the command @code{x} to examine memory. |
3647 | @end table | |
3648 | ||
3649 | @var{n}, @var{f}, and @var{u} are all optional parameters that specify how | |
3650 | much memory to display and how to format it; @var{addr} is an | |
cedaf8bc RP |
3651 | expression giving the address where you want to start displaying memory. |
3652 | If you use defaults for @var{nfu}, you need not type the slash @samp{/}. | |
3653 | Several commands set convenient defaults for @var{addr}. | |
70b88761 | 3654 | |
1041a570 RP |
3655 | @table @r |
3656 | @item @var{n}, the repeat count | |
3657 | The repeat count is a decimal integer; the default is 1. It specifies | |
3658 | how much memory (counting by units @var{u}) to display. | |
cedaf8bc RP |
3659 | @c This really is **decimal**; unaffected by 'set radix' as of GDB |
3660 | @c 4.1.2. | |
70b88761 | 3661 | |
1041a570 RP |
3662 | @item @var{f}, the display format |
3663 | The display format is one of the formats used by @code{print}, | |
cedaf8bc RP |
3664 | or @samp{s} (null-terminated string) or @samp{i} (machine instruction). |
3665 | The default is @samp{x} (hexadecimal) initially, or the format from the | |
3666 | last time you used either @code{x} or @code{print}. | |
70b88761 | 3667 | |
1041a570 RP |
3668 | @item @var{u}, the unit size |
3669 | The unit size is any of | |
70b88761 RP |
3670 | @table @code |
3671 | @item b | |
cedaf8bc | 3672 | Bytes. |
70b88761 | 3673 | @item h |
cedaf8bc | 3674 | Halfwords (two bytes). |
70b88761 | 3675 | @item w |
cedaf8bc | 3676 | Words (four bytes). This is the initial default. |
70b88761 | 3677 | @item g |
cedaf8bc | 3678 | Giant words (eight bytes). |
70b88761 RP |
3679 | @end table |
3680 | ||
cedaf8bc RP |
3681 | Each time you specify a unit size with @code{x}, that size becomes the |
3682 | default unit the next time you use @code{x}. (For the @samp{s} and | |
3683 | @samp{i} formats, the unit size is ignored and is normally not written.) | |
3684 | ||
1041a570 | 3685 | @item @var{addr}, starting display address |
cedaf8bc RP |
3686 | @var{addr} is the address where you want _GDBN__ to begin displaying |
3687 | memory. The expression need not have a pointer value (though it may); | |
3688 | it is always interpreted as an integer address of a byte of memory. | |
1041a570 | 3689 | @xref{Expressions, ,Expressions}, for more information on expressions. The default for |
cedaf8bc RP |
3690 | @var{addr} is usually just after the last address examined---but several |
3691 | other commands also set the default address: @code{info breakpoints} (to | |
3692 | the address of the last breakpoint listed), @code{info line} (to the | |
3693 | starting address of a line), and @code{print} (if you use it to display | |
3694 | a value from memory). | |
1041a570 | 3695 | @end table |
70b88761 | 3696 | |
cedaf8bc RP |
3697 | For example, @samp{x/3uh 0x54320} is a request to display three halfwords |
3698 | (@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}), | |
3699 | starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four | |
3700 | words (@samp{w}) of memory above the stack pointer (here, @samp{$sp}; | |
3701 | @pxref{Registers}) in hexadecimal (@samp{x}). | |
70b88761 | 3702 | |
cedaf8bc | 3703 | Since the letters indicating unit sizes are all distinct from the |
29a2b744 | 3704 | letters specifying output formats, you do not have to remember whether |
cedaf8bc RP |
3705 | unit size or format comes first; either order will work. The output |
3706 | specifications @samp{4xw} and @samp{4wx} mean exactly the same thing. | |
3707 | (However, the count @var{n} must come first; @samp{wx4} will not work.) | |
3708 | ||
3709 | Even though the unit size @var{u} is ignored for the formats @samp{s} | |
3710 | and @samp{i}, you might still want to use a count @var{n}; for example, | |
3711 | @samp{3i} specifies that you want to see three machine instructions, | |
3712 | including any operands. The command @code{disassemble} gives an | |
3713 | alternative way of inspecting machine instructions; @pxref{Machine | |
3714 | Code}. | |
3715 | ||
3716 | All the defaults for the arguments to @code{x} are designed to make it | |
3717 | easy to continue scanning memory with minimal specifications each time | |
1041a570 | 3718 | you use @code{x}. For example, after you have inspected three machine |
cedaf8bc RP |
3719 | instructions with @samp{x/3i @var{addr}}, you can inspect the next seven |
3720 | with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command, | |
3721 | the repeat count @var{n} is used again; the other arguments default as | |
3722 | for successive uses of @code{x}. | |
70b88761 | 3723 | |
c338a2fd | 3724 | @cindex @code{$_}, @code{$__}, and value history |
cedaf8bc | 3725 | The addresses and contents printed by the @code{x} command are not saved |
70b88761 RP |
3726 | in the value history because there is often too much of them and they |
3727 | would get in the way. Instead, _GDBN__ makes these values available for | |
3728 | subsequent use in expressions as values of the convenience variables | |
3729 | @code{$_} and @code{$__}. After an @code{x} command, the last address | |
3730 | examined is available for use in expressions in the convenience variable | |
3731 | @code{$_}. The contents of that address, as examined, are available in | |
3732 | the convenience variable @code{$__}. | |
3733 | ||
3734 | If the @code{x} command has a repeat count, the address and contents saved | |
3735 | are from the last memory unit printed; this is not the same as the last | |
3736 | address printed if several units were printed on the last line of output. | |
3737 | ||
3738 | @node Auto Display, Print Settings, Memory, Data | |
3739 | @section Automatic Display | |
3740 | @cindex automatic display | |
3741 | @cindex display of expressions | |
3742 | ||
3743 | If you find that you want to print the value of an expression frequently | |
3744 | (to see how it changes), you might want to add it to the @dfn{automatic | |
29a2b744 | 3745 | display list} so that _GDBN__ will print its value each time your program stops. |
70b88761 RP |
3746 | Each expression added to the list is given a number to identify it; |
3747 | to remove an expression from the list, you specify that number. | |
3748 | The automatic display looks like this: | |
3749 | ||
3750 | @example | |
3751 | 2: foo = 38 | |
3752 | 3: bar[5] = (struct hack *) 0x3804 | |
3753 | @end example | |
3754 | ||
3755 | @noindent | |
3756 | showing item numbers, expressions and their current values. As with | |
3757 | displays you request manually using @code{x} or @code{print}, you can | |
3758 | specify the output format you prefer; in fact, @code{display} decides | |
3759 | whether to use @code{print} or @code{x} depending on how elaborate your | |
3760 | format specification is---it uses @code{x} if you specify a unit size, | |
3761 | or one of the two formats (@samp{i} and @samp{s}) that are only | |
3762 | supported by @code{x}; otherwise it uses @code{print}. | |
3763 | ||
3764 | @table @code | |
3765 | @item display @var{exp} | |
3766 | @kindex display | |
3767 | Add the expression @var{exp} to the list of expressions to display | |
1041a570 | 3768 | each time your program stops. @xref{Expressions, ,Expressions}. |
70b88761 RP |
3769 | |
3770 | @code{display} will not repeat if you press @key{RET} again after using it. | |
3771 | ||
3772 | @item display/@var{fmt} @var{exp} | |
3773 | For @var{fmt} specifying only a display format and not a size or | |
3774 | count, add the expression @var{exp} to the auto-display list but | |
3775 | arranges to display it each time in the specified format @var{fmt}. | |
3776 | @xref{Output formats}. | |
3777 | ||
3778 | @item display/@var{fmt} @var{addr} | |
3779 | For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a | |
3780 | number of units, add the expression @var{addr} as a memory address to | |
29a2b744 RP |
3781 | be examined each time your program stops. Examining means in effect |
3782 | doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory, ,Examining Memory}. | |
70b88761 RP |
3783 | @end table |
3784 | ||
3785 | For example, @samp{display/i $pc} can be helpful, to see the machine | |
3786 | instruction about to be executed each time execution stops (@samp{$pc} | |
3787 | is a common name for the program counter; @pxref{Registers}). | |
3788 | ||
3789 | @table @code | |
3790 | @item undisplay @var{dnums}@dots{} | |
3791 | @itemx delete display @var{dnums}@dots{} | |
3792 | @kindex delete display | |
3793 | @kindex undisplay | |
3794 | Remove item numbers @var{dnums} from the list of expressions to display. | |
3795 | ||
3796 | @code{undisplay} will not repeat if you press @key{RET} after using it. | |
3797 | (Otherwise you would just get the error @samp{No display number @dots{}}.) | |
3798 | ||
3799 | @item disable display @var{dnums}@dots{} | |
3800 | @kindex disable display | |
3801 | Disable the display of item numbers @var{dnums}. A disabled display | |
3802 | item is not printed automatically, but is not forgotten. It may be | |
3803 | enabled again later. | |
3804 | ||
3805 | @item enable display @var{dnums}@dots{} | |
3806 | @kindex enable display | |
3807 | Enable display of item numbers @var{dnums}. It becomes effective once | |
3808 | again in auto display of its expression, until you specify otherwise. | |
3809 | ||
3810 | @item display | |
3811 | Display the current values of the expressions on the list, just as is | |
29a2b744 | 3812 | done when your program stops. |
70b88761 RP |
3813 | |
3814 | @item info display | |
3815 | @kindex info display | |
3816 | Print the list of expressions previously set up to display | |
3817 | automatically, each one with its item number, but without showing the | |
3818 | values. This includes disabled expressions, which are marked as such. | |
3819 | It also includes expressions which would not be displayed right now | |
3820 | because they refer to automatic variables not currently available. | |
3821 | @end table | |
3822 | ||
3823 | If a display expression refers to local variables, then it does not make | |
3824 | sense outside the lexical context for which it was set up. Such an | |
3825 | expression is disabled when execution enters a context where one of its | |
3826 | variables is not defined. For example, if you give the command | |
3827 | @code{display last_char} while inside a function with an argument | |
29a2b744 | 3828 | @code{last_char}, then this argument will be displayed while your program |
70b88761 RP |
3829 | continues to stop inside that function. When it stops elsewhere---where |
3830 | there is no variable @code{last_char}---display is disabled. The next time | |
3831 | your program stops where @code{last_char} is meaningful, you can enable the | |
3832 | display expression once again. | |
3833 | ||
3834 | @node Print Settings, Value History, Auto Display, Data | |
3835 | @section Print Settings | |
3836 | ||
3837 | @cindex format options | |
3838 | @cindex print settings | |
3839 | _GDBN__ provides the following ways to control how arrays, structures, | |
e251e767 | 3840 | and symbols are printed. |
70b88761 RP |
3841 | |
3842 | @noindent | |
3843 | These settings are useful for debugging programs in any language: | |
3844 | ||
3845 | @table @code | |
3846 | @item set print address | |
3847 | @item set print address on | |
3848 | @kindex set print address | |
3849 | _GDBN__ will print memory addresses showing the location of stack | |
3850 | traces, structure values, pointer values, breakpoints, and so forth, | |
3851 | even when it also displays the contents of those addresses. The default | |
3852 | is on. For example, this is what a stack frame display looks like, with | |
3853 | @code{set print address on}: | |
1041a570 | 3854 | |
70b88761 | 3855 | @smallexample |
1041a570 | 3856 | @group |
70b88761 | 3857 | (_GDBP__) f |
e251e767 | 3858 | #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") |
70b88761 | 3859 | at input.c:530 |
b80282d5 | 3860 | 530 if (lquote != def_lquote) |
1041a570 | 3861 | @end group |
70b88761 RP |
3862 | @end smallexample |
3863 | ||
3864 | @item set print address off | |
3865 | Do not print addresses when displaying their contents. For example, | |
3866 | this is the same stack frame displayed with @code{set print address off}: | |
1041a570 | 3867 | |
70b88761 | 3868 | @example |
1041a570 | 3869 | @group |
70b88761 RP |
3870 | (_GDBP__) set print addr off |
3871 | (_GDBP__) f | |
3872 | #0 set_quotes (lq="<<", rq=">>") at input.c:530 | |
b80282d5 | 3873 | 530 if (lquote != def_lquote) |
1041a570 | 3874 | @end group |
70b88761 RP |
3875 | @end example |
3876 | ||
3877 | @item show print address | |
3878 | @kindex show print address | |
3879 | Show whether or not addresses are to be printed. | |
3880 | ||
3881 | @item set print array | |
3882 | @itemx set print array on | |
3883 | @kindex set print array | |
3884 | _GDBN__ will pretty print arrays. This format is more convenient to read, | |
3885 | but uses more space. The default is off. | |
3886 | ||
3887 | @item set print array off. | |
3888 | Return to compressed format for arrays. | |
3889 | ||
3890 | @item show print array | |
3891 | @kindex show print array | |
3892 | Show whether compressed or pretty format is selected for displaying | |
e251e767 | 3893 | arrays. |
70b88761 RP |
3894 | |
3895 | @item set print elements @var{number-of-elements} | |
3896 | @kindex set print elements | |
3897 | If _GDBN__ is printing a large array, it will stop printing after it has | |
3898 | printed the number of elements set by the @code{set print elements} command. | |
3899 | This limit also applies to the display of strings. | |
3900 | ||
3901 | @item show print elements | |
3902 | @kindex show print elements | |
3903 | Display the number of elements of a large array that _GDBN__ will print | |
3904 | before losing patience. | |
3905 | ||
3906 | @item set print pretty on | |
3907 | @kindex set print pretty | |
3908 | Cause _GDBN__ to print structures in an indented format with one member per | |
3909 | line, like this: | |
3910 | ||
3911 | @example | |
1041a570 | 3912 | @group |
70b88761 RP |
3913 | $1 = @{ |
3914 | next = 0x0, | |
3915 | flags = @{ | |
3916 | sweet = 1, | |
3917 | sour = 1 | |
3918 | @}, | |
3919 | meat = 0x54 "Pork" | |
3920 | @} | |
1041a570 | 3921 | @end group |
70b88761 RP |
3922 | @end example |
3923 | ||
3924 | @item set print pretty off | |
3925 | Cause _GDBN__ to print structures in a compact format, like this: | |
3926 | ||
3927 | @smallexample | |
1041a570 | 3928 | @group |
70b88761 RP |
3929 | $1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \ |
3930 | = 0x54 "Pork"@} | |
1041a570 | 3931 | @end group |
70b88761 RP |
3932 | @end smallexample |
3933 | ||
3934 | @noindent | |
3935 | This is the default format. | |
3936 | ||
3937 | @item show print pretty | |
3938 | @kindex show print pretty | |
3939 | Show which format _GDBN__ will use to print structures. | |
3940 | ||
3941 | @item set print sevenbit-strings on | |
f2857bd9 | 3942 | @kindex set print sevenbit-strings |
e251e767 | 3943 | Print using only seven-bit characters; if this option is set, |
70b88761 RP |
3944 | _GDBN__ will display any eight-bit characters (in strings or character |
3945 | values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is | |
3946 | displayed as @code{\341}. | |
3947 | ||
3948 | @item set print sevenbit-strings off | |
3949 | Print using either seven-bit or eight-bit characters, as required. This | |
3950 | is the default. | |
3951 | ||
3952 | @item show print sevenbit-strings | |
f2857bd9 | 3953 | @kindex show print sevenbit-strings |
70b88761 RP |
3954 | Show whether or not _GDBN__ will print only seven-bit characters. |
3955 | ||
3956 | @item set print union on | |
3957 | @kindex set print union | |
3958 | Tell _GDBN__ to print unions which are contained in structures. This is the | |
3959 | default setting. | |
3960 | ||
3961 | @item set print union off | |
3962 | Tell _GDBN__ not to print unions which are contained in structures. | |
3963 | ||
3964 | @item show print union | |
3965 | @kindex show print union | |
3966 | Ask _GDBN__ whether or not it will print unions which are contained in | |
e251e767 | 3967 | structures. |
70b88761 RP |
3968 | |
3969 | For example, given the declarations | |
3970 | ||
3971 | @smallexample | |
3972 | typedef enum @{Tree, Bug@} Species; | |
3973 | typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms; | |
203eea5d RP |
3974 | typedef enum @{Caterpillar, Cocoon, Butterfly@} |
3975 | Bug_forms; | |
70b88761 RP |
3976 | |
3977 | struct thing @{ | |
3978 | Species it; | |
3979 | union @{ | |
3980 | Tree_forms tree; | |
3981 | Bug_forms bug; | |
3982 | @} form; | |
3983 | @}; | |
3984 | ||
3985 | struct thing foo = @{Tree, @{Acorn@}@}; | |
3986 | @end smallexample | |
3987 | ||
3988 | @noindent | |
3989 | with @code{set print union on} in effect @samp{p foo} would print | |
3990 | ||
3991 | @smallexample | |
3992 | $1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@} | |
3993 | @end smallexample | |
3994 | ||
3995 | @noindent | |
3996 | and with @code{set print union off} in effect it would print | |
3997 | ||
3998 | @smallexample | |
3999 | $1 = @{it = Tree, form = @{...@}@} | |
4000 | @end smallexample | |
4001 | @end table | |
4002 | ||
4003 | @noindent | |
4004 | These settings are of interest when debugging C++ programs: | |
4005 | ||
4006 | @table @code | |
e251e767 RP |
4007 | @item set print demangle |
4008 | @itemx set print demangle on | |
70b88761 RP |
4009 | @kindex set print demangle |
4010 | Print C++ names in their source form rather than in the mangled form | |
4011 | in which they are passed to the assembler and linker for type-safe linkage. | |
4012 | The default is on. | |
4013 | ||
4014 | @item show print demangle | |
4015 | @kindex show print demangle | |
4016 | Show whether C++ names will be printed in mangled or demangled form. | |
4017 | ||
e251e767 RP |
4018 | @item set print asm-demangle |
4019 | @itemx set print asm-demangle on | |
70b88761 RP |
4020 | @kindex set print asm-demangle |
4021 | Print C++ names in their source form rather than their mangled form, even | |
4022 | in assembler code printouts such as instruction disassemblies. | |
4023 | The default is off. | |
4024 | ||
4025 | @item show print asm-demangle | |
4026 | @kindex show print asm-demangle | |
4027 | Show whether C++ names in assembly listings will be printed in mangled | |
4028 | or demangled form. | |
4029 | ||
4030 | @item set print object | |
4031 | @itemx set print object on | |
4032 | @kindex set print object | |
4033 | When displaying a pointer to an object, identify the @emph{actual} | |
4034 | (derived) type of the object rather than the @emph{declared} type, using | |
4035 | the virtual function table. | |
4036 | ||
4037 | @item set print object off | |
4038 | Display only the declared type of objects, without reference to the | |
4039 | virtual function table. This is the default setting. | |
4040 | ||
4041 | @item show print object | |
4042 | @kindex show print object | |
4043 | Show whether actual, or declared, object types will be displayed. | |
4044 | ||
e251e767 RP |
4045 | @item set print vtbl |
4046 | @itemx set print vtbl on | |
70b88761 RP |
4047 | @kindex set print vtbl |
4048 | Pretty print C++ virtual function tables. The default is off. | |
4049 | ||
4050 | @item set print vtbl off | |
4051 | Do not pretty print C++ virtual function tables. | |
4052 | ||
4053 | @item show print vtbl | |
4054 | @kindex show print vtbl | |
4055 | Show whether C++ virtual function tables are pretty printed, or not. | |
70b88761 RP |
4056 | @end table |
4057 | ||
4058 | @node Value History, Convenience Vars, Print Settings, Data | |
4059 | @section Value History | |
4060 | ||
4061 | @cindex value history | |
4062 | Values printed by the @code{print} command are saved in _GDBN__'s @dfn{value | |
4063 | history} so that you can refer to them in other expressions. Values are | |
4064 | kept until the symbol table is re-read or discarded (for example with | |
4065 | the @code{file} or @code{symbol-file} commands). When the symbol table | |
4066 | changes, the value history is discarded, since the values may contain | |
4067 | pointers back to the types defined in the symbol table. | |
4068 | ||
4069 | @cindex @code{$} | |
4070 | @cindex @code{$$} | |
4071 | @cindex history number | |
4072 | The values printed are given @dfn{history numbers} for you to refer to them | |
4073 | by. These are successive integers starting with one. @code{print} shows you | |
4074 | the history number assigned to a value by printing @samp{$@var{num} = } | |
4075 | before the value; here @var{num} is the history number. | |
4076 | ||
4077 | To refer to any previous value, use @samp{$} followed by the value's | |
4078 | history number. The way @code{print} labels its output is designed to | |
4079 | remind you of this. Just @code{$} refers to the most recent value in | |
4080 | the history, and @code{$$} refers to the value before that. | |
4081 | @code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2} | |
4082 | is the value just prior to @code{$$}, @code{$$1} is equivalent to | |
4083 | @code{$$}, and @code{$$0} is equivalent to @code{$}. | |
4084 | ||
4085 | For example, suppose you have just printed a pointer to a structure and | |
4086 | want to see the contents of the structure. It suffices to type | |
4087 | ||
4088 | @example | |
4089 | p *$ | |
4090 | @end example | |
4091 | ||
4092 | If you have a chain of structures where the component @code{next} points | |
4093 | to the next one, you can print the contents of the next one with this: | |
4094 | ||
4095 | @example | |
4096 | p *$.next | |
4097 | @end example | |
4098 | ||
4099 | @noindent | |
4100 | You can print successive links in the chain by repeating this | |
4101 | command---which you can do by just typing @key{RET}. | |
4102 | ||
4103 | Note that the history records values, not expressions. If the value of | |
4104 | @code{x} is 4 and you type these commands: | |
4105 | ||
4106 | @example | |
4107 | print x | |
4108 | set x=5 | |
4109 | @end example | |
4110 | ||
4111 | @noindent | |
4112 | then the value recorded in the value history by the @code{print} command | |
4113 | remains 4 even though the value of @code{x} has changed. | |
4114 | ||
4115 | @table @code | |
4116 | @kindex show values | |
4117 | @item show values | |
4118 | Print the last ten values in the value history, with their item numbers. | |
4119 | This is like @samp{p@ $$9} repeated ten times, except that @code{show | |
4120 | values} does not change the history. | |
4121 | ||
4122 | @item show values @var{n} | |
4123 | Print ten history values centered on history item number @var{n}. | |
4124 | ||
4125 | @item show values + | |
4126 | Print ten history values just after the values last printed. If no more | |
4127 | values are available, produces no display. | |
4128 | @end table | |
4129 | ||
4130 | Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the | |
e251e767 | 4131 | same effect as @samp{show values +}. |
70b88761 RP |
4132 | |
4133 | @node Convenience Vars, Registers, Value History, Data | |
4134 | @section Convenience Variables | |
4135 | ||
4136 | @cindex convenience variables | |
4137 | _GDBN__ provides @dfn{convenience variables} that you can use within | |
4138 | _GDBN__ to hold on to a value and refer to it later. These variables | |
4139 | exist entirely within _GDBN__; they are not part of your program, and | |
4140 | setting a convenience variable has no direct effect on further execution | |
1041a570 | 4141 | of your program. That is why you can use them freely. |
70b88761 RP |
4142 | |
4143 | Convenience variables are prefixed with @samp{$}. Any name preceded by | |
4144 | @samp{$} can be used for a convenience variable, unless it is one of | |
4145 | the predefined machine-specific register names (@pxref{Registers}). | |
4146 | (Value history references, in contrast, are @emph{numbers} preceded | |
1041a570 | 4147 | by @samp{$}. @xref{Value History, ,Value History}.) |
70b88761 RP |
4148 | |
4149 | You can save a value in a convenience variable with an assignment | |
4150 | expression, just as you would set a variable in your program. Example: | |
4151 | ||
4152 | @example | |
4153 | set $foo = *object_ptr | |
4154 | @end example | |
4155 | ||
4156 | @noindent | |
4157 | would save in @code{$foo} the value contained in the object pointed to by | |
4158 | @code{object_ptr}. | |
4159 | ||
4160 | Using a convenience variable for the first time creates it; but its value | |
4161 | is @code{void} until you assign a new value. You can alter the value with | |
4162 | another assignment at any time. | |
4163 | ||
4164 | Convenience variables have no fixed types. You can assign a convenience | |
4165 | variable any type of value, including structures and arrays, even if | |
4166 | that variable already has a value of a different type. The convenience | |
4167 | variable, when used as an expression, has the type of its current value. | |
4168 | ||
4169 | @table @code | |
4170 | @item show convenience | |
4171 | @kindex show convenience | |
4172 | Print a list of convenience variables used so far, and their values. | |
4173 | Abbreviated @code{show con}. | |
4174 | @end table | |
4175 | ||
4176 | One of the ways to use a convenience variable is as a counter to be | |
4177 | incremented or a pointer to be advanced. For example, to print | |
4178 | a field from successive elements of an array of structures: | |
4179 | ||
4180 | _0__@example | |
4181 | set $i = 0 | |
4182 | print bar[$i++]->contents | |
4183 | @i{@dots{} repeat that command by typing @key{RET}.} | |
4184 | _1__@end example | |
4185 | ||
4186 | Some convenience variables are created automatically by _GDBN__ and given | |
4187 | values likely to be useful. | |
4188 | ||
4189 | @table @code | |
4190 | @item $_ | |
c338a2fd | 4191 | @kindex $_ |
70b88761 | 4192 | The variable @code{$_} is automatically set by the @code{x} command to |
29a2b744 RP |
4193 | the last address examined (@pxref{Memory, ,Examining Memory}). Other |
4194 | commands which provide a default address for @code{x} to examine also | |
4195 | set @code{$_} to that address; these commands include @code{info line} | |
4196 | and @code{info breakpoint}. The type of @code{$_} is @code{void *} | |
4197 | except when set by the @code{x} command, in which case it is a pointer | |
4198 | to the type of @code{$__}. | |
70b88761 RP |
4199 | |
4200 | @item $__ | |
c338a2fd | 4201 | @kindex $__ |
70b88761 | 4202 | The variable @code{$__} is automatically set by the @code{x} command |
c2bbbb22 RP |
4203 | to the value found in the last address examined. Its type is chosen |
4204 | to match the format in which the data was printed. | |
70b88761 RP |
4205 | @end table |
4206 | ||
4207 | @node Registers, Floating Point Hardware, Convenience Vars, Data | |
4208 | @section Registers | |
4209 | ||
4210 | @cindex registers | |
b80282d5 | 4211 | You can refer to machine register contents, in expressions, as variables |
70b88761 RP |
4212 | with names starting with @samp{$}. The names of registers are different |
4213 | for each machine; use @code{info registers} to see the names used on | |
e251e767 | 4214 | your machine. |
70b88761 RP |
4215 | |
4216 | @table @code | |
4217 | @item info registers | |
4218 | @kindex info registers | |
b80282d5 RP |
4219 | Print the names and values of all registers except floating-point |
4220 | registers (in the selected stack frame). | |
4221 | ||
4222 | @item info all-registers | |
4223 | @kindex info all-registers | |
4224 | @cindex floating point registers | |
4225 | Print the names and values of all registers, including floating-point | |
4226 | registers. | |
70b88761 RP |
4227 | |
4228 | @item info registers @var{regname} | |
4229 | Print the relativized value of register @var{regname}. @var{regname} | |
4230 | may be any register name valid on the machine you are using, with | |
4231 | or without the initial @samp{$}. | |
4232 | @end table | |
4233 | ||
09267865 | 4234 | _GDBN__ has four ``standard'' register names that are available (in |
29a2b744 | 4235 | expressions) on most machines---whenever they do not conflict with an |
09267865 RP |
4236 | architecture's canonical mnemonics for registers. The register names |
4237 | @code{$pc} and @code{$sp} are used for the program counter register and | |
4238 | the stack pointer. @code{$fp} is used for a register that contains a | |
4239 | pointer to the current stack frame, and @code{$ps} is used for a | |
4240 | register that contains the processor status. For example, | |
70b88761 | 4241 | you could print the program counter in hex with |
1041a570 | 4242 | |
70b88761 RP |
4243 | @example |
4244 | p/x $pc | |
4245 | @end example | |
4246 | ||
4247 | @noindent | |
4248 | or print the instruction to be executed next with | |
1041a570 | 4249 | |
70b88761 RP |
4250 | @example |
4251 | x/i $pc | |
4252 | @end example | |
4253 | ||
4254 | @noindent | |
29a2b744 RP |
4255 | or add four to the stack pointer @footnote{This is a way of removing |
4256 | one word from the stack, on machines where stacks grow downward in | |
4257 | memory (most machines, nowadays). This assumes that the innermost | |
4258 | stack frame is selected; setting @code{$sp} is not allowed when other | |
4259 | stack frames are selected. To pop entire frames off the stack, | |
4260 | regardless of machine architecture, use @code{return}; | |
1041a570 RP |
4261 | @pxref{Returning, ,Returning from a Function}.} with |
4262 | ||
70b88761 RP |
4263 | @example |
4264 | set $sp += 4 | |
4265 | @end example | |
4266 | ||
09267865 RP |
4267 | Whenever possible, these four standard register names are available on |
4268 | your machine even though the machine has different canonical mnemonics, | |
4269 | so long as there is no conflict. The @code{info registers} command | |
4270 | shows the canonical names. For example, on the SPARC, @code{info | |
70b88761 RP |
4271 | registers} displays the processor status register as @code{$psr} but you |
4272 | can also refer to it as @code{$ps}. | |
4273 | ||
4274 | _GDBN__ always considers the contents of an ordinary register as an | |
4275 | integer when the register is examined in this way. Some machines have | |
4276 | special registers which can hold nothing but floating point; these | |
4277 | registers are considered to have floating point values. There is no way | |
4278 | to refer to the contents of an ordinary register as floating point value | |
4279 | (although you can @emph{print} it as a floating point value with | |
4280 | @samp{print/f $@var{regname}}). | |
4281 | ||
4282 | Some registers have distinct ``raw'' and ``virtual'' data formats. This | |
4283 | means that the data format in which the register contents are saved by | |
4284 | the operating system is not the same one that your program normally | |
4285 | sees. For example, the registers of the 68881 floating point | |
4286 | coprocessor are always saved in ``extended'' (raw) format, but all C | |
4287 | programs expect to work with ``double'' (virtual) format. In such | |
4288 | cases, _GDBN__ normally works with the virtual format only (the format that | |
4289 | makes sense for your program), but the @code{info registers} command | |
4290 | prints the data in both formats. | |
4291 | ||
4292 | Normally, register values are relative to the selected stack frame | |
29a2b744 RP |
4293 | (@pxref{Selection, ,Selecting a Frame}). This means that you get the |
4294 | value that the register would contain if all stack frames farther in | |
4295 | were exited and their saved registers restored. In order to see the | |
4296 | true contents of hardware registers, you must select the innermost | |
4297 | frame (with @samp{frame 0}). | |
70b88761 RP |
4298 | |
4299 | However, _GDBN__ must deduce where registers are saved, from the machine | |
4300 | code generated by your compiler. If some registers are not saved, or if | |
4301 | _GDBN__ is unable to locate the saved registers, the selected stack | |
4302 | frame will make no difference. | |
4303 | ||
4304 | @node Floating Point Hardware, , Registers, Data | |
4305 | @section Floating Point Hardware | |
4306 | @cindex floating point | |
1041a570 | 4307 | |
70b88761 RP |
4308 | Depending on the host machine architecture, _GDBN__ may be able to give |
4309 | you more information about the status of the floating point hardware. | |
4310 | ||
4311 | @table @code | |
4312 | @item info float | |
4313 | @kindex info float | |
4314 | If available, provides hardware-dependent information about the floating | |
4315 | point unit. The exact contents and layout vary depending on the | |
4316 | floating point chip. | |
4317 | @end table | |
4318 | @c FIXME: this is a cop-out. Try to get examples, explanations. Only | |
e251e767 RP |
4319 | @c FIXME...supported currently on arm's and 386's. Mark properly with |
4320 | @c FIXME... m4 macros to isolate general statements from hardware-dep, | |
70b88761 RP |
4321 | @c FIXME... at that point. |
4322 | ||
c2bbbb22 RP |
4323 | @node Languages, Symbols, Data, Top |
4324 | @chapter Using _GDBN__ with Different Languages | |
4325 | @cindex languages | |
4326 | ||
4327 | Although programming languages generally have common aspects, they are | |
4328 | rarely expressed in the same manner. For instance, in ANSI C, | |
4329 | dereferencing a pointer @code{p} is accomplished by @code{*p}, but in | |
4330 | Modula-2, it is accomplished by @code{p^}. Values can also be | |
4331 | represented (and displayed) differently. Hex numbers in C are written | |
4332 | like @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}. | |
4333 | ||
4334 | @cindex working language | |
4335 | Language-specific information is built into _GDBN__ for some languages, | |
29a2b744 | 4336 | allowing you to express operations like the above in your program's |
c2bbbb22 | 4337 | native language, and allowing _GDBN__ to output values in a manner |
29a2b744 | 4338 | consistent with the syntax of your program's native language. The |
c2bbbb22 RP |
4339 | language you use to build expressions, called the @dfn{working |
4340 | language}, can be selected manually, or _GDBN__ can set it | |
4341 | automatically. | |
4342 | ||
4343 | @menu | |
4344 | * Setting:: Switching between source languages | |
4345 | * Show:: Displaying the language | |
4346 | * Checks:: Type and Range checks | |
4347 | * Support:: Supported languages | |
4348 | @end menu | |
4349 | ||
4350 | @node Setting, Show, Languages, Languages | |
4351 | @section Switching between source languages | |
4352 | ||
4353 | There are two ways to control the working language---either have _GDBN__ | |
4354 | set it automatically, or select it manually yourself. You can use the | |
4355 | @code{set language} command for either purpose. On startup, _GDBN__ | |
4356 | defaults to setting the language automatically. | |
4357 | ||
4358 | @menu | |
4359 | * Manually:: Setting the working language manually | |
4360 | * Automatically:: Having _GDBN__ infer the source language | |
4361 | @end menu | |
4362 | ||
4363 | @node Manually, Automatically, Setting, Setting | |
4364 | @subsection Setting the working language | |
4365 | ||
4366 | @kindex set language | |
4367 | To set the language, issue the command @samp{set language @var{lang}}, | |
c338a2fd RP |
4368 | where @var{lang} is the name of a language: @code{c} or @code{modula-2}. |
4369 | For a list of the supported languages, type @samp{set language}. | |
c2bbbb22 RP |
4370 | |
4371 | Setting the language manually prevents _GDBN__ from updating the working | |
4372 | language automatically. This can lead to confusion if you try | |
4373 | to debug a program when the working language is not the same as the | |
4374 | source language, when an expression is acceptable to both | |
4375 | languages---but means different things. For instance, if the current | |
4376 | source file were written in C, and _GDBN__ was parsing Modula-2, a | |
4377 | command such as: | |
4378 | ||
4379 | @example | |
4380 | print a = b + c | |
4381 | @end example | |
4382 | ||
4383 | @noindent | |
4384 | might not have the effect you intended. In C, this means to add | |
4385 | @code{b} and @code{c} and place the result in @code{a}. The result | |
4386 | printed would be the value of @code{a}. In Modula-2, this means to compare | |
4387 | @code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value. | |
4388 | ||
4389 | If you allow _GDBN__ to set the language automatically, then | |
4390 | you can count on expressions evaluating the same way in your debugging | |
4391 | session and in your program. | |
4392 | ||
4393 | @node Automatically, , Manually, Setting | |
4394 | @subsection Having _GDBN__ infer the source language | |
4395 | ||
4396 | To have _GDBN__ set the working language automatically, use @samp{set | |
4397 | language local} or @samp{set language auto}. _GDBN__ then infers the | |
4398 | language that a program was written in by looking at the name of its | |
4399 | source files, and examining their extensions: | |
4400 | ||
4401 | @table @file | |
4402 | @item *.mod | |
4403 | Modula-2 source file | |
4404 | ||
4405 | @item *.c | |
4406 | @itemx *.cc | |
4407 | C or C++ source file. | |
4408 | @end table | |
4409 | ||
4410 | This information is recorded for each function or procedure in a source | |
4411 | file. When your program stops in a frame (usually by encountering a | |
4412 | breakpoint), _GDBN__ sets the working language to the language recorded | |
4413 | for the function in that frame. If the language for a frame is unknown | |
4414 | (that is, if the function or block corresponding to the frame was | |
4415 | defined in a source file that does not have a recognized extension), the | |
4416 | current working language is not changed, and _GDBN__ issues a warning. | |
4417 | ||
4418 | This may not seem necessary for most programs, which are written | |
4419 | entirely in one source language. However, program modules and libraries | |
4420 | written in one source language can be used by a main program written in | |
4421 | a different source language. Using @samp{set language auto} in this | |
4422 | case frees you from having to set the working language manually. | |
4423 | ||
4424 | @node Show, Checks, Setting, Languages | |
4425 | @section Displaying the language | |
4426 | ||
4427 | The following commands will help you find out which language is the | |
4428 | working language, and also what language source files were written in. | |
4429 | ||
4430 | @kindex show language | |
4431 | @kindex info frame | |
4432 | @kindex info source | |
4433 | @table @code | |
4434 | @item show language | |
4435 | Display the current working language. This is the | |
4436 | language you can use with commands such as @code{print} to | |
29a2b744 | 4437 | build and compute expressions that may involve variables in your program. |
c2bbbb22 RP |
4438 | |
4439 | @item info frame | |
1041a570 | 4440 | Among the other information listed here (@pxref{Frame Info, ,Information |
c2bbbb22 RP |
4441 | about a Frame}) is the source language for this frame. This is the |
4442 | language that will become the working language if you ever use an | |
4443 | identifier that is in this frame. | |
4444 | ||
4445 | @item info source | |
1041a570 | 4446 | Among the other information listed here (@pxref{Symbols, ,Examining the |
c2bbbb22 | 4447 | Symbol Table}) is the source language of this source file. |
c2bbbb22 RP |
4448 | @end table |
4449 | ||
4450 | @node Checks, Support, Show, Languages | |
4451 | @section Type and range Checking | |
4452 | ||
4453 | @quotation | |
4454 | @emph{Warning:} In this release, the _GDBN__ commands for type and range | |
4455 | checking are included, but they do not yet have any effect. This | |
4456 | section documents the intended facilities. | |
4457 | @end quotation | |
4458 | @c FIXME remove warning when type/range code added | |
4459 | ||
4460 | Some languages are designed to guard you against making seemingly common | |
4461 | errors through a series of compile- and run-time checks. These include | |
4462 | checking the type of arguments to functions and operators, and making | |
4463 | sure mathematical overflows are caught at run time. Checks such as | |
4464 | these help to ensure a program's correctness once it has been compiled | |
4465 | by eliminating type mismatches, and providing active checks for range | |
29a2b744 | 4466 | errors when your program is running. |
c2bbbb22 | 4467 | |
1041a570 RP |
4468 | _GDBN__ can check for conditions like the above if you wish. |
4469 | Although _GDBN__ will not check the statements in your program, it | |
4470 | can check expressions entered directly into _GDBN__ for evaluation via | |
4471 | the @code{print} command, for example. As with the working language, | |
c2bbbb22 | 4472 | _GDBN__ can also decide whether or not to check automatically based on |
1041a570 RP |
4473 | your program's source language. @xref{Support, ,Supported Languages}, |
4474 | for the default settings of supported languages. | |
c2bbbb22 RP |
4475 | |
4476 | @menu | |
4477 | * Type Checking:: An overview of type checking | |
4478 | * Range Checking:: An overview of range checking | |
4479 | @end menu | |
4480 | ||
4481 | @cindex type checking | |
4482 | @cindex checks, type | |
4483 | @node Type Checking, Range Checking, Checks, Checks | |
4484 | @subsection An overview of type checking | |
4485 | ||
4486 | Some languages, such as Modula-2, are strongly typed, meaning that the | |
4487 | arguments to operators and functions have to be of the correct type, | |
4488 | otherwise an error occurs. These checks prevent type mismatch | |
4489 | errors from ever causing any run-time problems. For example, | |
4490 | ||
4491 | @example | |
4492 | 1 + 2 @result{} 3 | |
1041a570 | 4493 | @exdent but |
c2bbbb22 RP |
4494 | @error{} 1 + 2.3 |
4495 | @end example | |
4496 | ||
4497 | The second example fails because the @code{CARDINAL} 1 is not | |
4498 | type-compatible with the @code{REAL} 2.3. | |
4499 | ||
4500 | For expressions you use in _GDBN__ commands, you can tell the _GDBN__ | |
4501 | type checker to skip checking; to treat any mismatches as errors and | |
4502 | abandon the expression; or only issue warnings when type mismatches | |
4503 | occur, but evaluate the expression anyway. When you choose the last of | |
4504 | these, _GDBN__ evaluates expressions like the second example above, but | |
4505 | also issues a warning. | |
4506 | ||
4507 | Even though you may turn type checking off, other type-based reasons may | |
4508 | prevent _GDBN__ from evaluating an expression. For instance, _GDBN__ does not | |
4509 | know how to add an @code{int} and a @code{struct foo}. These particular | |
4510 | type errors have nothing to do with the language in use, and usually | |
4511 | arise from expressions, such as the one described above, which make | |
4512 | little sense to evaluate anyway. | |
4513 | ||
4514 | Each language defines to what degree it is strict about type. For | |
4515 | instance, both Modula-2 and C require the arguments to arithmetical | |
4516 | operators to be numbers. In C, enumerated types and pointers can be | |
4517 | represented as numbers, so that they are valid arguments to mathematical | |
1041a570 | 4518 | operators. @xref{Support, ,Supported Languages}, for further |
c2bbbb22 RP |
4519 | details on specific languages. |
4520 | ||
4521 | _GDBN__ provides some additional commands for controlling the type checker: | |
4522 | ||
4523 | @kindex set check | |
4524 | @kindex set check type | |
4525 | @kindex show check type | |
4526 | @table @code | |
4527 | @item set check type auto | |
e251e767 | 4528 | Set type checking on or off based on the current working language. |
1041a570 | 4529 | @xref{Support, ,Supported Languages}, for the default settings for |
c2bbbb22 RP |
4530 | each language. |
4531 | ||
4532 | @item set check type on | |
4533 | @itemx set check type off | |
4534 | Set type checking on or off, overriding the default setting for the | |
4535 | current working language. Issue a warning if the setting does not | |
4536 | match the language's default. If any type mismatches occur in | |
4537 | evaluating an expression while typechecking is on, _GDBN__ prints a | |
4538 | message and aborts evaluation of the expression. | |
4539 | ||
4540 | @item set check type warn | |
4541 | Cause the type checker to issue warnings, but to always attempt to | |
4542 | evaluate the expression. Evaluating the expression may still | |
4543 | be impossible for other reasons. For example, _GDBN__ cannot add | |
4544 | numbers and structures. | |
4545 | ||
4546 | @item show type | |
e251e767 | 4547 | Show the current setting of the type checker, and whether or not _GDBN__ is |
c2bbbb22 RP |
4548 | setting it automatically. |
4549 | @end table | |
4550 | ||
4551 | @cindex range checking | |
4552 | @cindex checks, range | |
4553 | @node Range Checking, , Type Checking, Checks | |
4554 | @subsection An overview of Range Checking | |
4555 | ||
4556 | In some languages (such as Modula-2), it is an error to exceed the | |
4557 | bounds of a type; this is enforced with run-time checks. Such range | |
4558 | checking is meant to ensure program correctness by making sure | |
4559 | computations do not overflow, or indices on an array element access do | |
4560 | not exceed the bounds of the array. | |
4561 | ||
4562 | For expressions you use in _GDBN__ commands, you can tell _GDBN__ to | |
4563 | ignore range errors; to always treat them as errors and abandon the | |
4564 | expression; or to issue warnings when a range error occurs but evaluate | |
4565 | the expression anyway. | |
4566 | ||
4567 | A range error can result from numerical overflow, from exceeding an | |
4568 | array index bound, or when you type in a constant that is not a member | |
4569 | of any type. Some languages, however, do not treat overflows as an | |
4570 | error. In many implementations of C, mathematical overflow causes the | |
4571 | result to ``wrap around'' to lower values---for example, if @var{m} is | |
4572 | the largest integer value, and @var{s} is the smallest, then | |
1041a570 | 4573 | |
c2bbbb22 RP |
4574 | @example |
4575 | @var{m} + 1 @result{} @var{s} | |
4576 | @end example | |
4577 | ||
4578 | This, too, is specific to individual languages, and in some cases | |
1041a570 | 4579 | specific to individual compilers or machines. @xref{Support, , |
c2bbbb22 RP |
4580 | Supported Languages}, for further details on specific languages. |
4581 | ||
4582 | _GDBN__ provides some additional commands for controlling the range checker: | |
4583 | ||
4584 | @kindex set check | |
4585 | @kindex set check range | |
4586 | @kindex show check range | |
4587 | @table @code | |
4588 | @item set check range auto | |
e251e767 | 4589 | Set range checking on or off based on the current working language. |
1041a570 | 4590 | @xref{Support, ,Supported Languages}, for the default settings for |
c2bbbb22 RP |
4591 | each language. |
4592 | ||
4593 | @item set check range on | |
4594 | @itemx set check range off | |
4595 | Set range checking on or off, overriding the default setting for the | |
4596 | current working language. A warning is issued if the setting does not | |
4597 | match the language's default. If a range error occurs, then a message | |
4598 | is printed and evaluation of the expression is aborted. | |
4599 | ||
4600 | @item set check range warn | |
4601 | Output messages when the _GDBN__ range checker detects a range error, | |
4602 | but attempt to evaluate the expression anyway. Evaluating the | |
4603 | expression may still be impossible for other reasons, such as accessing | |
4604 | memory that the process does not own (a typical example from many UNIX | |
4605 | systems). | |
4606 | ||
4607 | @item show range | |
e251e767 | 4608 | Show the current setting of the range checker, and whether or not it is |
c2bbbb22 RP |
4609 | being set automatically by _GDBN__. |
4610 | @end table | |
4611 | ||
4612 | @node Support, , Checks, Languages | |
4613 | @section Supported Languages | |
4614 | ||
1041a570 RP |
4615 | _GDBN__ 4 supports C, C++, and Modula-2. The syntax for C and C++ is so |
4616 | closely related that _GDBN__ does not distinguish the two. Some _GDBN__ | |
4617 | features may be used in expressions regardless of the language you | |
4618 | use: the _GDBN__ @code{@@} and @code{::} operators, and the | |
4619 | @samp{@{type@}addr} construct (@pxref{Expressions, ,Expressions}) can be | |
4620 | used with the constructs of any of the supported languages. | |
c2bbbb22 RP |
4621 | |
4622 | The following sections detail to what degree each of these | |
4623 | source languages is supported by _GDBN__. These sections are | |
4624 | not meant to be language tutorials or references, but serve only as a | |
4625 | reference guide to what the _GDBN__ expression parser will accept, and | |
4626 | what input and output formats should look like for different languages. | |
4627 | There are many good books written on each of these languages; please | |
4628 | look to these for a language reference or tutorial. | |
4629 | ||
4630 | @menu | |
4631 | * C:: C and C++ | |
4632 | * Modula-2:: Modula-2 | |
4633 | @end menu | |
4634 | ||
4635 | @node C, Modula-2, Support, Support | |
4636 | @subsection C and C++ | |
4637 | @cindex C and C++ | |
4638 | ||
4639 | @cindex expressions in C or C++ | |
4640 | Since C and C++ are so closely related, _GDBN__ does not distinguish | |
4641 | between them when interpreting the expressions recognized in _GDBN__ | |
e251e767 | 4642 | commands. |
b80282d5 RP |
4643 | |
4644 | @cindex C++ | |
4645 | @kindex g++ | |
4646 | @cindex GNU C++ | |
c2bbbb22 RP |
4647 | The C++ debugging facilities are jointly implemented by the GNU C++ |
4648 | compiler and _GDBN__. Therefore, to debug your C++ code effectively, | |
4649 | you must compile your C++ programs with the GNU C++ compiler, | |
4650 | @code{g++}. | |
4651 | ||
b80282d5 | 4652 | @menu |
c2bbbb22 RP |
4653 | * C Operators:: C and C++ Operators |
4654 | * C Constants:: C and C++ Constants | |
4655 | * Cplusplus expressions:: C++ Expressions | |
4656 | * C Defaults:: Default settings for C and C++ | |
4657 | * C Checks:: C and C++ Type and Range Checks | |
4658 | * Debugging C:: _GDBN__ and C | |
4659 | * Debugging C plus plus:: Special features for C++ | |
b80282d5 RP |
4660 | @end menu |
4661 | ||
c2bbbb22 RP |
4662 | @cindex C and C++ operators |
4663 | @node C Operators, C Constants, C, C | |
4664 | @subsubsection C and C++ Operators | |
4665 | ||
4666 | Operators must be defined on values of specific types. For instance, | |
4667 | @code{+} is defined on numbers, but not on structures. Operators are | |
4668 | often defined on groups of types. For the purposes of C and C++, the | |
4669 | following definitions hold: | |
4670 | ||
4671 | @itemize @bullet | |
e251e767 | 4672 | @item |
c2bbbb22 RP |
4673 | @emph{Integral types} include @code{int} with any of its storage-class |
4674 | specifiers, @code{char}, and @code{enum}s. | |
4675 | ||
4676 | @item | |
4677 | @emph{Floating-point types} include @code{float} and @code{double}. | |
4678 | ||
4679 | @item | |
4680 | @emph{Pointer types} include all types defined as @code{(@var{type} | |
4681 | *)}. | |
4682 | ||
e251e767 | 4683 | @item |
c2bbbb22 | 4684 | @emph{Scalar types} include all of the above. |
c2bbbb22 RP |
4685 | @end itemize |
4686 | ||
4687 | @noindent | |
4688 | The following operators are supported. They are listed here | |
4689 | in order of increasing precedence: | |
4690 | ||
4691 | @table @code | |
1041a570 | 4692 | _0__@item , |
c2bbbb22 RP |
4693 | The comma or sequencing operator. Expressions in a comma-separated list |
4694 | are evaluated from left to right, with the result of the entire | |
4695 | expression being the last expression evaluated. | |
4696 | ||
4697 | @item = | |
4698 | Assignment. The value of an assignment expression is the value | |
4699 | assigned. Defined on scalar types. | |
4700 | ||
4701 | @item @var{op}= | |
1041a570 RP |
4702 | Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}}, |
4703 | and translated to @w{@code{@var{a} = @var{a op b}}}. | |
4704 | @w{@code{@var{op}=}} and @code{=} have the same precendence. | |
4705 | @var{op} is any one of the operators @code{|}, @code{^}, @code{&}, | |
4706 | @code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}. | |
c2bbbb22 RP |
4707 | |
4708 | @item ?: | |
4709 | The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought | |
4710 | of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an | |
4711 | integral type. | |
4712 | ||
4713 | @item || | |
1041a570 | 4714 | Logical @sc{or}. Defined on integral types. |
c2bbbb22 RP |
4715 | |
4716 | @item && | |
1041a570 | 4717 | Logical @sc{and}. Defined on integral types. |
c2bbbb22 RP |
4718 | |
4719 | @item | | |
1041a570 | 4720 | Bitwise @sc{or}. Defined on integral types. |
c2bbbb22 RP |
4721 | |
4722 | @item ^ | |
1041a570 | 4723 | Bitwise exclusive-@sc{or}. Defined on integral types. |
c2bbbb22 RP |
4724 | |
4725 | @item & | |
1041a570 | 4726 | Bitwise @sc{and}. Defined on integral types. |
c2bbbb22 RP |
4727 | |
4728 | @item ==@r{, }!= | |
4729 | Equality and inequality. Defined on scalar types. The value of these | |
4730 | expressions is 0 for false and non-zero for true. | |
4731 | ||
4732 | @item <@r{, }>@r{, }<=@r{, }>= | |
4733 | Less than, greater than, less than or equal, greater than or equal. | |
4734 | Defined on scalar types. The value of these expressions is 0 for false | |
4735 | and non-zero for true. | |
4736 | ||
4737 | @item <<@r{, }>> | |
4738 | left shift, and right shift. Defined on integral types. | |
4739 | ||
e251e767 | 4740 | @item @@ |
1041a570 | 4741 | The _GDBN__ ``artificial array'' operator (@pxref{Expressions, ,Expressions}). |
c2bbbb22 RP |
4742 | |
4743 | @item +@r{, }- | |
4744 | Addition and subtraction. Defined on integral types, floating-point types and | |
e251e767 | 4745 | pointer types. |
c2bbbb22 RP |
4746 | |
4747 | @item *@r{, }/@r{, }% | |
4748 | Multiplication, division, and modulus. Multiplication and division are | |
4749 | defined on integral and floating-point types. Modulus is defined on | |
4750 | integral types. | |
4751 | ||
4752 | @item ++@r{, }-- | |
4753 | Increment and decrement. When appearing before a variable, the | |
4754 | operation is performed before the variable is used in an expression; | |
4755 | when appearing after it, the variable's value is used before the | |
4756 | operation takes place. | |
4757 | ||
4758 | @item * | |
4759 | Pointer dereferencing. Defined on pointer types. Same precedence as | |
4760 | @code{++}. | |
4761 | ||
4762 | @item & | |
4763 | Address operator. Defined on variables. Same precedence as @code{++}. | |
4764 | ||
6ca72cc6 RP |
4765 | For debugging C++, _GDBN__ implements a use of @samp{&} beyond what's |
4766 | allowed in the C++ language itself: you can use @samp{&(&@var{ref})} | |
4767 | (or, if you prefer, simply @samp{&&@var{ref}} to examine the address | |
4768 | where a C++ reference variable (declared with @samp{&@var{ref}}) is | |
4769 | stored. | |
4770 | ||
c2bbbb22 RP |
4771 | @item - |
4772 | Negative. Defined on integral and floating-point types. Same | |
4773 | precedence as @code{++}. | |
4774 | ||
4775 | @item ! | |
4776 | Logical negation. Defined on integral types. Same precedence as | |
4777 | @code{++}. | |
4778 | ||
4779 | @item ~ | |
4780 | Bitwise complement operator. Defined on integral types. Same precedence as | |
4781 | @code{++}. | |
4782 | ||
4783 | @item .@r{, }-> | |
4784 | Structure member, and pointer-to-structure member. For convenience, | |
4785 | _GDBN__ regards the two as equivalent, choosing whether to dereference a | |
e251e767 | 4786 | pointer based on the stored type information. |
c2bbbb22 RP |
4787 | Defined on @code{struct}s and @code{union}s. |
4788 | ||
4789 | @item [] | |
4790 | Array indexing. @code{@var{a}[@var{i}]} is defined as | |
4791 | @code{*(@var{a}+@var{i})}. Same precedence as @code{->}. | |
4792 | ||
4793 | @item () | |
4794 | Function parameter list. Same precedence as @code{->}. | |
4795 | ||
4796 | @item :: | |
4797 | C++ scope resolution operator. Defined on | |
4798 | @code{struct}, @code{union}, and @code{class} types. | |
4799 | ||
4800 | @item :: | |
1041a570 RP |
4801 | The _GDBN__ scope operator (@pxref{Expressions, ,Expressions}). Same precedence as |
4802 | @code{::}, above._1__ | |
c2bbbb22 RP |
4803 | @end table |
4804 | ||
4805 | @cindex C and C++ constants | |
4806 | @node C Constants, Cplusplus expressions, C Operators, C | |
4807 | @subsubsection C and C++ Constants | |
4808 | ||
4809 | _GDBN__ allows you to express the constants of C and C++ in the | |
4810 | following ways: | |
4811 | ||
4812 | @itemize @bullet | |
c2bbbb22 RP |
4813 | @item |
4814 | Integer constants are a sequence of digits. Octal constants are | |
4815 | specified by a leading @samp{0} (ie. zero), and hexadecimal constants by | |
1041a570 | 4816 | a leading @samp{0x} or @samp{0X}. Constants may also end with a letter |
c2bbbb22 RP |
4817 | @samp{l}, specifying that the constant should be treated as a |
4818 | @code{long} value. | |
4819 | ||
4820 | @item | |
4821 | Floating point constants are a sequence of digits, followed by a decimal | |
4822 | point, followed by a sequence of digits, and optionally followed by an | |
4823 | exponent. An exponent is of the form: | |
4824 | @samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another | |
4825 | sequence of digits. The @samp{+} is optional for positive exponents. | |
4826 | ||
4827 | @item | |
4828 | Enumerated constants consist of enumerated identifiers, or their | |
4829 | integral equivalents. | |
4830 | ||
4831 | @item | |
4832 | Character constants are a single character surrounded by single quotes | |
4833 | (@code{'}), or a number---the ordinal value of the corresponding character | |
4834 | (usually its @sc{ASCII} value). Within quotes, the single character may | |
4835 | be represented by a letter or by @dfn{escape sequences}, which are of | |
4836 | the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation | |
4837 | of the character's ordinal value; or of the form @samp{\@var{x}}, where | |
4838 | @samp{@var{x}} is a predefined special character---for example, | |
4839 | @samp{\n} for newline. | |
4840 | ||
4841 | @item | |
4842 | String constants are a sequence of character constants surrounded | |
4843 | by double quotes (@code{"}). | |
4844 | ||
4845 | @item | |
4846 | Pointer constants are an integral value. | |
c2bbbb22 RP |
4847 | @end itemize |
4848 | ||
c2bbbb22 RP |
4849 | @node Cplusplus expressions, C Defaults, C Constants, C |
4850 | @subsubsection C++ Expressions | |
b80282d5 RP |
4851 | |
4852 | @cindex expressions in C++ | |
c2bbbb22 RP |
4853 | _GDBN__'s expression handling has the following extensions to |
4854 | interpret a significant subset of C++ expressions: | |
b80282d5 RP |
4855 | |
4856 | @enumerate | |
4857 | ||
4858 | @cindex member functions | |
e251e767 | 4859 | @item |
b80282d5 | 4860 | Member function calls are allowed; you can use expressions like |
1041a570 | 4861 | |
b80282d5 RP |
4862 | @example |
4863 | count = aml->GetOriginal(x, y) | |
4864 | @end example | |
4865 | ||
4866 | @kindex this | |
4867 | @cindex namespace in C++ | |
e251e767 | 4868 | @item |
b80282d5 RP |
4869 | While a member function is active (in the selected stack frame), your |
4870 | expressions have the same namespace available as the member function; | |
4871 | that is, _GDBN__ allows implicit references to the class instance | |
4872 | pointer @code{this} following the same rules as C++. | |
4873 | ||
4874 | @cindex call overloaded functions | |
4875 | @cindex type conversions in C++ | |
e251e767 | 4876 | @item |
b80282d5 RP |
4877 | You can call overloaded functions; _GDBN__ will resolve the function |
4878 | call to the right definition, with one restriction---you must use | |
4879 | arguments of the type required by the function that you want to call. | |
4880 | _GDBN__ will not perform conversions requiring constructors or | |
4881 | user-defined type operators. | |
4882 | ||
4883 | @cindex reference declarations | |
4884 | @item | |
4885 | _GDBN__ understands variables declared as C++ references; you can use them in | |
4886 | expressions just as you do in C++ source---they are automatically | |
e251e767 | 4887 | dereferenced. |
b80282d5 RP |
4888 | |
4889 | In the parameter list shown when _GDBN__ displays a frame, the values of | |
4890 | reference variables are not displayed (unlike other variables); this | |
4891 | avoids clutter, since references are often used for large structures. | |
4892 | The @emph{address} of a reference variable is always shown, unless | |
1041a570 | 4893 | you have specified @samp{set print address off}. |
b80282d5 RP |
4894 | |
4895 | @item | |
4896 | _GDBN__ supports the C++ name resolution operator @code{::}---your | |
c2bbbb22 RP |
4897 | expressions can use it just as expressions in your program do. Since |
4898 | one scope may be defined in another, you can use @code{::} repeatedly if | |
4899 | necessary, for example in an expression like | |
4900 | @samp{@var{scope1}::@var{scope2}::@var{name}}. _GDBN__ also allows | |
4901 | resolving name scope by reference to source files, in both C and C++ | |
1041a570 | 4902 | debugging (@pxref{Variables, ,Program Variables}). |
b80282d5 RP |
4903 | @end enumerate |
4904 | ||
c2bbbb22 RP |
4905 | @node C Defaults, C Checks, Cplusplus expressions, C |
4906 | @subsubsection C and C++ Defaults | |
4907 | @cindex C and C++ defaults | |
4908 | ||
e251e767 RP |
4909 | If you allow _GDBN__ to set type and range checking automatically, they |
4910 | both default to @code{off} whenever the working language changes to | |
c2bbbb22 RP |
4911 | C/C++. This happens regardless of whether you, or _GDBN__, |
4912 | selected the working language. | |
4913 | ||
4914 | If you allow _GDBN__ to set the language automatically, it sets the | |
4915 | working language to C/C++ on entering code compiled from a source file | |
4916 | whose name ends with @file{.c} or @file{.cc}. | |
1041a570 | 4917 | @xref{Automatically, ,Having _GDBN__ infer the source language}, for |
c2bbbb22 RP |
4918 | further details. |
4919 | ||
4920 | @node C Checks, Debugging C, C Defaults, C | |
4921 | @subsubsection C and C++ Type and Range Checks | |
4922 | @cindex C and C++ checks | |
4923 | ||
4924 | @quotation | |
4925 | @emph{Warning:} in this release, _GDBN__ does not yet perform type or | |
4926 | range checking. | |
4927 | @end quotation | |
4928 | @c FIXME remove warning when type/range checks added | |
4929 | ||
4930 | By default, when _GDBN__ parses C or C++ expressions, type checking | |
4931 | is not used. However, if you turn type checking on, _GDBN__ will | |
4932 | consider two variables type equivalent if: | |
4933 | ||
4934 | @itemize @bullet | |
4935 | @item | |
4936 | The two variables are structured and have the same structure, union, or | |
4937 | enumerated tag. | |
4938 | ||
e251e767 | 4939 | @item |
c2bbbb22 RP |
4940 | Two two variables have the same type name, or types that have been |
4941 | declared equivalent through @code{typedef}. | |
4942 | ||
4943 | @ignore | |
4944 | @c leaving this out because neither J Gilmore nor R Pesch understand it. | |
4945 | @c FIXME--beers? | |
4946 | @item | |
4947 | The two @code{struct}, @code{union}, or @code{enum} variables are | |
4948 | declared in the same declaration. (Note: this may not be true for all C | |
4949 | compilers.) | |
4950 | @end ignore | |
c2bbbb22 RP |
4951 | @end itemize |
4952 | ||
4953 | Range checking, if turned on, is done on mathematical operations. Array | |
4954 | indices are not checked, since they are often used to index a pointer | |
4955 | that is not itself an array. | |
4956 | ||
4957 | @node Debugging C, Debugging C plus plus, C Checks, C | |
4958 | @subsubsection _GDBN__ and C | |
4959 | ||
4960 | The @code{set print union} and @code{show print union} commands apply to | |
4961 | the @code{union} type. When set to @samp{on}, any @code{union} that is | |
4962 | inside a @code{struct} or @code{class} will also be printed. | |
4963 | Otherwise, it will appear as @samp{@{...@}}. | |
4964 | ||
4965 | The @code{@@} operator aids in the debugging of dynamic arrays, formed | |
1041a570 | 4966 | with pointers and a memory allocation function. (@pxref{Expressions, ,Expressions}) |
c2bbbb22 RP |
4967 | |
4968 | @node Debugging C plus plus, , Debugging C, C | |
4969 | @subsubsection _GDBN__ Commands for C++ | |
b80282d5 RP |
4970 | |
4971 | @cindex commands for C++ | |
4972 | Some _GDBN__ commands are particularly useful with C++, and some are | |
4973 | designed specifically for use with C++. Here is a summary: | |
4974 | ||
4975 | @table @code | |
4976 | @cindex break in overloaded functions | |
4977 | @item @r{breakpoint menus} | |
4978 | When you want a breakpoint in a function whose name is overloaded, | |
4979 | _GDBN__'s breakpoint menus help you specify which function definition | |
4980 | you want. @xref{Breakpoint Menus}. | |
4981 | ||
4982 | @cindex overloading in C++ | |
4983 | @item rbreak @var{regex} | |
4984 | Setting breakpoints using regular expressions is helpful for setting | |
4985 | breakpoints on overloaded functions that are not members of any special | |
e251e767 | 4986 | classes. |
29a2b744 | 4987 | @xref{Set Breaks, ,Setting Breakpoints}. |
b80282d5 RP |
4988 | |
4989 | @cindex C++ exception handling | |
4990 | @item catch @var{exceptions} | |
4991 | @itemx info catch | |
29a2b744 | 4992 | Debug C++ exception handling using these commands. @xref{Exception |
1041a570 | 4993 | Handling, ,Breakpoints and Exceptions}. |
b80282d5 | 4994 | |
e251e767 | 4995 | @cindex inheritance |
b80282d5 RP |
4996 | @item ptype @var{typename} |
4997 | Print inheritance relationships as well as other information for type | |
e251e767 | 4998 | @var{typename}. |
1041a570 | 4999 | @xref{Symbols, ,Examining the Symbol Table}. |
b80282d5 RP |
5000 | |
5001 | @cindex C++ symbol display | |
5002 | @item set print demangle | |
5003 | @itemx show print demangle | |
5004 | @itemx set print asm-demangle | |
5005 | @itemx show print asm-demangle | |
5006 | Control whether C++ symbols display in their source form, both when | |
5007 | displaying code as C++ source and when displaying disassemblies. | |
1041a570 | 5008 | @xref{Print Settings, ,Print Settings}. |
b80282d5 RP |
5009 | |
5010 | @item set print object | |
5011 | @itemx show print object | |
e251e767 | 5012 | Choose whether to print derived (actual) or declared types of objects. |
1041a570 | 5013 | @xref{Print Settings, ,Print Settings}. |
b80282d5 RP |
5014 | |
5015 | @item set print vtbl | |
5016 | @itemx show print vtbl | |
5017 | Control the format for printing virtual function tables. | |
1041a570 | 5018 | @xref{Print Settings, ,Print Settings}. |
b80282d5 RP |
5019 | @end table |
5020 | ||
c2bbbb22 RP |
5021 | @node Modula-2, , C, Support |
5022 | @subsection Modula-2 | |
5023 | @cindex Modula-2 | |
5024 | ||
5025 | The extensions made to _GDBN__ to support Modula-2 support output | |
5026 | from the GNU Modula-2 compiler (which is currently being developed). | |
5027 | Other Modula-2 compilers are not currently supported, and attempting to | |
5028 | debug executables produced by them will most likely result in an error | |
5029 | as _GDBN__ reads in the executable's symbol table. | |
5030 | ||
5031 | @cindex expressions in Modula-2 | |
5032 | @menu | |
5033 | * M2 Operators:: Built-in operators | |
29a2b744 | 5034 | * Built-In Func/Proc:: Built-in Functions and Procedures |
c2bbbb22 RP |
5035 | * M2 Constants:: Modula-2 Constants |
5036 | * M2 Defaults:: Default settings for Modula-2 | |
5037 | * Deviations:: Deviations from standard Modula-2 | |
5038 | * M2 Checks:: Modula-2 Type and Range Checks | |
5039 | * M2 Scope:: The scope operators @code{::} and @code{.} | |
5040 | * GDB/M2:: _GDBN__ and Modula-2 | |
5041 | @end menu | |
5042 | ||
29a2b744 | 5043 | @node M2 Operators, Built-In Func/Proc, Modula-2, Modula-2 |
c2bbbb22 RP |
5044 | @subsubsection Operators |
5045 | @cindex Modula-2 operators | |
5046 | ||
5047 | Operators must be defined on values of specific types. For instance, | |
5048 | @code{+} is defined on numbers, but not on structures. Operators are | |
5049 | often defined on groups of types. For the purposes of Modula-2, the | |
5050 | following definitions hold: | |
5051 | ||
5052 | @itemize @bullet | |
5053 | ||
5054 | @item | |
5055 | @emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and | |
5056 | their subranges. | |
5057 | ||
5058 | @item | |
5059 | @emph{Character types} consist of @code{CHAR} and its subranges. | |
5060 | ||
5061 | @item | |
5062 | @emph{Floating-point types} consist of @code{REAL}. | |
5063 | ||
5064 | @item | |
5065 | @emph{Pointer types} consist of anything declared as @code{POINTER TO | |
5066 | @var{type}}. | |
5067 | ||
5068 | @item | |
5069 | @emph{Scalar types} consist of all of the above. | |
5070 | ||
5071 | @item | |
5072 | @emph{Set types} consist of @code{SET}s and @code{BITSET}s. | |
5073 | ||
5074 | @item | |
5075 | @emph{Boolean types} consist of @code{BOOLEAN}. | |
c2bbbb22 RP |
5076 | @end itemize |
5077 | ||
5078 | @noindent | |
5079 | The following operators are supported, and appear in order of | |
5080 | increasing precedence: | |
5081 | ||
5082 | @table @code | |
c2bbbb22 RP |
5083 | @item , |
5084 | Function argument or array index separator. | |
1041a570 | 5085 | _0__ |
c2bbbb22 RP |
5086 | @item := |
5087 | Assignment. The value of @var{var} @code{:=} @var{value} is | |
5088 | @var{value}. | |
5089 | ||
5090 | @item <@r{, }> | |
5091 | Less than, greater than on integral, floating-point, or enumerated | |
5092 | types. | |
5093 | ||
5094 | @item <=@r{, }>= | |
5095 | Less than, greater than, less than or equal to, greater than or equal to | |
5096 | on integral, floating-point and enumerated types, or set inclusion on | |
5097 | set types. Same precedence as @code{<}. | |
5098 | ||
5099 | @item =@r{, }<>@r{, }# | |
5100 | Equality and two ways of expressing inequality, valid on scalar types. | |
5101 | Same precedence as @code{<}. In _GDBN__ scripts, only @code{<>} is | |
5102 | available for inequality, since @code{#} conflicts with the script | |
5103 | comment character. | |
5104 | ||
5105 | @item IN | |
5106 | Set membership. Defined on set types and the types of their members. | |
5107 | Same precedence as @code{<}. | |
5108 | ||
5109 | @item OR | |
5110 | Boolean disjunction. Defined on boolean types. | |
5111 | ||
5112 | @item AND@r{, }& | |
5113 | Boolean conjuction. Defined on boolean types. | |
5114 | ||
5115 | @item @@ | |
1041a570 | 5116 | The _GDBN__ ``artificial array'' operator (@pxref{Expressions, ,Expressions}). |
c2bbbb22 RP |
5117 | |
5118 | @item +@r{, }- | |
5119 | Addition and subtraction on integral and floating-point types, or union | |
5120 | and difference on set types. | |
5121 | ||
5122 | @item * | |
5123 | Multiplication on integral and floating-point types, or set intersection | |
5124 | on set types. | |
5125 | ||
5126 | @item / | |
5127 | Division on floating-point types, or symmetric set difference on set | |
5128 | types. Same precedence as @code{*}. | |
5129 | ||
5130 | @item DIV@r{, }MOD | |
5131 | Integer division and remainder. Defined on integral types. Same | |
5132 | precedence as @code{*}. | |
5133 | ||
5134 | @item - | |
5135 | Negative. Defined on @code{INTEGER}s and @code{REAL}s. | |
5136 | ||
5137 | @item ^ | |
e251e767 | 5138 | Pointer dereferencing. Defined on pointer types. |
c2bbbb22 RP |
5139 | |
5140 | @item NOT | |
5141 | Boolean negation. Defined on boolean types. Same precedence as | |
5142 | @code{^}. | |
5143 | ||
5144 | @item . | |
5145 | @code{RECORD} field selector. Defined on @code{RECORD}s. Same | |
5146 | precedence as @code{^}. | |
5147 | ||
5148 | @item [] | |
5149 | Array indexing. Defined on @code{ARRAY}s. Same precedence as @code{^}. | |
5150 | ||
5151 | @item () | |
5152 | Procedure argument list. Defined on @code{PROCEDURE}s. Same precedence | |
5153 | as @code{^}. | |
5154 | ||
5155 | @item ::@r{, }. | |
5156 | _GDBN__ and Modula-2 scope operators. | |
c2bbbb22 RP |
5157 | @end table |
5158 | ||
5159 | @quotation | |
5160 | @emph{Warning:} Sets and their operations are not yet supported, so _GDBN__ | |
5161 | will treat the use of the operator @code{IN}, or the use of operators | |
5162 | @code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#}, | |
5163 | @code{<=}, and @code{>=} on sets as an error. | |
5164 | @end quotation | |
5165 | _1__ | |
29a2b744 RP |
5166 | @cindex Modula-2 built-ins |
5167 | @node Built-In Func/Proc, M2 Constants, M2 Operators, Modula-2 | |
c2bbbb22 RP |
5168 | @subsubsection Built-in Functions and Procedures |
5169 | ||
5170 | Modula-2 also makes available several built-in procedures and functions. | |
5171 | In describing these, the following metavariables are used: | |
5172 | ||
5173 | @table @var | |
5174 | ||
5175 | @item a | |
5176 | represents an @code{ARRAY} variable. | |
5177 | ||
5178 | @item c | |
5179 | represents a @code{CHAR} constant or variable. | |
5180 | ||
5181 | @item i | |
5182 | represents a variable or constant of integral type. | |
5183 | ||
5184 | @item m | |
5185 | represents an identifier that belongs to a set. Generally used in the | |
5186 | same function with the metavariable @var{s}. The type of @var{s} should | |
5187 | be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}. | |
5188 | ||
5189 | @item n | |
5190 | represents a variable or constant of integral or floating-point type. | |
5191 | ||
5192 | @item r | |
5193 | represents a variable or constant of floating-point type. | |
5194 | ||
5195 | @item t | |
5196 | represents a type. | |
5197 | ||
5198 | @item v | |
5199 | represents a variable. | |
5200 | ||
5201 | @item x | |
5202 | represents a variable or constant of one of many types. See the | |
5203 | explanation of the function for details. | |
c2bbbb22 RP |
5204 | @end table |
5205 | ||
5206 | All Modula-2 built-in procedures also return a result, described below. | |
5207 | ||
5208 | @table @code | |
5209 | @item ABS(@var{n}) | |
5210 | Returns the absolute value of @var{n}. | |
5211 | ||
5212 | @item CAP(@var{c}) | |
5213 | If @var{c} is a lower case letter, it returns its upper case | |
5214 | equivalent, otherwise it returns its argument | |
5215 | ||
5216 | @item CHR(@var{i}) | |
5217 | Returns the character whose ordinal value is @var{i}. | |
5218 | ||
5219 | @item DEC(@var{v}) | |
5220 | Decrements the value in the variable @var{v}. Returns the new value. | |
5221 | ||
5222 | @item DEC(@var{v},@var{i}) | |
5223 | Decrements the value in the variable @var{v} by @var{i}. Returns the | |
5224 | new value. | |
5225 | ||
5226 | @item EXCL(@var{m},@var{s}) | |
5227 | Removes the element @var{m} from the set @var{s}. Returns the new | |
5228 | set. | |
5229 | ||
5230 | @item FLOAT(@var{i}) | |
5231 | Returns the floating point equivalent of the integer @var{i}. | |
5232 | ||
5233 | @item HIGH(@var{a}) | |
5234 | Returns the index of the last member of @var{a}. | |
5235 | ||
5236 | @item INC(@var{v}) | |
5237 | Increments the value in the variable @var{v}. Returns the new value. | |
5238 | ||
5239 | @item INC(@var{v},@var{i}) | |
5240 | Increments the value in the variable @var{v} by @var{i}. Returns the | |
5241 | new value. | |
5242 | ||
5243 | @item INCL(@var{m},@var{s}) | |
5244 | Adds the element @var{m} to the set @var{s} if it is not already | |
5245 | there. Returns the new set. | |
5246 | ||
5247 | @item MAX(@var{t}) | |
5248 | Returns the maximum value of the type @var{t}. | |
5249 | ||
5250 | @item MIN(@var{t}) | |
5251 | Returns the minimum value of the type @var{t}. | |
5252 | ||
5253 | @item ODD(@var{i}) | |
5254 | Returns boolean TRUE if @var{i} is an odd number. | |
5255 | ||
5256 | @item ORD(@var{x}) | |
5257 | Returns the ordinal value of its argument. For example, the ordinal | |
5258 | value of a character is its ASCII value (on machines supporting the | |
5259 | ASCII character set). @var{x} must be of an ordered type, which include | |
5260 | integral, character and enumerated types. | |
5261 | ||
5262 | @item SIZE(@var{x}) | |
5263 | Returns the size of its argument. @var{x} can be a variable or a type. | |
5264 | ||
5265 | @item TRUNC(@var{r}) | |
5266 | Returns the integral part of @var{r}. | |
5267 | ||
5268 | @item VAL(@var{t},@var{i}) | |
5269 | Returns the member of the type @var{t} whose ordinal value is @var{i}. | |
5270 | @end table | |
5271 | ||
5272 | @quotation | |
5273 | @emph{Warning:} Sets and their operations are not yet supported, so | |
5274 | _GDBN__ will treat the use of procedures @code{INCL} and @code{EXCL} as | |
5275 | an error. | |
5276 | @end quotation | |
5277 | ||
5278 | @cindex Modula-2 constants | |
29a2b744 | 5279 | @node M2 Constants, M2 Defaults, Built-In Func/Proc, Modula-2 |
c2bbbb22 RP |
5280 | @subsubsection Constants |
5281 | ||
5282 | _GDBN__ allows you to express the constants of Modula-2 in the following | |
5283 | ways: | |
5284 | ||
5285 | @itemize @bullet | |
5286 | ||
5287 | @item | |
5288 | Integer constants are simply a sequence of digits. When used in an | |
5289 | expression, a constant is interpreted to be type-compatible with the | |
5290 | rest of the expression. Hexadecimal integers are specified by a | |
5291 | trailing @samp{H}, and octal integers by a trailing @samp{B}. | |
5292 | ||
5293 | @item | |
5294 | Floating point constants appear as a sequence of digits, followed by a | |
5295 | decimal point and another sequence of digits. An optional exponent can | |
5296 | then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where | |
5297 | @samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the | |
5298 | digits of the floating point constant must be valid decimal (base 10) | |
5299 | digits. | |
5300 | ||
5301 | @item | |
5302 | Character constants consist of a single character enclosed by a pair of | |
5303 | like quotes, either single (@code{'}) or double (@code{"}). They may | |
5304 | also be expressed by their ordinal value (their ASCII value, usually) | |
5305 | followed by a @samp{C}. | |
5306 | ||
5307 | @item | |
1041a570 RP |
5308 | String constants consist of a sequence of characters enclosed by a |
5309 | pair of like quotes, either single (@code{'}) or double (@code{"}). | |
5310 | Escape sequences in the style of C are also allowed. @xref{C | |
5311 | Constants, ,C and C++ Constants}, for a brief explanation of escape | |
5312 | sequences. | |
c2bbbb22 RP |
5313 | |
5314 | @item | |
5315 | Enumerated constants consist of an enumerated identifier. | |
5316 | ||
5317 | @item | |
5318 | Boolean constants consist of the identifiers @code{TRUE} and | |
5319 | @code{FALSE}. | |
5320 | ||
5321 | @item | |
5322 | Pointer constants consist of integral values only. | |
5323 | ||
5324 | @item | |
5325 | Set constants are not yet supported. | |
c2bbbb22 RP |
5326 | @end itemize |
5327 | ||
5328 | @node M2 Defaults, Deviations, M2 Constants, Modula-2 | |
5329 | @subsubsection Modula-2 Defaults | |
5330 | @cindex Modula-2 defaults | |
5331 | ||
e251e767 RP |
5332 | If type and range checking are set automatically by _GDBN__, they |
5333 | both default to @code{on} whenever the working language changes to | |
c2bbbb22 RP |
5334 | Modula-2. This happens regardless of whether you, or _GDBN__, |
5335 | selected the working language. | |
5336 | ||
5337 | If you allow _GDBN__ to set the language automatically, then entering | |
5338 | code compiled from a file whose name ends with @file{.mod} will set the | |
1041a570 | 5339 | working language to Modula-2. @xref{Automatically, ,Having _GDBN__ set |
c2bbbb22 RP |
5340 | the language automatically}, for further details. |
5341 | ||
5342 | @node Deviations, M2 Checks, M2 Defaults, Modula-2 | |
5343 | @subsubsection Deviations from Standard Modula-2 | |
5344 | @cindex Modula-2, deviations from | |
5345 | ||
5346 | A few changes have been made to make Modula-2 programs easier to debug. | |
5347 | This is done primarily via loosening its type strictness: | |
5348 | ||
5349 | @itemize @bullet | |
e251e767 | 5350 | @item |
c2bbbb22 RP |
5351 | Unlike in standard Modula-2, pointer constants can be formed by |
5352 | integers. This allows you to modify pointer variables during | |
5353 | debugging. (In standard Modula-2, the actual address contained in a | |
5354 | pointer variable is hidden from you; it can only be modified | |
5355 | through direct assignment to another pointer variable or expression that | |
5356 | returned a pointer.) | |
5357 | ||
e251e767 | 5358 | @item |
c2bbbb22 RP |
5359 | C escape sequences can be used in strings and characters to represent |
5360 | non-printable characters. _GDBN__ will print out strings with these | |
5361 | escape sequences embedded. Single non-printable characters are | |
5362 | printed using the @samp{CHR(@var{nnn})} format. | |
5363 | ||
5364 | @item | |
5365 | The assignment operator (@code{:=}) returns the value of its right-hand | |
5366 | argument. | |
5367 | ||
5368 | @item | |
29a2b744 | 5369 | All built-in procedures both modify @emph{and} return their argument. |
e251e767 | 5370 | @end itemize |
c2bbbb22 RP |
5371 | |
5372 | @node M2 Checks, M2 Scope, Deviations, Modula-2 | |
5373 | @subsubsection Modula-2 Type and Range Checks | |
5374 | @cindex Modula-2 checks | |
5375 | ||
5376 | @quotation | |
5377 | @emph{Warning:} in this release, _GDBN__ does not yet perform type or | |
5378 | range checking. | |
5379 | @end quotation | |
5380 | @c FIXME remove warning when type/range checks added | |
5381 | ||
5382 | _GDBN__ considers two Modula-2 variables type equivalent if: | |
5383 | ||
5384 | @itemize @bullet | |
5385 | @item | |
5386 | They are of types that have been declared equivalent via a @code{TYPE | |
5387 | @var{t1} = @var{t2}} statement | |
5388 | ||
5389 | @item | |
5390 | They have been declared on the same line. (Note: This is true of the | |
5391 | GNU Modula-2 compiler, but it may not be true of other compilers.) | |
c2bbbb22 RP |
5392 | @end itemize |
5393 | ||
5394 | As long as type checking is enabled, any attempt to combine variables | |
5395 | whose types are not equivalent is an error. | |
5396 | ||
5397 | Range checking is done on all mathematical operations, assignment, array | |
29a2b744 | 5398 | index bounds, and all built-in functions and procedures. |
c2bbbb22 RP |
5399 | |
5400 | @node M2 Scope, GDB/M2, M2 Checks, Modula-2 | |
5401 | @subsubsection The scope operators @code{::} and @code{.} | |
5402 | @cindex scope | |
5403 | @kindex . | |
e94b4a2b | 5404 | @cindex colon, doubled as scope operator |
1041a570 RP |
5405 | @ifinfo |
5406 | @kindex colon-colon | |
5407 | @c Info cannot handoe :: but TeX can. | |
5408 | @end ifinfo | |
5409 | @iftex | |
c2bbbb22 | 5410 | @kindex :: |
1041a570 | 5411 | @end iftex |
c2bbbb22 RP |
5412 | |
5413 | There are a few subtle differences between the Modula-2 scope operator | |
5414 | (@code{.}) and the _GDBN__ scope operator (@code{::}). The two have | |
5415 | similar syntax: | |
5416 | ||
5417 | @example | |
5418 | ||
5419 | @var{module} . @var{id} | |
5420 | @var{scope} :: @var{id} | |
c2bbbb22 RP |
5421 | @end example |
5422 | ||
5423 | @noindent | |
5424 | where @var{scope} is the name of a module or a procedure, | |
29a2b744 RP |
5425 | @var{module} the name of a module, and @var{id} is any declared |
5426 | identifier within your program, except another module. | |
c2bbbb22 RP |
5427 | |
5428 | Using the @code{::} operator makes _GDBN__ search the scope | |
5429 | specified by @var{scope} for the identifier @var{id}. If it is not | |
5430 | found in the specified scope, then _GDBN__ will search all scopes | |
5431 | enclosing the one specified by @var{scope}. | |
5432 | ||
5433 | Using the @code{.} operator makes _GDBN__ search the current scope for | |
5434 | the identifier specified by @var{id} that was imported from the | |
5435 | definition module specified by @var{module}. With this operator, it is | |
5436 | an error if the identifier @var{id} was not imported from definition | |
5437 | module @var{module}, or if @var{id} is not an identifier in | |
5438 | @var{module}. | |
5439 | ||
5440 | @node GDB/M2, , M2 Scope, Modula-2 | |
5441 | @subsubsection _GDBN__ and Modula-2 | |
5442 | ||
5443 | Some _GDBN__ commands have little use when debugging Modula-2 programs. | |
5444 | Five subcommands of @code{set print} and @code{show print} apply | |
5445 | specifically to C and C++: @samp{vtbl}, @samp{demangle}, | |
5446 | @samp{asm-demangle}, @samp{object}, and @samp{union}. The first four | |
5447 | apply to C++, and the last to C's @code{union} type, which has no direct | |
5448 | analogue in Modula-2. | |
5449 | ||
1041a570 | 5450 | The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available |
c2bbbb22 RP |
5451 | while using any language, is not useful with Modula-2. Its |
5452 | intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be | |
5453 | created in Modula-2 as they can in C or C++. However, because an | |
5454 | address can be specified by an integral constant, the construct | |
1041a570 | 5455 | @samp{@{@var{type}@}@var{adrexp}} is still useful. (@pxref{Expressions, ,Expressions}) |
c2bbbb22 RP |
5456 | _0__ |
5457 | @cindex @code{#} in Modula-2 | |
5458 | In _GDBN__ scripts, the Modula-2 inequality operator @code{#} is | |
5459 | interpreted as the beginning of a comment. Use @code{<>} instead. | |
5460 | _1__ | |
c2bbbb22 | 5461 | @node Symbols, Altering, Languages, Top |
70b88761 RP |
5462 | @chapter Examining the Symbol Table |
5463 | ||
5464 | The commands described in this section allow you to inquire about the | |
5465 | symbols (names of variables, functions and types) defined in your | |
5466 | program. This information is inherent in the text of your program and | |
29a2b744 | 5467 | does not change as your program executes. _GDBN__ finds it in your |
e251e767 | 5468 | program's symbol table, in the file indicated when you started _GDBN__ |
1041a570 RP |
5469 | (@pxref{File Options, ,Choosing Files}), or by one of the |
5470 | file-management commands (@pxref{Files, ,Commands to Specify Files}). | |
70b88761 RP |
5471 | |
5472 | @table @code | |
5473 | @item info address @var{symbol} | |
5474 | @kindex info address | |
5475 | Describe where the data for @var{symbol} is stored. For a register | |
5476 | variable, this says which register it is kept in. For a non-register | |
5477 | local variable, this prints the stack-frame offset at which the variable | |
5478 | is always stored. | |
5479 | ||
5480 | Note the contrast with @samp{print &@var{symbol}}, which does not work | |
5481 | at all for a register variables, and for a stack local variable prints | |
5482 | the exact address of the current instantiation of the variable. | |
5483 | ||
5484 | @item whatis @var{exp} | |
5485 | @kindex whatis | |
5486 | Print the data type of expression @var{exp}. @var{exp} is not | |
5487 | actually evaluated, and any side-effecting operations (such as | |
5488 | assignments or function calls) inside it do not take place. | |
1041a570 | 5489 | @xref{Expressions, ,Expressions}. |
70b88761 RP |
5490 | |
5491 | @item whatis | |
5492 | Print the data type of @code{$}, the last value in the value history. | |
5493 | ||
5494 | @item ptype @var{typename} | |
5495 | @kindex ptype | |
5496 | Print a description of data type @var{typename}. @var{typename} may be | |
5497 | the name of a type, or for C code it may have the form | |
5498 | @samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or | |
1041a570 | 5499 | @samp{enum @var{enum-tag}}. |
70b88761 RP |
5500 | |
5501 | @item ptype @var{exp} | |
e0dacfd1 | 5502 | @itemx ptype |
70b88761 | 5503 | Print a description of the type of expression @var{exp}. @code{ptype} |
1041a570 RP |
5504 | differs from @code{whatis} by printing a detailed description, instead |
5505 | of just the name of the type. For example, if your program declares a | |
5506 | variable as | |
5507 | ||
70b88761 RP |
5508 | @example |
5509 | struct complex @{double real; double imag;@} v; | |
5510 | @end example | |
1041a570 | 5511 | |
70b88761 RP |
5512 | @noindent |
5513 | compare the output of the two commands: | |
1041a570 | 5514 | |
70b88761 | 5515 | @example |
1041a570 | 5516 | @group |
70b88761 RP |
5517 | (_GDBP__) whatis v |
5518 | type = struct complex | |
5519 | (_GDBP__) ptype v | |
5520 | type = struct complex @{ | |
5521 | double real; | |
5522 | double imag; | |
5523 | @} | |
1041a570 | 5524 | @end group |
70b88761 | 5525 | @end example |
1041a570 | 5526 | |
e0dacfd1 RP |
5527 | @noindent |
5528 | As with @code{whatis}, using @code{ptype} without an argument refers to | |
5529 | the type of @code{$}, the last value in the value history. | |
70b88761 RP |
5530 | |
5531 | @item info types @var{regexp} | |
5532 | @itemx info types | |
e251e767 | 5533 | @kindex info types |
70b88761 RP |
5534 | Print a brief description of all types whose name matches @var{regexp} |
5535 | (or all types in your program, if you supply no argument). Each | |
5536 | complete typename is matched as though it were a complete line; thus, | |
5537 | @samp{i type value} gives information on all types in your program whose | |
5538 | name includes the string @code{value}, but @samp{i type ^value$} gives | |
5539 | information only on types whose complete name is @code{value}. | |
5540 | ||
5541 | This command differs from @code{ptype} in two ways: first, like | |
5542 | @code{whatis}, it does not print a detailed description; second, it | |
5543 | lists all source files where a type is defined. | |
5544 | ||
5545 | @item info source | |
5546 | @kindex info source | |
5547 | Show the name of the current source file---that is, the source file for | |
c2bbbb22 RP |
5548 | the function containing the current point of execution---and the language |
5549 | it was written in. | |
70b88761 RP |
5550 | |
5551 | @item info sources | |
5552 | @kindex info sources | |
29a2b744 | 5553 | Print the names of all source files in your program for which there is |
b80282d5 RP |
5554 | debugging information, organized into two lists: files whose symbols |
5555 | have already been read, and files whose symbols will be read when needed. | |
70b88761 RP |
5556 | |
5557 | @item info functions | |
5558 | @kindex info functions | |
5559 | Print the names and data types of all defined functions. | |
5560 | ||
5561 | @item info functions @var{regexp} | |
5562 | Print the names and data types of all defined functions | |
5563 | whose names contain a match for regular expression @var{regexp}. | |
5564 | Thus, @samp{info fun step} finds all functions whose names | |
5565 | include @code{step}; @samp{info fun ^step} finds those whose names | |
5566 | start with @code{step}. | |
5567 | ||
5568 | @item info variables | |
5569 | @kindex info variables | |
5570 | Print the names and data types of all variables that are declared | |
5571 | outside of functions (i.e., excluding local variables). | |
5572 | ||
5573 | @item info variables @var{regexp} | |
5574 | Print the names and data types of all variables (except for local | |
5575 | variables) whose names contain a match for regular expression | |
5576 | @var{regexp}. | |
5577 | ||
70b88761 RP |
5578 | @ignore |
5579 | This was never implemented. | |
5580 | @item info methods | |
5581 | @itemx info methods @var{regexp} | |
5582 | @kindex info methods | |
5583 | The @code{info methods} command permits the user to examine all defined | |
5584 | methods within C++ program, or (with the @var{regexp} argument) a | |
5585 | specific set of methods found in the various C++ classes. Many | |
5586 | C++ classes provide a large number of methods. Thus, the output | |
5587 | from the @code{ptype} command can be overwhelming and hard to use. The | |
5588 | @code{info-methods} command filters the methods, printing only those | |
5589 | which match the regular-expression @var{regexp}. | |
5590 | @end ignore | |
5591 | ||
5592 | @item printsyms @var{filename} | |
440d9834 | 5593 | @itemx printpsyms @var{filename} |
d24e0922 | 5594 | @itemx printmsyms @var{filename} |
70b88761 | 5595 | @kindex printsyms |
440d9834 RP |
5596 | @cindex symbol dump |
5597 | @kindex printsyms | |
5598 | @cindex partial symbol dump | |
5599 | Write a dump of debugging symbol data into the file @var{filename}. | |
e0dacfd1 RP |
5600 | These commands are used to debug the _GDBN__ symbol-reading code. Only |
5601 | symbols with debugging data are included. If you use @code{printsyms}, | |
5602 | _GDBN__ includes all the symbols for which it has already collected full | |
5603 | details: that is, @var{filename} reflects symbols for only those files | |
5604 | whose symbols _GDBN__ has read. You can use the command @code{info | |
5605 | sources} to find out which files these are. If you use | |
d24e0922 | 5606 | @code{printpsyms} instead, the dump shows information about symbols that |
e0dacfd1 | 5607 | _GDBN__ only knows partially---that is, symbols defined in files that |
d24e0922 RP |
5608 | _GDBN__ has skimmed, but not yet read completely. Finally, |
5609 | @code{printmsyms} dumos just the minimal symbol information required for | |
5610 | each object file from which _GDBN__ has read some symbols. The description of | |
5611 | @code{symbol-file} explains how _GDBN__ reads symbols; both @code{info | |
5612 | source} and @code{symbol-file} are described in @ref{Files, ,Commands | |
5613 | to Specify Files}. | |
70b88761 RP |
5614 | @end table |
5615 | ||
5616 | @node Altering, _GDBN__ Files, Symbols, Top | |
5617 | @chapter Altering Execution | |
5618 | ||
29a2b744 | 5619 | Once you think you have found an error in your program, you might want to |
70b88761 RP |
5620 | find out for certain whether correcting the apparent error would lead to |
5621 | correct results in the rest of the run. You can find the answer by | |
5622 | experiment, using the _GDBN__ features for altering execution of the | |
5623 | program. | |
5624 | ||
5625 | For example, you can store new values into variables or memory | |
29a2b744 | 5626 | locations, give your program a signal, restart it at a different address, |
70b88761 RP |
5627 | or even return prematurely from a function to its caller. |
5628 | ||
5629 | @menu | |
b80282d5 RP |
5630 | * Assignment:: Assignment to Variables |
5631 | * Jumping:: Continuing at a Different Address | |
29a2b744 | 5632 | * Signaling:: Giving your program a Signal |
b80282d5 RP |
5633 | * Returning:: Returning from a Function |
5634 | * Calling:: Calling your Program's Functions | |
c338a2fd | 5635 | * Patching:: Patching your Program |
70b88761 RP |
5636 | @end menu |
5637 | ||
5638 | @node Assignment, Jumping, Altering, Altering | |
5639 | @section Assignment to Variables | |
5640 | ||
5641 | @cindex assignment | |
5642 | @cindex setting variables | |
5643 | To alter the value of a variable, evaluate an assignment expression. | |
1041a570 | 5644 | @xref{Expressions, ,Expressions}. For example, |
70b88761 RP |
5645 | |
5646 | @example | |
5647 | print x=4 | |
5648 | @end example | |
5649 | ||
5650 | @noindent | |
1041a570 RP |
5651 | stores the value 4 into the variable @code{x}, and then prints the |
5652 | value of the assignment expression (which is 4). @xref{Languages, | |
5653 | ,Using _GDBN__ with Different Languages}, for more information on | |
5654 | operators in supported languages. | |
70b88761 | 5655 | |
70b88761 RP |
5656 | @kindex set variable |
5657 | @cindex variables, setting | |
5658 | If you are not interested in seeing the value of the assignment, use the | |
5659 | @code{set} command instead of the @code{print} command. @code{set} is | |
5660 | really the same as @code{print} except that the expression's value is not | |
1041a570 | 5661 | printed and is not put in the value history (@pxref{Value History, ,Value History}). The |
70b88761 RP |
5662 | expression is evaluated only for its effects. |
5663 | ||
5664 | If the beginning of the argument string of the @code{set} command | |
5665 | appears identical to a @code{set} subcommand, use the @code{set | |
5666 | variable} command instead of just @code{set}. This command is identical | |
5667 | to @code{set} except for its lack of subcommands. For example, a | |
5668 | program might well have a variable @code{width}---which leads to | |
5669 | an error if we try to set a new value with just @samp{set width=13}, as | |
1041a570 RP |
5670 | we might if @code{set width} did not happen to be a _GDBN__ command: |
5671 | ||
70b88761 RP |
5672 | @example |
5673 | (_GDBP__) whatis width | |
5674 | type = double | |
5675 | (_GDBP__) p width | |
5676 | $4 = 13 | |
5677 | (_GDBP__) set width=47 | |
5678 | Invalid syntax in expression. | |
5679 | @end example | |
1041a570 | 5680 | |
70b88761 RP |
5681 | @noindent |
5682 | The invalid expression, of course, is @samp{=47}. What we can do in | |
e251e767 | 5683 | order to actually set our program's variable @code{width} is |
1041a570 | 5684 | |
70b88761 RP |
5685 | @example |
5686 | (_GDBP__) set var width=47 | |
5687 | @end example | |
5688 | ||
1041a570 RP |
5689 | _GDBN__ allows more implicit conversions in assignments than C; you can |
5690 | freely store an integer value into a pointer variable or vice versa, | |
5691 | and any structure can be converted to any other structure that is the | |
5692 | same length or shorter. | |
e251e767 | 5693 | @comment FIXME: how do structs align/pad in these conversions? |
70b88761 RP |
5694 | @comment /[email protected] 18dec1990 |
5695 | ||
5696 | To store values into arbitrary places in memory, use the @samp{@{@dots{}@}} | |
5697 | construct to generate a value of specified type at a specified address | |
1041a570 | 5698 | (@pxref{Expressions, ,Expressions}). For example, @code{@{int@}0x83040} refers |
70b88761 RP |
5699 | to memory location @code{0x83040} as an integer (which implies a certain size |
5700 | and representation in memory), and | |
5701 | ||
5702 | @example | |
5703 | set @{int@}0x83040 = 4 | |
5704 | @end example | |
5705 | ||
5706 | @noindent | |
5707 | stores the value 4 into that memory location. | |
5708 | ||
5709 | @node Jumping, Signaling, Assignment, Altering | |
5710 | @section Continuing at a Different Address | |
5711 | ||
29a2b744 | 5712 | Ordinarily, when you continue your program, you do so at the place where |
70b88761 RP |
5713 | it stopped, with the @code{continue} command. You can instead continue at |
5714 | an address of your own choosing, with the following commands: | |
5715 | ||
5716 | @table @code | |
5717 | @item jump @var{linespec} | |
5718 | @kindex jump | |
5719 | Resume execution at line @var{linespec}. Execution will stop | |
29a2b744 RP |
5720 | immediately if there is a breakpoint there. @xref{List, ,Printing |
5721 | Source Lines}, for a description of the different forms of | |
5722 | @var{linespec}. | |
70b88761 RP |
5723 | |
5724 | The @code{jump} command does not change the current stack frame, or | |
5725 | the stack pointer, or the contents of any memory location or any | |
5726 | register other than the program counter. If line @var{linespec} is in | |
5727 | a different function from the one currently executing, the results may | |
5728 | be bizarre if the two functions expect different patterns of arguments or | |
5729 | of local variables. For this reason, the @code{jump} command requests | |
5730 | confirmation if the specified line is not in the function currently | |
5731 | executing. However, even bizarre results are predictable if you are | |
29a2b744 | 5732 | well acquainted with the machine-language code of your program. |
70b88761 RP |
5733 | |
5734 | @item jump *@var{address} | |
5735 | Resume execution at the instruction at address @var{address}. | |
5736 | @end table | |
5737 | ||
5738 | You can get much the same effect as the @code{jump} command by storing a | |
5739 | new value into the register @code{$pc}. The difference is that this | |
29a2b744 | 5740 | does not start your program running; it only changes the address where it |
70b88761 RP |
5741 | @emph{will} run when it is continued. For example, |
5742 | ||
5743 | @example | |
5744 | set $pc = 0x485 | |
5745 | @end example | |
5746 | ||
5747 | @noindent | |
5748 | causes the next @code{continue} command or stepping command to execute at | |
1041a570 RP |
5749 | address @code{0x485}, rather than at the address where your program stopped. |
5750 | @xref{Continuing and Stepping, ,Continuing and Stepping}. | |
70b88761 RP |
5751 | |
5752 | The most common occasion to use the @code{jump} command is to back up, | |
5753 | perhaps with more breakpoints set, over a portion of a program that has | |
5754 | already executed, in order to examine its execution in more detail. | |
5755 | ||
5756 | @node Signaling, Returning, Jumping, Altering | |
5757 | @c @group | |
29a2b744 | 5758 | @section Giving your program a Signal |
70b88761 RP |
5759 | |
5760 | @table @code | |
5761 | @item signal @var{signalnum} | |
5762 | @kindex signal | |
29a2b744 | 5763 | Resume execution where your program stopped, but give it immediately the |
70b88761 RP |
5764 | signal number @var{signalnum}. |
5765 | ||
5766 | Alternatively, if @var{signalnum} is zero, continue execution without | |
29a2b744 | 5767 | giving a signal. This is useful when your program stopped on account of |
70b88761 RP |
5768 | a signal and would ordinary see the signal when resumed with the |
5769 | @code{continue} command; @samp{signal 0} causes it to resume without a | |
5770 | signal. | |
5771 | ||
5772 | @code{signal} does not repeat when you press @key{RET} a second time | |
5773 | after executing the command. | |
5774 | @end table | |
5775 | @c @end group | |
5776 | ||
5777 | @node Returning, Calling, Signaling, Altering | |
5778 | @section Returning from a Function | |
5779 | ||
5780 | @table @code | |
5781 | @item return | |
5782 | @itemx return @var{expression} | |
5783 | @cindex returning from a function | |
5784 | @kindex return | |
5785 | You can cancel execution of a function call with the @code{return} | |
5786 | command. If you give an | |
5787 | @var{expression} argument, its value is used as the function's return | |
e251e767 | 5788 | value. |
70b88761 RP |
5789 | @end table |
5790 | ||
5791 | When you use @code{return}, _GDBN__ discards the selected stack frame | |
5792 | (and all frames within it). You can think of this as making the | |
5793 | discarded frame return prematurely. If you wish to specify a value to | |
5794 | be returned, give that value as the argument to @code{return}. | |
5795 | ||
29a2b744 RP |
5796 | This pops the selected stack frame (@pxref{Selection, ,Selecting a |
5797 | Frame}), and any other frames inside of it, leaving its caller as the | |
5798 | innermost remaining frame. That frame becomes selected. The | |
5799 | specified value is stored in the registers used for returning values | |
5800 | of functions. | |
70b88761 RP |
5801 | |
5802 | The @code{return} command does not resume execution; it leaves the | |
5803 | program stopped in the state that would exist if the function had just | |
1041a570 RP |
5804 | returned. In contrast, the @code{finish} command (@pxref{Continuing |
5805 | and Stepping, ,Continuing and Stepping}) resumes execution until the | |
5806 | selected stack frame returns naturally. | |
70b88761 | 5807 | |
c338a2fd | 5808 | @node Calling, Patching, Returning, Altering |
70b88761 RP |
5809 | @section Calling your Program's Functions |
5810 | ||
5811 | @cindex calling functions | |
5812 | @kindex call | |
5813 | @table @code | |
5814 | @item call @var{expr} | |
5815 | Evaluate the expression @var{expr} without displaying @code{void} | |
5816 | returned values. | |
5817 | @end table | |
5818 | ||
5819 | You can use this variant of the @code{print} command if you want to | |
5820 | execute a function from your program, but without cluttering the output | |
5821 | with @code{void} returned values. The result is printed and saved in | |
5822 | the value history, if it is not void. | |
5823 | ||
c338a2fd RP |
5824 | @node Patching, , Calling, Altering |
5825 | @section Patching your Program | |
5826 | @cindex patching binaries | |
5827 | @cindex writing into executables | |
5828 | @cindex writing into corefiles | |
1041a570 | 5829 | |
c338a2fd RP |
5830 | By default, _GDBN__ opens the file containing your program's executable |
5831 | code (or the corefile) read-only. This prevents accidental alterations | |
5832 | to machine code; but it also prevents you from intentionally patching | |
5833 | your program's binary. | |
5834 | ||
5835 | If you'd like to be able to patch the binary, you can specify that | |
5836 | explicitly with the @code{set write} command. For example, you might | |
5837 | want to turn on internal debugging flags, or even to make emergency | |
e251e767 | 5838 | repairs. |
c338a2fd RP |
5839 | |
5840 | @table @code | |
5841 | @item set write on | |
5842 | @itemx set write off | |
5843 | @kindex set write | |
5844 | If you specify @samp{set write on}, _GDBN__ will open executable and | |
5845 | core files for both reading and writing; if you specify @samp{set write | |
5846 | off} (the default), _GDBN__ will open them read-only. | |
5847 | ||
1041a570 | 5848 | If you have already loaded a file, you must load it |
c338a2fd RP |
5849 | again (using the @code{exec-file} or @code{core-file} command) after |
5850 | changing @code{set write}, for your new setting to take effect. | |
5851 | ||
5852 | @item show write | |
7d7ff5f6 | 5853 | @kindex show write |
c338a2fd RP |
5854 | Display whether executable files and core files will be opened for |
5855 | writing as well as reading. | |
c338a2fd RP |
5856 | @end table |
5857 | ||
70b88761 RP |
5858 | @node _GDBN__ Files, Targets, Altering, Top |
5859 | @chapter _GDBN__'s Files | |
5860 | ||
1041a570 RP |
5861 | _GDBN__ needs to know the file name of the program to be debugged, both in |
5862 | order to read its symbol table and in order to start your program. To | |
5863 | debug a core dump of a previous run, _GDBN__ must be told the file name of | |
5864 | the core dump. | |
5865 | ||
70b88761 | 5866 | @menu |
b80282d5 RP |
5867 | * Files:: Commands to Specify Files |
5868 | * Symbol Errors:: Errors Reading Symbol Files | |
70b88761 RP |
5869 | @end menu |
5870 | ||
5871 | @node Files, Symbol Errors, _GDBN__ Files, _GDBN__ Files | |
5872 | @section Commands to Specify Files | |
5873 | @cindex core dump file | |
5874 | @cindex symbol table | |
70b88761 | 5875 | |
1041a570 RP |
5876 | The usual way to specify executable and core dump file names is with |
5877 | the command arguments given when you start _GDBN__, (@pxref{Invocation, | |
5878 | ,Getting In and Out of _GDBN__}. | |
70b88761 RP |
5879 | |
5880 | Occasionally it is necessary to change to a different file during a | |
5881 | _GDBN__ session. Or you may run _GDBN__ and forget to specify the files you | |
5882 | want to use. In these situations the _GDBN__ commands to specify new files | |
5883 | are useful. | |
5884 | ||
5885 | @table @code | |
5886 | @item file @var{filename} | |
5887 | @cindex executable file | |
5888 | @kindex file | |
5889 | Use @var{filename} as the program to be debugged. It is read for its | |
5890 | symbols and for the contents of pure memory. It is also the program | |
5891 | executed when you use the @code{run} command. If you do not specify a | |
1041a570 RP |
5892 | directory and the file is not found in _GDBN__'s working directory, _GDBN__ |
5893 | uses the environment variable @code{PATH} as a list of directories to | |
5894 | search, just as the shell does when looking for a program to run. You | |
5895 | can change the value of this variable, for both _GDBN__ and your program, | |
5896 | using the @code{path} command. | |
70b88761 | 5897 | |
14d01801 RP |
5898 | On systems with memory-mapped files, an auxiliary symbol table file |
5899 | @file{@var{filename}.syms} may be available for @var{filename}. If it | |
5900 | is, _GDBN__ will map in the symbol table from | |
5901 | @file{@var{filename}.syms}, starting up more quickly. See the | |
95d5ceb9 RP |
5902 | descriptions of the options @samp{-mapped} and @samp{-readnow} (available |
5903 | with @code{file}, @code{symbol-file}, or @code{add-symbol-file}), for | |
5904 | more information. | |
14d01801 | 5905 | |
e0dacfd1 | 5906 | @item file |
70b88761 RP |
5907 | @code{file} with no argument makes _GDBN__ discard any information it |
5908 | has on both executable file and the symbol table. | |
5909 | ||
e0dacfd1 | 5910 | @item exec-file @r{[} @var{filename} @r{]} |
70b88761 RP |
5911 | @kindex exec-file |
5912 | Specify that the program to be run (but not the symbol table) is found | |
5913 | in @var{filename}. _GDBN__ will search the environment variable @code{PATH} | |
29a2b744 | 5914 | if necessary to locate your program. Omitting @var{filename} means to |
e0dacfd1 | 5915 | discard information on the executable file. |
70b88761 | 5916 | |
e0dacfd1 | 5917 | @item symbol-file @r{[} @var{filename} @r{]} |
70b88761 RP |
5918 | @kindex symbol-file |
5919 | Read symbol table information from file @var{filename}. @code{PATH} is | |
5920 | searched when necessary. Use the @code{file} command to get both symbol | |
5921 | table and program to run from the same file. | |
5922 | ||
5923 | @code{symbol-file} with no argument clears out _GDBN__'s information on your | |
5924 | program's symbol table. | |
5925 | ||
5926 | The @code{symbol-file} command causes _GDBN__ to forget the contents of its | |
5927 | convenience variables, the value history, and all breakpoints and | |
5928 | auto-display expressions. This is because they may contain pointers to | |
5929 | the internal data recording symbols and data types, which are part of | |
5930 | the old symbol table data being discarded inside _GDBN__. | |
5931 | ||
5932 | @code{symbol-file} will not repeat if you press @key{RET} again after | |
5933 | executing it once. | |
5934 | ||
14d01801 RP |
5935 | When _GDBN__ is configured for a particular environment, it will |
5936 | understand debugging information in whatever format is the standard | |
5937 | generated for that environment; you may use either a GNU compiler, or | |
5938 | other compilers that adhere to the local conventions. Best results are | |
5939 | usually obtained from GNU compilers; for example, using @code{_GCC__} | |
5940 | you can generate debugging information for optimized code. | |
5941 | ||
70b88761 | 5942 | On some kinds of object files, the @code{symbol-file} command does not |
14d01801 | 5943 | normally read the symbol table in full right away. Instead, it scans |
70b88761 RP |
5944 | the symbol table quickly to find which source files and which symbols |
5945 | are present. The details are read later, one source file at a time, | |
1041a570 | 5946 | as they are needed. |
70b88761 RP |
5947 | |
5948 | The purpose of this two-stage reading strategy is to make _GDBN__ start up | |
1041a570 RP |
5949 | faster. For the most part, it is invisible except for occasional |
5950 | pauses while the symbol table details for a particular source file are | |
5951 | being read. (The @code{set verbose} command can turn these pauses | |
5952 | into messages if desired. @xref{Messages/Warnings, ,Optional Warnings | |
5953 | and Messages}.) | |
70b88761 RP |
5954 | |
5955 | When the symbol table is stored in COFF format, @code{symbol-file} does | |
1041a570 | 5956 | read the symbol table data in full right away. We have not implemented |
70b88761 RP |
5957 | the two-stage strategy for COFF yet. |
5958 | ||
95d5ceb9 RP |
5959 | @item symbol-file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]} |
5960 | @itemx file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]} | |
14d01801 RP |
5961 | @kindex readnow |
5962 | @cindex reading symbols immediately | |
5963 | @cindex symbols, reading immediately | |
5964 | @kindex mapped | |
5965 | @cindex memory-mapped symbol file | |
5966 | @cindex saving symbol table with memory mapping | |
5967 | You can override the _GDBN__ two-stage strategy for reading symbol | |
95d5ceb9 | 5968 | tables by using the @samp{-readnow} option with any of the commands that |
14d01801 RP |
5969 | load symbol table information, if you want to be sure _GDBN__ has the |
5970 | entire symbol table available. | |
5971 | ||
5972 | If memory-mapped files are available on your system through the | |
95d5ceb9 | 5973 | @code{mmap} system call, you can use another option, @samp{-mapped}, to |
14d01801 RP |
5974 | get _GDBN__ to write out the symbols for your program in a reusable |
5975 | file. Next time _GDBN__ starts up (if the program hasn't changed), it | |
5976 | will map in symbol information from this auxiliary symbol file, rather | |
5977 | than spending time reading the symbol table from the executable program. | |
95d5ceb9 | 5978 | Using the @samp{-mapped} option has the same effect as starting _GDBN__ |
14d01801 RP |
5979 | with the @samp{-m} command-line option. |
5980 | ||
95d5ceb9 | 5981 | You can use both options together, to make sure the auxiliary symbol |
14d01801 RP |
5982 | file has all the symbol information for your program. |
5983 | ||
5984 | The auxiliary symbol file for a program called @var{myprog} is called | |
5985 | @samp{@var{myprog}.syms}. Once this file exists (so long as it is newer | |
5986 | than the corresponding executable), _GDBN__ will always attempt to use | |
5987 | it when you debug @var{myprog}; no special options or commands are | |
5988 | needed. | |
5989 | @c FIXME: for now no mention of directories, since this seems to be in | |
5990 | @c flux. 13mar1992 status is that in theory GDB would look either in | |
5991 | @c current dir or in same dir as myprog; but issues like competing | |
5992 | @c GDB's, or clutter in system dirs, mean that in practice right now | |
5993 | @c only current dir is used. FFish says maybe a special GDB hierarchy | |
5994 | @c (eg rooted in val of env var GDBSYMS) could exist for mappable symbol | |
5995 | @c files. | |
70b88761 | 5996 | |
e0dacfd1 | 5997 | @item core-file @r{[} @var{filename} @r{]} |
70b88761 RP |
5998 | @kindex core |
5999 | @kindex core-file | |
6000 | Specify the whereabouts of a core dump file to be used as the ``contents | |
6001 | of memory''. Traditionally, core files contain only some parts of the | |
6002 | address space of the process that generated them; _GDBN__ can access the | |
6003 | executable file itself for other parts. | |
6004 | ||
6005 | @code{core-file} with no argument specifies that no core file is | |
6006 | to be used. | |
6007 | ||
6008 | Note that the core file is ignored when your program is actually running | |
29a2b744 | 6009 | under _GDBN__. So, if you have been running your program and you wish to |
70b88761 RP |
6010 | debug a core file instead, you must kill the subprocess in which the |
6011 | program is running. To do this, use the @code{kill} command | |
1041a570 | 6012 | (@pxref{Kill Process, ,Killing the Child Process}). |
70b88761 RP |
6013 | |
6014 | @item load @var{filename} | |
6015 | @kindex load | |
6016 | _if__(_GENERIC__) | |
6017 | Depending on what remote debugging facilities are configured into | |
6018 | _GDBN__, the @code{load} command may be available. Where it exists, it | |
6019 | is meant to make @var{filename} (an executable) available for debugging | |
6020 | on the remote system---by downloading, or dynamic linking, for example. | |
6021 | @code{load} also records @var{filename}'s symbol table in _GDBN__, like | |
6022 | the @code{add-symbol-file} command. | |
6023 | ||
6024 | If @code{load} is not available on your _GDBN__, attempting to execute | |
6025 | it gets the error message ``@code{You can't do that when your target is | |
e251e767 | 6026 | @dots{}}'' |
70b88761 RP |
6027 | _fi__(_GENERIC__) |
6028 | ||
e251e767 | 6029 | _if__(_VXWORKS__) |
70b88761 RP |
6030 | On VxWorks, @code{load} will dynamically link @var{filename} on the |
6031 | current target system as well as adding its symbols in _GDBN__. | |
6032 | _fi__(_VXWORKS__) | |
6033 | ||
6034 | _if__(_I960__) | |
6035 | @cindex download to Nindy-960 | |
6036 | With the Nindy interface to an Intel 960 board, @code{load} will | |
6037 | download @var{filename} to the 960 as well as adding its symbols in | |
e251e767 | 6038 | _GDBN__. |
70b88761 RP |
6039 | _fi__(_I960__) |
6040 | ||
c7cb8acb RP |
6041 | _if__(_H8__) |
6042 | @cindex download to H8/300 | |
6043 | @cindex H8/300 download | |
6044 | When you select remote debugging to a Hitachi H8/300 board (@pxref{Hitachi | |
6045 | H8/300 Remote,,_GDBN__ and the Hitachi H8/300}), the | |
6046 | @code{load} command downloads your program to the H8/300 and also opens | |
6047 | it as the current executable target for _GDBN__ on your host (like the | |
6048 | @code{file} command). | |
6049 | _fi__(_H8__) | |
6050 | ||
70b88761 RP |
6051 | @code{load} will not repeat if you press @key{RET} again after using it. |
6052 | ||
6053 | @item add-symbol-file @var{filename} @var{address} | |
95d5ceb9 | 6054 | @itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]} @r{[} -mapped @r{]} |
70b88761 RP |
6055 | @kindex add-symbol-file |
6056 | @cindex dynamic linking | |
6057 | The @code{add-symbol-file} command reads additional symbol table information | |
b80282d5 | 6058 | from the file @var{filename}. You would use this command when @var{filename} |
70b88761 RP |
6059 | has been dynamically loaded (by some other means) into the program that |
6060 | is running. @var{address} should be the memory address at which the | |
6061 | file has been loaded; _GDBN__ cannot figure this out for itself. | |
6062 | ||
6063 | The symbol table of the file @var{filename} is added to the symbol table | |
6064 | originally read with the @code{symbol-file} command. You can use the | |
6065 | @code{add-symbol-file} command any number of times; the new symbol data thus | |
6066 | read keeps adding to the old. To discard all old symbol data instead, | |
e251e767 | 6067 | use the @code{symbol-file} command. |
70b88761 RP |
6068 | |
6069 | @code{add-symbol-file} will not repeat if you press @key{RET} after using it. | |
6070 | ||
95d5ceb9 RP |
6071 | You can use the @samp{-mapped} and @samp{-readnow} options just as with |
6072 | the @code{symbol-file} command, to change how _GDBN__ manages the symbol | |
6073 | tabl einformation for @var{filename}. | |
6074 | ||
70b88761 RP |
6075 | @item info files |
6076 | @itemx info target | |
6077 | @kindex info files | |
6078 | @kindex info target | |
1041a570 RP |
6079 | @code{info files} and @code{info target} are synonymous; both print |
6080 | the current targets (@pxref{Targets, ,Specifying a Debugging Target}), | |
6081 | including the names of the executable and core dump files currently in | |
6082 | use by _GDBN__, and the files from which symbols were loaded. The command | |
6083 | @code{help targets} lists all possible targets rather than current | |
6084 | ones. | |
70b88761 RP |
6085 | |
6086 | @end table | |
6087 | ||
6088 | All file-specifying commands allow both absolute and relative file names | |
6089 | as arguments. _GDBN__ always converts the file name to an absolute path | |
6090 | name and remembers it that way. | |
6091 | ||
70b88761 RP |
6092 | @cindex shared libraries |
6093 | ||
c338a2fd RP |
6094 | _GDBN__ supports the SunOS shared library format. _GDBN__ automatically |
6095 | loads symbol definitions from shared libraries when you use the | |
6096 | @code{run} command, or when you examine a core file. (Before you issue | |
1041a570 | 6097 | the @code{run} command, _GDBN__ will not understand references to a |
29a2b744 | 6098 | function in a shared library, however---unless you are debugging a core |
c338a2fd RP |
6099 | file). |
6100 | @c FIXME: next _GDBN__ release should permit some refs to undef | |
1041a570 | 6101 | @c FIXME...symbols---eg in a break cmd---assuming they are from a shared lib |
14d01801 | 6102 | @c FIXME: still only SunOS?? |
70b88761 RP |
6103 | |
6104 | @table @code | |
70b88761 RP |
6105 | @item info share |
6106 | @itemx info sharedlibrary | |
6107 | @kindex info sharedlibrary | |
6108 | @kindex info share | |
c338a2fd | 6109 | Print the names of the shared libraries which are currently loaded. |
70b88761 | 6110 | |
c338a2fd RP |
6111 | @item sharedlibrary @var{regex} |
6112 | @itemx share @var{regex} | |
6113 | @kindex sharedlibrary | |
6114 | @kindex share | |
6115 | This is an obsolescent command; you can use it to explicitly | |
6116 | load shared object library symbols for files matching a UNIX regular | |
6117 | expression, but as with files loaded automatically, it will only load | |
6118 | shared libraries required by your program for a core file or after | |
6119 | typing @code{run}. If @var{regex} is omitted all shared libraries | |
6120 | required by your program are loaded. | |
6121 | @end table | |
70b88761 RP |
6122 | |
6123 | @node Symbol Errors, , Files, _GDBN__ Files | |
6124 | @section Errors Reading Symbol Files | |
1041a570 RP |
6125 | |
6126 | While reading a symbol file, _GDBN__ will occasionally encounter problems, | |
6127 | such as symbol types it does not recognize, or known bugs in compiler | |
6128 | output. By default, _GDBN__ does not notify you of such problems, since | |
6129 | they are relatively common and primarily of interest to people | |
6130 | debugging compilers. If you are interested in seeing information | |
b80282d5 RP |
6131 | about ill-constructed symbol tables, you can either ask _GDBN__ to print |
6132 | only one message about each such type of problem, no matter how many | |
6133 | times the problem occurs; or you can ask _GDBN__ to print more messages, | |
1041a570 RP |
6134 | to see how many times the problems occur, with the @code{set |
6135 | complaints} command (@pxref{Messages/Warnings, ,Optional Warnings and | |
6136 | Messages}). | |
70b88761 RP |
6137 | |
6138 | The messages currently printed, and their meanings, are: | |
6139 | ||
6140 | @table @code | |
6141 | @item inner block not inside outer block in @var{symbol} | |
6142 | ||
6143 | The symbol information shows where symbol scopes begin and end | |
6144 | (such as at the start of a function or a block of statements). This | |
6145 | error indicates that an inner scope block is not fully contained | |
e251e767 | 6146 | in its outer scope blocks. |
70b88761 RP |
6147 | |
6148 | _GDBN__ circumvents the problem by treating the inner block as if it had | |
6149 | the same scope as the outer block. In the error message, @var{symbol} | |
6150 | may be shown as ``@code{(don't know)}'' if the outer block is not a | |
6151 | function. | |
6152 | ||
6153 | @item block at @var{address} out of order | |
6154 | ||
e251e767 | 6155 | The symbol information for symbol scope blocks should occur in |
70b88761 | 6156 | order of increasing addresses. This error indicates that it does not |
e251e767 | 6157 | do so. |
70b88761 RP |
6158 | |
6159 | _GDBN__ does not circumvent this problem, and will have trouble locating | |
6160 | symbols in the source file whose symbols being read. (You can often | |
6161 | determine what source file is affected by specifying @code{set verbose | |
29a2b744 | 6162 | on}. @xref{Messages/Warnings, ,Optional Warnings and Messages}.) |
70b88761 RP |
6163 | |
6164 | @item bad block start address patched | |
6165 | ||
6166 | The symbol information for a symbol scope block has a start address | |
6167 | smaller than the address of the preceding source line. This is known | |
e251e767 | 6168 | to occur in the SunOS 4.1.1 (and earlier) C compiler. |
70b88761 RP |
6169 | |
6170 | _GDBN__ circumvents the problem by treating the symbol scope block as | |
6171 | starting on the previous source line. | |
6172 | ||
70b88761 RP |
6173 | @item bad string table offset in symbol @var{n} |
6174 | ||
6175 | @cindex foo | |
6176 | Symbol number @var{n} contains a pointer into the string table which is | |
e251e767 | 6177 | larger than the size of the string table. |
70b88761 RP |
6178 | |
6179 | _GDBN__ circumvents the problem by considering the symbol to have the | |
6180 | name @code{foo}, which may cause other problems if many symbols end up | |
6181 | with this name. | |
6182 | ||
6183 | @item unknown symbol type @code{0x@var{nn}} | |
6184 | ||
6185 | The symbol information contains new data types that _GDBN__ does not yet | |
6186 | know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood | |
e251e767 | 6187 | information, in hexadecimal. |
70b88761 RP |
6188 | |
6189 | _GDBN__ circumvents the error by ignoring this symbol information. This | |
29a2b744 | 6190 | will usually allow your program to be debugged, though certain symbols |
70b88761 RP |
6191 | will not be accessible. If you encounter such a problem and feel like |
6192 | debugging it, you can debug @code{_GDBP__} with itself, breakpoint on | |
6193 | @code{complain}, then go up to the function @code{read_dbx_symtab} and | |
6194 | examine @code{*bufp} to see the symbol. | |
6195 | ||
6196 | @item stub type has NULL name | |
e251e767 | 6197 | _GDBN__ could not find the full definition for a struct or class. |
70b88761 | 6198 | |
440d9834 | 6199 | @item const/volatile indicator missing (ok if using g++ v1.x), got@dots{} |
70b88761 RP |
6200 | |
6201 | The symbol information for a C++ member function is missing some | |
440d9834 RP |
6202 | information that recent versions of the compiler should have output |
6203 | for it. | |
70b88761 | 6204 | |
440d9834 | 6205 | @item info mismatch between compiler and debugger |
70b88761 | 6206 | |
440d9834 | 6207 | _GDBN__ could not parse a type specification output by the compiler. |
70b88761 RP |
6208 | @end table |
6209 | ||
6210 | @node Targets, Controlling _GDBN__, _GDBN__ Files, Top | |
e251e767 | 6211 | @chapter Specifying a Debugging Target |
70b88761 RP |
6212 | @cindex debugging target |
6213 | @kindex target | |
1041a570 | 6214 | |
cedaf8bc | 6215 | A @dfn{target} is the execution environment occupied by your program. |
1041a570 RP |
6216 | Often, _GDBN__ runs in the same host environment as your program; in |
6217 | that case, the debugging target is specified as a side effect when you | |
6218 | use the @code{file} or @code{core} commands. When you need more | |
6219 | flexibility---for example, running _GDBN__ on a physically separate | |
6220 | host, or controlling a standalone system over a serial port or a | |
6221 | realtime system over a TCP/IP connection---you can use the @code{target} | |
6222 | command to specify one of the target types configured for _GDBN__ | |
6223 | (@pxref{Target Commands, ,Commands for Managing Targets}). | |
70b88761 RP |
6224 | |
6225 | @menu | |
b80282d5 RP |
6226 | * Active Targets:: Active Targets |
6227 | * Target Commands:: Commands for Managing Targets | |
6228 | * Remote:: Remote Debugging | |
70b88761 RP |
6229 | @end menu |
6230 | ||
6231 | @node Active Targets, Target Commands, Targets, Targets | |
6232 | @section Active Targets | |
6233 | @cindex stacking targets | |
6234 | @cindex active targets | |
6235 | @cindex multiple targets | |
6236 | ||
cedaf8bc RP |
6237 | There are three classes of targets: processes, core files, and |
6238 | executable files. _GDBN__ can work concurrently on up to three active | |
6239 | targets, one in each class. This allows you to (for example) start a | |
6240 | process and inspect its activity without abandoning your work on a core | |
6241 | file. | |
70b88761 | 6242 | |
cedaf8bc RP |
6243 | If, for example, you execute @samp{gdb a.out}, then the executable file |
6244 | @code{a.out} is the only active target. If you designate a core file as | |
6245 | well---presumably from a prior run that crashed and coredumped---then | |
6246 | _GDBN__ has two active targets and will use them in tandem, looking | |
6247 | first in the corefile target, then in the executable file, to satisfy | |
6248 | requests for memory addresses. (Typically, these two classes of target | |
29a2b744 | 6249 | are complementary, since core files contain only a program's |
cedaf8bc RP |
6250 | read-write memory---variables and so on---plus machine status, while |
6251 | executable files contain only the program text and initialized data.) | |
6252 | ||
6253 | When you type @code{run}, your executable file becomes an active process | |
6254 | target as well. When a process target is active, all _GDBN__ commands | |
6255 | requesting memory addresses refer to that target; addresses in an active | |
6256 | core file or executable file target are obscured while the process | |
6257 | target is active. | |
6258 | ||
1041a570 RP |
6259 | Use the @code{core-file} and @code{exec-file} commands to select a |
6260 | new core file or executable target (@pxref{Files, ,Commands to Specify | |
6261 | Files}). To specify as a target a process that is already running, use | |
6262 | the @code{attach} command (@pxref{Attach, ,Debugging an | |
6263 | Already-Running Process}.). | |
70b88761 RP |
6264 | |
6265 | @node Target Commands, Remote, Active Targets, Targets | |
6266 | @section Commands for Managing Targets | |
6267 | ||
6268 | @table @code | |
6269 | @item target @var{type} @var{parameters} | |
6270 | Connects the _GDBN__ host environment to a target machine or process. A | |
6271 | target is typically a protocol for talking to debugging facilities. You | |
6272 | use the argument @var{type} to specify the type or protocol of the | |
6273 | target machine. | |
6274 | ||
6275 | Further @var{parameters} are interpreted by the target protocol, but | |
6276 | typically include things like device names or host names to connect | |
e251e767 | 6277 | with, process numbers, and baud rates. |
70b88761 RP |
6278 | |
6279 | The @code{target} command will not repeat if you press @key{RET} again | |
6280 | after executing the command. | |
6281 | ||
6282 | @item help target | |
6283 | @kindex help target | |
6284 | Displays the names of all targets available. To display targets | |
6285 | currently selected, use either @code{info target} or @code{info files} | |
29a2b744 | 6286 | (@pxref{Files, ,Commands to Specify Files}). |
70b88761 RP |
6287 | |
6288 | @item help target @var{name} | |
6289 | Describe a particular target, including any parameters necessary to | |
6290 | select it. | |
6291 | @end table | |
6292 | ||
c7cb8acb | 6293 | Here are some common targets (available, or not, depending on the GDB |
70b88761 RP |
6294 | configuration): |
6295 | ||
6296 | @table @code | |
6297 | @item target exec @var{prog} | |
6298 | @kindex target exec | |
6299 | An executable file. @samp{target exec @var{prog}} is the same as | |
6300 | @samp{exec-file @var{prog}}. | |
6301 | ||
6302 | @item target core @var{filename} | |
6303 | @kindex target core | |
6304 | A core dump file. @samp{target core @var{filename}} is the same as | |
6305 | @samp{core-file @var{filename}}. | |
6306 | ||
6307 | @item target remote @var{dev} | |
6308 | @kindex target remote | |
c7cb8acb | 6309 | Remote serial target in GDB-specific protocol. The argument @var{dev} |
70b88761 | 6310 | specifies what serial device to use for the connection (e.g. |
1041a570 | 6311 | @file{/dev/ttya}). @xref{Remote, ,Remote Debugging}. |
70b88761 RP |
6312 | |
6313 | _if__(_AMD29K__) | |
6314 | @item target amd-eb @var{dev} @var{speed} @var{PROG} | |
6315 | @kindex target amd-eb | |
6316 | @cindex AMD EB29K | |
6317 | Remote PC-resident AMD EB29K board, attached over serial lines. | |
6318 | @var{dev} is the serial device, as for @code{target remote}; | |
6319 | @var{speed} allows you to specify the linespeed; and @var{PROG} is the | |
6320 | name of the program to be debugged, as it appears to DOS on the PC. | |
1041a570 | 6321 | @xref{EB29K Remote, ,GDB with a Remote EB29K}. |
70b88761 RP |
6322 | |
6323 | _fi__(_AMD29K__) | |
c7cb8acb RP |
6324 | _if__(_H8__) |
6325 | @item target hms | |
6326 | @kindex target hms | |
6327 | A Hitachi H8/300 board, attached via serial line to your host. Use | |
6328 | special commands @code{device} and @code{speed} to control the serial | |
6329 | line and the communications speed used. @xref{Hitachi H8/300 | |
6330 | Remote,,_GDBN__ and the Hitachi H8/300}. | |
6331 | ||
6332 | _fi__(_H8__) | |
70b88761 RP |
6333 | _if__(_I960__) |
6334 | @item target nindy @var{devicename} | |
6335 | @kindex target nindy | |
6336 | An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is | |
6337 | the name of the serial device to use for the connection, e.g. | |
1041a570 | 6338 | @file{/dev/ttya}. @xref{i960-Nindy Remote, ,_GDBN__ with a Remote i960 (Nindy)}. |
70b88761 RP |
6339 | |
6340 | _fi__(_I960__) | |
6341 | _if__(_VXWORKS__) | |
6342 | @item target vxworks @var{machinename} | |
6343 | @kindex target vxworks | |
6344 | A VxWorks system, attached via TCP/IP. The argument @var{machinename} | |
6345 | is the target system's machine name or IP address. | |
1041a570 | 6346 | @xref{VxWorks Remote, ,_GDBN__ and VxWorks}. |
70b88761 RP |
6347 | _fi__(_VXWORKS__) |
6348 | @end table | |
6349 | ||
6350 | _if__(_GENERIC__) | |
6351 | Different targets are available on different configurations of _GDBN__; your | |
6352 | configuration may have more or fewer targets. | |
6353 | _fi__(_GENERIC__) | |
6354 | ||
6355 | @node Remote, , Target Commands, Targets | |
6356 | @section Remote Debugging | |
6357 | @cindex remote debugging | |
6358 | ||
29a2b744 | 6359 | If you are trying to debug a program running on a machine that cannot run |
c7cb8acb | 6360 | GDB in the usual way, it is often useful to use remote debugging. For |
70b88761 RP |
6361 | example, you might use remote debugging on an operating system kernel, or on |
6362 | a small system which does not have a general purpose operating system | |
e251e767 | 6363 | powerful enough to run a full-featured debugger. |
70b88761 | 6364 | |
c7cb8acb | 6365 | Some configurations of GDB have special serial or TCP/IP interfaces |
70b88761 | 6366 | to make this work with particular debugging targets. In addition, |
c7cb8acb | 6367 | GDB comes with a generic serial protocol (specific to GDB, but |
70b88761 RP |
6368 | not specific to any particular target system) which you can use if you |
6369 | write the remote stubs---the code that will run on the remote system to | |
c7cb8acb | 6370 | communicate with GDB. |
70b88761 | 6371 | |
c7cb8acb | 6372 | To use the GDB remote serial protocol, the program to be debugged on |
70b88761 | 6373 | the remote machine needs to contain a debugging stub which talks to |
c7cb8acb RP |
6374 | GDB over the serial line. Several working remote stubs are |
6375 | distributed with GDB; see the @file{README} file in the GDB | |
70b88761 RP |
6376 | distribution for more information. |
6377 | ||
6378 | For details of this communication protocol, see the comments in the | |
c7cb8acb | 6379 | GDB source file @file{remote.c}. |
70b88761 | 6380 | |
c7cb8acb RP |
6381 | To start remote debugging, first run GDB and specify as an executable file |
6382 | the program that is running in the remote machine. This tells GDB how | |
29a2b744 | 6383 | to find your program's symbols and the contents of its pure text. Then |
70b88761 RP |
6384 | establish communication using the @code{target remote} command with a device |
6385 | name as an argument. For example: | |
6386 | ||
6387 | @example | |
6388 | target remote /dev/ttyb | |
6389 | @end example | |
6390 | ||
6391 | @noindent | |
6392 | if the serial line is connected to the device named @file{/dev/ttyb}. This | |
6393 | will stop the remote machine if it is not already stopped. | |
6394 | ||
6395 | Now you can use all the usual commands to examine and change data and to | |
6396 | step and continue the remote program. | |
6397 | ||
6398 | To resume the remote program and stop debugging it, use the @code{detach} | |
6399 | command. | |
6400 | ||
6401 | Other remote targets may be available in your | |
c7cb8acb | 6402 | configuration of GDB; use @code{help targets} to list them. |
70b88761 RP |
6403 | |
6404 | _if__(_GENERIC__) | |
1041a570 RP |
6405 | _dnl__ Text on starting up GDB in various specific cases; it goes up front |
6406 | _dnl__ in manuals configured for any of those particular situations, here | |
6407 | _dnl__ otherwise. | |
6408 | @menu | |
6409 | _include__(gdbinv-m.m4)<>_dnl__ | |
6410 | @end menu | |
70b88761 RP |
6411 | _include__(gdbinv-s.m4) |
6412 | _fi__(_GENERIC__) | |
6413 | ||
6414 | @node Controlling _GDBN__, Sequences, Targets, Top | |
6415 | @chapter Controlling _GDBN__ | |
6416 | ||
6417 | You can alter many aspects of _GDBN__'s interaction with you by using | |
6418 | the @code{set} command. For commands controlling how _GDBN__ displays | |
1041a570 | 6419 | data, @pxref{Print Settings, ,Print Settings}; other settings are described here. |
70b88761 RP |
6420 | |
6421 | @menu | |
b80282d5 RP |
6422 | * Prompt:: Prompt |
6423 | * Editing:: Command Editing | |
6424 | * History:: Command History | |
6425 | * Screen Size:: Screen Size | |
6426 | * Numbers:: Numbers | |
6427 | * Messages/Warnings:: Optional Warnings and Messages | |
70b88761 RP |
6428 | @end menu |
6429 | ||
6430 | @node Prompt, Editing, Controlling _GDBN__, Controlling _GDBN__ | |
6431 | @section Prompt | |
6432 | @cindex prompt | |
1041a570 | 6433 | |
70b88761 RP |
6434 | _GDBN__ indicates its readiness to read a command by printing a string |
6435 | called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You | |
6436 | can change the prompt string with the @code{set prompt} command. For | |
6437 | instance, when debugging _GDBN__ with _GDBN__, it is useful to change | |
6438 | the prompt in one of the _GDBN__<>s so that you can always tell which | |
6439 | one you are talking to. | |
6440 | ||
6441 | @table @code | |
6442 | @item set prompt @var{newprompt} | |
6443 | @kindex set prompt | |
6444 | Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth. | |
6445 | @kindex show prompt | |
6446 | @item show prompt | |
6447 | Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} | |
6448 | @end table | |
6449 | ||
6450 | @node Editing, History, Prompt, Controlling _GDBN__ | |
6451 | @section Command Editing | |
6452 | @cindex readline | |
6453 | @cindex command line editing | |
1041a570 | 6454 | |
70b88761 RP |
6455 | _GDBN__ reads its input commands via the @dfn{readline} interface. This |
6456 | GNU library provides consistent behavior for programs which provide a | |
6457 | command line interface to the user. Advantages are @code{emacs}-style | |
6458 | or @code{vi}-style inline editing of commands, @code{csh}-like history | |
6459 | substitution, and a storage and recall of command history across | |
6460 | debugging sessions. | |
6461 | ||
6462 | You may control the behavior of command line editing in _GDBN__ with the | |
e251e767 | 6463 | command @code{set}. |
70b88761 RP |
6464 | |
6465 | @table @code | |
6466 | @kindex set editing | |
6467 | @cindex editing | |
6468 | @item set editing | |
6469 | @itemx set editing on | |
6470 | Enable command line editing (enabled by default). | |
6471 | ||
6472 | @item set editing off | |
6473 | Disable command line editing. | |
6474 | ||
6475 | @kindex show editing | |
6476 | @item show editing | |
6477 | Show whether command line editing is enabled. | |
6478 | @end table | |
6479 | ||
6480 | @node History, Screen Size, Editing, Controlling _GDBN__ | |
6481 | @section Command History | |
1041a570 | 6482 | |
70b88761 RP |
6483 | @table @code |
6484 | @cindex history substitution | |
6485 | @cindex history file | |
6486 | @kindex set history filename | |
6487 | @item set history filename @var{fname} | |
6488 | Set the name of the _GDBN__ command history file to @var{fname}. This is | |
6489 | the file from which _GDBN__ will read an initial command history | |
6490 | list or to which it will write this list when it exits. This list is | |
6491 | accessed through history expansion or through the history | |
6492 | command editing characters listed below. This file defaults to the | |
6493 | value of the environment variable @code{GDBHISTFILE}, or to | |
6494 | @file{./.gdb_history} if this variable is not set. | |
6495 | ||
6496 | @cindex history save | |
6497 | @kindex set history save | |
6498 | @item set history save | |
6499 | @itemx set history save on | |
6500 | Record command history in a file, whose name may be specified with the | |
6501 | @code{set history filename} command. By default, this option is disabled. | |
6502 | ||
6503 | @item set history save off | |
6504 | Stop recording command history in a file. | |
6505 | ||
6506 | @cindex history size | |
6507 | @kindex set history size | |
6508 | @item set history size @var{size} | |
6509 | Set the number of commands which _GDBN__ will keep in its history list. | |
6510 | This defaults to the value of the environment variable | |
6511 | @code{HISTSIZE}, or to 256 if this variable is not set. | |
6512 | @end table | |
6513 | ||
6514 | @cindex history expansion | |
6515 | History expansion assigns special meaning to the character @kbd{!}. | |
6516 | @iftex | |
1041a570 | 6517 | @xref{Event Designators}. |
70b88761 RP |
6518 | @end iftex |
6519 | Since @kbd{!} is also the logical not operator in C, history expansion | |
6520 | is off by default. If you decide to enable history expansion with the | |
6521 | @code{set history expansion on} command, you may sometimes need to | |
6522 | follow @kbd{!} (when it is used as logical not, in an expression) with | |
6523 | a space or a tab to prevent it from being expanded. The readline | |
6524 | history facilities will not attempt substitution on the strings | |
6525 | @kbd{!=} and @kbd{!(}, even when history expansion is enabled. | |
6526 | ||
6527 | The commands to control history expansion are: | |
6528 | ||
6529 | @table @code | |
6530 | ||
6531 | @kindex set history expansion | |
6532 | @item set history expansion on | |
6533 | @itemx set history expansion | |
6534 | Enable history expansion. History expansion is off by default. | |
6535 | ||
6536 | @item set history expansion off | |
6537 | Disable history expansion. | |
6538 | ||
6539 | The readline code comes with more complete documentation of | |
6540 | editing and history expansion features. Users unfamiliar with @code{emacs} | |
e251e767 | 6541 | or @code{vi} may wish to read it. |
70b88761 RP |
6542 | @iftex |
6543 | @xref{Command Line Editing}. | |
6544 | @end iftex | |
6545 | ||
6546 | @c @group | |
6547 | @kindex show history | |
6548 | @item show history | |
6549 | @itemx show history filename | |
6550 | @itemx show history save | |
6551 | @itemx show history size | |
6552 | @itemx show history expansion | |
6553 | These commands display the state of the _GDBN__ history parameters. | |
6554 | @code{show history} by itself displays all four states. | |
6555 | @c @end group | |
70b88761 RP |
6556 | @end table |
6557 | ||
6558 | @table @code | |
6559 | @kindex show commands | |
6560 | @item show commands | |
6561 | Display the last ten commands in the command history. | |
6562 | ||
6563 | @item show commands @var{n} | |
6564 | Print ten commands centered on command number @var{n}. | |
6565 | ||
6566 | @item show commands + | |
6567 | Print ten commands just after the commands last printed. | |
70b88761 RP |
6568 | @end table |
6569 | ||
6570 | @node Screen Size, Numbers, History, Controlling _GDBN__ | |
6571 | @section Screen Size | |
6572 | @cindex size of screen | |
6573 | @cindex pauses in output | |
1041a570 | 6574 | |
70b88761 RP |
6575 | Certain commands to _GDBN__ may produce large amounts of information |
6576 | output to the screen. To help you read all of it, _GDBN__ pauses and | |
6577 | asks you for input at the end of each page of output. Type @key{RET} | |
6578 | when you want to continue the output. _GDBN__ also uses the screen | |
6579 | width setting to determine when to wrap lines of output. Depending on | |
6580 | what is being printed, it tries to break the line at a readable place, | |
6581 | rather than simply letting it overflow onto the following line. | |
6582 | ||
6583 | Normally _GDBN__ knows the size of the screen from the termcap data base | |
6584 | together with the value of the @code{TERM} environment variable and the | |
6585 | @code{stty rows} and @code{stty cols} settings. If this is not correct, | |
6586 | you can override it with the @code{set height} and @code{set | |
6587 | width} commands: | |
6588 | ||
6589 | @table @code | |
6590 | @item set height @var{lpp} | |
6591 | @itemx show height | |
6592 | @itemx set width @var{cpl} | |
6593 | @itemx show width | |
6594 | @kindex set height | |
6595 | @kindex set width | |
6596 | @kindex show width | |
6597 | @kindex show height | |
6598 | These @code{set} commands specify a screen height of @var{lpp} lines and | |
6599 | a screen width of @var{cpl} characters. The associated @code{show} | |
6600 | commands display the current settings. | |
6601 | ||
6602 | If you specify a height of zero lines, _GDBN__ will not pause during output | |
6603 | no matter how long the output is. This is useful if output is to a file | |
6604 | or to an editor buffer. | |
6605 | @end table | |
6606 | ||
6607 | @node Numbers, Messages/Warnings, Screen Size, Controlling _GDBN__ | |
6608 | @section Numbers | |
6609 | @cindex number representation | |
6610 | @cindex entering numbers | |
1041a570 | 6611 | |
70b88761 RP |
6612 | You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by |
6613 | the usual conventions: octal numbers begin with @samp{0}, decimal | |
6614 | numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}. | |
6615 | Numbers that begin with none of these are, by default, entered in base | |
6616 | 10; likewise, the default display for numbers---when no particular | |
6617 | format is specified---is base 10. You can change the default base for | |
6618 | both input and output with the @code{set radix} command. | |
6619 | ||
6620 | @table @code | |
6621 | @kindex set radix | |
6622 | @item set radix @var{base} | |
6623 | Set the default base for numeric input and display. Supported choices | |
c2bbbb22 | 6624 | for @var{base} are decimal 2, 8, 10, 16. @var{base} must itself be |
70b88761 RP |
6625 | specified either unambiguously or using the current default radix; for |
6626 | example, any of | |
6627 | ||
6628 | @example | |
c2bbbb22 | 6629 | set radix 1010 |
70b88761 RP |
6630 | set radix 012 |
6631 | set radix 10. | |
6632 | set radix 0xa | |
6633 | @end example | |
6634 | ||
6635 | @noindent | |
6636 | will set the base to decimal. On the other hand, @samp{set radix 10} | |
6637 | will leave the radix unchanged no matter what it was. | |
6638 | ||
6639 | @kindex show radix | |
6640 | @item show radix | |
6641 | Display the current default base for numeric input and display. | |
70b88761 RP |
6642 | @end table |
6643 | ||
c2bbbb22 | 6644 | @node Messages/Warnings, , Numbers, Controlling _GDBN__ |
70b88761 | 6645 | @section Optional Warnings and Messages |
1041a570 | 6646 | |
70b88761 RP |
6647 | By default, _GDBN__ is silent about its inner workings. If you are running |
6648 | on a slow machine, you may want to use the @code{set verbose} command. | |
6649 | It will make _GDBN__ tell you when it does a lengthy internal operation, so | |
1041a570 | 6650 | you will not think it has crashed. |
70b88761 | 6651 | |
1041a570 RP |
6652 | Currently, the messages controlled by @code{set verbose} are those |
6653 | which announce that the symbol table for a source file is being read | |
6654 | (@pxref{Files, ,Commands to Specify Files}, in the description of the | |
6655 | command @code{symbol-file}). | |
29a2b744 | 6656 | @c The following is the right way to do it, but emacs 18.55 does not support |
70b88761 | 6657 | @c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo |
e251e767 | 6658 | @c is released. |
70b88761 | 6659 | @ignore |
29a2b744 | 6660 | see @code{symbol-file} in @ref{Files, ,Commands to Specify Files}). |
70b88761 RP |
6661 | @end ignore |
6662 | ||
6663 | @table @code | |
6664 | @kindex set verbose | |
6665 | @item set verbose on | |
6666 | Enables _GDBN__'s output of certain informational messages. | |
6667 | ||
6668 | @item set verbose off | |
6669 | Disables _GDBN__'s output of certain informational messages. | |
6670 | ||
6671 | @kindex show verbose | |
6672 | @item show verbose | |
6673 | Displays whether @code{set verbose} is on or off. | |
6674 | @end table | |
6675 | ||
b80282d5 RP |
6676 | By default, if _GDBN__ encounters bugs in the symbol table of an object |
6677 | file, it is silent; but if you are debugging a compiler, you may find | |
1041a570 | 6678 | this information useful (@pxref{Symbol Errors, ,Errors Reading Symbol Files}). |
70b88761 RP |
6679 | |
6680 | @table @code | |
6681 | @kindex set complaints | |
6682 | @item set complaints @var{limit} | |
6683 | Permits _GDBN__ to output @var{limit} complaints about each type of unusual | |
6684 | symbols before becoming silent about the problem. Set @var{limit} to | |
6685 | zero to suppress all complaints; set it to a large number to prevent | |
6686 | complaints from being suppressed. | |
6687 | ||
6688 | @kindex show complaints | |
6689 | @item show complaints | |
6690 | Displays how many symbol complaints _GDBN__ is permitted to produce. | |
6691 | @end table | |
6692 | ||
6693 | By default, _GDBN__ is cautious, and asks what sometimes seem to be a | |
6694 | lot of stupid questions to confirm certain commands. For example, if | |
6695 | you try to run a program which is already running: | |
1041a570 | 6696 | |
70b88761 RP |
6697 | @example |
6698 | (_GDBP__) run | |
6699 | The program being debugged has been started already. | |
e251e767 | 6700 | Start it from the beginning? (y or n) |
70b88761 RP |
6701 | @end example |
6702 | ||
29a2b744 | 6703 | If you are willing to unflinchingly face the consequences of your own |
70b88761 RP |
6704 | commands, you can disable this ``feature'': |
6705 | ||
6706 | @table @code | |
6707 | @kindex set confirm | |
6708 | @cindex flinching | |
6709 | @cindex confirmation | |
6710 | @cindex stupid questions | |
6711 | @item set confirm off | |
6712 | Disables confirmation requests. | |
6713 | ||
6714 | @item set confirm on | |
6715 | Enables confirmation requests (the default). | |
6716 | ||
6717 | @item show confirm | |
6718 | @kindex show confirm | |
6719 | Displays state of confirmation requests. | |
6720 | @end table | |
6721 | ||
29a2b744 | 6722 | @c FIXME this does not really belong here. But where *does* it belong? |
b80282d5 RP |
6723 | @cindex reloading symbols |
6724 | Some systems allow individual object files that make up your program to | |
6725 | be replaced without stopping and restarting your program. | |
6726 | _if__(_VXWORKS__) | |
6727 | For example, in VxWorks you can simply recompile a defective object file | |
6728 | and keep on running. | |
6729 | _fi__(_VXWORKS__) | |
29a2b744 | 6730 | If you are running on one of these systems, you can allow _GDBN__ to |
1041a570 RP |
6731 | reload the symbols for automatically relinked modules: |
6732 | ||
b80282d5 RP |
6733 | @table @code |
6734 | @kindex set symbol-reloading | |
6735 | @item set symbol-reloading on | |
6736 | Replace symbol definitions for the corresponding source file when an | |
6737 | object file with a particular name is seen again. | |
6738 | ||
6739 | @item set symbol-reloading off | |
1041a570 | 6740 | Do not replace symbol definitions when re-encountering object files of |
29a2b744 | 6741 | the same name. This is the default state; if you are not running on a |
b80282d5 RP |
6742 | system that permits automatically relinking modules, you should leave |
6743 | @code{symbol-reloading} off, since otherwise _GDBN__ may discard symbols | |
6744 | when linking large programs, that may contain several modules (from | |
6745 | different directories or libraries) with the same name. | |
6746 | ||
6747 | @item show symbol-reloading | |
6748 | Show the current @code{on} or @code{off} setting. | |
6749 | @end table | |
6750 | ||
70b88761 RP |
6751 | @node Sequences, Emacs, Controlling _GDBN__, Top |
6752 | @chapter Canned Sequences of Commands | |
6753 | ||
29a2b744 | 6754 | Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint |
1041a570 RP |
6755 | Command Lists}), _GDBN__ provides two ways to store sequences of commands |
6756 | for execution as a unit: user-defined commands and command files. | |
70b88761 RP |
6757 | |
6758 | @menu | |
b80282d5 RP |
6759 | * Define:: User-Defined Commands |
6760 | * Command Files:: Command Files | |
6761 | * Output:: Commands for Controlled Output | |
70b88761 RP |
6762 | @end menu |
6763 | ||
6764 | @node Define, Command Files, Sequences, Sequences | |
6765 | @section User-Defined Commands | |
6766 | ||
6767 | @cindex user-defined command | |
6768 | A @dfn{user-defined command} is a sequence of _GDBN__ commands to which you | |
6769 | assign a new name as a command. This is done with the @code{define} | |
6770 | command. | |
6771 | ||
6772 | @table @code | |
6773 | @item define @var{commandname} | |
6774 | @kindex define | |
6775 | Define a command named @var{commandname}. If there is already a command | |
6776 | by that name, you are asked to confirm that you want to redefine it. | |
6777 | ||
6778 | The definition of the command is made up of other _GDBN__ command lines, | |
6779 | which are given following the @code{define} command. The end of these | |
6780 | commands is marked by a line containing @code{end}. | |
6781 | ||
6782 | @item document @var{commandname} | |
6783 | @kindex document | |
6784 | Give documentation to the user-defined command @var{commandname}. The | |
6785 | command @var{commandname} must already be defined. This command reads | |
6786 | lines of documentation just as @code{define} reads the lines of the | |
6787 | command definition, ending with @code{end}. After the @code{document} | |
6788 | command is finished, @code{help} on command @var{commandname} will print | |
6789 | the documentation you have specified. | |
6790 | ||
6791 | You may use the @code{document} command again to change the | |
6792 | documentation of a command. Redefining the command with @code{define} | |
6793 | does not change the documentation. | |
6794 | ||
6795 | @item help user-defined | |
6796 | @kindex help user-defined | |
6797 | List all user-defined commands, with the first line of the documentation | |
6798 | (if any) for each. | |
6799 | ||
6800 | @item info user | |
6801 | @itemx info user @var{commandname} | |
6802 | @kindex info user | |
6803 | Display the _GDBN__ commands used to define @var{commandname} (but not its | |
6804 | documentation). If no @var{commandname} is given, display the | |
6805 | definitions for all user-defined commands. | |
6806 | @end table | |
6807 | ||
6808 | User-defined commands do not take arguments. When they are executed, the | |
6809 | commands of the definition are not printed. An error in any command | |
6810 | stops execution of the user-defined command. | |
6811 | ||
6812 | Commands that would ask for confirmation if used interactively proceed | |
6813 | without asking when used inside a user-defined command. Many _GDBN__ commands | |
6814 | that normally print messages to say what they are doing omit the messages | |
6815 | when used in a user-defined command. | |
6816 | ||
6817 | @node Command Files, Output, Define, Sequences | |
6818 | @section Command Files | |
6819 | ||
6820 | @cindex command files | |
6821 | A command file for _GDBN__ is a file of lines that are _GDBN__ commands. Comments | |
6822 | (lines starting with @kbd{#}) may also be included. An empty line in a | |
6823 | command file does nothing; it does not mean to repeat the last command, as | |
6824 | it would from the terminal. | |
6825 | ||
6826 | @cindex init file | |
6827 | @cindex @file{_GDBINIT__} | |
6828 | When you start _GDBN__, it automatically executes commands from its | |
1041a570 RP |
6829 | @dfn{init files}. These are files named @file{_GDBINIT__}. _GDBN__ reads |
6830 | the init file (if any) in your home directory and then the init file | |
6831 | (if any) in the current working directory. (The init files are not | |
6832 | executed if you use the @samp{-nx} option; @pxref{Mode Options, | |
6833 | ,Choosing Modes}.) You can also request the execution of a command | |
6834 | file with the @code{source} command: | |
70b88761 RP |
6835 | |
6836 | @table @code | |
6837 | @item source @var{filename} | |
6838 | @kindex source | |
6839 | Execute the command file @var{filename}. | |
6840 | @end table | |
6841 | ||
6842 | The lines in a command file are executed sequentially. They are not | |
6843 | printed as they are executed. An error in any command terminates execution | |
6844 | of the command file. | |
6845 | ||
6846 | Commands that would ask for confirmation if used interactively proceed | |
6847 | without asking when used in a command file. Many _GDBN__ commands that | |
6848 | normally print messages to say what they are doing omit the messages | |
6849 | when called from command files. | |
6850 | ||
6851 | @node Output, , Command Files, Sequences | |
6852 | @section Commands for Controlled Output | |
6853 | ||
6854 | During the execution of a command file or a user-defined command, normal | |
6855 | _GDBN__ output is suppressed; the only output that appears is what is | |
6856 | explicitly printed by the commands in the definition. This section | |
6857 | describes three commands useful for generating exactly the output you | |
6858 | want. | |
6859 | ||
6860 | @table @code | |
6861 | @item echo @var{text} | |
6862 | @kindex echo | |
29a2b744 RP |
6863 | @c I do not consider backslash-space a standard C escape sequence |
6864 | @c because it is not in ANSI. | |
1041a570 RP |
6865 | Print @var{text}. Nonprinting characters can be included in |
6866 | @var{text} using C escape sequences, such as @samp{\n} to print a | |
6867 | newline. @strong{No newline will be printed unless you specify one.} | |
6868 | In addition to the standard C escape sequences, a backslash followed | |
6869 | by a space stands for a space. This is useful for outputting a | |
6870 | string with spaces at the beginning or the end, since leading and | |
6871 | trailing spaces are otherwise trimmed from all arguments. | |
6872 | To print @samp{@w{ }and foo =@w{ }}, use the command | |
6873 | @samp{echo \@w{ }and foo = \@w{ }}. | |
70b88761 RP |
6874 | |
6875 | A backslash at the end of @var{text} can be used, as in C, to continue | |
6876 | the command onto subsequent lines. For example, | |
6877 | ||
6878 | @example | |
6879 | echo This is some text\n\ | |
6880 | which is continued\n\ | |
6881 | onto several lines.\n | |
6882 | @end example | |
6883 | ||
6884 | produces the same output as | |
6885 | ||
6886 | @example | |
6887 | echo This is some text\n | |
6888 | echo which is continued\n | |
6889 | echo onto several lines.\n | |
6890 | @end example | |
6891 | ||
6892 | @item output @var{expression} | |
6893 | @kindex output | |
6894 | Print the value of @var{expression} and nothing but that value: no | |
6895 | newlines, no @samp{$@var{nn} = }. The value is not entered in the | |
1041a570 | 6896 | value history either. @xref{Expressions, ,Expressions}, for more information on |
e251e767 | 6897 | expressions. |
70b88761 RP |
6898 | |
6899 | @item output/@var{fmt} @var{expression} | |
6900 | Print the value of @var{expression} in format @var{fmt}. You can use | |
6901 | the same formats as for @code{print}; @pxref{Output formats}, for more | |
6902 | information. | |
6903 | ||
6904 | @item printf @var{string}, @var{expressions}@dots{} | |
6905 | @kindex printf | |
6906 | Print the values of the @var{expressions} under the control of | |
6907 | @var{string}. The @var{expressions} are separated by commas and may | |
6908 | be either numbers or pointers. Their values are printed as specified | |
29a2b744 | 6909 | by @var{string}, exactly as if your program were to execute |
70b88761 RP |
6910 | |
6911 | @example | |
6912 | printf (@var{string}, @var{expressions}@dots{}); | |
6913 | @end example | |
6914 | ||
6915 | For example, you can print two values in hex like this: | |
6916 | ||
6917 | @example | |
6918 | printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo | |
6919 | @end example | |
6920 | ||
6921 | The only backslash-escape sequences that you can use in the format | |
6922 | string are the simple ones that consist of backslash followed by a | |
6923 | letter. | |
6924 | @end table | |
6925 | ||
6ca72cc6 RP |
6926 | _if__(_LUCID__) |
6927 | @node Emacs, Energize, Sequences, Top | |
6928 | _fi__(_LUCID__) | |
6929 | _if__(!_LUCID__) | |
70b88761 | 6930 | @node Emacs, _GDBN__ Bugs, Sequences, Top |
6ca72cc6 | 6931 | _fi__(!_LUCID__) |
70b88761 RP |
6932 | @chapter Using _GDBN__ under GNU Emacs |
6933 | ||
6934 | @cindex emacs | |
6935 | A special interface allows you to use GNU Emacs to view (and | |
6936 | edit) the source files for the program you are debugging with | |
6937 | _GDBN__. | |
6938 | ||
6939 | To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the | |
6940 | executable file you want to debug as an argument. This command starts | |
6941 | _GDBN__ as a subprocess of Emacs, with input and output through a newly | |
6942 | created Emacs buffer. | |
6943 | ||
6944 | Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two | |
6945 | things: | |
6946 | ||
6947 | @itemize @bullet | |
6948 | @item | |
e251e767 | 6949 | All ``terminal'' input and output goes through the Emacs buffer. |
70b88761 RP |
6950 | @end itemize |
6951 | ||
6952 | This applies both to _GDBN__ commands and their output, and to the input | |
6953 | and output done by the program you are debugging. | |
6954 | ||
6955 | This is useful because it means that you can copy the text of previous | |
6956 | commands and input them again; you can even use parts of the output | |
6957 | in this way. | |
6958 | ||
3d3ab540 RP |
6959 | All the facilities of Emacs' Shell mode are available for interacting |
6960 | with your program. In particular, you can send signals the usual | |
6961 | way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a | |
6962 | stop. | |
70b88761 RP |
6963 | |
6964 | @itemize @bullet | |
6965 | @item | |
e251e767 | 6966 | _GDBN__ displays source code through Emacs. |
70b88761 RP |
6967 | @end itemize |
6968 | ||
6969 | Each time _GDBN__ displays a stack frame, Emacs automatically finds the | |
6970 | source file for that frame and puts an arrow (_0__@samp{=>}_1__) at the | |
6971 | left margin of the current line. Emacs uses a separate buffer for | |
6972 | source display, and splits the window to show both your _GDBN__ session | |
6973 | and the source. | |
6974 | ||
6975 | Explicit _GDBN__ @code{list} or search commands still produce output as | |
6976 | usual, but you probably will have no reason to use them. | |
6977 | ||
6978 | @quotation | |
6979 | @emph{Warning:} If the directory where your program resides is not your | |
6980 | current directory, it can be easy to confuse Emacs about the location of | |
6981 | the source files, in which case the auxiliary display buffer will not | |
6982 | appear to show your source. _GDBN__ can find programs by searching your | |
6983 | environment's @code{PATH} variable, so the _GDBN__ input and output | |
29a2b744 | 6984 | session will proceed normally; but Emacs does not get enough information |
70b88761 RP |
6985 | back from _GDBN__ to locate the source files in this situation. To |
6986 | avoid this problem, either start _GDBN__ mode from the directory where | |
6987 | your program resides, or specify a full path name when prompted for the | |
6988 | @kbd{M-x gdb} argument. | |
6989 | ||
6990 | A similar confusion can result if you use the _GDBN__ @code{file} command to | |
6991 | switch to debugging a program in some other location, from an existing | |
6992 | _GDBN__ buffer in Emacs. | |
6993 | @end quotation | |
6994 | ||
6995 | By default, @kbd{M-x gdb} calls the program called @file{gdb}. If | |
6996 | you need to call _GDBN__ by a different name (for example, if you keep | |
6997 | several configurations around, with different names) you can set the | |
6998 | Emacs variable @code{gdb-command-name}; for example, | |
1041a570 | 6999 | |
70b88761 RP |
7000 | @example |
7001 | (setq gdb-command-name "mygdb") | |
7002 | @end example | |
1041a570 | 7003 | |
70b88761 RP |
7004 | @noindent |
7005 | (preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or | |
7006 | in your @file{.emacs} file) will make Emacs call the program named | |
7007 | ``@code{mygdb}'' instead. | |
7008 | ||
7009 | In the _GDBN__ I/O buffer, you can use these special Emacs commands in | |
7010 | addition to the standard Shell mode commands: | |
7011 | ||
7012 | @table @kbd | |
7013 | @item C-h m | |
7014 | Describe the features of Emacs' _GDBN__ Mode. | |
7015 | ||
7016 | @item M-s | |
7017 | Execute to another source line, like the _GDBN__ @code{step} command; also | |
7018 | update the display window to show the current file and location. | |
7019 | ||
7020 | @item M-n | |
7021 | Execute to next source line in this function, skipping all function | |
7022 | calls, like the _GDBN__ @code{next} command. Then update the display window | |
7023 | to show the current file and location. | |
7024 | ||
7025 | @item M-i | |
7026 | Execute one instruction, like the _GDBN__ @code{stepi} command; update | |
7027 | display window accordingly. | |
7028 | ||
7029 | @item M-x gdb-nexti | |
7030 | Execute to next instruction, using the _GDBN__ @code{nexti} command; update | |
7031 | display window accordingly. | |
7032 | ||
7033 | @item C-c C-f | |
7034 | Execute until exit from the selected stack frame, like the _GDBN__ | |
7035 | @code{finish} command. | |
7036 | ||
7037 | @item M-c | |
29a2b744 | 7038 | Continue execution of your program, like the _GDBN__ @code{continue} |
1041a570 | 7039 | command. |
203eea5d RP |
7040 | |
7041 | @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}. | |
70b88761 RP |
7042 | |
7043 | @item M-u | |
7044 | Go up the number of frames indicated by the numeric argument | |
7045 | (@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}), | |
1041a570 | 7046 | like the _GDBN__ @code{up} command. |
203eea5d | 7047 | |
1041a570 | 7048 | @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-u}. |
70b88761 RP |
7049 | |
7050 | @item M-d | |
7051 | Go down the number of frames indicated by the numeric argument, like the | |
1041a570 | 7052 | _GDBN__ @code{down} command. |
203eea5d RP |
7053 | |
7054 | @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-d}. | |
70b88761 RP |
7055 | |
7056 | @item C-x & | |
7057 | Read the number where the cursor is positioned, and insert it at the end | |
7058 | of the _GDBN__ I/O buffer. For example, if you wish to disassemble code | |
7059 | around an address that was displayed earlier, type @kbd{disassemble}; | |
7060 | then move the cursor to the address display, and pick up the | |
e251e767 | 7061 | argument for @code{disassemble} by typing @kbd{C-x &}. |
70b88761 RP |
7062 | |
7063 | You can customize this further on the fly by defining elements of the list | |
7064 | @code{gdb-print-command}; once it is defined, you can format or | |
7065 | otherwise process numbers picked up by @kbd{C-x &} before they are | |
c2bbbb22 | 7066 | inserted. A numeric argument to @kbd{C-x &} will both indicate that you |
70b88761 RP |
7067 | wish special formatting, and act as an index to pick an element of the |
7068 | list. If the list element is a string, the number to be inserted is | |
7069 | formatted using the Emacs function @code{format}; otherwise the number | |
7070 | is passed as an argument to the corresponding list element. | |
70b88761 RP |
7071 | @end table |
7072 | ||
7073 | In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break}) | |
7074 | tells _GDBN__ to set a breakpoint on the source line point is on. | |
7075 | ||
7076 | If you accidentally delete the source-display buffer, an easy way to get | |
7077 | it back is to type the command @code{f} in the _GDBN__ buffer, to | |
7078 | request a frame display; when you run under Emacs, this will recreate | |
7079 | the source buffer if necessary to show you the context of the current | |
7080 | frame. | |
7081 | ||
7082 | The source files displayed in Emacs are in ordinary Emacs buffers | |
7083 | which are visiting the source files in the usual way. You can edit | |
7084 | the files with these buffers if you wish; but keep in mind that _GDBN__ | |
7085 | communicates with Emacs in terms of line numbers. If you add or | |
7086 | delete lines from the text, the line numbers that _GDBN__ knows will cease | |
7087 | to correspond properly to the code. | |
7088 | ||
7089 | @c The following dropped because Epoch is nonstandard. Reactivate | |
7090 | @c if/when v19 does something similar. [email protected] 19dec1990 | |
7091 | @ignore | |
e251e767 | 7092 | @kindex emacs epoch environment |
70b88761 RP |
7093 | @kindex epoch |
7094 | @kindex inspect | |
7095 | ||
7096 | Version 18 of Emacs has a built-in window system called the @code{epoch} | |
7097 | environment. Users of this environment can use a new command, | |
7098 | @code{inspect} which performs identically to @code{print} except that | |
7099 | each value is printed in its own window. | |
7100 | @end ignore | |
7101 | ||
6ca72cc6 RP |
7102 | _if__(_LUCID__) |
7103 | @node Energize, _GDBN__ Bugs, Emacs, Top | |
7104 | @chapter Using _GDBN__ with Energize | |
7105 | ||
7106 | @cindex Energize | |
7107 | The Energize Programming System is an integrated development environment | |
7108 | that includes a point-and-click interface to many programming tools. | |
7109 | When you use _GDBN__ in this environment, you can use the standard | |
7110 | Energize graphical interface to drive _GDBN__; you can also, if you | |
7111 | choose, type _GDBN__ commands as usual in a debugging window. Even if | |
7112 | you use the graphical interface, the debugging window (which uses Emacs, | |
7113 | and resembles the standard Emacs interface to _GDBN__) displays the | |
7114 | equivalent commands, so that the history of your debugging session is | |
7115 | properly reflected. | |
7116 | ||
7117 | When Energize starts up a _GDBN__ session, it uses one of the | |
7118 | command-line options @samp{-energize} or @samp{-cadillac} (``cadillac'' | |
7119 | is the name of the communications protocol used by the Energize system). | |
7120 | This option makes _GDBN__ run as one of the tools in the Energize Tool | |
7121 | Set: it sends all output to the Energize kernel, and accept input from | |
7122 | it as well. | |
7123 | ||
7124 | See the user manual for the Energize Programming System for | |
7125 | information on how to use the Energize graphical interface and the other | |
7126 | development tools that Energize integrates with _GDBN__. | |
7127 | ||
7128 | @node _GDBN__ Bugs, Renamed Commands, Energize, Top | |
7129 | _fi__(_LUCID__) | |
7130 | _if__(!_LUCID__) | |
70b88761 | 7131 | @node _GDBN__ Bugs, Renamed Commands, Emacs, Top |
6ca72cc6 | 7132 | _fi__(!_LUCID__) |
70b88761 RP |
7133 | @chapter Reporting Bugs in _GDBN__ |
7134 | @cindex Bugs in _GDBN__ | |
7135 | @cindex Reporting Bugs in _GDBN__ | |
7136 | ||
7137 | Your bug reports play an essential role in making _GDBN__ reliable. | |
7138 | ||
7139 | Reporting a bug may help you by bringing a solution to your problem, or it | |
7140 | may not. But in any case the principal function of a bug report is to help | |
7141 | the entire community by making the next version of _GDBN__ work better. Bug | |
7142 | reports are your contribution to the maintenance of _GDBN__. | |
7143 | ||
7144 | In order for a bug report to serve its purpose, you must include the | |
7145 | information that enables us to fix the bug. | |
7146 | ||
7147 | @menu | |
b80282d5 RP |
7148 | * Bug Criteria:: Have You Found a Bug? |
7149 | * Bug Reporting:: How to Report Bugs | |
70b88761 RP |
7150 | @end menu |
7151 | ||
7152 | @node Bug Criteria, Bug Reporting, _GDBN__ Bugs, _GDBN__ Bugs | |
7153 | @section Have You Found a Bug? | |
7154 | @cindex Bug Criteria | |
7155 | ||
7156 | If you are not sure whether you have found a bug, here are some guidelines: | |
7157 | ||
7158 | @itemize @bullet | |
7159 | @item | |
7160 | @cindex Fatal Signal | |
7161 | @cindex Core Dump | |
7162 | If the debugger gets a fatal signal, for any input whatever, that is a | |
7163 | _GDBN__ bug. Reliable debuggers never crash. | |
7164 | ||
7165 | @item | |
7166 | @cindex error on Valid Input | |
7167 | If _GDBN__ produces an error message for valid input, that is a bug. | |
7168 | ||
7169 | @item | |
7170 | @cindex Invalid Input | |
7171 | If _GDBN__ does not produce an error message for invalid input, | |
7172 | that is a bug. However, you should note that your idea of | |
7173 | ``invalid input'' might be our idea of ``an extension'' or ``support | |
7174 | for traditional practice''. | |
7175 | ||
7176 | @item | |
7177 | If you are an experienced user of debugging tools, your suggestions | |
7178 | for improvement of _GDBN__ are welcome in any case. | |
7179 | @end itemize | |
7180 | ||
7181 | @node Bug Reporting, , Bug Criteria, _GDBN__ Bugs | |
7182 | @section How to Report Bugs | |
7183 | @cindex Bug Reports | |
3d3ab540 | 7184 | @cindex _GDBN__ Bugs, Reporting |
70b88761 RP |
7185 | |
7186 | A number of companies and individuals offer support for GNU products. | |
7187 | If you obtained _GDBN__ from a support organization, we recommend you | |
e251e767 | 7188 | contact that organization first. |
70b88761 RP |
7189 | |
7190 | Contact information for many support companies and individuals is | |
7191 | available in the file @file{etc/SERVICE} in the GNU Emacs distribution. | |
7192 | ||
7193 | In any event, we also recommend that you send bug reports for _GDBN__ to one | |
7194 | of these addresses: | |
7195 | ||
7196 | @example | |
7197 | bug-gdb@@prep.ai.mit.edu | |
7198 | @{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb | |
7199 | @end example | |
7200 | ||
7201 | @strong{Do not send bug reports to @samp{info-gdb}, or to | |
7202 | @samp{help-gdb}, or to any newsgroups.} Most users of _GDBN__ do not want to | |
7203 | receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}. | |
7204 | ||
3d3ab540 RP |
7205 | The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which |
7206 | serves as a repeater. The mailing list and the newsgroup carry exactly | |
7207 | the same messages. Often people think of posting bug reports to the | |
7208 | newsgroup instead of mailing them. This appears to work, but it has one | |
7209 | problem which can be crucial: a newsgroup posting often lacks a mail | |
7210 | path back to the sender. Thus, if we need to ask for more information, | |
7211 | we may be unable to reach you. For this reason, it is better to send | |
7212 | bug reports to the mailing list. | |
70b88761 RP |
7213 | |
7214 | As a last resort, send bug reports on paper to: | |
7215 | ||
7216 | @example | |
7217 | GNU Debugger Bugs | |
3d3ab540 | 7218 | Free Software Foundation |
70b88761 RP |
7219 | 545 Tech Square |
7220 | Cambridge, MA 02139 | |
7221 | @end example | |
7222 | ||
7223 | The fundamental principle of reporting bugs usefully is this: | |
7224 | @strong{report all the facts}. If you are not sure whether to state a | |
7225 | fact or leave it out, state it! | |
7226 | ||
7227 | Often people omit facts because they think they know what causes the | |
29a2b744 | 7228 | problem and assume that some details do not matter. Thus, you might |
70b88761 | 7229 | assume that the name of the variable you use in an example does not matter. |
29a2b744 | 7230 | Well, probably it does not, but one cannot be sure. Perhaps the bug is a |
70b88761 RP |
7231 | stray memory reference which happens to fetch from the location where that |
7232 | name is stored in memory; perhaps, if the name were different, the contents | |
7233 | of that location would fool the debugger into doing the right thing despite | |
7234 | the bug. Play it safe and give a specific, complete example. That is the | |
7235 | easiest thing for you to do, and the most helpful. | |
7236 | ||
7237 | Keep in mind that the purpose of a bug report is to enable us to fix | |
1041a570 | 7238 | the bug if it is new to us. It is not as important as what happens if |
70b88761 RP |
7239 | the bug is already known. Therefore, always write your bug reports on |
7240 | the assumption that the bug has not been reported previously. | |
7241 | ||
7242 | Sometimes people give a few sketchy facts and ask, ``Does this ring a | |
7243 | bell?'' Those bug reports are useless, and we urge everyone to | |
7244 | @emph{refuse to respond to them} except to chide the sender to report | |
7245 | bugs properly. | |
7246 | ||
7247 | To enable us to fix the bug, you should include all these things: | |
7248 | ||
7249 | @itemize @bullet | |
7250 | @item | |
7251 | The version of _GDBN__. _GDBN__ announces it if you start with no | |
7252 | arguments; you can also print it at any time using @code{show version}. | |
7253 | ||
1041a570 | 7254 | Without this, we will not know whether there is any point in looking for |
70b88761 RP |
7255 | the bug in the current version of _GDBN__. |
7256 | ||
7257 | @item | |
ddf21240 JG |
7258 | The type of machine you are using, and the operating system name and |
7259 | version number. | |
70b88761 RP |
7260 | |
7261 | @item | |
7262 | What compiler (and its version) was used to compile _GDBN__---e.g. | |
c7cb8acb | 7263 | ``_GCC__-2.0''. |
70b88761 | 7264 | |
ddf21240 JG |
7265 | @item |
7266 | What compiler (and its version) was used to compile the program you | |
c7cb8acb | 7267 | are debugging---e.g. ``_GCC__-2.0''. |
ddf21240 | 7268 | |
70b88761 RP |
7269 | @item |
7270 | The command arguments you gave the compiler to compile your example and | |
7271 | observe the bug. For example, did you use @samp{-O}? To guarantee | |
1041a570 | 7272 | you will not omit something important, list them all. A copy of the |
ddf21240 | 7273 | Makefile (or the output from make) is sufficient. |
70b88761 RP |
7274 | |
7275 | If we were to try to guess the arguments, we would probably guess wrong | |
7276 | and then we might not encounter the bug. | |
7277 | ||
7278 | @item | |
ddf21240 JG |
7279 | A complete input script, and all necessary source files, that will |
7280 | reproduce the bug. | |
70b88761 RP |
7281 | |
7282 | @item | |
7283 | A description of what behavior you observe that you believe is | |
7284 | incorrect. For example, ``It gets a fatal signal.'' | |
7285 | ||
7286 | Of course, if the bug is that _GDBN__ gets a fatal signal, then we will | |
7287 | certainly notice it. But if the bug is incorrect output, we might not | |
7288 | notice unless it is glaringly wrong. We are human, after all. You | |
7289 | might as well not give us a chance to make a mistake. | |
7290 | ||
7291 | Even if the problem you experience is a fatal signal, you should still | |
7292 | say so explicitly. Suppose something strange is going on, such as, | |
7293 | your copy of _GDBN__ is out of synch, or you have encountered a | |
7294 | bug in the C library on your system. (This has happened!) Your copy | |
7295 | might crash and ours would not. If you told us to expect a crash, | |
7296 | then when ours fails to crash, we would know that the bug was not | |
7297 | happening for us. If you had not told us to expect a crash, then we | |
7298 | would not be able to draw any conclusion from our observations. | |
7299 | ||
7300 | @item | |
7301 | If you wish to suggest changes to the _GDBN__ source, send us context | |
7302 | diffs. If you even discuss something in the _GDBN__ source, refer to | |
7303 | it by context, not by line number. | |
7304 | ||
1041a570 | 7305 | The line numbers in our development sources will not match those in your |
70b88761 | 7306 | sources. Your line numbers would convey no useful information to us. |
70b88761 RP |
7307 | @end itemize |
7308 | ||
7309 | Here are some things that are not necessary: | |
7310 | ||
7311 | @itemize @bullet | |
7312 | @item | |
7313 | A description of the envelope of the bug. | |
7314 | ||
7315 | Often people who encounter a bug spend a lot of time investigating | |
7316 | which changes to the input file will make the bug go away and which | |
7317 | changes will not affect it. | |
7318 | ||
7319 | This is often time consuming and not very useful, because the way we | |
7320 | will find the bug is by running a single example under the debugger | |
7321 | with breakpoints, not by pure deduction from a series of examples. | |
7322 | We recommend that you save your time for something else. | |
7323 | ||
7324 | Of course, if you can find a simpler example to report @emph{instead} | |
7325 | of the original one, that is a convenience for us. Errors in the | |
7326 | output will be easier to spot, running under the debugger will take | |
e251e767 | 7327 | less time, etc. |
70b88761 | 7328 | |
29a2b744 | 7329 | However, simplification is not vital; if you do not want to do this, |
70b88761 RP |
7330 | report the bug anyway and send us the entire test case you used. |
7331 | ||
7332 | @item | |
7333 | A patch for the bug. | |
7334 | ||
29a2b744 | 7335 | A patch for the bug does help us if it is a good one. But do not omit |
70b88761 RP |
7336 | the necessary information, such as the test case, on the assumption that |
7337 | a patch is all we need. We might see problems with your patch and decide | |
7338 | to fix the problem another way, or we might not understand it at all. | |
7339 | ||
7340 | Sometimes with a program as complicated as _GDBN__ it is very hard to | |
7341 | construct an example that will make the program follow a certain path | |
1041a570 RP |
7342 | through the code. If you do not send us the example, we will not be able |
7343 | to construct one, so we will not be able to verify that the bug is fixed. | |
70b88761 | 7344 | |
29a2b744 | 7345 | And if we cannot understand what bug you are trying to fix, or why your |
1041a570 | 7346 | patch should be an improvement, we will not install it. A test case will |
70b88761 RP |
7347 | help us to understand. |
7348 | ||
7349 | @item | |
7350 | A guess about what the bug is or what it depends on. | |
7351 | ||
29a2b744 | 7352 | Such guesses are usually wrong. Even we cannot guess right about such |
70b88761 RP |
7353 | things without first using the debugger to find the facts. |
7354 | @end itemize | |
7355 | ||
1041a570 RP |
7356 | @c Note: no need to update nodes for rdl-apps.texi since it appears |
7357 | @c *only* in the TeX version of the manual. | |
7358 | @c Note: eventually, make a cross reference to the readline Info nodes. | |
70b88761 | 7359 | @iftex |
cacf5942 RP |
7360 | @c appendices describing GNU readline. Distributed with readline code. |
7361 | @include rluser.texinfo | |
7362 | @include inc-hist.texi | |
70b88761 RP |
7363 | @end iftex |
7364 | ||
c7cb8acb | 7365 | @node Renamed Commands, Installing GDB, _GDBN__ Bugs, Top |
70b88761 RP |
7366 | @appendix Renamed Commands |
7367 | ||
c7cb8acb | 7368 | The following commands were renamed in GDB 4, in order to make the |
70b88761 RP |
7369 | command set as a whole more consistent and easier to use and remember: |
7370 | ||
e251e767 RP |
7371 | @kindex add-syms |
7372 | @kindex delete environment | |
7373 | @kindex info copying | |
7374 | @kindex info convenience | |
7375 | @kindex info directories | |
7376 | @kindex info editing | |
7377 | @kindex info history | |
7378 | @kindex info targets | |
7379 | @kindex info values | |
7380 | @kindex info version | |
7381 | @kindex info warranty | |
7382 | @kindex set addressprint | |
7383 | @kindex set arrayprint | |
7384 | @kindex set prettyprint | |
7385 | @kindex set screen-height | |
7386 | @kindex set screen-width | |
7387 | @kindex set unionprint | |
7388 | @kindex set vtblprint | |
7389 | @kindex set demangle | |
7390 | @kindex set asm-demangle | |
7391 | @kindex set sevenbit-strings | |
7392 | @kindex set array-max | |
7393 | @kindex set caution | |
7394 | @kindex set history write | |
7395 | @kindex show addressprint | |
7396 | @kindex show arrayprint | |
7397 | @kindex show prettyprint | |
7398 | @kindex show screen-height | |
7399 | @kindex show screen-width | |
7400 | @kindex show unionprint | |
7401 | @kindex show vtblprint | |
7402 | @kindex show demangle | |
7403 | @kindex show asm-demangle | |
7404 | @kindex show sevenbit-strings | |
7405 | @kindex show array-max | |
7406 | @kindex show caution | |
7407 | @kindex show history write | |
7408 | @kindex unset | |
70b88761 | 7409 | |
92b73793 | 7410 | @c TEXI2ROFF-KILL |
70b88761 | 7411 | @ifinfo |
92b73793 | 7412 | @c END TEXI2ROFF-KILL |
cf496415 RP |
7413 | @example |
7414 | OLD COMMAND NEW COMMAND | |
92b73793 | 7415 | @c TEXI2ROFF-KILL |
cf496415 | 7416 | --------------- ------------------------------- |
92b73793 | 7417 | @c END TEXI2ROFF-KILL |
cf496415 RP |
7418 | add-syms add-symbol-file |
7419 | delete environment unset environment | |
7420 | info convenience show convenience | |
7421 | info copying show copying | |
e251e767 | 7422 | info directories show directories |
cf496415 RP |
7423 | info editing show commands |
7424 | info history show values | |
7425 | info targets help target | |
7426 | info values show values | |
7427 | info version show version | |
7428 | info warranty show warranty | |
7429 | set/show addressprint set/show print address | |
7430 | set/show array-max set/show print elements | |
7431 | set/show arrayprint set/show print array | |
7432 | set/show asm-demangle set/show print asm-demangle | |
7433 | set/show caution set/show confirm | |
7434 | set/show demangle set/show print demangle | |
7435 | set/show history write set/show history save | |
7436 | set/show prettyprint set/show print pretty | |
7437 | set/show screen-height set/show height | |
7438 | set/show screen-width set/show width | |
7439 | set/show sevenbit-strings set/show print sevenbit-strings | |
7440 | set/show unionprint set/show print union | |
7441 | set/show vtblprint set/show print vtbl | |
7442 | ||
7443 | unset [No longer an alias for delete] | |
7444 | @end example | |
92b73793 | 7445 | @c TEXI2ROFF-KILL |
70b88761 RP |
7446 | @end ifinfo |
7447 | ||
7448 | @tex | |
7449 | \vskip \parskip\vskip \baselineskip | |
7450 | \halign{\tt #\hfil &\qquad#&\tt #\hfil\cr | |
7451 | {\bf Old Command} &&{\bf New Command}\cr | |
7452 | add-syms &&add-symbol-file\cr | |
7453 | delete environment &&unset environment\cr | |
7454 | info convenience &&show convenience\cr | |
7455 | info copying &&show copying\cr | |
7456 | info directories &&show directories \cr | |
7457 | info editing &&show commands\cr | |
7458 | info history &&show values\cr | |
7459 | info targets &&help target\cr | |
7460 | info values &&show values\cr | |
7461 | info version &&show version\cr | |
7462 | info warranty &&show warranty\cr | |
7463 | set{\rm / }show addressprint &&set{\rm / }show print address\cr | |
7464 | set{\rm / }show array-max &&set{\rm / }show print elements\cr | |
7465 | set{\rm / }show arrayprint &&set{\rm / }show print array\cr | |
7466 | set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr | |
7467 | set{\rm / }show caution &&set{\rm / }show confirm\cr | |
7468 | set{\rm / }show demangle &&set{\rm / }show print demangle\cr | |
7469 | set{\rm / }show history write &&set{\rm / }show history save\cr | |
7470 | set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr | |
7471 | set{\rm / }show screen-height &&set{\rm / }show height\cr | |
7472 | set{\rm / }show screen-width &&set{\rm / }show width\cr | |
7473 | set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr | |
7474 | set{\rm / }show unionprint &&set{\rm / }show print union\cr | |
7475 | set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr | |
7476 | \cr | |
7477 | unset &&\rm(No longer an alias for delete)\cr | |
7478 | } | |
7479 | @end tex | |
92b73793 | 7480 | @c END TEXI2ROFF-KILL |
70b88761 | 7481 | |
c7cb8acb RP |
7482 | @node Installing GDB, Copying, Renamed Commands, Top |
7483 | @appendix Installing GDB | |
7484 | @cindex configuring GDB | |
70b88761 RP |
7485 | @cindex installation |
7486 | ||
f672bb7f RP |
7487 | @iftex |
7488 | @c irrelevant in info file; it's as current as the code it lives with. | |
7489 | @quotation | |
7490 | @emph{Warning:} These installation instructions are current as of | |
c7cb8acb RP |
7491 | GDB version _GDB_VN__. If you're installing a more recent release |
7492 | of GDB, we may have improved the installation procedures since | |
f672bb7f RP |
7493 | printing this manual; see the @file{README} file included in your |
7494 | release for the most recent instructions. | |
7495 | @end quotation | |
7496 | @end iftex | |
7497 | ||
c7cb8acb RP |
7498 | GDB comes with a @code{configure} script that automates the process |
7499 | of preparing GDB for installation; you can then use @code{make} to | |
7500 | build the program. | |
b80282d5 | 7501 | |
c7cb8acb | 7502 | The GDB distribution includes all the source code you need for GDB in |
1041a570 RP |
7503 | a single directory, whose name is usually composed by appending the |
7504 | version number to @samp{gdb}. | |
7505 | ||
c7cb8acb | 7506 | For example, the GDB version _GDB_VN__ distribution is in the @file{gdb-_GDB_VN__} |
1041a570 | 7507 | directory. That directory contains: |
b80282d5 | 7508 | |
3d3ab540 | 7509 | @table @code |
c7637ea6 | 7510 | @item gdb-_GDB_VN__/configure @r{(and supporting files)} |
c7cb8acb | 7511 | script for configuring GDB and all its supporting libraries. |
b80282d5 | 7512 | |
3e0d0a27 | 7513 | @item gdb-_GDB_VN__/gdb |
c7cb8acb | 7514 | the source specific to GDB itself |
3d3ab540 | 7515 | |
3e0d0a27 | 7516 | @item gdb-_GDB_VN__/bfd |
3d3ab540 RP |
7517 | source for the Binary File Descriptor Library |
7518 | ||
3e0d0a27 | 7519 | @item gdb-_GDB_VN__/include |
b80282d5 | 7520 | GNU include files |
3d3ab540 | 7521 | |
3e0d0a27 | 7522 | @item gdb-_GDB_VN__/libiberty |
3d3ab540 RP |
7523 | source for the @samp{-liberty} free software library |
7524 | ||
3e0d0a27 | 7525 | @item gdb-_GDB_VN__/readline |
b80282d5 | 7526 | source for the GNU command-line interface |
3d3ab540 | 7527 | @end table |
1041a570 | 7528 | |
c7cb8acb | 7529 | The simplest way to configure and build GDB is to run @code{configure} |
1041a570 RP |
7530 | from the @file{gdb-@var{version-number}} source directory, which in |
7531 | this example is the @file{gdb-_GDB_VN__} directory. | |
7532 | ||
7533 | First switch to the @file{gdb-@var{version-number}} source directory | |
7534 | if you are not already in it; then run @code{configure}. Pass the | |
c7cb8acb | 7535 | identifier for the platform on which GDB will run as an |
1041a570 RP |
7536 | argument. |
7537 | ||
7538 | For example: | |
7539 | ||
7463aadd | 7540 | @example |
3e0d0a27 | 7541 | cd gdb-_GDB_VN__ |
3d3ab540 | 7542 | ./configure @var{host} |
7463aadd RP |
7543 | make |
7544 | @end example | |
1041a570 | 7545 | |
7463aadd | 7546 | @noindent |
1041a570 | 7547 | where @var{host} is an identifier such as @samp{sun4} or |
c7cb8acb | 7548 | @samp{decstation}, that identifies the platform where GDB will run. |
1041a570 | 7549 | |
6ca72cc6 RP |
7550 | This sequence of @code{configure} and @code{make} builds the three |
7551 | libraries @file{bfd}, @file{readline}, and @file{libiberty}, then | |
7552 | @code{gdb} itself. The configured source files, and the binaries, are | |
7553 | left in the corresponding source directories. | |
3d3ab540 | 7554 | |
e251e767 | 7555 | @code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your |
29a2b744 | 7556 | system does not recognize this automatically when you run a different |
1041a570 RP |
7557 | shell, you may need to run @code{sh} on it explicitly: |
7558 | ||
7559 | @example | |
7560 | sh configure @var{host} | |
7561 | @end example | |
e251e767 | 7562 | |
f672bb7f RP |
7563 | If you run @code{configure} from a directory that contains source |
7564 | directories for multiple libraries or programs, such as the | |
7565 | @file{gdb-_GDB_VN__} source directory for version _GDB_VN__, @code{configure} | |
7566 | creates configuration files for every directory level underneath (unless | |
98349959 | 7567 | you tell it not to, with the @samp{--norecursion} option). |
f672bb7f RP |
7568 | |
7569 | You can run the @code{configure} script from any of the | |
c7cb8acb | 7570 | subordinate directories in the GDB distribution, if you only want to |
1041a570 RP |
7571 | configure that subdirectory; but be sure to specify a path to it. |
7572 | ||
7573 | For example, with version _GDB_VN__, type the following to configure only | |
7574 | the @code{bfd} subdirectory: | |
7575 | ||
e251e767 | 7576 | @example |
203eea5d | 7577 | @group |
e251e767 RP |
7578 | cd gdb-_GDB_VN__/bfd |
7579 | ../configure @var{host} | |
203eea5d | 7580 | @end group |
e251e767 RP |
7581 | @end example |
7582 | ||
1041a570 RP |
7583 | You can install @code{_GDBP__} anywhere; it has no hardwired paths. |
7584 | However, you should make sure that the shell on your path (named by | |
7585 | the @samp{SHELL} environment variable) is publicly readable. Remember | |
c7cb8acb RP |
7586 | that GDB uses the shell to start your program---some systems refuse to |
7587 | let GDB debug child processes whose programs are not readable. | |
3d3ab540 RP |
7588 | |
7589 | @menu | |
c7cb8acb | 7590 | * Separate Objdir:: Compiling GDB in another directory |
b80282d5 RP |
7591 | * Config Names:: Specifying names for hosts and targets |
7592 | * configure Options:: Summary of options for configure | |
c7cb8acb | 7593 | * Formatting Documentation:: How to format and print GDB documentation |
3d3ab540 RP |
7594 | @end menu |
7595 | ||
c7cb8acb RP |
7596 | @node Separate Objdir, Config Names, Installing GDB, Installing GDB |
7597 | @section Compiling GDB in Another Directory | |
1041a570 | 7598 | |
c7cb8acb RP |
7599 | If you want to run GDB versions for several host or target machines, |
7600 | you'll need a different @code{gdb} compiled for each combination of | |
1041a570 | 7601 | host and target. @code{configure} is designed to make this easy by |
f672bb7f RP |
7602 | allowing you to generate each configuration in a separate subdirectory, |
7603 | rather than in the source directory. If your @code{make} program | |
7604 | handles the @samp{VPATH} feature (GNU @code{make} does), running | |
c7cb8acb | 7605 | @code{make} in each of these directories then builds the @code{gdb} |
f672bb7f | 7606 | program specified there. |
b80282d5 | 7607 | |
c7cb8acb | 7608 | To build @code{gdb} in a separate directory, run @code{configure} |
f672bb7f RP |
7609 | with the @samp{--srcdir} option to specify where to find the source. |
7610 | (Remember, you'll also need to specify a path to find @code{configure} | |
7611 | itself from your working directory.) | |
1041a570 | 7612 | |
c7cb8acb | 7613 | For example, with version _GDB_VN__, you can build GDB in a separate |
f672bb7f | 7614 | directory for a Sun 4 like this: |
70b88761 RP |
7615 | |
7616 | @example | |
3d3ab540 | 7617 | @group |
3e0d0a27 | 7618 | cd gdb-_GDB_VN__ |
f672bb7f RP |
7619 | mkdir ../gdb-sun4 |
7620 | cd ../gdb-sun4 | |
7621 | ../gdb-_GDB_VN__/configure --srcdir=../gdb-_GDB_VN__ sun4 | |
70b88761 | 7622 | make |
3d3ab540 | 7623 | @end group |
70b88761 RP |
7624 | @end example |
7625 | ||
f672bb7f RP |
7626 | When @code{configure} builds a configuration using a remote source |
7627 | directory, it creates a tree for the binaries with the same structure | |
7628 | (and using the same names) as the tree under the source directory. In | |
7629 | the example, you'd find the Sun 4 library @file{libiberty.a} in the | |
c7cb8acb | 7630 | directory @file{gdb-sun4/libiberty}, and GDB itself in |
f672bb7f | 7631 | @file{gdb-sun4/gdb}. |
1041a570 | 7632 | |
c7cb8acb RP |
7633 | One popular use for building several GDB configurations in separate |
7634 | directories is to configure GDB for cross-compiling (where GDB | |
f672bb7f RP |
7635 | runs on one machine---the host---while debugging programs that run on |
7636 | another machine---the target). You specify a cross-debugging target by | |
7637 | giving the @samp{--target=@var{target}} option to @code{configure}. | |
c7637ea6 | 7638 | |
1041a570 | 7639 | When you run @code{make} to build a program or library, you must run |
f672bb7f RP |
7640 | it in a configured directory---whatever directory you were in when you |
7641 | called @code{configure} (or one of its subdirectories). | |
c7637ea6 RP |
7642 | |
7643 | The @code{Makefile} generated by @code{configure} for each source | |
f672bb7f RP |
7644 | directory also runs recursively. If you type @code{make} in a source |
7645 | directory such as @file{gdb-_GDB_VN__} (or in a separate configured | |
7646 | directory configured with @samp{--srcdir=@var{path}/gdb-_GDB_VN__}), you | |
c7cb8acb | 7647 | will build all the required libraries, then build GDB. |
3d3ab540 | 7648 | |
f672bb7f RP |
7649 | When you have multiple hosts or targets configured in separate |
7650 | directories, you can run @code{make} on them in parallel (for example, | |
7651 | if they are NFS-mounted on each of the hosts); they will not interfere | |
7652 | with each other. | |
3d3ab540 | 7653 | |
c7cb8acb | 7654 | @node Config Names, configure Options, Separate Objdir, Installing GDB |
b80282d5 RP |
7655 | @section Specifying Names for Hosts and Targets |
7656 | ||
7657 | The specifications used for hosts and targets in the @code{configure} | |
7658 | script are based on a three-part naming scheme, but some short predefined | |
7659 | aliases are also supported. The full naming scheme encodes three pieces | |
e251e767 | 7660 | of information in the following pattern: |
1041a570 | 7661 | |
b80282d5 RP |
7662 | @example |
7663 | @var{architecture}-@var{vendor}-@var{os} | |
7664 | @end example | |
7665 | ||
7666 | For example, you can use the alias @code{sun4} as a @var{host} argument | |
5e3186ab | 7667 | or in a @code{--target=@var{target}} option, but the equivalent full name |
e251e767 | 7668 | is @samp{sparc-sun-sunos4}. |
b80282d5 | 7669 | |
1041a570 | 7670 | The following table shows all the architectures, hosts, and OS |
c7cb8acb | 7671 | prefixes that @code{configure} recognizes in GDB version _GDB_VN__. Entries |
1041a570 RP |
7672 | in the ``OS prefix'' column ending in a @samp{*} may be followed by a |
7673 | release number. | |
b80282d5 | 7674 | |
1041a570 | 7675 | @c FIXME! Update for gdb 4.4 |
92b73793 | 7676 | @c TEXI2ROFF-KILL |
b80282d5 | 7677 | @ifinfo |
92b73793 | 7678 | @c END TEXI2ROFF-KILL |
b80282d5 RP |
7679 | @example |
7680 | ||
203eea5d | 7681 | ARCHITECTURE VENDOR OS prefix |
92b73793 | 7682 | @c TEXI2ROFF-KILL |
203eea5d | 7683 | ------------+--------------------------+--------------------------- |
92b73793 | 7684 | @c END TEXI2ROFF-KILL |
203eea5d RP |
7685 | | | |
7686 | 580 | altos hp | aix* msdos* | |
7687 | a29k | amd ibm | amigados newsos* | |
7688 | alliant | amdahl intel | aout nindy* | |
7689 | arm | aout isi | bout osf* | |
7690 | c1 | apollo little | bsd* sco* | |
7691 | c2 | att mips | coff sunos* | |
7692 | cray2 | bcs motorola | ctix* svr4 | |
7693 | h8300 | bout ncr | dgux* sym* | |
7694 | i386 | bull next | dynix* sysv* | |
7695 | i860 | cbm nyu | ebmon ultrix* | |
7696 | i960 | coff sco | esix* unicos* | |
7697 | m68000 | convergent sequent | hds unos* | |
7698 | m68k | convex sgi | hpux* uts | |
7699 | m88k | cray sony | irix* v88r* | |
7700 | mips | dec sun | isc* vms* | |
7701 | ns32k | encore unicom | kern vxworks* | |
7702 | pyramid | gould utek | mach* | |
7703 | romp | hitachi wrs | | |
7704 | rs6000 | | | |
7705 | sparc | | | |
7706 | tahoe | | | |
7707 | tron | | | |
7708 | vax | | | |
7709 | xmp | | | |
7710 | ymp | | | |
b80282d5 | 7711 | @end example |
1041a570 | 7712 | |
92b73793 | 7713 | @c TEXI2ROFF-KILL |
b80282d5 RP |
7714 | @end ifinfo |
7715 | @tex | |
c338a2fd RP |
7716 | %\vskip\parskip |
7717 | \vskip \baselineskip | |
203eea5d RP |
7718 | \hfil\vbox{\offinterlineskip |
7719 | \halign{\strut\tt #\hfil\ &\vrule#&\strut\ \tt #\hfil\ &\strut\ \tt #\hfil | |
7720 | \ &\vrule#&\strut\ \tt #\hfil\ &\strut\ \tt #\hfil \cr | |
7721 | {\bf Architecture} &&{\bf Vendor} &&&{\bf OS prefix}\cr | |
7722 | \multispan7\hrulefill\cr | |
7723 | 580 && altos & hp && aix* & msdos* \cr | |
7724 | a29k && amd & ibm && amigados & newsos* \cr | |
7725 | alliant && amdahl & intel && aout & nindy* \cr | |
7726 | arm && aout & isi && bout & osf* \cr | |
7727 | c1 && apollo & little && bsd* & sco* \cr | |
7728 | c2 && att & mips && coff & sunos* \cr | |
7729 | cray2 && bcs & motorola && ctix* & svr4 \cr | |
7730 | h8300 && bout & ncr && dgux* & sym* \cr | |
7731 | i386 && bull & next && dynix* & sysv* \cr | |
7732 | i860 && cbm & nyu && ebmon & ultrix* \cr | |
7733 | i960 && coff & sco && esix* & unicos* \cr | |
7734 | m68000 && convergent& sequent && hds & unos* \cr | |
7735 | m68k && convex & sgi && hpux* & uts \cr | |
7736 | m88k && cray & sony && irix* & v88r* \cr | |
7737 | mips && dec & sun && isc* & vms* \cr | |
7738 | ns32k && encore & unicom && kern & vxworks* \cr | |
7739 | pyramid && gould & utek && mach* & \cr | |
7740 | romp && hitachi & wrs && & \cr | |
7741 | rs6000 && & && & \cr | |
7742 | sparc && & && & \cr | |
7743 | tahoe && & && & \cr | |
7744 | tron && & && & \cr | |
7745 | vax && & && & \cr | |
7746 | xmp && & && & \cr | |
7747 | ymp && & && & \cr | |
7748 | }\hfil} | |
1041a570 | 7749 | @end tex |
92b73793 | 7750 | @c END TEXI2ROFF-KILL |
1041a570 | 7751 | |
203eea5d | 7752 | @quotation |
a6d0b6d3 RP |
7753 | @emph{Warning:} @code{configure} can represent a very large number of |
7754 | combinations of architecture, vendor, and OS. There is by no means | |
7755 | support available for all possible combinations! | |
203eea5d | 7756 | @end quotation |
b80282d5 | 7757 | |
c7cb8acb | 7758 | The @code{configure} script accompanying GDB does not provide |
b80282d5 RP |
7759 | any query facility to list all supported host and target names or |
7760 | aliases. @code{configure} calls the Bourne shell script | |
7761 | @code{config.sub} to map abbreviations to full names; you can read the | |
7762 | script, if you wish, or you can use it to test your guesses on | |
7763 | abbreviations---for example: | |
1041a570 | 7764 | |
b80282d5 RP |
7765 | @example |
7766 | % sh config.sub sun4 | |
7767 | sparc-sun-sunos4 | |
7768 | % sh config.sub sun3 | |
7769 | m68k-sun-sunos4 | |
7770 | % sh config.sub decstation | |
7771 | mips-dec-ultrix | |
7772 | % sh config.sub hp300bsd | |
7773 | m68k-hp-bsd | |
7774 | % sh config.sub i386v | |
7775 | i386-none-sysv | |
e94b4a2b RP |
7776 | % sh config.sub i786v |
7777 | *** Configuration "i786v" not recognized | |
b80282d5 | 7778 | @end example |
1041a570 | 7779 | |
c7637ea6 | 7780 | @noindent |
1041a570 RP |
7781 | @code{config.sub} is also distributed in the GDB source |
7782 | directory (@file{gdb-_GDB_VN__}, for version _GDB_VN__). | |
b80282d5 | 7783 | |
c7cb8acb | 7784 | @node configure Options, Formatting Documentation, Config Names, Installing GDB |
3d3ab540 | 7785 | @section @code{configure} Options |
7463aadd RP |
7786 | |
7787 | Here is a summary of all the @code{configure} options and arguments that | |
c7cb8acb | 7788 | you might use for building GDB: |
7463aadd RP |
7789 | |
7790 | @example | |
f672bb7f RP |
7791 | configure @r{[}--destdir=@var{dir}@r{]} @r{[}--srcdir=@var{path}@r{]} |
7792 | @r{[}--norecursion@r{]} @r{[}--rm@r{]} | |
7793 | @r{[}--target=@var{target}@r{]} @var{host} | |
7463aadd | 7794 | @end example |
1041a570 | 7795 | |
3d3ab540 | 7796 | @noindent |
f672bb7f RP |
7797 | You may introduce options with a single @samp{-} rather than |
7798 | @samp{--} if you prefer; but you may abbreviate option names if you use | |
7799 | @samp{--}. | |
70b88761 RP |
7800 | |
7801 | @table @code | |
f672bb7f | 7802 | @item --destdir=@var{dir} |
3d3ab540 | 7803 | @var{dir} is an installation directory @emph{path prefix}. After you |
c7cb8acb RP |
7804 | configure with this option, @code{make install} will install GDB as |
7805 | @file{@var{dir}/bin/gdb}, and the libraries in @file{@var{dir}/lib}. | |
f672bb7f | 7806 | If you specify @samp{--destdir=/usr/local}, for example, @code{make |
1041a570 | 7807 | install} creates @file{/usr/local/bin/gdb}. |
7463aadd | 7808 | |
f672bb7f | 7809 | @item --srcdir=@var{path} |
6ca72cc6 RP |
7810 | @strong{Warning: using this option requires GNU @code{make}, or another |
7811 | @code{make} that implements the @code{VPATH} feature.}@* | |
f672bb7f | 7812 | Use this option to make configurations in directories separate from the |
c7cb8acb | 7813 | GDB source directories. Among other things, you can use this to |
f672bb7f RP |
7814 | build (or maintain) several configurations simultaneously, in separate |
7815 | directories. @code{configure} writes configuration specific files in | |
7816 | the current directory, but arranges for them to use the source in the | |
7817 | directory @var{path}. @code{configure} will create directories under | |
7818 | the working directory in parallel to the source directories below | |
7819 | @var{path}. | |
7820 | ||
7821 | @item --norecursion | |
7822 | Configure only the directory level where @code{configure} is executed; do not | |
7463aadd RP |
7823 | propagate configuration to subdirectories. |
7824 | ||
f672bb7f | 7825 | @item --rm |
b80282d5 | 7826 | Remove the configuration that the other arguments specify. |
7463aadd | 7827 | |
29a2b744 | 7828 | @c This does not work (yet if ever). FIXME. |
f672bb7f | 7829 | @c @item --parse=@var{lang} @dots{} |
c7cb8acb RP |
7830 | @c Configure the GDB expression parser to parse the listed languages. |
7831 | @c @samp{all} configures GDB for all supported languages. To get a | |
d7b569d5 | 7832 | @c list of all supported languages, omit the argument. Without this |
c7cb8acb | 7833 | @c option, GDB is configured to parse all supported languages. |
c2bbbb22 | 7834 | |
f672bb7f | 7835 | @item --target=@var{target} |
c7cb8acb RP |
7836 | Configure GDB for cross-debugging programs running on the specified |
7837 | @var{target}. Without this option, GDB is configured to debug | |
7838 | programs that run on the same machine (@var{host}) as GDB itself. | |
b80282d5 RP |
7839 | |
7840 | There is no convenient way to generate a list of all available targets. | |
7463aadd RP |
7841 | |
7842 | @item @var{host} @dots{} | |
c7cb8acb | 7843 | Configure GDB to run on the specified @var{host}. |
b80282d5 RP |
7844 | |
7845 | There is no convenient way to generate a list of all available hosts. | |
70b88761 RP |
7846 | @end table |
7847 | ||
3d3ab540 RP |
7848 | @noindent |
7849 | @code{configure} accepts other options, for compatibility with | |
b80282d5 | 7850 | configuring other GNU tools recursively; but these are the only |
c7cb8acb | 7851 | options that affect GDB or its supporting libraries. |
3d3ab540 | 7852 | |
c7cb8acb | 7853 | @node Formatting Documentation, , configure Options, Installing GDB |
d7b569d5 RP |
7854 | @section Formatting the Documentation |
7855 | ||
c7cb8acb | 7856 | All the documentation for GDB, including this manual, comes as part of |
1041a570 RP |
7857 | the distribution. The documentation is written in Texinfo format, |
7858 | which is a documentation system that uses a single source file to | |
7859 | produce both on-line information and a printed manual. You can use | |
7860 | one of the Info formatting commands to create the on-line version of | |
7861 | the documentation and @TeX{} (or @code{texi2roff}) to typeset the | |
7862 | printed version. | |
7863 | ||
c7cb8acb | 7864 | GDB includes an already formatted copy of the on-line Info version of |
1041a570 RP |
7865 | this manual in the @file{gdb} subdirectory. The main Info file is |
7866 | @file{gdb-@var{version-number}/gdb/gdb.info}, and it refers to | |
7867 | subordinate files matching @samp{gdb.info*} in the same directory. | |
7868 | ||
7869 | If you want to format these Info files yourself, you need one of the | |
7870 | Info formatting programs, such as @code{texinfo-format-buffer} or | |
7871 | @code{makeinfo}. | |
7872 | ||
c7cb8acb | 7873 | If you have @code{makeinfo} installed, and are in the top level GDB |
1041a570 RP |
7874 | source directory (@file{gdb-_GDB_VN__}, in the case of version _GDB_VN__), you can |
7875 | make the Info file by typing: | |
b80282d5 | 7876 | |
3d3ab540 | 7877 | @example |
1041a570 | 7878 | cd gdb |
3d3ab540 RP |
7879 | make gdb.info |
7880 | @end example | |
3d3ab540 | 7881 | |
1041a570 RP |
7882 | If you want to typeset and print copies of this manual, you need |
7883 | @TeX{}, a printing program such as @code{lpr}, and @file{texinfo.tex}, | |
7884 | the Texinfo definitions file. | |
7885 | ||
7886 | @TeX{} is typesetting program; it does not print files directly, but | |
7887 | produces output files called @sc{dvi} files. To print a typeset | |
7888 | document, you need a program to print @sc{dvi} files. If your system | |
7889 | has @TeX{} installed, chances are it has such a program. The precise | |
7890 | command to use depends on your system; @kbd{lpr -d} is common; another | |
7891 | is @kbd{dvips}. The @sc{dvi} print command may require a file name | |
7892 | without any extension or a @samp{.dvi} extension. | |
7893 | ||
7894 | @TeX{} also requires a macro definitions file called | |
7895 | @file{texinfo.tex}. This file tells @TeX{} how to typeset a document | |
7896 | written in Texinfo format. On its own, @TeX{} cannot read, much less | |
c7cb8acb | 7897 | typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB |
1041a570 RP |
7898 | and is located in the @file{gdb-@var{version-number}/texinfo} |
7899 | directory. | |
7900 | ||
7901 | If you have @TeX{} and a @sc{dvi} printer program installed, you can | |
7902 | typeset and print this manual. First switch to the the @file{gdb} | |
7903 | subdirectory of the main source directory (for example, to | |
7904 | @file{gdb-_GDB_VN__/gdb}) and then type: | |
7905 | ||
3d3ab540 | 7906 | @example |
3d3ab540 RP |
7907 | make gdb.dvi |
7908 | @end example | |
3d3ab540 | 7909 | |
c7cb8acb | 7910 | @cindex GDB reference card |
1041a570 | 7911 | @cindex reference card |
c7cb8acb RP |
7912 | In addition to the manual, the GDB 4 release includes a three-column |
7913 | reference card. Format the GDB reference card by typing: | |
1041a570 | 7914 | |
b80282d5 | 7915 | @example |
b80282d5 RP |
7916 | make refcard.dvi |
7917 | @end example | |
b80282d5 | 7918 | |
c7cb8acb | 7919 | The GDB reference card is designed to print in landscape mode on US |
b80282d5 RP |
7920 | ``letter'' size paper; that is, on a sheet 11 inches wide by 8.5 inches |
7921 | high. You will need to specify this form of printing as an option to | |
7922 | your @sc{dvi} output program. | |
7923 | ||
1041a570 RP |
7924 | The GDB 4 release includes an already-formatted reference card, ready |
7925 | for printing on a PostScript or GhostScript printer, in the @file{gdb} | |
7926 | subdirectory of the main source directory---in | |
7927 | @file{gdb-4.2/gdb/refcard.ps} of the version 4.2 release. If you have | |
7928 | a PostScript or GhostScript printer, you can print the reference card | |
7929 | by just sending @file{refcard.ps} to the printer. | |
b80282d5 | 7930 | |
c7cb8acb | 7931 | @node Copying, Index, Installing GDB, Top |
70b88761 | 7932 | @unnumbered GNU GENERAL PUBLIC LICENSE |
7463aadd | 7933 | @center Version 2, June 1991 |
70b88761 RP |
7934 | |
7935 | @display | |
7463aadd | 7936 | Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. |
70b88761 RP |
7937 | 675 Mass Ave, Cambridge, MA 02139, USA |
7938 | ||
7939 | Everyone is permitted to copy and distribute verbatim copies | |
7940 | of this license document, but changing it is not allowed. | |
7941 | @end display | |
7942 | ||
7943 | @unnumberedsec Preamble | |
7944 | ||
7463aadd RP |
7945 | The licenses for most software are designed to take away your |
7946 | freedom to share and change it. By contrast, the GNU General Public | |
70b88761 | 7947 | License is intended to guarantee your freedom to share and change free |
7463aadd RP |
7948 | software---to make sure the software is free for all its users. This |
7949 | General Public License applies to most of the Free Software | |
7950 | Foundation's software and to any other program whose authors commit to | |
7951 | using it. (Some other Free Software Foundation software is covered by | |
7952 | the GNU Library General Public License instead.) You can apply it to | |
7953 | your programs, too. | |
70b88761 RP |
7954 | |
7955 | When we speak of free software, we are referring to freedom, not | |
7463aadd RP |
7956 | price. Our General Public Licenses are designed to make sure that you |
7957 | have the freedom to distribute copies of free software (and charge for | |
7958 | this service if you wish), that you receive source code or can get it | |
7959 | if you want it, that you can change the software or use pieces of it | |
7960 | in new free programs; and that you know you can do these things. | |
70b88761 RP |
7961 | |
7962 | To protect your rights, we need to make restrictions that forbid | |
7963 | anyone to deny you these rights or to ask you to surrender the rights. | |
7964 | These restrictions translate to certain responsibilities for you if you | |
7965 | distribute copies of the software, or if you modify it. | |
7966 | ||
7463aadd | 7967 | For example, if you distribute copies of such a program, whether |
70b88761 RP |
7968 | gratis or for a fee, you must give the recipients all the rights that |
7969 | you have. You must make sure that they, too, receive or can get the | |
7463aadd RP |
7970 | source code. And you must show them these terms so they know their |
7971 | rights. | |
70b88761 RP |
7972 | |
7973 | We protect your rights with two steps: (1) copyright the software, and | |
7974 | (2) offer you this license which gives you legal permission to copy, | |
7975 | distribute and/or modify the software. | |
7976 | ||
7977 | Also, for each author's protection and ours, we want to make certain | |
7978 | that everyone understands that there is no warranty for this free | |
7979 | software. If the software is modified by someone else and passed on, we | |
7980 | want its recipients to know that what they have is not the original, so | |
7981 | that any problems introduced by others will not reflect on the original | |
7982 | authors' reputations. | |
7983 | ||
7463aadd RP |
7984 | Finally, any free program is threatened constantly by software |
7985 | patents. We wish to avoid the danger that redistributors of a free | |
7986 | program will individually obtain patent licenses, in effect making the | |
7987 | program proprietary. To prevent this, we have made it clear that any | |
7988 | patent must be licensed for everyone's free use or not licensed at all. | |
7989 | ||
70b88761 RP |
7990 | The precise terms and conditions for copying, distribution and |
7991 | modification follow. | |
7992 | ||
7993 | @iftex | |
7463aadd | 7994 | @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
70b88761 RP |
7995 | @end iftex |
7996 | @ifinfo | |
7463aadd | 7997 | @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
70b88761 RP |
7998 | @end ifinfo |
7999 | ||
8000 | @enumerate | |
8001 | @item | |
7463aadd RP |
8002 | This License applies to any program or other work which contains |
8003 | a notice placed by the copyright holder saying it may be distributed | |
8004 | under the terms of this General Public License. The ``Program'', below, | |
8005 | refers to any such program or work, and a ``work based on the Program'' | |
8006 | means either the Program or any derivative work under copyright law: | |
8007 | that is to say, a work containing the Program or a portion of it, | |
8008 | either verbatim or with modifications and/or translated into another | |
8009 | language. (Hereinafter, translation is included without limitation in | |
8010 | the term ``modification''.) Each licensee is addressed as ``you''. | |
8011 | ||
8012 | Activities other than copying, distribution and modification are not | |
8013 | covered by this License; they are outside its scope. The act of | |
8014 | running the Program is not restricted, and the output from the Program | |
8015 | is covered only if its contents constitute a work based on the | |
8016 | Program (independent of having been made by running the Program). | |
8017 | Whether that is true depends on what the Program does. | |
70b88761 RP |
8018 | |
8019 | @item | |
7463aadd RP |
8020 | You may copy and distribute verbatim copies of the Program's |
8021 | source code as you receive it, in any medium, provided that you | |
8022 | conspicuously and appropriately publish on each copy an appropriate | |
8023 | copyright notice and disclaimer of warranty; keep intact all the | |
8024 | notices that refer to this License and to the absence of any warranty; | |
8025 | and give any other recipients of the Program a copy of this License | |
8026 | along with the Program. | |
70b88761 | 8027 | |
7463aadd RP |
8028 | You may charge a fee for the physical act of transferring a copy, and |
8029 | you may at your option offer warranty protection in exchange for a fee. | |
70b88761 | 8030 | |
70b88761 | 8031 | @item |
7463aadd RP |
8032 | You may modify your copy or copies of the Program or any portion |
8033 | of it, thus forming a work based on the Program, and copy and | |
8034 | distribute such modifications or work under the terms of Section 1 | |
8035 | above, provided that you also meet all of these conditions: | |
70b88761 | 8036 | |
1041a570 | 8037 | @enumerate a |
70b88761 | 8038 | @item |
7463aadd RP |
8039 | You must cause the modified files to carry prominent notices |
8040 | stating that you changed the files and the date of any change. | |
70b88761 RP |
8041 | |
8042 | @item | |
7463aadd RP |
8043 | You must cause any work that you distribute or publish, that in |
8044 | whole or in part contains or is derived from the Program or any | |
8045 | part thereof, to be licensed as a whole at no charge to all third | |
8046 | parties under the terms of this License. | |
70b88761 RP |
8047 | |
8048 | @item | |
7463aadd RP |
8049 | If the modified program normally reads commands interactively |
8050 | when run, you must cause it, when started running for such | |
8051 | interactive use in the most ordinary way, to print or display an | |
8052 | announcement including an appropriate copyright notice and a | |
8053 | notice that there is no warranty (or else, saying that you provide | |
8054 | a warranty) and that users may redistribute the program under | |
8055 | these conditions, and telling the user how to view a copy of this | |
8056 | License. (Exception: if the Program itself is interactive but | |
8057 | does not normally print such an announcement, your work based on | |
8058 | the Program is not required to print an announcement.) | |
1041a570 | 8059 | @end enumerate |
7463aadd RP |
8060 | |
8061 | These requirements apply to the modified work as a whole. If | |
8062 | identifiable sections of that work are not derived from the Program, | |
8063 | and can be reasonably considered independent and separate works in | |
8064 | themselves, then this License, and its terms, do not apply to those | |
8065 | sections when you distribute them as separate works. But when you | |
8066 | distribute the same sections as part of a whole which is a work based | |
8067 | on the Program, the distribution of the whole must be on the terms of | |
8068 | this License, whose permissions for other licensees extend to the | |
8069 | entire whole, and thus to each and every part regardless of who wrote it. | |
8070 | ||
8071 | Thus, it is not the intent of this section to claim rights or contest | |
8072 | your rights to work written entirely by you; rather, the intent is to | |
8073 | exercise the right to control the distribution of derivative or | |
8074 | collective works based on the Program. | |
8075 | ||
8076 | In addition, mere aggregation of another work not based on the Program | |
8077 | with the Program (or with a work based on the Program) on a volume of | |
8078 | a storage or distribution medium does not bring the other work under | |
8079 | the scope of this License. | |
70b88761 RP |
8080 | |
8081 | @item | |
7463aadd RP |
8082 | You may copy and distribute the Program (or a work based on it, |
8083 | under Section 2) in object code or executable form under the terms of | |
8084 | Sections 1 and 2 above provided that you also do one of the following: | |
70b88761 | 8085 | |
1041a570 | 8086 | @enumerate a |
70b88761 | 8087 | @item |
7463aadd RP |
8088 | Accompany it with the complete corresponding machine-readable |
8089 | source code, which must be distributed under the terms of Sections | |
8090 | 1 and 2 above on a medium customarily used for software interchange; or, | |
70b88761 RP |
8091 | |
8092 | @item | |
7463aadd RP |
8093 | Accompany it with a written offer, valid for at least three |
8094 | years, to give any third party, for a charge no more than your | |
8095 | cost of physically performing source distribution, a complete | |
8096 | machine-readable copy of the corresponding source code, to be | |
8097 | distributed under the terms of Sections 1 and 2 above on a medium | |
8098 | customarily used for software interchange; or, | |
70b88761 RP |
8099 | |
8100 | @item | |
7463aadd RP |
8101 | Accompany it with the information you received as to the offer |
8102 | to distribute corresponding source code. (This alternative is | |
70b88761 | 8103 | allowed only for noncommercial distribution and only if you |
7463aadd RP |
8104 | received the program in object code or executable form with such |
8105 | an offer, in accord with Subsection b above.) | |
1041a570 | 8106 | @end enumerate |
7463aadd RP |
8107 | |
8108 | The source code for a work means the preferred form of the work for | |
8109 | making modifications to it. For an executable work, complete source | |
8110 | code means all the source code for all modules it contains, plus any | |
8111 | associated interface definition files, plus the scripts used to | |
8112 | control compilation and installation of the executable. However, as a | |
8113 | special exception, the source code distributed need not include | |
8114 | anything that is normally distributed (in either source or binary | |
8115 | form) with the major components (compiler, kernel, and so on) of the | |
8116 | operating system on which the executable runs, unless that component | |
8117 | itself accompanies the executable. | |
8118 | ||
8119 | If distribution of executable or object code is made by offering | |
8120 | access to copy from a designated place, then offering equivalent | |
8121 | access to copy the source code from the same place counts as | |
8122 | distribution of the source code, even though third parties are not | |
8123 | compelled to copy the source along with the object code. | |
70b88761 RP |
8124 | |
8125 | @item | |
7463aadd RP |
8126 | You may not copy, modify, sublicense, or distribute the Program |
8127 | except as expressly provided under this License. Any attempt | |
8128 | otherwise to copy, modify, sublicense or distribute the Program is | |
8129 | void, and will automatically terminate your rights under this License. | |
8130 | However, parties who have received copies, or rights, from you under | |
8131 | this License will not have their licenses terminated so long as such | |
8132 | parties remain in full compliance. | |
70b88761 RP |
8133 | |
8134 | @item | |
7463aadd RP |
8135 | You are not required to accept this License, since you have not |
8136 | signed it. However, nothing else grants you permission to modify or | |
8137 | distribute the Program or its derivative works. These actions are | |
8138 | prohibited by law if you do not accept this License. Therefore, by | |
8139 | modifying or distributing the Program (or any work based on the | |
8140 | Program), you indicate your acceptance of this License to do so, and | |
8141 | all its terms and conditions for copying, distributing or modifying | |
8142 | the Program or works based on it. | |
70b88761 RP |
8143 | |
8144 | @item | |
8145 | Each time you redistribute the Program (or any work based on the | |
7463aadd RP |
8146 | Program), the recipient automatically receives a license from the |
8147 | original licensor to copy, distribute or modify the Program subject to | |
8148 | these terms and conditions. You may not impose any further | |
8149 | restrictions on the recipients' exercise of the rights granted herein. | |
8150 | You are not responsible for enforcing compliance by third parties to | |
8151 | this License. | |
8152 | ||
8153 | @item | |
8154 | If, as a consequence of a court judgment or allegation of patent | |
8155 | infringement or for any other reason (not limited to patent issues), | |
8156 | conditions are imposed on you (whether by court order, agreement or | |
8157 | otherwise) that contradict the conditions of this License, they do not | |
8158 | excuse you from the conditions of this License. If you cannot | |
8159 | distribute so as to satisfy simultaneously your obligations under this | |
8160 | License and any other pertinent obligations, then as a consequence you | |
8161 | may not distribute the Program at all. For example, if a patent | |
8162 | license would not permit royalty-free redistribution of the Program by | |
8163 | all those who receive copies directly or indirectly through you, then | |
8164 | the only way you could satisfy both it and this License would be to | |
8165 | refrain entirely from distribution of the Program. | |
8166 | ||
8167 | If any portion of this section is held invalid or unenforceable under | |
8168 | any particular circumstance, the balance of the section is intended to | |
8169 | apply and the section as a whole is intended to apply in other | |
8170 | circumstances. | |
8171 | ||
8172 | It is not the purpose of this section to induce you to infringe any | |
8173 | patents or other property right claims or to contest validity of any | |
8174 | such claims; this section has the sole purpose of protecting the | |
8175 | integrity of the free software distribution system, which is | |
8176 | implemented by public license practices. Many people have made | |
8177 | generous contributions to the wide range of software distributed | |
8178 | through that system in reliance on consistent application of that | |
8179 | system; it is up to the author/donor to decide if he or she is willing | |
8180 | to distribute software through any other system and a licensee cannot | |
8181 | impose that choice. | |
8182 | ||
8183 | This section is intended to make thoroughly clear what is believed to | |
8184 | be a consequence of the rest of this License. | |
8185 | ||
8186 | @item | |
8187 | If the distribution and/or use of the Program is restricted in | |
8188 | certain countries either by patents or by copyrighted interfaces, the | |
8189 | original copyright holder who places the Program under this License | |
8190 | may add an explicit geographical distribution limitation excluding | |
8191 | those countries, so that distribution is permitted only in or among | |
8192 | countries not thus excluded. In such case, this License incorporates | |
8193 | the limitation as if written in the body of this License. | |
70b88761 RP |
8194 | |
8195 | @item | |
8196 | The Free Software Foundation may publish revised and/or new versions | |
8197 | of the General Public License from time to time. Such new versions will | |
8198 | be similar in spirit to the present version, but may differ in detail to | |
8199 | address new problems or concerns. | |
8200 | ||
8201 | Each version is given a distinguishing version number. If the Program | |
7463aadd | 8202 | specifies a version number of this License which applies to it and ``any |
70b88761 RP |
8203 | later version'', you have the option of following the terms and conditions |
8204 | either of that version or of any later version published by the Free | |
8205 | Software Foundation. If the Program does not specify a version number of | |
7463aadd | 8206 | this License, you may choose any version ever published by the Free Software |
70b88761 RP |
8207 | Foundation. |
8208 | ||
8209 | @item | |
8210 | If you wish to incorporate parts of the Program into other free | |
8211 | programs whose distribution conditions are different, write to the author | |
8212 | to ask for permission. For software which is copyrighted by the Free | |
8213 | Software Foundation, write to the Free Software Foundation; we sometimes | |
8214 | make exceptions for this. Our decision will be guided by the two goals | |
8215 | of preserving the free status of all derivatives of our free software and | |
8216 | of promoting the sharing and reuse of software generally. | |
8217 | ||
8218 | @iftex | |
8219 | @heading NO WARRANTY | |
8220 | @end iftex | |
8221 | @ifinfo | |
8222 | @center NO WARRANTY | |
8223 | @end ifinfo | |
8224 | ||
8225 | @item | |
8226 | BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | |
8227 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | |
8228 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | |
8229 | PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | |
8230 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
8231 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | |
8232 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | |
8233 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | |
8234 | REPAIR OR CORRECTION. | |
8235 | ||
8236 | @item | |
7463aadd RP |
8237 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
8238 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | |
70b88761 | 8239 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
7463aadd RP |
8240 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
8241 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | |
8242 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | |
8243 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | |
8244 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | |
8245 | POSSIBILITY OF SUCH DAMAGES. | |
70b88761 RP |
8246 | @end enumerate |
8247 | ||
8248 | @iftex | |
8249 | @heading END OF TERMS AND CONDITIONS | |
8250 | @end iftex | |
8251 | @ifinfo | |
8252 | @center END OF TERMS AND CONDITIONS | |
8253 | @end ifinfo | |
8254 | ||
8255 | @page | |
54e6b3c3 | 8256 | @unnumberedsec Applying These Terms to Your New Programs |
70b88761 RP |
8257 | |
8258 | If you develop a new program, and you want it to be of the greatest | |
7463aadd RP |
8259 | possible use to the public, the best way to achieve this is to make it |
8260 | free software which everyone can redistribute and change under these terms. | |
70b88761 | 8261 | |
7463aadd RP |
8262 | To do so, attach the following notices to the program. It is safest |
8263 | to attach them to the start of each source file to most effectively | |
8264 | convey the exclusion of warranty; and each file should have at least | |
8265 | the ``copyright'' line and a pointer to where the full notice is found. | |
70b88761 RP |
8266 | |
8267 | @smallexample | |
203eea5d | 8268 | @var{one line to give the program's name and an idea of what it does.} |
70b88761 RP |
8269 | Copyright (C) 19@var{yy} @var{name of author} |
8270 | ||
203eea5d RP |
8271 | This program is free software; you can redistribute it and/or |
8272 | modify it under the terms of the GNU General Public License | |
8273 | as published by the Free Software Foundation; either version 2 | |
8274 | of the License, or (at your option) any later version. | |
70b88761 RP |
8275 | |
8276 | This program is distributed in the hope that it will be useful, | |
8277 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8278 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
8279 | GNU General Public License for more details. | |
8280 | ||
8281 | You should have received a copy of the GNU General Public License | |
203eea5d RP |
8282 | along with this program; if not, write to the |
8283 | Free Software Foundation, Inc., 675 Mass Ave, | |
8284 | Cambridge, MA 02139, USA. | |
70b88761 RP |
8285 | @end smallexample |
8286 | ||
8287 | Also add information on how to contact you by electronic and paper mail. | |
8288 | ||
8289 | If the program is interactive, make it output a short notice like this | |
8290 | when it starts in an interactive mode: | |
8291 | ||
8292 | @smallexample | |
8293 | Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} | |
203eea5d RP |
8294 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details |
8295 | type `show w'. This is free software, and you are welcome | |
8296 | to redistribute it under certain conditions; type `show c' | |
8297 | for details. | |
70b88761 RP |
8298 | @end smallexample |
8299 | ||
7463aadd RP |
8300 | The hypothetical commands @samp{show w} and @samp{show c} should show |
8301 | the appropriate parts of the General Public License. Of course, the | |
8302 | commands you use may be called something other than @samp{show w} and | |
8303 | @samp{show c}; they could even be mouse-clicks or menu items---whatever | |
8304 | suits your program. | |
70b88761 RP |
8305 | |
8306 | You should also get your employer (if you work as a programmer) or your | |
8307 | school, if any, to sign a ``copyright disclaimer'' for the program, if | |
8308 | necessary. Here is a sample; alter the names: | |
8309 | ||
1041a570 RP |
8310 | @example |
8311 | Yoyodyne, Inc., hereby disclaims all copyright | |
8312 | interest in the program `Gnomovision' | |
8313 | (which makes passes at compilers) written | |
8314 | by James Hacker. | |
70b88761 RP |
8315 | |
8316 | @var{signature of Ty Coon}, 1 April 1989 | |
8317 | Ty Coon, President of Vice | |
1041a570 | 8318 | @end example |
7463aadd RP |
8319 | |
8320 | This General Public License does not permit incorporating your program into | |
8321 | proprietary programs. If your program is a subroutine library, you may | |
8322 | consider it more useful to permit linking proprietary applications with the | |
8323 | library. If this is what you want to do, use the GNU Library General | |
8324 | Public License instead of this License. | |
70b88761 | 8325 | |
9c3ad547 | 8326 | @node Index, , Copying, Top |
d2e08421 | 8327 | @unnumbered Index |
e91b87a3 | 8328 | |
8329 | @printindex cp | |
8330 | ||
fe3f5fc8 RP |
8331 | @tex |
8332 | % I think something like @colophon should be in texinfo. In the | |
8333 | % meantime: | |
8334 | \long\def\colophon{\hbox to0pt{}\vfill | |
8335 | \centerline{The body of this manual is set in} | |
8336 | \centerline{\fontname\tenrm,} | |
8337 | \centerline{with headings in {\bf\fontname\tenbf}} | |
8338 | \centerline{and examples in {\tt\fontname\tentt}.} | |
a6d0b6d3 RP |
8339 | \centerline{{\it\fontname\tenit\/},} |
8340 | \centerline{{\bf\fontname\tenbf}, and} | |
fe3f5fc8 RP |
8341 | \centerline{{\sl\fontname\tensl\/}} |
8342 | \centerline{are used for emphasis.}\vfill} | |
8343 | \page\colophon | |
a6d0b6d3 | 8344 | % Blame: [email protected], 1991. |
fe3f5fc8 RP |
8345 | @end tex |
8346 | ||
e91b87a3 | 8347 | @contents |
8348 | @bye |