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