Commit | Line | Data |
---|---|---|
29a2b744 | 1 | \input texinfo @c -*-texinfo-*- |
1041a570 | 2 | @c Copyright (c) 1988 1989 1990 1991 1992 Free Software Foundation, Inc. |
18fae2a8 | 3 | @c |
29a2b744 | 4 | @c %**start of header |
18fae2a8 RP |
5 | @c makeinfo ignores cmds prev to setfilename, so its arg cannot make use |
6 | @c of @set vars. However, we can override filename with makeinfo -o. | |
7 | @setfilename gdb.info | |
8 | @c | |
9 | @include gdb-config.texi | |
10 | @c | |
11 | @ifset GENERIC | |
12 | @settitle Debugging with @value{GDBN} | |
13 | @end ifset | |
14 | @ifclear GENERIC | |
15 | @settitle Debugging with @value{GDBN} (@value{HOST}) | |
16 | @end ifclear | |
29a2b744 | 17 | @setchapternewpage odd |
fb4bb43e RP |
18 | @c @smallbook |
19 | @c @cropmarks | |
29a2b744 RP |
20 | @c %**end of header |
21 | ||
22 | @finalout | |
23 | @syncodeindex ky cp | |
24 | ||
18fae2a8 | 25 | @c ===> NOTE! <== |
29a2b744 RP |
26 | @c Determine the edition number in *three* places by hand: |
27 | @c 1. First ifinfo section 2. title page 3. top node | |
28 | @c To find the locations, search for !!set | |
29 | ||
30 | @c The following is for Pesch for his RCS system. | |
31 | @c This revision number *not* the same as the Edition number. | |
32 | @tex | |
33 | \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ | |
34 | \xdef\manvers{\$Revision$} % For use in headers, footers too | |
35 | @end tex | |
36 | ||
d24e0922 | 37 | @c GDB CHANGELOG CONSULTED BETWEEN: |
29a2b744 RP |
38 | @c Fri Oct 11 23:27:06 1991 John Gilmore (gnu at cygnus.com) |
39 | @c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint) | |
40 | ||
9c3ad547 | 41 | @c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly. |
29a2b744 | 42 | |
b7becc8f RP |
43 | @ifinfo |
44 | @format | |
45 | START-INFO-DIR-ENTRY | |
29a2b744 | 46 | * Gdb: (gdb). The GNU debugger. |
b7becc8f RP |
47 | END-INFO-DIR-ENTRY |
48 | @end format | |
49 | @end ifinfo | |
18fae2a8 | 50 | @c |
70b88761 | 51 | @c |
70b88761 | 52 | @ifinfo |
18fae2a8 | 53 | This file documents the GNU debugger @value{GDBN}. |
70b88761 | 54 | |
29a2b744 | 55 | @c !!set edition, date, version |
a37d76c9 | 56 | This is Edition 4.06, October 1992, |
18fae2a8 RP |
57 | of @cite{Debugging with @value{GDBN}: the GNU Source-Level Debugger} |
58 | for GDB Version @value{GDBVN}. | |
29a2b744 | 59 | |
95d5ceb9 | 60 | Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. |
70b88761 RP |
61 | |
62 | Permission is granted to make and distribute verbatim copies of | |
63 | this manual provided the copyright notice and this permission notice | |
64 | are preserved on all copies. | |
65 | ||
66 | @ignore | |
67 | Permission is granted to process this file through TeX and print the | |
68 | results, provided the printed document carries copying permission | |
69 | notice identical to this one except for the removal of this paragraph | |
70 | (this paragraph not being relevant to the printed manual). | |
71 | ||
72 | @end ignore | |
73 | Permission is granted to copy and distribute modified versions of this | |
74 | manual under the conditions for verbatim copying, provided also that the | |
75 | section entitled ``GNU General Public License'' is included exactly as | |
76 | in the original, and provided that the entire resulting derived work is | |
77 | distributed under the terms of a permission notice identical to this | |
78 | one. | |
79 | ||
80 | Permission is granted to copy and distribute translations of this manual | |
81 | into another language, under the above conditions for modified versions, | |
82 | except that the section entitled ``GNU General Public License'' may be | |
83 | included in a translation approved by the Free Software Foundation | |
84 | instead of in the original English. | |
85 | @end ifinfo | |
1041a570 | 86 | |
70b88761 | 87 | @titlepage |
18fae2a8 | 88 | @title Debugging with @value{GDBN} |
95d5ceb9 | 89 | @subtitle The GNU Source-Level Debugger |
18fae2a8 RP |
90 | @ifclear GENERIC |
91 | @subtitle on @value{HOST} Systems | |
92 | @end ifclear | |
70b88761 | 93 | @sp 1 |
29a2b744 | 94 | @c !!set edition, date, version |
18fae2a8 | 95 | @subtitle Edition 4.06, for @value{GDBN} version @value{GDBVN} |
a37d76c9 | 96 | @subtitle October 1992 |
29a2b744 | 97 | @author by Richard M. Stallman and Roland H. Pesch |
70b88761 RP |
98 | @page |
99 | @tex | |
100 | {\parskip=0pt | |
93ac5532 | 101 | \hfill pesch\@cygnus.com\par |
18fae2a8 RP |
102 | \hfill (Send bugs and comments on @value{GDBN} to bug-gdb\@prep.ai.mit.edu.)\par |
103 | \hfill {\it Debugging with @value{GDBN}}, \manvers\par | |
70b88761 RP |
104 | \hfill \TeX{}info \texinfoversion\par |
105 | } | |
106 | @end tex | |
107 | ||
108 | @vskip 0pt plus 1filll | |
1041a570 | 109 | Copyright @copyright{} 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. |
70b88761 RP |
110 | |
111 | Permission is granted to make and distribute verbatim copies of | |
112 | this manual provided the copyright notice and this permission notice | |
113 | are preserved on all copies. | |
114 | ||
115 | Permission is granted to copy and distribute modified versions of this | |
116 | manual under the conditions for verbatim copying, provided also that the | |
117 | section entitled ``GNU General Public License'' is included exactly as | |
118 | in the original, and provided that the entire resulting derived work is | |
119 | distributed under the terms of a permission notice identical to this | |
120 | one. | |
121 | ||
122 | Permission is granted to copy and distribute translations of this manual | |
123 | into another language, under the above conditions for modified versions, | |
124 | except that the section entitled ``GNU General Public License'' may be | |
125 | included in a translation approved by the Free Software Foundation | |
126 | instead of in the original English. | |
127 | @end titlepage | |
128 | @page | |
129 | ||
70b88761 | 130 | @ifinfo |
4eb4cf57 | 131 | @node Top |
18fae2a8 | 132 | @top Debugging with @value{GDBN} |
29a2b744 | 133 | |
18fae2a8 | 134 | This file describes @value{GDBN}, the GNU symbolic debugger. |
29a2b744 RP |
135 | |
136 | @c !!set edition, date, version | |
18fae2a8 | 137 | This is Edition 4.06, October 1992, for GDB Version @value{GDBVN}. |
70b88761 | 138 | |
18fae2a8 RP |
139 | @c Makeinfo node defaulting gets very confused by conditionals in menus, |
140 | @c unfortunately. Otherwise we would use the following ignored menu, | |
141 | @c which involves four switches: | |
142 | @ignore | |
70b88761 | 143 | @menu |
18fae2a8 RP |
144 | * Summary:: Summary of @value{GDBN} |
145 | @ifset NOVEL | |
c7cb8acb | 146 | * New Features:: New features since GDB version 3.5 |
18fae2a8 RP |
147 | @end ifset |
148 | @ifclear BARETARGET | |
149 | * Sample Session:: A sample @value{GDBN} session | |
150 | @end ifclear | |
151 | * Invocation:: Getting in and out of @value{GDBN} | |
152 | * Commands:: @value{GDBN} commands | |
153 | * Running:: Running programs under @value{GDBN} | |
29a2b744 RP |
154 | * Stopping:: Stopping and continuing |
155 | * Stack:: Examining the stack | |
156 | * Source:: Examining source files | |
157 | * Data:: Examining data | |
18fae2a8 RP |
158 | @ifclear CONLY |
159 | * Languages:: Using @value{GDBN} with different languages | |
160 | @end ifclear | |
161 | @ifset CONLY | |
4eb4cf57 | 162 | * C:: C and C++ |
18fae2a8 RP |
163 | @end ifset |
164 | * Symbols:: Examining the symbol table | |
165 | * Altering:: Altering execution | |
166 | * GDB Files:: @value{GDBN}'s files | |
167 | * Targets:: Specifying a debugging target | |
168 | * Controlling GDB:: Controlling @value{GDBN} | |
169 | * Sequences:: Canned sequences of commands | |
170 | @ifclear DOSHOST | |
171 | * Emacs:: Using @value{GDBN} under GNU Emacs | |
172 | @end ifclear | |
173 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
174 | @ifset NOVEL | |
175 | * Renamed Commands:: | |
176 | @end ifset | |
177 | * Formatting Documentation:: How to format and print GDB documentation | |
178 | * Installing GDB:: Installing GDB | |
179 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
180 | * Index:: Index | |
181 | @end menu | |
182 | @end ignore | |
183 | @c | |
184 | @c Since that doesn't work, we must unroll the above into 16 cases: | |
185 | @c | |
186 | @c Menu for NOVEL && !BARETARGET && !CONLY && !DOSHOST | |
187 | @ifset NOVEL | |
188 | @ifclear BARETARGET | |
189 | @ifclear CONLY | |
190 | @ifclear DOSHOST | |
191 | @menu | |
192 | * Summary:: Summary of @value{GDBN} | |
193 | * New Features:: New features since GDB version 3.5 | |
194 | * Sample Session:: A sample @value{GDBN} session | |
195 | * Invocation:: Getting in and out of @value{GDBN} | |
196 | * Commands:: @value{GDBN} commands | |
197 | * Running:: Running programs under @value{GDBN} | |
198 | * Stopping:: Stopping and continuing | |
199 | * Stack:: Examining the stack | |
200 | * Source:: Examining source files | |
201 | * Data:: Examining data | |
202 | * Languages:: Using @value{GDBN} with different languages | |
203 | * Symbols:: Examining the symbol table | |
204 | * Altering:: Altering execution | |
205 | * GDB Files:: @value{GDBN}'s files | |
206 | * Targets:: Specifying a debugging target | |
207 | * Controlling GDB:: Controlling @value{GDBN} | |
208 | * Sequences:: Canned sequences of commands | |
209 | * Emacs:: Using @value{GDBN} under GNU Emacs | |
210 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
211 | * Renamed Commands:: | |
212 | * Formatting Documentation:: How to format and print GDB documentation | |
213 | * Installing GDB:: Installing GDB | |
214 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
215 | * Index:: Index | |
216 | @end menu | |
217 | @end ifclear | |
218 | @end ifclear | |
219 | @end ifclear | |
220 | @end ifset | |
221 | ||
222 | @c Menu for NOVEL && !BARETARGET && !CONLY && DOSHOST | |
223 | @ifset NOVEL | |
224 | @ifclear BARETARGET | |
225 | @ifclear CONLY | |
226 | @ifset DOSHOST | |
227 | @menu | |
228 | * Summary:: Summary of @value{GDBN} | |
229 | * New Features:: New features since GDB version 3.5 | |
230 | * Sample Session:: A sample @value{GDBN} session | |
231 | * Invocation:: Getting in and out of @value{GDBN} | |
232 | * Commands:: @value{GDBN} commands | |
233 | * Running:: Running programs under @value{GDBN} | |
234 | * Stopping:: Stopping and continuing | |
235 | * Stack:: Examining the stack | |
236 | * Source:: Examining source files | |
237 | * Data:: Examining data | |
238 | * Languages:: Using @value{GDBN} with different languages | |
239 | * Symbols:: Examining the symbol table | |
240 | * Altering:: Altering execution | |
241 | * GDB Files:: @value{GDBN}'s files | |
242 | * Targets:: Specifying a debugging target | |
243 | * Controlling GDB:: Controlling @value{GDBN} | |
244 | * Sequences:: Canned sequences of commands | |
245 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
246 | * Renamed Commands:: | |
247 | * Formatting Documentation:: How to format and print GDB documentation | |
248 | * Installing GDB:: Installing GDB | |
249 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
250 | * Index:: Index | |
251 | @end menu | |
252 | @end ifset | |
253 | @end ifclear | |
254 | @end ifclear | |
255 | @end ifset | |
256 | ||
257 | @c Menu for NOVEL && !BARETARGET && CONLY && !DOSHOST | |
258 | @ifset NOVEL | |
259 | @ifclear BARETARGET | |
260 | @ifset CONLY | |
261 | @ifclear DOSHOST | |
262 | @menu | |
263 | * Summary:: Summary of @value{GDBN} | |
264 | * New Features:: New features since GDB version 3.5 | |
265 | * Sample Session:: A sample @value{GDBN} session | |
266 | * Invocation:: Getting in and out of @value{GDBN} | |
267 | * Commands:: @value{GDBN} commands | |
268 | * Running:: Running programs under @value{GDBN} | |
269 | * Stopping:: Stopping and continuing | |
270 | * Stack:: Examining the stack | |
271 | * Source:: Examining source files | |
272 | * Data:: Examining data | |
273 | * C:: C Language Support | |
274 | * Symbols:: Examining the symbol table | |
275 | * Altering:: Altering execution | |
276 | * GDB Files:: @value{GDBN}'s files | |
277 | * Targets:: Specifying a debugging target | |
278 | * Controlling GDB:: Controlling @value{GDBN} | |
279 | * Sequences:: Canned sequences of commands | |
280 | * Emacs:: Using @value{GDBN} under GNU Emacs | |
281 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
282 | * Renamed Commands:: | |
283 | * Formatting Documentation:: How to format and print GDB documentation | |
284 | * Installing GDB:: Installing GDB | |
285 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
286 | * Index:: Index | |
287 | @end menu | |
288 | @end ifclear | |
289 | @end ifset | |
290 | @end ifclear | |
291 | @end ifset | |
292 | ||
293 | @c Menu for NOVEL && !BARETARGET && CONLY && DOSHOST | |
294 | @ifset NOVEL | |
295 | @ifclear BARETARGET | |
296 | @ifset CONLY | |
297 | @ifset DOSHOST | |
298 | @menu | |
299 | * Summary:: Summary of @value{GDBN} | |
300 | * New Features:: New features since GDB version 3.5 | |
301 | * Sample Session:: A sample @value{GDBN} session | |
302 | * Invocation:: Getting in and out of @value{GDBN} | |
303 | * Commands:: @value{GDBN} commands | |
304 | * Running:: Running programs under @value{GDBN} | |
305 | * Stopping:: Stopping and continuing | |
306 | * Stack:: Examining the stack | |
307 | * Source:: Examining source files | |
308 | * Data:: Examining data | |
309 | * C:: C Language Support | |
310 | * Symbols:: Examining the symbol table | |
311 | * Altering:: Altering execution | |
312 | * GDB Files:: @value{GDBN}'s files | |
313 | * Targets:: Specifying a debugging target | |
314 | * Controlling GDB:: Controlling @value{GDBN} | |
315 | * Sequences:: Canned sequences of commands | |
316 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
317 | * Renamed Commands:: | |
318 | * Formatting Documentation:: How to format and print GDB documentation | |
319 | * Installing GDB:: Installing GDB | |
320 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
321 | * Index:: Index | |
322 | @end menu | |
323 | @end ifset | |
324 | @end ifset | |
325 | @end ifclear | |
326 | @end ifset | |
327 | ||
328 | @c Menu for NOVEL && BARETARGET && !CONLY && !DOSHOST | |
329 | @ifset NOVEL | |
330 | @ifset BARETARGET | |
331 | @ifclear CONLY | |
332 | @ifclear DOSHOST | |
333 | @menu | |
334 | * Summary:: Summary of @value{GDBN} | |
335 | * New Features:: New features since GDB version 3.5 | |
336 | * Invocation:: Getting in and out of @value{GDBN} | |
337 | * Commands:: @value{GDBN} commands | |
338 | * Running:: Running programs under @value{GDBN} | |
339 | * Stopping:: Stopping and continuing | |
340 | * Stack:: Examining the stack | |
341 | * Source:: Examining source files | |
342 | * Data:: Examining data | |
343 | * Languages:: Using @value{GDBN} with different languages | |
344 | * Symbols:: Examining the symbol table | |
345 | * Altering:: Altering execution | |
346 | * GDB Files:: @value{GDBN}'s files | |
347 | * Targets:: Specifying a debugging target | |
348 | * Controlling GDB:: Controlling @value{GDBN} | |
349 | * Sequences:: Canned sequences of commands | |
350 | * Emacs:: Using @value{GDBN} under GNU Emacs | |
351 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
352 | * Renamed Commands:: | |
353 | * Formatting Documentation:: How to format and print GDB documentation | |
354 | * Installing GDB:: Installing GDB | |
355 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
356 | * Index:: Index | |
357 | @end menu | |
358 | @end ifclear | |
359 | @end ifclear | |
360 | @end ifset | |
361 | @end ifset | |
362 | ||
363 | @c Menu for NOVEL && BARETARGET && !CONLY && DOSHOST | |
364 | @ifset NOVEL | |
365 | @ifset BARETARGET | |
366 | @ifclear CONLY | |
367 | @ifset DOSHOST | |
368 | @menu | |
369 | * Summary:: Summary of @value{GDBN} | |
370 | * New Features:: New features since GDB version 3.5 | |
371 | * Invocation:: Getting in and out of @value{GDBN} | |
372 | * Commands:: @value{GDBN} commands | |
373 | * Running:: Running programs under @value{GDBN} | |
374 | * Stopping:: Stopping and continuing | |
375 | * Stack:: Examining the stack | |
376 | * Source:: Examining source files | |
377 | * Data:: Examining data | |
378 | * Languages:: Using @value{GDBN} with different languages | |
379 | * Symbols:: Examining the symbol table | |
380 | * Altering:: Altering execution | |
381 | * GDB Files:: @value{GDBN}'s files | |
382 | * Targets:: Specifying a debugging target | |
383 | * Controlling GDB:: Controlling @value{GDBN} | |
384 | * Sequences:: Canned sequences of commands | |
385 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
386 | * Renamed Commands:: | |
387 | * Formatting Documentation:: How to format and print GDB documentation | |
388 | * Installing GDB:: Installing GDB | |
389 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
390 | * Index:: Index | |
391 | @end menu | |
392 | @end ifset | |
393 | @end ifclear | |
394 | @end ifset | |
395 | @end ifset | |
396 | ||
397 | @c Menu for NOVEL && BARETARGET && CONLY && !DOSHOST | |
398 | @ifset NOVEL | |
399 | @ifset BARETARGET | |
400 | @ifset CONLY | |
401 | @ifclear DOSHOST | |
402 | @menu | |
403 | * Summary:: Summary of @value{GDBN} | |
404 | * New Features:: New features since GDB version 3.5 | |
405 | * Invocation:: Getting in and out of @value{GDBN} | |
406 | * Commands:: @value{GDBN} commands | |
407 | * Running:: Running programs under @value{GDBN} | |
408 | * Stopping:: Stopping and continuing | |
409 | * Stack:: Examining the stack | |
410 | * Source:: Examining source files | |
411 | * Data:: Examining data | |
412 | * C:: C Language support | |
29a2b744 RP |
413 | * Symbols:: Examining the symbol table |
414 | * Altering:: Altering execution | |
18fae2a8 | 415 | * GDB Files:: @value{GDBN}'s files |
29a2b744 | 416 | * Targets:: Specifying a debugging target |
18fae2a8 | 417 | * Controlling GDB:: Controlling @value{GDBN} |
29a2b744 | 418 | * Sequences:: Canned sequences of commands |
18fae2a8 RP |
419 | * Emacs:: Using @value{GDBN} under GNU Emacs |
420 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
e251e767 | 421 | * Renamed Commands:: |
77b46d13 | 422 | * Formatting Documentation:: How to format and print GDB documentation |
c7cb8acb | 423 | * Installing GDB:: Installing GDB |
b80282d5 RP |
424 | * Copying:: GNU GENERAL PUBLIC LICENSE |
425 | * Index:: Index | |
70b88761 | 426 | @end menu |
18fae2a8 RP |
427 | @end ifclear |
428 | @end ifset | |
429 | @end ifset | |
430 | @end ifset | |
431 | ||
432 | @c Menu for NOVEL && BARETARGET && CONLY && DOSHOST | |
433 | @ifset NOVEL | |
434 | @ifset BARETARGET | |
435 | @ifset CONLY | |
436 | @ifset DOSHOST | |
437 | @menu | |
438 | * Summary:: Summary of @value{GDBN} | |
439 | * New Features:: New features since GDB version 3.5 | |
440 | * Invocation:: Getting in and out of @value{GDBN} | |
441 | * Commands:: @value{GDBN} commands | |
442 | * Running:: Running programs under @value{GDBN} | |
443 | * Stopping:: Stopping and continuing | |
444 | * Stack:: Examining the stack | |
445 | * Source:: Examining source files | |
446 | * Data:: Examining data | |
447 | * C:: C Language support | |
448 | * Symbols:: Examining the symbol table | |
449 | * Altering:: Altering execution | |
450 | * GDB Files:: @value{GDBN}'s files | |
451 | * Targets:: Specifying a debugging target | |
452 | * Controlling GDB:: Controlling @value{GDBN} | |
453 | * Sequences:: Canned sequences of commands | |
454 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
455 | * Renamed Commands:: | |
456 | * Formatting Documentation:: How to format and print GDB documentation | |
457 | * Installing GDB:: Installing GDB | |
458 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
459 | * Index:: Index | |
460 | @end menu | |
461 | @end ifset | |
462 | @end ifset | |
463 | @end ifset | |
464 | @end ifset | |
465 | ||
466 | @c Menu for !NOVEL && !BARETARGET && !CONLY && !DOSHOST | |
467 | @ifclear NOVEL | |
468 | @ifclear BARETARGET | |
469 | @ifclear CONLY | |
470 | @ifclear DOSHOST | |
471 | @menu | |
472 | * Summary:: Summary of @value{GDBN} | |
473 | * Sample Session:: A sample @value{GDBN} session | |
474 | * Invocation:: Getting in and out of @value{GDBN} | |
475 | * Commands:: @value{GDBN} commands | |
476 | * Running:: Running programs under @value{GDBN} | |
477 | * Stopping:: Stopping and continuing | |
478 | * Stack:: Examining the stack | |
479 | * Source:: Examining source files | |
480 | * Data:: Examining data | |
481 | * Languages:: Using @value{GDBN} with different languages | |
482 | * Symbols:: Examining the symbol table | |
483 | * Altering:: Altering execution | |
484 | * GDB Files:: @value{GDBN}'s files | |
485 | * Targets:: Specifying a debugging target | |
486 | * Controlling GDB:: Controlling @value{GDBN} | |
487 | * Sequences:: Canned sequences of commands | |
488 | * Emacs:: Using @value{GDBN} under GNU Emacs | |
489 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
490 | * Formatting Documentation:: How to format and print GDB documentation | |
491 | * Installing GDB:: Installing GDB | |
492 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
493 | * Index:: Index | |
494 | @end menu | |
495 | @end ifclear | |
496 | @end ifclear | |
497 | @end ifclear | |
498 | @end ifclear | |
499 | ||
500 | @c Menu for !NOVEL && !BARETARGET && !CONLY && DOSHOST | |
501 | @ifclear NOVEL | |
502 | @ifclear BARETARGET | |
503 | @ifclear CONLY | |
504 | @ifset DOSHOST | |
505 | @menu | |
506 | * Summary:: Summary of @value{GDBN} | |
507 | * Sample Session:: A sample @value{GDBN} session | |
508 | * Invocation:: Getting in and out of @value{GDBN} | |
509 | * Commands:: @value{GDBN} commands | |
510 | * Running:: Running programs under @value{GDBN} | |
511 | * Stopping:: Stopping and continuing | |
512 | * Stack:: Examining the stack | |
513 | * Source:: Examining source files | |
514 | * Data:: Examining data | |
515 | * Languages:: Using @value{GDBN} with different languages | |
516 | * Symbols:: Examining the symbol table | |
517 | * Altering:: Altering execution | |
518 | * GDB Files:: @value{GDBN}'s files | |
519 | * Targets:: Specifying a debugging target | |
520 | * Controlling GDB:: Controlling @value{GDBN} | |
521 | * Sequences:: Canned sequences of commands | |
522 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
523 | * Formatting Documentation:: How to format and print GDB documentation | |
524 | * Installing GDB:: Installing GDB | |
525 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
526 | * Index:: Index | |
527 | @end menu | |
528 | @end ifset | |
529 | @end ifclear | |
530 | @end ifclear | |
531 | @end ifclear | |
532 | ||
533 | @c Menu for !NOVEL && !BARETARGET && CONLY && !DOSHOST | |
534 | @ifclear NOVEL | |
535 | @ifclear BARETARGET | |
536 | @ifset CONLY | |
537 | @ifclear DOSHOST | |
538 | @menu | |
539 | * Summary:: Summary of @value{GDBN} | |
540 | * Sample Session:: A sample @value{GDBN} session | |
541 | * Invocation:: Getting in and out of @value{GDBN} | |
542 | * Commands:: @value{GDBN} commands | |
543 | * Running:: Running programs under @value{GDBN} | |
544 | * Stopping:: Stopping and continuing | |
545 | * Stack:: Examining the stack | |
546 | * Source:: Examining source files | |
547 | * Data:: Examining data | |
548 | * C:: C Language support | |
549 | * Symbols:: Examining the symbol table | |
550 | * Altering:: Altering execution | |
551 | * GDB Files:: @value{GDBN}'s files | |
552 | * Targets:: Specifying a debugging target | |
553 | * Controlling GDB:: Controlling @value{GDBN} | |
554 | * Sequences:: Canned sequences of commands | |
555 | * Emacs:: Using @value{GDBN} under GNU Emacs | |
556 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
557 | * Formatting Documentation:: How to format and print GDB documentation | |
558 | * Installing GDB:: Installing GDB | |
559 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
560 | * Index:: Index | |
561 | @end menu | |
562 | @end ifclear | |
563 | @end ifset | |
564 | @end ifclear | |
565 | @end ifclear | |
566 | ||
567 | @c Menu for !NOVEL && !BARETARGET && CONLY && DOSHOST | |
568 | @ifclear NOVEL | |
569 | @ifclear BARETARGET | |
570 | @ifset CONLY | |
571 | @ifset DOSHOST | |
572 | @menu | |
573 | * Summary:: Summary of @value{GDBN} | |
574 | * Sample Session:: A sample @value{GDBN} session | |
575 | * Invocation:: Getting in and out of @value{GDBN} | |
576 | * Commands:: @value{GDBN} commands | |
577 | * Running:: Running programs under @value{GDBN} | |
578 | * Stopping:: Stopping and continuing | |
579 | * Stack:: Examining the stack | |
580 | * Source:: Examining source files | |
581 | * Data:: Examining data | |
582 | * C:: C Language support | |
583 | * Symbols:: Examining the symbol table | |
584 | * Altering:: Altering execution | |
585 | * GDB Files:: @value{GDBN}'s files | |
586 | * Targets:: Specifying a debugging target | |
587 | * Controlling GDB:: Controlling @value{GDBN} | |
588 | * Sequences:: Canned sequences of commands | |
589 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
590 | * Formatting Documentation:: How to format and print GDB documentation | |
591 | * Installing GDB:: Installing GDB | |
592 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
593 | * Index:: Index | |
594 | @end menu | |
595 | @end ifset | |
596 | @end ifset | |
597 | @end ifclear | |
598 | @end ifclear | |
599 | ||
600 | @c Menu for !NOVEL && BARETARGET && !CONLY && !DOSHOST | |
601 | @ifclear NOVEL | |
602 | @ifset BARETARGET | |
603 | @ifclear CONLY | |
604 | @ifclear DOSHOST | |
605 | @menu | |
606 | * Summary:: Summary of @value{GDBN} | |
607 | * Invocation:: Getting in and out of @value{GDBN} | |
608 | * Commands:: @value{GDBN} commands | |
609 | * Running:: Running programs under @value{GDBN} | |
610 | * Stopping:: Stopping and continuing | |
611 | * Stack:: Examining the stack | |
612 | * Source:: Examining source files | |
613 | * Data:: Examining data | |
614 | * Languages:: Using @value{GDBN} with different languages | |
615 | * Symbols:: Examining the symbol table | |
616 | * Altering:: Altering execution | |
617 | * GDB Files:: @value{GDBN}'s files | |
618 | * Targets:: Specifying a debugging target | |
619 | * Controlling GDB:: Controlling @value{GDBN} | |
620 | * Sequences:: Canned sequences of commands | |
621 | * Emacs:: Using @value{GDBN} under GNU Emacs | |
622 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
623 | * Formatting Documentation:: How to format and print GDB documentation | |
624 | * Installing GDB:: Installing GDB | |
625 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
626 | * Index:: Index | |
627 | @end menu | |
628 | @end ifclear | |
629 | @end ifclear | |
630 | @end ifset | |
631 | @end ifclear | |
632 | ||
633 | @c Menu for !NOVEL && BARETARGET && !CONLY && DOSHOST | |
634 | @ifclear NOVEL | |
635 | @ifset BARETARGET | |
636 | @ifclear CONLY | |
637 | @ifset DOSHOST | |
638 | @menu | |
639 | * Summary:: Summary of @value{GDBN} | |
640 | * Invocation:: Getting in and out of @value{GDBN} | |
641 | * Commands:: @value{GDBN} commands | |
642 | * Running:: Running programs under @value{GDBN} | |
643 | * Stopping:: Stopping and continuing | |
644 | * Stack:: Examining the stack | |
645 | * Source:: Examining source files | |
646 | * Data:: Examining data | |
647 | * Languages:: Using @value{GDBN} with different languages | |
648 | * Symbols:: Examining the symbol table | |
649 | * Altering:: Altering execution | |
650 | * GDB Files:: @value{GDBN}'s files | |
651 | * Targets:: Specifying a debugging target | |
652 | * Controlling GDB:: Controlling @value{GDBN} | |
653 | * Sequences:: Canned sequences of commands | |
654 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
655 | * Formatting Documentation:: How to format and print GDB documentation | |
656 | * Installing GDB:: Installing GDB | |
657 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
658 | * Index:: Index | |
659 | @end menu | |
660 | @end ifset | |
661 | @end ifclear | |
662 | @end ifset | |
663 | @end ifclear | |
664 | ||
665 | @c Menu for !NOVEL && BARETARGET && CONLY && !DOSHOST | |
666 | @ifclear NOVEL | |
667 | @ifset BARETARGET | |
668 | @ifset CONLY | |
669 | @ifclear DOSHOST | |
670 | @menu | |
671 | * Summary:: Summary of @value{GDBN} | |
672 | * Invocation:: Getting in and out of @value{GDBN} | |
673 | * Commands:: @value{GDBN} commands | |
674 | * Running:: Running programs under @value{GDBN} | |
675 | * Stopping:: Stopping and continuing | |
676 | * Stack:: Examining the stack | |
677 | * Source:: Examining source files | |
678 | * Data:: Examining data | |
679 | * C:: C Language Support | |
680 | * Symbols:: Examining the symbol table | |
681 | * Altering:: Altering execution | |
682 | * GDB Files:: @value{GDBN}'s files | |
683 | * Targets:: Specifying a debugging target | |
684 | * Controlling GDB:: Controlling @value{GDBN} | |
685 | * Sequences:: Canned sequences of commands | |
686 | * Emacs:: Using @value{GDBN} under GNU Emacs | |
687 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
688 | * Formatting Documentation:: How to format and print GDB documentation | |
689 | * Installing GDB:: Installing GDB | |
690 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
691 | * Index:: Index | |
692 | @end menu | |
693 | @end ifclear | |
694 | @end ifset | |
695 | @end ifset | |
696 | @end ifclear | |
697 | ||
698 | @c Menu for !NOVEL && BARETARGET && CONLY && DOSHOST | |
699 | @ifclear NOVEL | |
700 | @ifset BARETARGET | |
701 | @ifset CONLY | |
702 | @ifset DOSHOST | |
703 | @menu | |
704 | * Summary:: Summary of @value{GDBN} | |
705 | * Invocation:: Getting in and out of @value{GDBN} | |
706 | * Commands:: @value{GDBN} commands | |
707 | * Running:: Running programs under @value{GDBN} | |
708 | * Stopping:: Stopping and continuing | |
709 | * Stack:: Examining the stack | |
710 | * Source:: Examining source files | |
711 | * Data:: Examining data | |
712 | * C:: C Language Support | |
713 | * Symbols:: Examining the symbol table | |
714 | * Altering:: Altering execution | |
715 | * GDB Files:: @value{GDBN}'s files | |
716 | * Targets:: Specifying a debugging target | |
717 | * Controlling GDB:: Controlling @value{GDBN} | |
718 | * Sequences:: Canned sequences of commands | |
719 | * GDB Bugs:: Reporting bugs in @value{GDBN} | |
720 | * Formatting Documentation:: How to format and print GDB documentation | |
721 | * Installing GDB:: Installing GDB | |
722 | * Copying:: GNU GENERAL PUBLIC LICENSE | |
723 | * Index:: Index | |
724 | @end menu | |
725 | @end ifset | |
726 | @end ifset | |
727 | @end ifset | |
728 | @end ifclear | |
729 | ||
730 | @end ifinfo | |
70b88761 | 731 | |
4eb4cf57 | 732 | @node Summary |
18fae2a8 | 733 | @unnumbered Summary of @value{GDBN} |
70b88761 | 734 | |
18fae2a8 | 735 | The purpose of a debugger such as @value{GDBN} is to allow you to see what is |
70b88761 | 736 | going on ``inside'' another program while it executes---or what another |
1041a570 | 737 | program was doing at the moment it crashed. |
70b88761 | 738 | |
18fae2a8 | 739 | @value{GDBN} can do four main kinds of things (plus other things in support of |
1041a570 | 740 | these) to help you catch bugs in the act: |
70b88761 RP |
741 | |
742 | @itemize @bullet | |
743 | @item | |
744 | Start your program, specifying anything that might affect its behavior. | |
745 | ||
746 | @item | |
747 | Make your program stop on specified conditions. | |
748 | ||
749 | @item | |
750 | Examine what has happened, when your program has stopped. | |
751 | ||
752 | @item | |
753 | Change things in your program, so you can experiment with correcting the | |
754 | effects of one bug and go on to learn about another. | |
755 | @end itemize | |
756 | ||
18fae2a8 RP |
757 | @ifclear CONLY |
758 | You can use @value{GDBN} to debug programs written in C, C++, and Modula-2. | |
c2bbbb22 | 759 | Fortran support will be added when a GNU Fortran compiler is ready. |
18fae2a8 | 760 | @end ifclear |
70b88761 RP |
761 | |
762 | @menu | |
b80282d5 RP |
763 | * Free Software:: Free Software |
764 | * Contributors:: Contributors to GDB | |
70b88761 RP |
765 | @end menu |
766 | ||
4eb4cf57 | 767 | @node Free Software |
70b88761 | 768 | @unnumberedsec Free Software |
1041a570 | 769 | |
18fae2a8 | 770 | @value{GDBN} is @dfn{free software}, protected by the GNU General Public License |
1041a570 | 771 | (GPL). The GPL gives you the freedom to copy or adapt a licensed |
70b88761 RP |
772 | program---but every person getting a copy also gets with it the |
773 | freedom to modify that copy (which means that they must get access to | |
774 | the source code), and the freedom to distribute further copies. | |
775 | Typical software companies use copyrights to limit your freedoms; the | |
776 | Free Software Foundation uses the GPL to preserve these freedoms. | |
777 | ||
778 | Fundamentally, the General Public License is a license which says that | |
29a2b744 | 779 | you have these freedoms and that you cannot take these freedoms away |
70b88761 RP |
780 | from anyone else. |
781 | ||
18fae2a8 | 782 | @ifclear AGGLOMERATION |
29a2b744 | 783 | For full details, @pxref{Copying, ,GNU GENERAL PUBLIC LICENSE}. |
18fae2a8 | 784 | @end ifclear |
1041a570 | 785 | |
4eb4cf57 | 786 | @node Contributors |
70b88761 RP |
787 | @unnumberedsec Contributors to GDB |
788 | ||
789 | Richard Stallman was the original author of GDB, and of many other GNU | |
790 | programs. Many others have contributed to its development. This | |
791 | section attempts to credit major contributors. One of the virtues of | |
792 | free software is that everyone is free to contribute to it; with | |
793 | regret, we cannot actually acknowledge everyone here. The file | |
794 | @file{ChangeLog} in the GDB distribution approximates a blow-by-blow | |
795 | account. | |
796 | ||
797 | Changes much prior to version 2.0 are lost in the mists of time. | |
798 | ||
799 | @quotation | |
800 | @emph{Plea:} Additions to this section are particularly welcome. If you | |
801 | or your friends (or enemies; let's be evenhanded) have been unfairly | |
802 | omitted from this list, we would like to add your names! | |
803 | @end quotation | |
804 | ||
805 | So that they may not regard their long labor as thankless, we | |
69bbcf05 | 806 | particularly thank those who shepherded GDB through major releases: Stu |
6f3ec223 RP |
807 | Grossman and John Gilmore (releases 4.6, 4.5, 4.4), John Gilmore |
808 | (releases 4.3, 4.2, 4.1, 4.0, and 3.9); Jim Kingdon (releases 3.5, 3.4, | |
809 | 3.3); and Randy Smith (releases 3.2, 3.1, 3.0). As major maintainer of | |
810 | GDB for some period, each contributed significantly to the structure, | |
811 | stability, and capabilities of the entire debugger. | |
70b88761 RP |
812 | |
813 | Richard Stallman, assisted at various times by Pete TerMaat, Chris | |
814 | Hanson, and Richard Mlynarik, handled releases through 2.8. | |
815 | ||
816 | Michael Tiemann is the author of most of the GNU C++ support in GDB, | |
817 | with significant additional contributions from Per Bothner. James | |
818 | Clark wrote the GNU C++ demangler. Early work on C++ was by Peter | |
819 | TerMaat (who also did much general update work leading to release 3.0). | |
820 | ||
1041a570 RP |
821 | GDB 4 uses the BFD subroutine library to examine multiple |
822 | object-file formats; BFD was a joint project of David V. | |
823 | Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore. | |
70b88761 | 824 | |
1041a570 RP |
825 | David Johnson wrote the original COFF support; Pace Willison did |
826 | the original support for encapsulated COFF. | |
70b88761 RP |
827 | |
828 | Adam de Boor and Bradley Davis contributed the ISI Optimum V support. | |
829 | Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS | |
1041a570 RP |
830 | support. Jean-Daniel Fekete contributed Sun 386i support. Chris |
831 | Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki | |
832 | Hasei contributed Sony/News OS 3 support. David Johnson contributed | |
833 | Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. | |
834 | Keith Packard contributed NS32K support. Doug Rabson contributed | |
835 | Acorn Risc Machine support. Chris Smith contributed Convex support | |
836 | (and Fortran debugging). Jonathan Stone contributed Pyramid support. | |
837 | Michael Tiemann contributed SPARC support. Tim Tucker contributed | |
838 | support for the Gould NP1 and Gould Powernode. Pace Willison | |
839 | contributed Intel 386 support. Jay Vosburgh contributed Symmetry | |
840 | support. | |
70b88761 | 841 | |
c338a2fd RP |
842 | Rich Schaefer and Peter Schauer helped with support of SunOS shared |
843 | libraries. | |
70b88761 RP |
844 | |
845 | Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about | |
846 | several machine instruction sets. | |
847 | ||
1041a570 RP |
848 | Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped |
849 | develop remote debugging. Intel Corporation and Wind River Systems | |
850 | contributed remote debugging modules for their products. | |
70b88761 | 851 | |
1041a570 RP |
852 | Brian Fox is the author of the readline libraries providing |
853 | command-line editing and command history. | |
70b88761 | 854 | |
1041a570 RP |
855 | Andrew Beers of SUNY Buffalo wrote the language-switching code and |
856 | the Modula-2 support, and contributed the Languages chapter of this | |
857 | manual. | |
c2bbbb22 | 858 | |
6f3ec223 RP |
859 | Fred Fish wrote most of the support for Unix System Vr4, and enhanced |
860 | the command-completion support to cover C++ overloaded symbols. | |
14d01801 | 861 | |
18fae2a8 | 862 | @ifset NOVEL |
4eb4cf57 | 863 | @node New Features |
c7cb8acb | 864 | @unnumbered New Features since GDB version 3.5 |
70b88761 RP |
865 | |
866 | @table @emph | |
867 | @item Targets | |
868 | Using the new command @code{target}, you can select at runtime whether | |
869 | you are debugging local files, local processes, standalone systems over | |
b80282d5 RP |
870 | a serial port, realtime systems over a TCP/IP connection, etc. The |
871 | command @code{load} can download programs into a remote system. Serial | |
b21b18e1 RP |
872 | stubs are available for Motorola 680x0, Intel 80386, and Sparc remote |
873 | systems; GDB also supports debugging realtime processes running under | |
b80282d5 | 874 | VxWorks, using SunRPC Remote Procedure Calls over TCP/IP to talk to a |
b21b18e1 RP |
875 | debugger stub on the target system. Internally, GDB now uses a function |
876 | vector to mediate access to different targets; if you need to add your | |
877 | own support for a remote protocol, this makes it much easier. | |
70b88761 RP |
878 | |
879 | @item Watchpoints | |
c7cb8acb | 880 | GDB now sports watchpoints as well as breakpoints. You can use a |
70b88761 RP |
881 | watchpoint to stop execution whenever the value of an expression |
882 | changes, without having to predict a particular place in your program | |
883 | where this may happen. | |
884 | ||
b80282d5 RP |
885 | @item Wide Output |
886 | Commands that issue wide output now insert newlines at places designed | |
887 | to make the output more readable. | |
888 | ||
70b88761 | 889 | @item Object Code Formats |
c7cb8acb | 890 | GDB uses a new library called the Binary File Descriptor (BFD) |
3d3ab540 RP |
891 | Library to permit it to switch dynamically, without reconfiguration or |
892 | recompilation, between different object-file formats. Formats currently | |
893 | supported are COFF, a.out, and the Intel 960 b.out; files may be read as | |
894 | .o's, archive libraries, or core dumps. BFD is available as a | |
895 | subroutine library so that other programs may take advantage of it, and | |
896 | the other GNU binary utilities are being converted to use it. | |
70b88761 | 897 | |
b80282d5 | 898 | @item Configuration and Ports |
70b88761 | 899 | Compile-time configuration (to select a particular architecture and |
7463aadd | 900 | operating system) is much easier. The script @code{configure} now |
c7cb8acb RP |
901 | allows you to configure GDB as either a native debugger or a |
902 | cross-debugger. @xref{Installing GDB}, for details on how to | |
6a8cb0e7 | 903 | configure. |
70b88761 RP |
904 | |
905 | @item Interaction | |
c7cb8acb | 906 | The user interface to GDB's control variables has been simplified |
70b88761 RP |
907 | and consolidated in two commands, @code{set} and @code{show}. Output |
908 | lines are now broken at readable places, rather than overflowing onto | |
909 | the next line. You can suppress output of machine-level addresses, | |
910 | displaying only source language information. | |
911 | ||
b80282d5 | 912 | @item C++ |
c7cb8acb | 913 | GDB now supports C++ multiple inheritance (if used with a GCC |
b80282d5 | 914 | version 2 compiler), and also has limited support for C++ exception |
c7cb8acb | 915 | handling, with the commands @code{catch} and @code{info catch}: GDB |
b80282d5 RP |
916 | can break when an exception is raised, before the stack is peeled back |
917 | to the exception handler's context. | |
70b88761 | 918 | |
c2bbbb22 | 919 | @item Modula-2 |
c7cb8acb | 920 | GDB now has preliminary support for the GNU Modula-2 compiler, |
c2bbbb22 | 921 | currently under development at the State University of New York at |
c7cb8acb | 922 | Buffalo. Coordinated development of both GDB and the GNU Modula-2 |
5b0fdf7b RP |
923 | compiler will continue into 1992. Other Modula-2 compilers are |
924 | currently not supported, and attempting to debug programs compiled with | |
925 | them will likely result in an error as the symbol table of the | |
926 | executable is read in. | |
c2bbbb22 | 927 | |
70b88761 | 928 | @item Command Rationalization |
c7cb8acb | 929 | Many GDB commands have been renamed to make them easier to remember |
70b88761 RP |
930 | and use. In particular, the subcommands of @code{info} and |
931 | @code{show}/@code{set} are grouped to make the former refer to the state | |
c7cb8acb | 932 | of your program, and the latter refer to the state of GDB itself. |
70b88761 RP |
933 | @xref{Renamed Commands}, for details on what commands were renamed. |
934 | ||
70b88761 | 935 | @item Shared Libraries |
77b46d13 JG |
936 | GDB 4 can debug programs and core files that use SunOS, SVR4, or IBM RS/6000 |
937 | shared libraries. | |
b80282d5 RP |
938 | |
939 | @item Reference Card | |
6f3ec223 RP |
940 | GDB 4 has a reference card. @xref{Formatting Documentation,,Formatting |
941 | the Documentation}, for instructions to print it. | |
70b88761 RP |
942 | |
943 | @item Work in Progress | |
944 | Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture | |
945 | support. | |
70b88761 | 946 | @end table |
18fae2a8 | 947 | @end ifset |
70b88761 | 948 | |
18fae2a8 | 949 | @ifclear BARETARGET |
4eb4cf57 | 950 | @node Sample Session |
18fae2a8 | 951 | @chapter A Sample @value{GDBN} Session |
70b88761 | 952 | |
18fae2a8 | 953 | You can use this manual at your leisure to read all about @value{GDBN}. |
70b88761 RP |
954 | However, a handful of commands are enough to get started using the |
955 | debugger. This chapter illustrates these commands. | |
956 | ||
957 | @iftex | |
6ca72cc6 | 958 | In this sample session, we emphasize user input like this: @b{input}, |
70b88761 RP |
959 | to make it easier to pick out from the surrounding output. |
960 | @end iftex | |
961 | ||
962 | @c FIXME: this example may not be appropriate for some configs, where | |
963 | @c FIXME...primary interest is in remote use. | |
18fae2a8 | 964 | |
70b88761 RP |
965 | One of the preliminary versions of GNU @code{m4} (a generic macro |
966 | processor) exhibits the following bug: sometimes, when we change its | |
967 | quote strings from the default, the commands used to capture one macro's | |
968 | definition in another stop working. In the following short @code{m4} | |
969 | session, we define a macro @code{foo} which expands to @code{0000}; we | |
29a2b744 | 970 | then use the @code{m4} built-in @code{defn} to define @code{bar} as the |
70b88761 RP |
971 | same thing. However, when we change the open quote string to |
972 | @code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same | |
973 | procedure fails to define a new synonym @code{baz}: | |
974 | ||
975 | @smallexample | |
6ca72cc6 RP |
976 | $ @b{cd gnu/m4} |
977 | $ @b{./m4} | |
978 | @b{define(foo,0000)} | |
70b88761 | 979 | |
6ca72cc6 | 980 | @b{foo} |
70b88761 | 981 | 0000 |
6ca72cc6 | 982 | @b{define(bar,defn(`foo'))} |
70b88761 | 983 | |
6ca72cc6 | 984 | @b{bar} |
70b88761 | 985 | 0000 |
6ca72cc6 | 986 | @b{changequote(<QUOTE>,<UNQUOTE>)} |
70b88761 | 987 | |
6ca72cc6 RP |
988 | @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))} |
989 | @b{baz} | |
990 | @b{C-d} | |
70b88761 RP |
991 | m4: End of input: 0: fatal error: EOF in string |
992 | @end smallexample | |
993 | ||
994 | @noindent | |
18fae2a8 | 995 | Let's use @value{GDBN} to try to see what's going on. |
70b88761 RP |
996 | |
997 | @smallexample | |
18fae2a8 | 998 | $ @b{@value{GDBP} m4} |
203eea5d RP |
999 | @c FIXME: this falsifies the exact text played out, to permit smallbook |
1000 | @c FIXME... format to come out better. | |
1001 | GDB is free software and you are welcome to distribute copies | |
1002 | of it under certain conditions; type "show copying" to see | |
1003 | the conditions. | |
1004 | There is absolutely no warranty for GDB; type "show warranty" | |
1005 | for details. | |
18fae2a8 RP |
1006 | GDB @value{GDBVN}, Copyright 1992 Free Software Foundation, Inc... |
1007 | (@value{GDBP}) | |
70b88761 RP |
1008 | @end smallexample |
1009 | ||
1010 | @noindent | |
18fae2a8 | 1011 | @value{GDBN} reads only enough symbol data to know where to find the rest when |
1041a570 | 1012 | needed; as a result, the first prompt comes up very quickly. We now |
18fae2a8 | 1013 | tell @value{GDBN} to use a narrower display width than usual, so that examples |
1041a570 | 1014 | will fit in this manual. |
70b88761 RP |
1015 | |
1016 | @smallexample | |
18fae2a8 | 1017 | (@value{GDBP}) @b{set width 70} |
70b88761 RP |
1018 | @end smallexample |
1019 | ||
e251e767 | 1020 | @noindent |
29a2b744 | 1021 | Let's see how the @code{m4} built-in @code{changequote} works. |
70b88761 | 1022 | Having looked at the source, we know the relevant subroutine is |
18fae2a8 | 1023 | @code{m4_changequote}, so we set a breakpoint there with @value{GDBN}'s |
70b88761 RP |
1024 | @code{break} command. |
1025 | ||
1026 | @smallexample | |
18fae2a8 | 1027 | (@value{GDBP}) @b{break m4_changequote} |
70b88761 RP |
1028 | Breakpoint 1 at 0x62f4: file builtin.c, line 879. |
1029 | @end smallexample | |
1030 | ||
1031 | @noindent | |
18fae2a8 | 1032 | Using the @code{run} command, we start @code{m4} running under @value{GDBN} |
70b88761 RP |
1033 | control; as long as control does not reach the @code{m4_changequote} |
1034 | subroutine, the program runs as usual: | |
1035 | ||
1036 | @smallexample | |
18fae2a8 | 1037 | (@value{GDBP}) @b{run} |
e251e767 | 1038 | Starting program: /work/Editorial/gdb/gnu/m4/m4 |
6ca72cc6 | 1039 | @b{define(foo,0000)} |
70b88761 | 1040 | |
6ca72cc6 | 1041 | @b{foo} |
70b88761 RP |
1042 | 0000 |
1043 | @end smallexample | |
1044 | ||
1045 | @noindent | |
18fae2a8 | 1046 | To trigger the breakpoint, we call @code{changequote}. @value{GDBN} |
70b88761 RP |
1047 | suspends execution of @code{m4}, displaying information about the |
1048 | context where it stops. | |
1049 | ||
1050 | @smallexample | |
6ca72cc6 | 1051 | @b{changequote(<QUOTE>,<UNQUOTE>)} |
70b88761 | 1052 | |
203eea5d RP |
1053 | Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) |
1054 | at builtin.c:879 | |
38962738 | 1055 | 879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3)) |
70b88761 RP |
1056 | @end smallexample |
1057 | ||
1058 | @noindent | |
1059 | Now we use the command @code{n} (@code{next}) to advance execution to | |
1060 | the next line of the current function. | |
1061 | ||
1062 | @smallexample | |
18fae2a8 | 1063 | (@value{GDBP}) @b{n} |
203eea5d RP |
1064 | 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\ |
1065 | : nil, | |
70b88761 RP |
1066 | @end smallexample |
1067 | ||
1068 | @noindent | |
1069 | @code{set_quotes} looks like a promising subroutine. We can go into it | |
1070 | by using the command @code{s} (@code{step}) instead of @code{next}. | |
1071 | @code{step} goes to the next line to be executed in @emph{any} | |
e251e767 | 1072 | subroutine, so it steps into @code{set_quotes}. |
70b88761 RP |
1073 | |
1074 | @smallexample | |
18fae2a8 | 1075 | (@value{GDBP}) @b{s} |
70b88761 RP |
1076 | set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>") |
1077 | at input.c:530 | |
1078 | 530 if (lquote != def_lquote) | |
1079 | @end smallexample | |
1080 | ||
1081 | @noindent | |
29a2b744 RP |
1082 | The display that shows the subroutine where @code{m4} is now |
1083 | suspended (and its arguments) is called a stack frame display. It | |
1084 | shows a summary of the stack. We can use the @code{backtrace} | |
1085 | command (which can also be spelled @code{bt}), to see where we are | |
1086 | in the stack as a whole: the @code{backtrace} command displays a | |
1087 | stack frame for each active subroutine. | |
70b88761 RP |
1088 | |
1089 | @smallexample | |
18fae2a8 | 1090 | (@value{GDBP}) @b{bt} |
70b88761 RP |
1091 | #0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>") |
1092 | at input.c:530 | |
203eea5d RP |
1093 | #1 0x6344 in m4_changequote (argc=3, argv=0x33c70) |
1094 | at builtin.c:882 | |
70b88761 RP |
1095 | #2 0x8174 in expand_macro (sym=0x33320) at macro.c:242 |
1096 | #3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30) | |
1097 | at macro.c:71 | |
1098 | #4 0x79dc in expand_input () at macro.c:40 | |
1099 | #5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195 | |
1100 | @end smallexample | |
1101 | ||
1102 | @noindent | |
1103 | Let's step through a few more lines to see what happens. The first two | |
1104 | times, we can use @samp{s}; the next two times we use @code{n} to avoid | |
1105 | falling into the @code{xstrdup} subroutine. | |
1041a570 | 1106 | |
70b88761 | 1107 | @smallexample |
18fae2a8 | 1108 | (@value{GDBP}) @b{s} |
70b88761 | 1109 | 0x3b5c 532 if (rquote != def_rquote) |
18fae2a8 | 1110 | (@value{GDBP}) @b{s} |
203eea5d RP |
1111 | 0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \ |
1112 | def_lquote : xstrdup(lq); | |
18fae2a8 | 1113 | (@value{GDBP}) @b{n} |
203eea5d RP |
1114 | 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ |
1115 | : xstrdup(rq); | |
18fae2a8 | 1116 | (@value{GDBP}) @b{n} |
70b88761 RP |
1117 | 538 len_lquote = strlen(rquote); |
1118 | @end smallexample | |
1119 | ||
1120 | @noindent | |
1121 | The last line displayed looks a little odd; let's examine the variables | |
1122 | @code{lquote} and @code{rquote} to see if they are in fact the new left | |
1123 | and right quotes we specified. We can use the command @code{p} | |
1124 | (@code{print}) to see their values. | |
1125 | ||
1126 | @smallexample | |
18fae2a8 | 1127 | (@value{GDBP}) @b{p lquote} |
70b88761 | 1128 | $1 = 0x35d40 "<QUOTE>" |
18fae2a8 | 1129 | (@value{GDBP}) @b{p rquote} |
70b88761 RP |
1130 | $2 = 0x35d50 "<UNQUOTE>" |
1131 | @end smallexample | |
1132 | ||
1133 | @noindent | |
1134 | @code{lquote} and @code{rquote} are indeed the new left and right quotes. | |
1135 | Let's look at some context; we can display ten lines of source | |
1136 | surrounding the current line, with the @code{l} (@code{list}) command. | |
1137 | ||
1138 | @smallexample | |
18fae2a8 | 1139 | (@value{GDBP}) @b{l} |
70b88761 | 1140 | 533 xfree(rquote); |
e251e767 | 1141 | 534 |
203eea5d RP |
1142 | 535 lquote = (lq == nil || *lq == '\0') ? def_lquote\ |
1143 | : xstrdup (lq); | |
1144 | 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ | |
1145 | : xstrdup (rq); | |
e251e767 | 1146 | 537 |
70b88761 RP |
1147 | 538 len_lquote = strlen(rquote); |
1148 | 539 len_rquote = strlen(lquote); | |
1149 | 540 @} | |
e251e767 | 1150 | 541 |
70b88761 RP |
1151 | 542 void |
1152 | @end smallexample | |
1153 | ||
1154 | @noindent | |
1155 | Let's step past the two lines that set @code{len_lquote} and | |
1156 | @code{len_rquote}, and then examine the values of those variables. | |
1157 | ||
1158 | @smallexample | |
18fae2a8 | 1159 | (@value{GDBP}) @b{n} |
70b88761 | 1160 | 539 len_rquote = strlen(lquote); |
18fae2a8 | 1161 | (@value{GDBP}) @b{n} |
70b88761 | 1162 | 540 @} |
18fae2a8 | 1163 | (@value{GDBP}) @b{p len_lquote} |
70b88761 | 1164 | $3 = 9 |
18fae2a8 | 1165 | (@value{GDBP}) @b{p len_rquote} |
70b88761 RP |
1166 | $4 = 7 |
1167 | @end smallexample | |
1168 | ||
1169 | @noindent | |
1170 | That certainly looks wrong, assuming @code{len_lquote} and | |
1171 | @code{len_rquote} are meant to be the lengths of @code{lquote} and | |
1172 | @code{rquote} respectively. Let's try setting them to better values. | |
1173 | We can use the @code{p} command for this, since it'll print the value of | |
1174 | any expression---and that expression can include subroutine calls and | |
e251e767 | 1175 | assignments. |
70b88761 RP |
1176 | |
1177 | @smallexample | |
18fae2a8 | 1178 | (@value{GDBP}) @b{p len_lquote=strlen(lquote)} |
70b88761 | 1179 | $5 = 7 |
18fae2a8 | 1180 | (@value{GDBP}) @b{p len_rquote=strlen(rquote)} |
70b88761 RP |
1181 | $6 = 9 |
1182 | @end smallexample | |
1183 | ||
1184 | @noindent | |
1185 | Let's see if that fixes the problem of using the new quotes with the | |
1186 | @code{m4} built-in @code{defn}. We can allow @code{m4} to continue | |
1187 | executing with the @code{c} (@code{continue}) command, and then try the | |
1188 | example that caused trouble initially: | |
1189 | ||
1190 | @smallexample | |
18fae2a8 | 1191 | (@value{GDBP}) @b{c} |
70b88761 RP |
1192 | Continuing. |
1193 | ||
6ca72cc6 | 1194 | @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))} |
70b88761 RP |
1195 | |
1196 | baz | |
1197 | 0000 | |
1198 | @end smallexample | |
1199 | ||
1200 | @noindent | |
1201 | Success! The new quotes now work just as well as the default ones. The | |
1202 | problem seems to have been just the two typos defining the wrong | |
1203 | lengths. We'll let @code{m4} exit by giving it an EOF as input. | |
1204 | ||
1205 | @smallexample | |
6ca72cc6 | 1206 | @b{C-d} |
70b88761 RP |
1207 | Program exited normally. |
1208 | @end smallexample | |
1209 | ||
e251e767 | 1210 | @noindent |
18fae2a8 RP |
1211 | The message @samp{Program exited normally.} is from @value{GDBN}; it |
1212 | indicates @code{m4} has finished executing. We can end our @value{GDBN} | |
1213 | session with the @value{GDBN} @code{quit} command. | |
70b88761 RP |
1214 | |
1215 | @smallexample | |
18fae2a8 RP |
1216 | (@value{GDBP}) @b{quit} |
1217 | @end smallexample | |
1218 | @end ifclear | |
70b88761 | 1219 | |
4eb4cf57 | 1220 | @node Invocation |
18fae2a8 | 1221 | @chapter Getting In and Out of @value{GDBN} |
70b88761 | 1222 | |
18fae2a8 RP |
1223 | This chapter discusses how to start @value{GDBN}, and how to get out of it. |
1224 | (The essentials: type @samp{@value{GDBP}} to start GDB, and type @kbd{quit} | |
c7cb8acb | 1225 | or @kbd{C-d} to exit.) |
29a2b744 | 1226 | |
18fae2a8 RP |
1227 | @ignore |
1228 | @c original form of menu, pre-unfolding: | |
70b88761 | 1229 | @menu |
18fae2a8 RP |
1230 | * Invoking GDB:: Starting @value{GDBN} |
1231 | * Leaving GDB:: Leaving @value{GDBN} | |
1232 | @ifclear BARETARGET | |
b80282d5 | 1233 | * Shell Commands:: Shell Commands |
18fae2a8 | 1234 | @end ifclear |
70b88761 | 1235 | @end menu |
18fae2a8 | 1236 | @end ignore |
70b88761 | 1237 | |
18fae2a8 RP |
1238 | @ifclear BARETARGET |
1239 | @menu | |
1240 | * Invoking GDB:: Starting @value{GDBN} | |
1241 | * Leaving GDB:: Leaving @value{GDBN} | |
1242 | * Shell Commands:: Shell Commands | |
1243 | @end menu | |
1244 | @end ifclear | |
70b88761 | 1245 | |
18fae2a8 RP |
1246 | @ifset BARETARGET |
1247 | @menu | |
1248 | * Invoking GDB:: Starting @value{GDBN} | |
1249 | * Leaving GDB:: Leaving @value{GDBN} | |
1250 | @end menu | |
1251 | @end ifset | |
1252 | ||
1253 | @node Invoking GDB | |
1254 | @section Starting @value{GDBN} | |
1255 | ||
1256 | @ifset HviiiEXCLUSIVE | |
1257 | For details on starting up @value{GDBP} as a | |
4eb4cf57 | 1258 | remote debugger attached to a Hitachi H8/300 board, see @ref{Hitachi |
18fae2a8 RP |
1259 | H8/300 Remote,,@value{GDBN} and the Hitachi H8/300}. |
1260 | @end ifset | |
4eb4cf57 | 1261 | |
18fae2a8 RP |
1262 | Start @value{GDBN} by running the program @code{@value{GDBP}}. Once it's running, |
1263 | @value{GDBN} reads commands from the terminal until you tell it to exit. | |
70b88761 | 1264 | |
18fae2a8 | 1265 | You can also run @code{@value{GDBP}} with a variety of arguments and options, |
c7cb8acb RP |
1266 | to specify more of your debugging environment at the outset. |
1267 | ||
18fae2a8 | 1268 | @ifset GENERIC |
c7cb8acb RP |
1269 | The command-line options described here are designed |
1270 | to cover a variety of situations; in some environments, some of these | |
1271 | options may effectively be unavailable. | |
18fae2a8 | 1272 | @end ifset |
c7cb8acb | 1273 | |
18fae2a8 | 1274 | The most usual way to start @value{GDBN} is with one argument, |
4eb4cf57 | 1275 | specifying an executable program: |
1041a570 | 1276 | |
70b88761 | 1277 | @example |
18fae2a8 | 1278 | @value{GDBP} @var{program} |
70b88761 | 1279 | @end example |
1041a570 | 1280 | |
18fae2a8 | 1281 | @ifclear BARETARGET |
70b88761 | 1282 | @noindent |
29a2b744 RP |
1283 | You can also start with both an executable program and a core file |
1284 | specified: | |
1041a570 | 1285 | |
70b88761 | 1286 | @example |
18fae2a8 | 1287 | @value{GDBP} @var{program} @var{core} |
70b88761 RP |
1288 | @end example |
1289 | ||
b80282d5 RP |
1290 | You can, instead, specify a process ID as a second argument, if you want |
1291 | to debug a running process: | |
1041a570 | 1292 | |
b80282d5 | 1293 | @example |
18fae2a8 | 1294 | @value{GDBP} @var{program} 1234 |
b80282d5 | 1295 | @end example |
1041a570 | 1296 | |
b80282d5 | 1297 | @noindent |
18fae2a8 RP |
1298 | would attach @value{GDBN} to process @code{1234} (unless you also have a file |
1299 | named @file{1234}; @value{GDBN} does check for a core file first). | |
b80282d5 | 1300 | |
c7cb8acb | 1301 | Taking advantage of the second command-line argument requires a fairly |
18fae2a8 | 1302 | complete operating system; when you use @value{GDBN} as a remote debugger |
c7cb8acb RP |
1303 | attached to a bare board, there may not be any notion of ``process'', |
1304 | and there is often no way to get a core dump. | |
18fae2a8 | 1305 | @end ifclear |
c7cb8acb | 1306 | |
70b88761 | 1307 | @noindent |
18fae2a8 RP |
1308 | You can further control how @value{GDBN} starts up by using command-line |
1309 | options. @value{GDBN} itself can remind you of the options available. | |
29a2b744 RP |
1310 | |
1311 | @noindent | |
1312 | Type | |
1313 | ||
70b88761 | 1314 | @example |
18fae2a8 | 1315 | @value{GDBP} -help |
70b88761 | 1316 | @end example |
29a2b744 | 1317 | |
70b88761 | 1318 | @noindent |
29a2b744 | 1319 | to display all available options and briefly describe their use |
18fae2a8 | 1320 | (@samp{@value{GDBP} -h} is a shorter equivalent). |
70b88761 RP |
1321 | |
1322 | All options and command line arguments you give are processed | |
1323 | in sequential order. The order makes a difference when the | |
e251e767 | 1324 | @samp{-x} option is used. |
70b88761 | 1325 | |
18fae2a8 RP |
1326 | |
1327 | @ignore | |
1328 | @c original, intended form of this menu (pre-unfolding): | |
70b88761 | 1329 | @menu |
18fae2a8 RP |
1330 | @ifclear GENERIC |
1331 | @ifset REMOTESTUB | |
1332 | * Remote Serial:: @value{GDBN} remote serial protocol | |
1333 | @end ifset | |
1334 | @ifset Icmlx | |
1335 | * i960-Nindy Remote:: @value{GDBN} with a remote i960 (Nindy) | |
1336 | @end ifset | |
1337 | @ifset AMDxxixK | |
1338 | * EB29K Remote:: @value{GDBN} with a remote EB29K | |
1339 | @end ifset | |
1340 | @ifset VXWORKS | |
1341 | * VxWorks Remote:: @value{GDBN} and VxWorks | |
1342 | @end ifset | |
1343 | @ifset STmm | |
1344 | * ST2000 Remote:: @value{GDBN} with a Tandem ST2000 | |
1345 | @end ifset | |
1346 | @ifset Hviii | |
1347 | * Hitachi H8/300 Remote:: @value{GDBN} and the Hitachi H8/300 | |
1348 | @end ifset | |
1349 | @ifset ZviiiK | |
1350 | * Z8000 Simulator:: @value{GDBN} and its Zilog Z8000 Simulator | |
1351 | @end ifset | |
1352 | @end ifclear | |
4eb4cf57 RP |
1353 | * File Options:: Choosing Files |
1354 | * Mode Options:: Choosing Modes | |
70b88761 | 1355 | @end menu |
18fae2a8 | 1356 | @end ignore |
70b88761 | 1357 | |
18fae2a8 RP |
1358 | @c Unfolded form: |
1359 | @c Sigh--- GENERIC plus 7 switches mean 1+2^7 forms of this menu! | |
1360 | @c Add them only on demand; no point in including forms for which | |
1361 | @c there's no defined config file. Maybe by the time all are needed, | |
1362 | @c makeinfo will be capable of dealing with menus like the above. | |
1363 | ||
1364 | @ifset GENERIC | |
1365 | @menu | |
1366 | * File Options:: Choosing Files | |
1367 | * Mode Options:: Choosing Modes | |
1368 | @end menu | |
1369 | @end ifset | |
1370 | ||
1371 | @c Hviii config: !GENERIC && Hviii && nothing else | |
1372 | @ifclear GENERIC | |
1373 | @ifclear REMOTESTUB | |
1374 | @ifclear Icmlx | |
1375 | @ifclear AMDxxixK | |
1376 | @ifclear VXWORKS | |
1377 | @ifclear STmm | |
1378 | @ifset Hviii | |
1379 | @ifclear ZviiiK | |
1380 | @menu | |
1381 | * Hitachi H8/300 Remote:: @value{GDBN} and the Hitachi H8/300 | |
1382 | * File Options:: Choosing Files | |
1383 | * Mode Options:: Choosing Modes | |
1384 | @end menu | |
1385 | @end ifclear | |
1386 | @end ifset | |
1387 | @end ifclear | |
1388 | @end ifclear | |
1389 | @end ifclear | |
1390 | @end ifclear | |
1391 | @end ifclear | |
1392 | @end ifclear | |
1393 | ||
1394 | @ifclear GENERIC | |
1395 | @include gdbinv-s.texi | |
1396 | @end ifclear | |
4eb4cf57 RP |
1397 | |
1398 | @node File Options | |
70b88761 RP |
1399 | @subsection Choosing Files |
1400 | ||
18fae2a8 RP |
1401 | @ifclear BARETARGET |
1402 | When @value{GDBN} starts, it reads any arguments other than options as | |
29a2b744 RP |
1403 | specifying an executable file and core file (or process ID). This is |
1404 | the same as if the arguments were specified by the @samp{-se} and | |
18fae2a8 | 1405 | @samp{-c} options respectively. (@value{GDBN} reads the first argument |
29a2b744 RP |
1406 | that does not have an associated option flag as equivalent to the |
1407 | @samp{-se} option followed by that argument; and the second argument | |
1408 | that does not have an associated option flag, if any, as equivalent to | |
1409 | the @samp{-c} option followed by that argument.) | |
18fae2a8 RP |
1410 | @end ifclear |
1411 | @ifset BARETARGET | |
1412 | When @value{GDBN} starts, it reads any argument other than options as | |
4eb4cf57 RP |
1413 | specifying an executable file. This is the same as if the argument was |
1414 | specified by the @samp{-se} option. | |
18fae2a8 | 1415 | @end ifset |
29a2b744 RP |
1416 | |
1417 | Many options have both long and short forms; both are shown in the | |
18fae2a8 | 1418 | following list. @value{GDBN} also recognizes the long forms if you truncate |
29a2b744 RP |
1419 | them, so long as enough of the option is present to be unambiguous. |
1420 | (If you prefer, you can flag option arguments with @samp{--} rather | |
1421 | than @samp{-}, though we illustrate the more usual convention.) | |
70b88761 RP |
1422 | |
1423 | @table @code | |
1424 | @item -symbols=@var{file} | |
1425 | @itemx -s @var{file} | |
1426 | Read symbol table from file @var{file}. | |
1427 | ||
1428 | @item -exec=@var{file} | |
1429 | @itemx -e @var{file} | |
1430 | Use file @var{file} as the executable file to execute when | |
1431 | appropriate, and for examining pure data in conjunction with a core | |
1432 | dump. | |
1433 | ||
3d3ab540 | 1434 | @item -se=@var{file} |
70b88761 RP |
1435 | Read symbol table from file @var{file} and use it as the executable |
1436 | file. | |
1437 | ||
18fae2a8 | 1438 | @ifclear BARETARGET |
70b88761 RP |
1439 | @item -core=@var{file} |
1440 | @itemx -c @var{file} | |
1441 | Use file @var{file} as a core dump to examine. | |
18fae2a8 | 1442 | @end ifclear |
70b88761 RP |
1443 | |
1444 | @item -command=@var{file} | |
1445 | @itemx -x @var{file} | |
18fae2a8 | 1446 | Execute @value{GDBN} commands from file @var{file}. @xref{Command Files}. |
70b88761 RP |
1447 | |
1448 | @item -directory=@var{directory} | |
1449 | @itemx -d @var{directory} | |
1450 | Add @var{directory} to the path to search for source files. | |
14d01801 | 1451 | |
18fae2a8 | 1452 | @ifclear BARETARGET |
14d01801 RP |
1453 | @item -m |
1454 | @itemx -mapped | |
1455 | @emph{Warning: this option depends on operating system facilities that are not | |
1456 | supported on all systems.}@* | |
77b46d13 JG |
1457 | If memory-mapped files are available on your system through the @code{mmap} |
1458 | system call, you can use this option | |
18fae2a8 | 1459 | to have @value{GDBN} write the symbols from your |
77b46d13 JG |
1460 | program into a reusable file in the current directory. If the program you are debugging is |
1461 | called @file{/tmp/fred}, the mapped symbol file will be @file{./fred.syms}. | |
18fae2a8 | 1462 | Future @value{GDBN} debugging sessions will notice the presence of this file, |
77b46d13 JG |
1463 | and will quickly map in symbol information from it, rather than reading |
1464 | the symbol table from the executable program. | |
1465 | ||
18fae2a8 RP |
1466 | The @file{.syms} file is specific to the host machine on which @value{GDBN} is run. |
1467 | It holds an exact image of @value{GDBN}'s internal symbol table. It cannot be | |
77b46d13 | 1468 | shared across multiple host platforms. |
18fae2a8 | 1469 | @end ifclear |
77b46d13 JG |
1470 | |
1471 | @item -r | |
1472 | @itemx -readnow | |
1473 | Read each symbol file's entire symbol table immediately, rather than | |
1474 | the default, which is to read it incrementally as it is needed. | |
1475 | This makes startup slower, but makes future operations faster. | |
70b88761 RP |
1476 | @end table |
1477 | ||
18fae2a8 | 1478 | @ifclear BARETARGET |
77b46d13 JG |
1479 | The @code{-mapped} and @code{-readnow} options are typically combined in order to |
1480 | build a @file{.syms} file that contains complete symbol information. | |
1481 | A simple GDB invocation to do nothing but build a @file{.syms} file for future | |
1482 | use is: | |
1483 | ||
1484 | @example | |
1485 | gdb -batch -nx -mapped -readnow programname | |
1486 | @end example | |
18fae2a8 | 1487 | @end ifclear |
77b46d13 | 1488 | |
4eb4cf57 | 1489 | @node Mode Options |
1041a570 RP |
1490 | @subsection Choosing Modes |
1491 | ||
18fae2a8 | 1492 | You can run @value{GDBN} in various alternative modes---for example, in |
29a2b744 | 1493 | batch mode or quiet mode. |
70b88761 RP |
1494 | |
1495 | @table @code | |
1496 | @item -nx | |
1497 | @itemx -n | |
18fae2a8 | 1498 | Do not execute commands from any @file{@value{GDBINIT}} initialization files. |
70b88761 | 1499 | Normally, the commands in these files are executed after all the |
e251e767 | 1500 | command options and arguments have been processed. |
c728f1f0 | 1501 | @xref{Command Files}. |
70b88761 RP |
1502 | |
1503 | @item -quiet | |
1504 | @itemx -q | |
1505 | ``Quiet''. Do not print the introductory and copyright messages. These | |
c338a2fd | 1506 | messages are also suppressed in batch mode. |
70b88761 RP |
1507 | |
1508 | @item -batch | |
1509 | Run in batch mode. Exit with status @code{0} after processing all the command | |
18fae2a8 RP |
1510 | files specified with @samp{-x} (and @file{@value{GDBINIT}}, if not inhibited). |
1511 | Exit with nonzero status if an error occurs in executing the @value{GDBN} | |
e251e767 | 1512 | commands in the command files. |
70b88761 | 1513 | |
18fae2a8 | 1514 | Batch mode may be useful for running @value{GDBN} as a filter, for example to |
70b88761 | 1515 | download and run a program on another computer; in order to make this |
e251e767 | 1516 | more useful, the message |
1041a570 | 1517 | |
70b88761 RP |
1518 | @example |
1519 | Program exited normally. | |
1520 | @end example | |
1041a570 | 1521 | |
70b88761 | 1522 | @noindent |
18fae2a8 | 1523 | (which is ordinarily issued whenever a program running under @value{GDBN} control |
70b88761 RP |
1524 | terminates) is not issued when running in batch mode. |
1525 | ||
3d3ab540 | 1526 | @item -cd=@var{directory} |
18fae2a8 | 1527 | Run @value{GDBN} using @var{directory} as its working directory, |
70b88761 RP |
1528 | instead of the current directory. |
1529 | ||
18fae2a8 | 1530 | @ifset LUCID |
45c53080 | 1531 | @item -context @var{authentication} |
18fae2a8 | 1532 | When the Energize programming system starts up @value{GDBN}, it uses this |
6ca72cc6 | 1533 | option to trigger an alternate mode of interaction. |
18fae2a8 | 1534 | @var{authentication} is a pair of numeric codes that identify @value{GDBN} |
6ca72cc6 | 1535 | as a client in the Energize environment. Avoid this option when you run |
18fae2a8 RP |
1536 | @value{GDBN} directly from the command line. See @ref{Energize,,Using |
1537 | @value{GDBN} with Energize} for more discussion of using @value{GDBN} with Energize. | |
1538 | @end ifset | |
6ca72cc6 | 1539 | |
70b88761 RP |
1540 | @item -fullname |
1541 | @itemx -f | |
18fae2a8 | 1542 | Emacs sets this option when it runs @value{GDBN} as a subprocess. It tells @value{GDBN} |
70b88761 RP |
1543 | to output the full file name and line number in a standard, |
1544 | recognizable fashion each time a stack frame is displayed (which | |
29a2b744 | 1545 | includes each time your program stops). This recognizable format looks |
70b88761 RP |
1546 | like two @samp{\032} characters, followed by the file name, line number |
1547 | and character position separated by colons, and a newline. The | |
18fae2a8 | 1548 | Emacs-to-@value{GDBN} interface program uses the two @samp{\032} characters as |
70b88761 RP |
1549 | a signal to display the source code for the frame. |
1550 | ||
18fae2a8 | 1551 | @ifset SERIAL |
70b88761 RP |
1552 | @item -b @var{bps} |
1553 | Set the line speed (baud rate or bits per second) of any serial | |
18fae2a8 | 1554 | interface used by @value{GDBN} for remote debugging. |
70b88761 | 1555 | |
3d3ab540 | 1556 | @item -tty=@var{device} |
70b88761 | 1557 | Run using @var{device} for your program's standard input and output. |
29a2b744 | 1558 | @c FIXME: kingdon thinks there is more to -tty. Investigate. |
18fae2a8 | 1559 | @end ifset |
70b88761 RP |
1560 | @end table |
1561 | ||
18fae2a8 RP |
1562 | @node Leaving GDB |
1563 | @section Leaving @value{GDBN} | |
1564 | @cindex exiting @value{GDBN} | |
1041a570 | 1565 | |
70b88761 RP |
1566 | @table @code |
1567 | @item quit | |
1568 | @kindex quit | |
1569 | @kindex q | |
18fae2a8 | 1570 | To exit @value{GDBN}, use the @code{quit} command (abbreviated @code{q}), or type |
e251e767 | 1571 | an end-of-file character (usually @kbd{C-d}). |
70b88761 RP |
1572 | @end table |
1573 | ||
1574 | @cindex interrupt | |
18fae2a8 RP |
1575 | An interrupt (often @kbd{C-c}) will not exit from @value{GDBN}, but rather |
1576 | will terminate the action of any @value{GDBN} command that is in progress and | |
1577 | return to @value{GDBN} command level. It is safe to type the interrupt | |
1578 | character at any time because @value{GDBN} does not allow it to take effect | |
70b88761 RP |
1579 | until a time when it is safe. |
1580 | ||
18fae2a8 RP |
1581 | @ifclear BARETARGET |
1582 | If you have been using @value{GDBN} to control an attached process or device, you | |
1041a570 RP |
1583 | can release it with the @code{detach} command; @pxref{Attach, |
1584 | ,Debugging an Already-Running Process}.. | |
18fae2a8 | 1585 | @end ifclear |
70b88761 | 1586 | |
18fae2a8 | 1587 | @ifclear BARETARGET |
4eb4cf57 | 1588 | @node Shell Commands |
70b88761 | 1589 | @section Shell Commands |
1041a570 | 1590 | |
70b88761 | 1591 | If you need to execute occasional shell commands during your |
18fae2a8 | 1592 | debugging session, there is no need to leave or suspend @value{GDBN}; you can |
70b88761 RP |
1593 | just use the @code{shell} command. |
1594 | ||
1595 | @table @code | |
1596 | @item shell @var{command string} | |
1597 | @kindex shell | |
1598 | @cindex shell escape | |
18fae2a8 | 1599 | Directs @value{GDBN} to invoke an inferior shell to execute @var{command |
70b88761 | 1600 | string}. If it exists, the environment variable @code{SHELL} is used |
18fae2a8 | 1601 | for the name of the shell to run. Otherwise @value{GDBN} uses |
70b88761 RP |
1602 | @code{/bin/sh}. |
1603 | @end table | |
1604 | ||
1605 | The utility @code{make} is often needed in development environments. | |
18fae2a8 | 1606 | You do not have to use the @code{shell} command for this purpose in @value{GDBN}: |
70b88761 RP |
1607 | |
1608 | @table @code | |
1609 | @item make @var{make-args} | |
1610 | @kindex make | |
1611 | @cindex calling make | |
18fae2a8 | 1612 | Causes @value{GDBN} to execute an inferior @code{make} program with the specified |
70b88761 RP |
1613 | arguments. This is equivalent to @samp{shell make @var{make-args}}. |
1614 | @end table | |
18fae2a8 | 1615 | @end ifclear |
70b88761 | 1616 | |
4eb4cf57 | 1617 | @node Commands |
18fae2a8 | 1618 | @chapter @value{GDBN} Commands |
70b88761 | 1619 | |
18fae2a8 | 1620 | You can abbreviate a @value{GDBN} command to the first few letters of the command |
6f3ec223 | 1621 | name, if that abbreviation is unambiguous; and you can repeat certain |
18fae2a8 RP |
1622 | @value{GDBN} commands by typing just @key{RET}. You can also use the @key{TAB} |
1623 | key to get @value{GDBN} to fill out the rest of a word in a command (or to | |
6f3ec223 | 1624 | show you the alternatives available, if there's more than one possibility). |
29a2b744 | 1625 | |
70b88761 | 1626 | @menu |
b80282d5 | 1627 | * Command Syntax:: Command Syntax |
6f3ec223 | 1628 | * Completion:: Command Completion |
b80282d5 | 1629 | * Help:: Getting Help |
70b88761 RP |
1630 | @end menu |
1631 | ||
4eb4cf57 | 1632 | @node Command Syntax |
70b88761 | 1633 | @section Command Syntax |
1041a570 | 1634 | |
18fae2a8 | 1635 | A @value{GDBN} command is a single line of input. There is no limit on how long |
70b88761 RP |
1636 | it can be. It starts with a command name, which is followed by arguments |
1637 | whose meaning depends on the command name. For example, the command | |
1638 | @code{step} accepts an argument which is the number of times to step, | |
1639 | as in @samp{step 5}. You can also use the @code{step} command with | |
1640 | no arguments. Some command names do not allow any arguments. | |
1641 | ||
1642 | @cindex abbreviation | |
18fae2a8 | 1643 | @value{GDBN} command names may always be truncated if that abbreviation is |
70b88761 RP |
1644 | unambiguous. Other possible command abbreviations are listed in the |
1645 | documentation for individual commands. In some cases, even ambiguous | |
1646 | abbreviations are allowed; for example, @code{s} is specially defined as | |
1647 | equivalent to @code{step} even though there are other commands whose | |
1648 | names start with @code{s}. You can test abbreviations by using them as | |
7463aadd | 1649 | arguments to the @code{help} command. |
70b88761 | 1650 | |
e251e767 | 1651 | @cindex repeating commands |
70b88761 | 1652 | @kindex RET |
18fae2a8 | 1653 | A blank line as input to @value{GDBN} (typing just @key{RET}) means to |
70b88761 RP |
1654 | repeat the previous command. Certain commands (for example, @code{run}) |
1655 | will not repeat this way; these are commands for which unintentional | |
1656 | repetition might cause trouble and which you are unlikely to want to | |
1657 | repeat. | |
1658 | ||
1659 | The @code{list} and @code{x} commands, when you repeat them with | |
1660 | @key{RET}, construct new arguments rather than repeating | |
1661 | exactly as typed. This permits easy scanning of source or memory. | |
1662 | ||
18fae2a8 | 1663 | @value{GDBN} can also use @key{RET} in another way: to partition lengthy |
b80282d5 | 1664 | output, in a way similar to the common utility @code{more} |
29a2b744 | 1665 | (@pxref{Screen Size}). Since it is easy to press one @key{RET} too many |
18fae2a8 | 1666 | in this situation, @value{GDBN} disables command repetition after any command |
b80282d5 RP |
1667 | that generates this sort of display. |
1668 | ||
70b88761 RP |
1669 | @kindex # |
1670 | @cindex comment | |
1671 | A line of input starting with @kbd{#} is a comment; it does nothing. | |
29a2b744 | 1672 | This is useful mainly in command files (@pxref{Command Files}). |
70b88761 | 1673 | |
4eb4cf57 | 1674 | @node Completion |
6f3ec223 RP |
1675 | @section Command Completion |
1676 | ||
1677 | @cindex completion | |
1678 | @cindex word completion | |
18fae2a8 | 1679 | @value{GDBN} can fill in the rest of a word in a command for you, if there's |
6f3ec223 | 1680 | only one possibility; it can also show you what the valid possibilities |
18fae2a8 RP |
1681 | are for the next word in a command, at any time. This works for @value{GDBN} |
1682 | commands, @value{GDBN} subcommands, and the names of symbols in your program. | |
6f3ec223 | 1683 | |
18fae2a8 RP |
1684 | Press the @key{TAB} key whenever you want @value{GDBN} to fill out the rest |
1685 | of a word. If there's only one possibility, @value{GDBN} will fill in the | |
6f3ec223 RP |
1686 | word, and wait for you to finish the command (or press @key{RET} to |
1687 | enter it). For example, if you type | |
1688 | ||
0fdc6e27 RP |
1689 | @c FIXME "@key" doesn't distinguish its argument sufficiently to permit |
1690 | @c complete accuracy in these examples; space introduced for clarity. | |
1691 | @c If texinfo enhancements make it unnecessary, it would be nice to | |
1692 | @c replace " @key" by "@key" in the following... | |
6f3ec223 | 1693 | @example |
18fae2a8 | 1694 | (@value{GDBP}) info bre @key{TAB} |
6f3ec223 RP |
1695 | @end example |
1696 | ||
1697 | @noindent | |
18fae2a8 | 1698 | @value{GDBN} fills in the rest of the word @samp{breakpoints}, since that's |
6f3ec223 RP |
1699 | the only @code{info} subcommand beginning with @samp{bre}: |
1700 | ||
1701 | @example | |
18fae2a8 | 1702 | (@value{GDBP}) info breakpoints |
6f3ec223 RP |
1703 | @end example |
1704 | ||
1705 | @noindent | |
1706 | You can either press @key{RET} at this point, to run the @code{info | |
1707 | breakpoints} command, or backspace and enter something else, if | |
1708 | @samp{breakpoints} doesn't look like the command you expected. (If you | |
1709 | were sure you wanted @code{info breakpoints} in the first place, you | |
1710 | might as well just type @key{RET} immediately after @samp{info bre}, | |
1711 | to exploit command abbreviations rather than command completion). | |
1712 | ||
1713 | If there is more than one possibility for the next word when you press | |
18fae2a8 | 1714 | @key{TAB}, @value{GDBN} will sound a bell. You can either supply more |
6f3ec223 | 1715 | characters and try again, or just press @key{TAB} a second time, and |
18fae2a8 | 1716 | @value{GDBN} will display all the possible completions for that word. For |
6f3ec223 | 1717 | example, you might want to set a breakpoint on a subroutine whose name |
18fae2a8 | 1718 | begins with @samp{make_}, but when you type @kbd{b make_@key{TAB}} @value{GDBN} |
6f3ec223 RP |
1719 | just sounds the bell. Typing @key{TAB} again will display all the |
1720 | function names in your program that begin with those characters, for | |
1721 | example: | |
1722 | ||
1723 | @example | |
18fae2a8 RP |
1724 | (@value{GDBP}) b make_ @key{TAB} |
1725 | @exdent @value{GDBN} sounds bell; press @key{TAB} again, to see: | |
6f3ec223 RP |
1726 | make_a_section_from_file make_environ |
1727 | make_abs_section make_function_type | |
1728 | make_blockvector make_pointer_type | |
1729 | make_cleanup make_reference_type | |
1730 | make_command make_symbol_completion_list | |
18fae2a8 | 1731 | (@value{GDBP}) b make_ |
6f3ec223 RP |
1732 | @end example |
1733 | ||
1734 | @noindent | |
18fae2a8 | 1735 | After displaying the available possibilities, @value{GDBN} copies your |
b1385986 | 1736 | partial input (@samp{b make_} in the example) so you can finish the |
6f3ec223 RP |
1737 | command. |
1738 | ||
1739 | If you just want to see the list of alternatives in the first place, you | |
b1385986 | 1740 | can press @kbd{M-?} rather than pressing @key{TAB} twice. @kbd{M-?} |
0f153e74 | 1741 | means @kbd{@key{META} ?}. You can type this |
18fae2a8 | 1742 | @ifclear DOSHOST |
0f153e74 | 1743 | either by holding down a |
b1385986 | 1744 | key designated as the @key{META} shift on your keyboard (if there is |
0f153e74 | 1745 | one) while typing @kbd{?}, or |
18fae2a8 | 1746 | @end ifclear |
0f153e74 | 1747 | as @key{ESC} followed by @kbd{?}. |
6f3ec223 RP |
1748 | |
1749 | @cindex quotes in commands | |
1750 | @cindex completion of quoted strings | |
1751 | Sometimes the string you need, while logically a ``word'', may contain | |
18fae2a8 | 1752 | parentheses or other characters that @value{GDBN} normally excludes from its |
6f3ec223 | 1753 | notion of a word. To permit word completion to work in this situation, |
18fae2a8 | 1754 | you may enclose words in @code{'} (single quote marks) in @value{GDBN} commands. |
6f3ec223 RP |
1755 | |
1756 | The most likely situation where you might need this is in typing the | |
1757 | name of a C++ function. This is because C++ allows function overloading | |
1758 | (multiple definitions of the same function, distinguished by argument | |
b1385986 RP |
1759 | type). For example, when you want to set a breakpoint you may need to |
1760 | distinguish whether you mean the version of @code{name} that takes an | |
1761 | @code{int} parameter, @code{name(int)}, or the version that takes a | |
1762 | @code{float} parameter, @code{name(float)}. To use the word-completion | |
1763 | facilities in this situation, type a single quote @code{'} at the | |
18fae2a8 | 1764 | beginning of the function name. This alerts @value{GDBN} that it may need to |
b1385986 RP |
1765 | consider more information than usual when you press @key{TAB} or |
1766 | @kbd{M-?} to request word completion: | |
6f3ec223 RP |
1767 | |
1768 | @example | |
18fae2a8 | 1769 | (@value{GDBP}) b 'bubble( @key{M-?} |
0fdc6e27 | 1770 | bubble(double,double) bubble(int,int) |
18fae2a8 | 1771 | (@value{GDBP}) b 'bubble( |
6f3ec223 RP |
1772 | @end example |
1773 | ||
18fae2a8 RP |
1774 | In some cases, @value{GDBN} can tell that completing a name will require |
1775 | quotes. When this happens, @value{GDBN} will insert the quote for you (while | |
0fdc6e27 RP |
1776 | completing as much as it can) if you do not type the quote in the first |
1777 | place: | |
1778 | ||
1779 | @example | |
18fae2a8 RP |
1780 | (@value{GDBP}) b bub @key{TAB} |
1781 | @exdent @value{GDBN} alters your input line to the following, and rings a bell: | |
1782 | (@value{GDBP}) b 'bubble( | |
0fdc6e27 RP |
1783 | @end example |
1784 | ||
1785 | @noindent | |
18fae2a8 | 1786 | In general, @value{GDBN} can tell that a quote is needed (and inserts it) if |
0fdc6e27 RP |
1787 | you have not yet started typing the argument list when you ask for |
1788 | completion on an overloaded symbol. | |
1789 | ||
1790 | ||
4eb4cf57 | 1791 | @node Help |
70b88761 RP |
1792 | @section Getting Help |
1793 | @cindex online documentation | |
1794 | @kindex help | |
1041a570 | 1795 | |
18fae2a8 | 1796 | You can always ask @value{GDBN} itself for information on its commands, using the |
e251e767 | 1797 | command @code{help}. |
70b88761 RP |
1798 | |
1799 | @table @code | |
1800 | @item help | |
1801 | @itemx h | |
1802 | @kindex h | |
1803 | You can use @code{help} (abbreviated @code{h}) with no arguments to | |
1804 | display a short list of named classes of commands: | |
1041a570 | 1805 | |
70b88761 | 1806 | @smallexample |
18fae2a8 | 1807 | (@value{GDBP}) help |
70b88761 RP |
1808 | List of classes of commands: |
1809 | ||
1810 | running -- Running the program | |
1811 | stack -- Examining the stack | |
1812 | data -- Examining data | |
1813 | breakpoints -- Making program stop at certain points | |
1814 | files -- Specifying and examining files | |
1815 | status -- Status inquiries | |
1816 | support -- Support facilities | |
1817 | user-defined -- User-defined commands | |
1818 | aliases -- Aliases of other commands | |
1819 | obscure -- Obscure features | |
1820 | ||
203eea5d RP |
1821 | Type "help" followed by a class name for a list of |
1822 | commands in that class. | |
1823 | Type "help" followed by command name for full | |
1824 | documentation. | |
70b88761 | 1825 | Command name abbreviations are allowed if unambiguous. |
18fae2a8 | 1826 | (@value{GDBP}) |
70b88761 RP |
1827 | @end smallexample |
1828 | ||
1829 | @item help @var{class} | |
1830 | Using one of the general help classes as an argument, you can get a | |
1831 | list of the individual commands in that class. For example, here is the | |
1832 | help display for the class @code{status}: | |
1041a570 | 1833 | |
70b88761 | 1834 | @smallexample |
18fae2a8 | 1835 | (@value{GDBP}) help status |
70b88761 RP |
1836 | Status inquiries. |
1837 | ||
1838 | List of commands: | |
1839 | ||
1840 | show -- Generic command for showing things set with "set" | |
1841 | info -- Generic command for printing status | |
1842 | ||
203eea5d RP |
1843 | Type "help" followed by command name for full |
1844 | documentation. | |
70b88761 | 1845 | Command name abbreviations are allowed if unambiguous. |
18fae2a8 | 1846 | (@value{GDBP}) |
70b88761 RP |
1847 | @end smallexample |
1848 | ||
1849 | @item help @var{command} | |
18fae2a8 | 1850 | With a command name as @code{help} argument, @value{GDBN} will display a |
e251e767 | 1851 | short paragraph on how to use that command. |
70b88761 RP |
1852 | @end table |
1853 | ||
18fae2a8 | 1854 | In addition to @code{help}, you can use the @value{GDBN} commands @code{info} |
70b88761 | 1855 | and @code{show} to inquire about the state of your program, or the state |
18fae2a8 | 1856 | of @value{GDBN} itself. Each command supports many topics of inquiry; this |
70b88761 RP |
1857 | manual introduces each of them in the appropriate context. The listings |
1858 | under @code{info} and under @code{show} in the Index point to | |
29a2b744 | 1859 | all the sub-commands. @xref{Index}. |
70b88761 RP |
1860 | |
1861 | @c @group | |
1862 | @table @code | |
1863 | @item info | |
1864 | @kindex info | |
1865 | @kindex i | |
1866 | This command (abbreviated @code{i}) is for describing the state of your | |
1867 | program; for example, it can list the arguments given to your program | |
1868 | (@code{info args}), the registers currently in use (@code{info | |
1041a570 | 1869 | registers}), or the breakpoints you have set (@code{info breakpoints}). |
70b88761 RP |
1870 | You can get a complete list of the @code{info} sub-commands with |
1871 | @w{@code{help info}}. | |
1872 | ||
1873 | @kindex show | |
1874 | @item show | |
18fae2a8 | 1875 | In contrast, @code{show} is for describing the state of @value{GDBN} itself. |
70b88761 RP |
1876 | You can change most of the things you can @code{show}, by using the |
1877 | related command @code{set}; for example, you can control what number | |
1878 | system is used for displays with @code{set radix}, or simply inquire | |
e251e767 | 1879 | which is currently in use with @code{show radix}. |
70b88761 RP |
1880 | |
1881 | @kindex info set | |
1882 | To display all the settable parameters and their current | |
1883 | values, you can use @code{show} with no arguments; you may also use | |
1884 | @code{info set}. Both commands produce the same display. | |
1885 | @c FIXME: "info set" violates the rule that "info" is for state of | |
1886 | @c FIXME...program. Ck w/ GNU: "info set" to be called something else, | |
1887 | @c FIXME...or change desc of rule---eg "state of prog and debugging session"? | |
1888 | @end table | |
1889 | @c @end group | |
1890 | ||
1891 | Here are three miscellaneous @code{show} subcommands, all of which are | |
1892 | exceptional in lacking corresponding @code{set} commands: | |
1893 | ||
1894 | @table @code | |
1895 | @kindex show version | |
3d3ab540 | 1896 | @cindex version number |
70b88761 | 1897 | @item show version |
18fae2a8 RP |
1898 | Show what version of @value{GDBN} is running. You should include this |
1899 | information in @value{GDBN} bug-reports. If multiple versions of @value{GDBN} are in | |
1041a570 | 1900 | use at your site, you may occasionally want to make sure what version |
18fae2a8 | 1901 | of @value{GDBN} you are running; as @value{GDBN} evolves, new commands are introduced, |
1041a570 | 1902 | and old ones may wither away. The version number is also announced |
18fae2a8 | 1903 | when you start @value{GDBN} with no arguments. |
70b88761 RP |
1904 | |
1905 | @kindex show copying | |
1906 | @item show copying | |
18fae2a8 | 1907 | Display information about permission for copying @value{GDBN}. |
70b88761 RP |
1908 | |
1909 | @kindex show warranty | |
1910 | @item show warranty | |
1911 | Display the GNU ``NO WARRANTY'' statement. | |
1912 | @end table | |
1913 | ||
4eb4cf57 | 1914 | @node Running |
18fae2a8 | 1915 | @chapter Running Programs Under @value{GDBN} |
70b88761 | 1916 | |
18fae2a8 | 1917 | To debug a program, you must run it under @value{GDBN}. |
1041a570 | 1918 | |
18fae2a8 RP |
1919 | @ignore |
1920 | @c pre-unfolding: | |
70b88761 | 1921 | @menu |
b80282d5 RP |
1922 | * Compilation:: Compiling for Debugging |
1923 | * Starting:: Starting your Program | |
18fae2a8 | 1924 | @ifclear BARETARGET |
b80282d5 RP |
1925 | * Arguments:: Your Program's Arguments |
1926 | * Environment:: Your Program's Environment | |
1927 | * Working Directory:: Your Program's Working Directory | |
1928 | * Input/Output:: Your Program's Input and Output | |
1929 | * Attach:: Debugging an Already-Running Process | |
1930 | * Kill Process:: Killing the Child Process | |
d24e0922 | 1931 | * Process Information:: Additional Process Information |
18fae2a8 | 1932 | @end ifclear |
70b88761 | 1933 | @end menu |
18fae2a8 RP |
1934 | @end ignore |
1935 | ||
1936 | @ifclear BARETARGET | |
1937 | @menu | |
1938 | * Compilation:: Compiling for Debugging | |
1939 | * Starting:: Starting your Program | |
1940 | * Arguments:: Your Program's Arguments | |
1941 | * Environment:: Your Program's Environment | |
1942 | * Working Directory:: Your Program's Working Directory | |
1943 | * Input/Output:: Your Program's Input and Output | |
1944 | * Attach:: Debugging an Already-Running Process | |
1945 | * Kill Process:: Killing the Child Process | |
1946 | * Process Information:: Additional Process Information | |
1947 | @end menu | |
1948 | @end ifclear | |
1949 | ||
1950 | @ifset BARETARGET | |
1951 | @menu | |
1952 | * Compilation:: Compiling for Debugging | |
1953 | * Starting:: Starting your Program | |
1954 | @end menu | |
1955 | @end ifset | |
70b88761 | 1956 | |
4eb4cf57 | 1957 | @node Compilation |
70b88761 RP |
1958 | @section Compiling for Debugging |
1959 | ||
1960 | In order to debug a program effectively, you need to generate | |
1961 | debugging information when you compile it. This debugging information | |
1962 | is stored in the object file; it describes the data type of each | |
1963 | variable or function and the correspondence between source line numbers | |
1964 | and addresses in the executable code. | |
1965 | ||
1966 | To request debugging information, specify the @samp{-g} option when you run | |
1967 | the compiler. | |
1968 | ||
1969 | Many C compilers are unable to handle the @samp{-g} and @samp{-O} | |
1970 | options together. Using those compilers, you cannot generate optimized | |
1971 | executables containing debugging information. | |
1972 | ||
18fae2a8 | 1973 | @value{NGCC}, the GNU C compiler, supports @samp{-g} with or without |
c7cb8acb RP |
1974 | @samp{-O}, making it possible to debug optimized code. We recommend |
1975 | that you @emph{always} use @samp{-g} whenever you compile a program. | |
1976 | You may think your program is correct, but there is no sense in pushing | |
1977 | your luck. | |
70b88761 | 1978 | |
6ca72cc6 RP |
1979 | @cindex optimized code, debugging |
1980 | @cindex debugging optimized code | |
1981 | When you debug a program compiled with @samp{-g -O}, remember that the | |
1982 | optimizer is rearranging your code; the debugger will show you what's | |
1983 | really there. Don't be too surprised when the execution path doesn't | |
1984 | exactly match your source file! An extreme example: if you define a | |
18fae2a8 | 1985 | variable, but never use it, @value{GDBN} will never see that |
6ca72cc6 RP |
1986 | variable---because the compiler optimizes it out of existence. |
1987 | ||
70b88761 RP |
1988 | Some things do not work as well with @samp{-g -O} as with just |
1989 | @samp{-g}, particularly on machines with instruction scheduling. If in | |
1990 | doubt, recompile with @samp{-g} alone, and if this fixes the problem, | |
1991 | please report it as a bug (including a test case!). | |
1992 | ||
1993 | Older versions of the GNU C compiler permitted a variant option | |
18fae2a8 | 1994 | @w{@samp{-gg}} for debugging information. @value{GDBN} no longer supports this |
70b88761 RP |
1995 | format; if your GNU C compiler has this option, do not use it. |
1996 | ||
1997 | @ignore | |
18fae2a8 | 1998 | @comment As far as I know, there are no cases in which @value{GDBN} will |
70b88761 RP |
1999 | @comment produce strange output in this case. (but no promises). |
2000 | If your program includes archives made with the @code{ar} program, and | |
2001 | if the object files used as input to @code{ar} were compiled without the | |
18fae2a8 | 2002 | @samp{-g} option and have names longer than 15 characters, @value{GDBN} will get |
29a2b744 | 2003 | confused reading your program's symbol table. No error message will be |
18fae2a8 | 2004 | given, but @value{GDBN} may behave strangely. The reason for this problem is a |
70b88761 RP |
2005 | deficiency in the Unix archive file format, which cannot represent file |
2006 | names longer than 15 characters. | |
2007 | ||
2008 | To avoid this problem, compile the archive members with the @samp{-g} | |
2009 | option or use shorter file names. Alternatively, use a version of GNU | |
2010 | @code{ar} dated more recently than August 1989. | |
2011 | @end ignore | |
2012 | ||
4eb4cf57 | 2013 | @node Starting |
70b88761 RP |
2014 | @section Starting your Program |
2015 | @cindex starting | |
2016 | @cindex running | |
1041a570 | 2017 | |
70b88761 RP |
2018 | @table @code |
2019 | @item run | |
2020 | @itemx r | |
2021 | @kindex run | |
18fae2a8 | 2022 | Use the @code{run} command to start your program under @value{GDBN}. You must |
1041a570 | 2023 | first specify the program name |
18fae2a8 | 2024 | @ifset VXWORKS |
7463aadd | 2025 | (except on VxWorks) |
18fae2a8 | 2026 | @end ifset |
1041a570 | 2027 | with an argument to |
18fae2a8 | 2028 | @value{GDBN} (@pxref{Invocation, ,Getting In and Out of @value{GDBN}}), or by using the |
1041a570 RP |
2029 | @code{file} or @code{exec-file} command (@pxref{Files, ,Commands to |
2030 | Specify Files}). | |
2031 | ||
70b88761 RP |
2032 | @end table |
2033 | ||
18fae2a8 | 2034 | @ifclear BARETARGET |
29a2b744 RP |
2035 | If you are running your program in an execution environment that |
2036 | supports processes, @code{run} creates an inferior process and makes | |
2037 | that process run your program. (In environments without processes, | |
2038 | @code{run} jumps to the start of your program.) | |
70b88761 RP |
2039 | |
2040 | The execution of a program is affected by certain information it | |
18fae2a8 | 2041 | receives from its superior. @value{GDBN} provides ways to specify this |
6ca72cc6 | 2042 | information, which you must do @emph{before} starting your program. (You |
29a2b744 RP |
2043 | can change it after starting your program, but such changes will only affect |
2044 | your program the next time you start it.) This information may be | |
70b88761 RP |
2045 | divided into four categories: |
2046 | ||
2047 | @table @asis | |
6ca72cc6 | 2048 | @item The @emph{arguments.} |
29a2b744 | 2049 | Specify the arguments to give your program as the arguments of the |
1041a570 RP |
2050 | @code{run} command. If a shell is available on your target, the shell |
2051 | is used to pass the arguments, so that you may use normal conventions | |
2052 | (such as wildcard expansion or variable substitution) in describing | |
2053 | the arguments. In Unix systems, you can control which shell is used | |
2054 | with the @code{SHELL} environment variable. @xref{Arguments, ,Your | |
2055 | Program's Arguments}. | |
70b88761 | 2056 | |
6ca72cc6 | 2057 | @item The @emph{environment.} |
18fae2a8 RP |
2058 | Your program normally inherits its environment from @value{GDBN}, but you can |
2059 | use the @value{GDBN} commands @code{set environment} and @code{unset | |
70b88761 | 2060 | environment} to change parts of the environment that will be given to |
1041a570 | 2061 | your program. @xref{Environment, ,Your Program's Environment}. |
70b88761 | 2062 | |
6ca72cc6 | 2063 | @item The @emph{working directory.} |
18fae2a8 RP |
2064 | Your program inherits its working directory from @value{GDBN}. You can set |
2065 | @value{GDBN}'s working directory with the @code{cd} command in @value{GDBN}. | |
29a2b744 | 2066 | @xref{Working Directory, ,Your Program's Working Directory}. |
70b88761 | 2067 | |
6ca72cc6 | 2068 | @item The @emph{standard input and output.} |
70b88761 | 2069 | Your program normally uses the same device for standard input and |
18fae2a8 | 2070 | standard output as @value{GDBN} is using. You can redirect input and output |
70b88761 RP |
2071 | in the @code{run} command line, or you can use the @code{tty} command to |
2072 | set a different device for your program. | |
1041a570 | 2073 | @xref{Input/Output, ,Your Program's Input and Output}. |
3d3ab540 RP |
2074 | |
2075 | @cindex pipes | |
29a2b744 RP |
2076 | @emph{Warning:} While input and output redirection work, you cannot use |
2077 | pipes to pass the output of the program you are debugging to another | |
18fae2a8 | 2078 | program; if you attempt this, @value{GDBN} is likely to wind up debugging the |
3d3ab540 | 2079 | wrong program. |
70b88761 | 2080 | @end table |
18fae2a8 | 2081 | @end ifclear |
70b88761 | 2082 | |
1041a570 | 2083 | When you issue the @code{run} command, your program begins to execute |
4eb4cf57 RP |
2084 | immediately. @xref{Stopping, ,Stopping and Continuing}, for discussion |
2085 | of how to arrange for your program to stop. Once your program has | |
2086 | stopped, you may calls functions in your program, using the @code{print} | |
2087 | or @code{call} commands. @xref{Data, ,Examining Data}. | |
70b88761 | 2088 | |
29a2b744 | 2089 | If the modification time of your symbol file has changed since the |
18fae2a8 RP |
2090 | last time @value{GDBN} read its symbols, @value{GDBN} will discard its symbol table and |
2091 | re-read it. When it does this, @value{GDBN} tries to retain your current | |
1041a570 | 2092 | breakpoints. |
70b88761 | 2093 | |
18fae2a8 | 2094 | @ifclear BARETARGET |
4eb4cf57 | 2095 | @node Arguments |
70b88761 RP |
2096 | @section Your Program's Arguments |
2097 | ||
2098 | @cindex arguments (to your program) | |
2099 | The arguments to your program can be specified by the arguments of the | |
2100 | @code{run} command. They are passed to a shell, which expands wildcard | |
29a2b744 | 2101 | characters and performs redirection of I/O, and thence to your program. |
18fae2a8 RP |
2102 | @value{GDBN} uses the shell indicated by your environment variable |
2103 | @code{SHELL} if it exists; otherwise, @value{GDBN} uses @code{/bin/sh}. | |
70b88761 RP |
2104 | |
2105 | @code{run} with no arguments uses the same arguments used by the previous | |
2106 | @code{run}, or those set by the @code{set args} command. | |
2107 | ||
2108 | @kindex set args | |
2109 | @table @code | |
2110 | @item set args | |
2111 | Specify the arguments to be used the next time your program is run. If | |
2112 | @code{set args} has no arguments, @code{run} will execute your program | |
e251e767 | 2113 | with no arguments. Once you have run your program with arguments, |
70b88761 RP |
2114 | using @code{set args} before the next @code{run} is the only way to run |
2115 | it again without arguments. | |
2116 | ||
2117 | @item show args | |
2118 | @kindex show args | |
2119 | Show the arguments to give your program when it is started. | |
2120 | @end table | |
2121 | ||
4eb4cf57 | 2122 | @node Environment |
70b88761 RP |
2123 | @section Your Program's Environment |
2124 | ||
2125 | @cindex environment (of your program) | |
2126 | The @dfn{environment} consists of a set of environment variables and | |
2127 | their values. Environment variables conventionally record such things as | |
2128 | your user name, your home directory, your terminal type, and your search | |
2129 | path for programs to run. Usually you set up environment variables with | |
2130 | the shell and they are inherited by all the other programs you run. When | |
29a2b744 | 2131 | debugging, it can be useful to try running your program with a modified |
18fae2a8 | 2132 | environment without having to start @value{GDBN} over again. |
70b88761 RP |
2133 | |
2134 | @table @code | |
2135 | @item path @var{directory} | |
2136 | @kindex path | |
2137 | Add @var{directory} to the front of the @code{PATH} environment variable | |
18fae2a8 | 2138 | (the search path for executables), for both @value{GDBN} and your program. |
70b88761 RP |
2139 | You may specify several directory names, separated by @samp{:} or |
2140 | whitespace. If @var{directory} is already in the path, it is moved to | |
e251e767 | 2141 | the front, so it will be searched sooner. |
7463aadd RP |
2142 | |
2143 | You can use the string @samp{$cwd} to refer to whatever is the current | |
18fae2a8 | 2144 | working directory at the time @value{GDBN} searches the path. If you use |
7463aadd | 2145 | @samp{.} instead, it refers to the directory where you executed the |
18fae2a8 | 2146 | @code{path} command. @value{GDBN} fills in the current path where needed in |
7463aadd | 2147 | the @var{directory} argument, before adding it to the search path. |
29a2b744 | 2148 | @c 'path' is explicitly nonrepeatable, but RMS points out it is silly to |
70b88761 RP |
2149 | @c document that, since repeating it would be a no-op. |
2150 | ||
2151 | @item show paths | |
2152 | @kindex show paths | |
2153 | Display the list of search paths for executables (the @code{PATH} | |
2154 | environment variable). | |
2155 | ||
2156 | @item show environment @r{[}@var{varname}@r{]} | |
2157 | @kindex show environment | |
2158 | Print the value of environment variable @var{varname} to be given to | |
29a2b744 | 2159 | your program when it starts. If you do not supply @var{varname}, |
70b88761 RP |
2160 | print the names and values of all environment variables to be given to |
2161 | your program. You can abbreviate @code{environment} as @code{env}. | |
2162 | ||
7463aadd | 2163 | @item set environment @var{varname} @r{[}=@r{]} @var{value} |
70b88761 RP |
2164 | @kindex set environment |
2165 | Sets environment variable @var{varname} to @var{value}. The value | |
18fae2a8 | 2166 | changes for your program only, not for @value{GDBN} itself. @var{value} may |
70b88761 RP |
2167 | be any string; the values of environment variables are just strings, and |
2168 | any interpretation is supplied by your program itself. The @var{value} | |
2169 | parameter is optional; if it is eliminated, the variable is set to a | |
2170 | null value. | |
29a2b744 | 2171 | @c "any string" here does not include leading, trailing |
70b88761 RP |
2172 | @c blanks. Gnu asks: does anyone care? |
2173 | ||
2174 | For example, this command: | |
2175 | ||
2176 | @example | |
2177 | set env USER = foo | |
2178 | @end example | |
2179 | ||
2180 | @noindent | |
2181 | tells a Unix program, when subsequently run, that its user is named | |
2182 | @samp{foo}. (The spaces around @samp{=} are used for clarity here; they | |
2183 | are not actually required.) | |
2184 | ||
2185 | @item unset environment @var{varname} | |
2186 | @kindex unset environment | |
2187 | Remove variable @var{varname} from the environment to be passed to your | |
2188 | program. This is different from @samp{set env @var{varname} =}; | |
2189 | @code{unset environment} removes the variable from the environment, | |
e251e767 | 2190 | rather than assigning it an empty value. |
70b88761 RP |
2191 | @end table |
2192 | ||
4eb4cf57 | 2193 | @node Working Directory |
70b88761 RP |
2194 | @section Your Program's Working Directory |
2195 | ||
2196 | @cindex working directory (of your program) | |
2197 | Each time you start your program with @code{run}, it inherits its | |
18fae2a8 | 2198 | working directory from the current working directory of @value{GDBN}. @value{GDBN}'s |
70b88761 RP |
2199 | working directory is initially whatever it inherited from its parent |
2200 | process (typically the shell), but you can specify a new working | |
18fae2a8 | 2201 | directory in @value{GDBN} with the @code{cd} command. |
70b88761 | 2202 | |
18fae2a8 RP |
2203 | The @value{GDBN} working directory also serves as a default for the commands |
2204 | that specify files for @value{GDBN} to operate on. @xref{Files, ,Commands to | |
1041a570 | 2205 | Specify Files}. |
70b88761 RP |
2206 | |
2207 | @table @code | |
2208 | @item cd @var{directory} | |
2209 | @kindex cd | |
18fae2a8 | 2210 | Set @value{GDBN}'s working directory to @var{directory}. |
70b88761 RP |
2211 | |
2212 | @item pwd | |
2213 | @kindex pwd | |
18fae2a8 | 2214 | Print @value{GDBN}'s working directory. |
70b88761 RP |
2215 | @end table |
2216 | ||
4eb4cf57 | 2217 | @node Input/Output |
70b88761 RP |
2218 | @section Your Program's Input and Output |
2219 | ||
2220 | @cindex redirection | |
2221 | @cindex i/o | |
2222 | @cindex terminal | |
18fae2a8 RP |
2223 | By default, the program you run under @value{GDBN} does input and output to |
2224 | the same terminal that @value{GDBN} uses. @value{GDBN} switches the terminal to | |
70b88761 RP |
2225 | its own terminal modes to interact with you, but it records the terminal |
2226 | modes your program was using and switches back to them when you continue | |
2227 | running your program. | |
2228 | ||
2229 | @table @code | |
2230 | @item info terminal | |
2231 | @kindex info terminal | |
18fae2a8 | 2232 | Displays @value{GDBN}'s recorded information about the terminal modes your |
70b88761 RP |
2233 | program is using. |
2234 | @end table | |
2235 | ||
29a2b744 | 2236 | You can redirect your program's input and/or output using shell |
70b88761 RP |
2237 | redirection with the @code{run} command. For example, |
2238 | ||
18fae2a8 | 2239 | @example |
70b88761 | 2240 | run > outfile |
18fae2a8 | 2241 | @end example |
70b88761 RP |
2242 | |
2243 | @noindent | |
29a2b744 | 2244 | starts your program, diverting its output to the file @file{outfile}. |
70b88761 RP |
2245 | |
2246 | @kindex tty | |
2247 | @cindex controlling terminal | |
29a2b744 | 2248 | Another way to specify where your program should do input and output is |
70b88761 RP |
2249 | with the @code{tty} command. This command accepts a file name as |
2250 | argument, and causes this file to be the default for future @code{run} | |
2251 | commands. It also resets the controlling terminal for the child | |
2252 | process, for future @code{run} commands. For example, | |
2253 | ||
2254 | @example | |
2255 | tty /dev/ttyb | |
2256 | @end example | |
2257 | ||
2258 | @noindent | |
2259 | directs that processes started with subsequent @code{run} commands | |
2260 | default to do input and output on the terminal @file{/dev/ttyb} and have | |
2261 | that as their controlling terminal. | |
2262 | ||
2263 | An explicit redirection in @code{run} overrides the @code{tty} command's | |
2264 | effect on the input/output device, but not its effect on the controlling | |
2265 | terminal. | |
2266 | ||
2267 | When you use the @code{tty} command or redirect input in the @code{run} | |
2268 | command, only the input @emph{for your program} is affected. The input | |
18fae2a8 | 2269 | for @value{GDBN} still comes from your terminal. |
70b88761 | 2270 | |
4eb4cf57 | 2271 | @node Attach |
70b88761 RP |
2272 | @section Debugging an Already-Running Process |
2273 | @kindex attach | |
2274 | @cindex attach | |
2275 | ||
2276 | @table @code | |
2277 | @item attach @var{process-id} | |
2278 | This command | |
18fae2a8 | 2279 | attaches to a running process---one that was started outside @value{GDBN}. |
70b88761 RP |
2280 | (@code{info files} will show your active targets.) The command takes as |
2281 | argument a process ID. The usual way to find out the process-id of | |
2282 | a Unix process is with the @code{ps} utility, or with the @samp{jobs -l} | |
e251e767 | 2283 | shell command. |
70b88761 RP |
2284 | |
2285 | @code{attach} will not repeat if you press @key{RET} a second time after | |
2286 | executing the command. | |
2287 | @end table | |
2288 | ||
2289 | To use @code{attach}, you must be debugging in an environment which | |
2290 | supports processes. You must also have permission to send the process a | |
18fae2a8 | 2291 | signal, and it must have the same effective user ID as the @value{GDBN} |
70b88761 RP |
2292 | process. |
2293 | ||
2294 | When using @code{attach}, you should first use the @code{file} command | |
2295 | to specify the program running in the process and load its symbol table. | |
29a2b744 | 2296 | @xref{Files, ,Commands to Specify Files}. |
70b88761 | 2297 | |
18fae2a8 | 2298 | The first thing @value{GDBN} does after arranging to debug the specified |
70b88761 | 2299 | process is to stop it. You can examine and modify an attached process |
18fae2a8 | 2300 | with all the @value{GDBN} commands that are ordinarily available when you start |
70b88761 RP |
2301 | processes with @code{run}. You can insert breakpoints; you can step and |
2302 | continue; you can modify storage. If you would rather the process | |
2303 | continue running, you may use the @code{continue} command after | |
18fae2a8 | 2304 | attaching @value{GDBN} to the process. |
70b88761 RP |
2305 | |
2306 | @table @code | |
2307 | @item detach | |
2308 | @kindex detach | |
2309 | When you have finished debugging the attached process, you can use the | |
18fae2a8 | 2310 | @code{detach} command to release it from @value{GDBN}'s control. Detaching |
70b88761 | 2311 | the process continues its execution. After the @code{detach} command, |
18fae2a8 | 2312 | that process and @value{GDBN} become completely independent once more, and you |
70b88761 RP |
2313 | are ready to @code{attach} another process or start one with @code{run}. |
2314 | @code{detach} will not repeat if you press @key{RET} again after | |
2315 | executing the command. | |
2316 | @end table | |
2317 | ||
18fae2a8 | 2318 | If you exit @value{GDBN} or use the @code{run} command while you have an attached |
70b88761 RP |
2319 | process, you kill that process. By default, you will be asked for |
2320 | confirmation if you try to do either of these things; you can control | |
2321 | whether or not you need to confirm by using the @code{set confirm} command | |
29a2b744 | 2322 | (@pxref{Messages/Warnings, ,Optional Warnings and Messages}). |
70b88761 | 2323 | |
4eb4cf57 | 2324 | @node Kill Process |
70b88761 RP |
2325 | @c @group |
2326 | @section Killing the Child Process | |
2327 | ||
2328 | @table @code | |
2329 | @item kill | |
2330 | @kindex kill | |
18fae2a8 | 2331 | Kill the child process in which your program is running under @value{GDBN}. |
70b88761 RP |
2332 | @end table |
2333 | ||
2334 | This command is useful if you wish to debug a core dump instead of a | |
18fae2a8 | 2335 | running process. @value{GDBN} ignores any core dump file while your program |
70b88761 RP |
2336 | is running. |
2337 | @c @end group | |
2338 | ||
18fae2a8 RP |
2339 | On some operating systems, a program cannot be executed outside @value{GDBN} |
2340 | while you have breakpoints set on it inside @value{GDBN}. You can use the | |
29a2b744 | 2341 | @code{kill} command in this situation to permit running your program |
70b88761 RP |
2342 | outside the debugger. |
2343 | ||
2344 | The @code{kill} command is also useful if you wish to recompile and | |
29a2b744 | 2345 | relink your program, since on many systems it is impossible to modify an |
70b88761 | 2346 | executable file while it is running in a process. In this case, when you |
18fae2a8 | 2347 | next type @code{run}, @value{GDBN} will notice that the file has changed, and |
70b88761 RP |
2348 | will re-read the symbol table (while trying to preserve your current |
2349 | breakpoint settings). | |
2350 | ||
4eb4cf57 | 2351 | @node Process Information |
d24e0922 RP |
2352 | @section Additional Process Information |
2353 | ||
2354 | @kindex /proc | |
2355 | @cindex process image | |
2356 | Some operating systems provide a facility called @samp{/proc} that can | |
cc9bc574 | 2357 | be used to examine the image of a running process using file-system |
18fae2a8 | 2358 | subroutines. If @value{GDBN} is configured for an operating system with this |
cc9bc574 RP |
2359 | facility, the command @code{info proc} is available to report on several |
2360 | kinds of information about the process running your program. | |
d24e0922 RP |
2361 | |
2362 | @table @code | |
2363 | @item info proc | |
2364 | @kindex info proc | |
2365 | Summarize available information about the process. | |
2366 | ||
2367 | @item info proc mappings | |
2368 | @kindex info proc mappings | |
2369 | Report on the address ranges accessible in the program, with information | |
2370 | on whether your program may read, write, or execute each range. | |
2371 | ||
2372 | @item info proc times | |
2373 | @kindex info proc times | |
2374 | Starting time, user CPU time, and system CPU time for your program and | |
2375 | its children. | |
2376 | ||
2377 | @item info proc id | |
2378 | @kindex info proc id | |
2379 | Report on the process ID's related to your program: its own process id, | |
2380 | the id of its parent, the process group id, and the session id. | |
2381 | ||
2382 | @item info proc status | |
2383 | @kindex info proc status | |
2384 | General information on the state of the process. If the process is | |
2385 | stopped, this report includes the reason for stopping, and any signal | |
2386 | received. | |
cc9bc574 RP |
2387 | |
2388 | @item info proc all | |
2389 | Show all the above information about the process. | |
d24e0922 | 2390 | @end table |
18fae2a8 | 2391 | @end ifclear |
d24e0922 | 2392 | |
4eb4cf57 | 2393 | @node Stopping |
70b88761 RP |
2394 | @chapter Stopping and Continuing |
2395 | ||
2396 | The principal purpose of using a debugger is so that you can stop your | |
29a2b744 | 2397 | program before it terminates; or so that, if your program runs into |
70b88761 RP |
2398 | trouble, you can investigate and find out why. |
2399 | ||
18fae2a8 RP |
2400 | Inside @value{GDBN}, your program may stop for any of several reasons, such |
2401 | as a signal, a breakpoint, or reaching a new line after a @value{GDBN} | |
70b88761 RP |
2402 | command such as @code{step}. You may then examine and change |
2403 | variables, set new breakpoints or remove old ones, and then continue | |
18fae2a8 | 2404 | execution. Usually, the messages shown by @value{GDBN} provide ample |
70b88761 RP |
2405 | explanation of the status of your program---but you can also explicitly |
2406 | request this information at any time. | |
2407 | ||
2408 | @table @code | |
2409 | @item info program | |
2410 | @kindex info program | |
2411 | Display information about the status of your program: whether it is | |
2412 | running or not, what process it is, and why it stopped. | |
2413 | @end table | |
2414 | ||
18fae2a8 RP |
2415 | @ignore |
2416 | @c original menu | |
2417 | @menu | |
2418 | @ifclear CONLY | |
2419 | * Breakpoints:: Breakpoints, Watchpoints, and Exceptions | |
2420 | @end ifclear | |
2421 | @ifset CONLY | |
2422 | * Breakpoints:: Breakpoints and Watchpoints | |
2423 | @end ifset | |
2424 | * Continuing and Stepping:: Resuming Execution | |
2425 | @ifset POSIX | |
2426 | * Signals:: Signals | |
2427 | @end ifset | |
2428 | @end menu | |
2429 | @end ignore | |
2430 | ||
2431 | @c !CONLY && POSIX | |
2432 | @ifclear CONLY | |
2433 | @ifset POSIX | |
70b88761 | 2434 | @menu |
b80282d5 | 2435 | * Breakpoints:: Breakpoints, Watchpoints, and Exceptions |
18fae2a8 RP |
2436 | * Continuing and Stepping:: Resuming Execution |
2437 | * Signals:: Signals | |
2438 | @end menu | |
2439 | @end ifset | |
2440 | @end ifclear | |
2441 | ||
2442 | @c CONLY && POSIX | |
2443 | @ifset CONLY | |
2444 | @ifset POSIX | |
2445 | @menu | |
0f153e74 | 2446 | * Breakpoints:: Breakpoints and Watchpoints |
b80282d5 RP |
2447 | * Continuing and Stepping:: Resuming Execution |
2448 | * Signals:: Signals | |
70b88761 | 2449 | @end menu |
18fae2a8 RP |
2450 | @end ifset |
2451 | @end ifset | |
2452 | ||
2453 | @c !CONLY && !POSIX | |
2454 | @ifclear CONLY | |
2455 | @ifclear POSIX | |
2456 | @menu | |
2457 | * Breakpoints:: Breakpoints, Watchpoints, and Exceptions | |
2458 | * Continuing and Stepping:: Resuming Execution | |
2459 | @end menu | |
2460 | @end ifclear | |
2461 | @end ifclear | |
2462 | ||
2463 | @c CONLY && !POSIX | |
2464 | @ifset CONLY | |
2465 | @ifclear POSIX | |
2466 | @menu | |
2467 | * Breakpoints:: Breakpoints and Watchpoints | |
2468 | * Continuing and Stepping:: Resuming Execution | |
2469 | @end menu | |
2470 | @end ifclear | |
2471 | @end ifset | |
70b88761 | 2472 | |
18fae2a8 RP |
2473 | @c node-defaulting requires adjacency of @node and sectioning cmds |
2474 | @c ...hence distribute @node Breakpoints over two possible @if expansions. | |
2475 | @c | |
2476 | @ifclear CONLY | |
4eb4cf57 | 2477 | @node Breakpoints |
70b88761 | 2478 | @section Breakpoints, Watchpoints, and Exceptions |
18fae2a8 RP |
2479 | @end ifclear |
2480 | @ifset CONLY | |
2481 | @node Breakpoints | |
0f153e74 | 2482 | @section Breakpoints and Watchpoints |
18fae2a8 | 2483 | @end ifset |
70b88761 RP |
2484 | |
2485 | @cindex breakpoints | |
2486 | A @dfn{breakpoint} makes your program stop whenever a certain point in | |
1041a570 | 2487 | the program is reached. For each breakpoint, you can add various |
29a2b744 | 2488 | conditions to control in finer detail whether your program will stop. |
70b88761 | 2489 | You can set breakpoints with the @code{break} command and its variants |
29a2b744 RP |
2490 | (@pxref{Set Breaks, ,Setting Breakpoints}), to specify the place where |
2491 | your program should stop by line number, function name or exact address | |
0f153e74 | 2492 | in the program. |
18fae2a8 | 2493 | @ifclear CONLY |
0f153e74 RP |
2494 | In languages with exception handling (such as GNU C++), you can also set |
2495 | breakpoints where an exception is raised (@pxref{Exception Handling, | |
2496 | ,Breakpoints and Exceptions}). | |
18fae2a8 | 2497 | @end ifclear |
70b88761 RP |
2498 | |
2499 | @cindex watchpoints | |
6ca72cc6 RP |
2500 | @cindex memory tracing |
2501 | @cindex breakpoint on memory address | |
2502 | @cindex breakpoint on variable modification | |
29a2b744 RP |
2503 | A @dfn{watchpoint} is a special breakpoint that stops your program |
2504 | when the value of an expression changes. You must use a different | |
2505 | command to set watchpoints (@pxref{Set Watchpoints, ,Setting | |
2506 | Watchpoints}), but aside from that, you can manage a watchpoint like | |
2507 | any other breakpoint: you enable, disable, and delete both breakpoints | |
1041a570 | 2508 | and watchpoints using the same commands. |
70b88761 | 2509 | |
6ca72cc6 RP |
2510 | @cindex breakpoint numbers |
2511 | @cindex numbers for breakpoints | |
18fae2a8 | 2512 | @value{GDBN} assigns a number to each breakpoint or watchpoint when you |
6ca72cc6 RP |
2513 | create it; these numbers are successive integers starting with one. In |
2514 | many of the commands for controlling various features of breakpoints you | |
2515 | use the breakpoint number to say which breakpoint you want to change. | |
2516 | Each breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has | |
29a2b744 | 2517 | no effect on your program until you enable it again. |
70b88761 RP |
2518 | |
2519 | @menu | |
b80282d5 RP |
2520 | * Set Breaks:: Setting Breakpoints |
2521 | * Set Watchpoints:: Setting Watchpoints | |
2522 | * Exception Handling:: Breakpoints and Exceptions | |
2523 | * Delete Breaks:: Deleting Breakpoints | |
2524 | * Disabling:: Disabling Breakpoints | |
2525 | * Conditions:: Break Conditions | |
2526 | * Break Commands:: Breakpoint Command Lists | |
2527 | * Breakpoint Menus:: Breakpoint Menus | |
e251e767 | 2528 | * Error in Breakpoints:: |
70b88761 RP |
2529 | @end menu |
2530 | ||
4eb4cf57 | 2531 | @node Set Breaks |
70b88761 RP |
2532 | @subsection Setting Breakpoints |
2533 | ||
4906534f RP |
2534 | @c FIXME LMB what does GDB do if no code on line of breakpt? |
2535 | @c consider in particular declaration with/without initialization. | |
2536 | @c | |
2537 | @c FIXME 2 is there stuff on this already? break at fun start, already init? | |
2538 | ||
70b88761 RP |
2539 | @kindex break |
2540 | @kindex b | |
6ca72cc6 RP |
2541 | @kindex $bpnum |
2542 | @cindex latest breakpoint | |
2543 | Breakpoints are set with the @code{break} command (abbreviated | |
2544 | @code{b}). The debugger convenience variable @samp{$bpnum} records the | |
2545 | number of the beakpoint you've set most recently; see @ref{Convenience | |
d24e0922 | 2546 | Vars,, Convenience Variables}, for a discussion of what you can do with |
6ca72cc6 | 2547 | convenience variables. |
70b88761 RP |
2548 | |
2549 | You have several ways to say where the breakpoint should go. | |
2550 | ||
2551 | @table @code | |
2552 | @item break @var{function} | |
0f153e74 | 2553 | Set a breakpoint at entry to function @var{function}. |
18fae2a8 | 2554 | @ifclear CONLY |
0f153e74 RP |
2555 | When using source languages that permit overloading of symbols, such as |
2556 | C++, @var{function} may refer to more than one possible place to break. | |
70b88761 | 2557 | @xref{Breakpoint Menus}, for a discussion of that situation. |
18fae2a8 | 2558 | @end ifclear |
70b88761 RP |
2559 | |
2560 | @item break +@var{offset} | |
2561 | @itemx break -@var{offset} | |
2562 | Set a breakpoint some number of lines forward or back from the position | |
2563 | at which execution stopped in the currently selected frame. | |
2564 | ||
2565 | @item break @var{linenum} | |
2566 | Set a breakpoint at line @var{linenum} in the current source file. | |
2567 | That file is the last file whose source text was printed. This | |
29a2b744 | 2568 | breakpoint will stop your program just before it executes any of the |
70b88761 RP |
2569 | code on that line. |
2570 | ||
2571 | @item break @var{filename}:@var{linenum} | |
2572 | Set a breakpoint at line @var{linenum} in source file @var{filename}. | |
2573 | ||
2574 | @item break @var{filename}:@var{function} | |
2575 | Set a breakpoint at entry to function @var{function} found in file | |
2576 | @var{filename}. Specifying a file name as well as a function name is | |
2577 | superfluous except when multiple files contain similarly named | |
2578 | functions. | |
2579 | ||
2580 | @item break *@var{address} | |
2581 | Set a breakpoint at address @var{address}. You can use this to set | |
29a2b744 | 2582 | breakpoints in parts of your program which do not have debugging |
70b88761 RP |
2583 | information or source files. |
2584 | ||
2585 | @item break | |
29a2b744 RP |
2586 | When called without any arguments, @code{break} sets a breakpoint at |
2587 | the next instruction to be executed in the selected stack frame | |
2588 | (@pxref{Stack, ,Examining the Stack}). In any selected frame but the | |
2589 | innermost, this will cause your program to stop as soon as control | |
2590 | returns to that frame. This is similar to the effect of a | |
2591 | @code{finish} command in the frame inside the selected frame---except | |
2592 | that @code{finish} does not leave an active breakpoint. If you use | |
18fae2a8 | 2593 | @code{break} without an argument in the innermost frame, @value{GDBN} will stop |
1041a570 RP |
2594 | the next time it reaches the current location; this may be useful |
2595 | inside loops. | |
70b88761 | 2596 | |
18fae2a8 | 2597 | @value{GDBN} normally ignores breakpoints when it resumes execution, until at |
70b88761 RP |
2598 | least one instruction has been executed. If it did not do this, you |
2599 | would be unable to proceed past a breakpoint without first disabling the | |
2600 | breakpoint. This rule applies whether or not the breakpoint already | |
29a2b744 | 2601 | existed when your program stopped. |
70b88761 RP |
2602 | |
2603 | @item break @dots{} if @var{cond} | |
2604 | Set a breakpoint with condition @var{cond}; evaluate the expression | |
2605 | @var{cond} each time the breakpoint is reached, and stop only if the | |
3d3ab540 | 2606 | value is nonzero---that is, if @var{cond} evaluates as true. |
1041a570 RP |
2607 | @samp{@dots{}} stands for one of the possible arguments described |
2608 | above (or no argument) specifying where to break. @xref{Conditions, | |
2609 | ,Break Conditions}, for more information on breakpoint conditions. | |
70b88761 RP |
2610 | |
2611 | @item tbreak @var{args} | |
2612 | @kindex tbreak | |
2613 | Set a breakpoint enabled only for one stop. @var{args} are the | |
2614 | same as for the @code{break} command, and the breakpoint is set in the same | |
29a2b744 RP |
2615 | way, but the breakpoint is automatically disabled after the first time your |
2616 | program stops there. @xref{Disabling, ,Disabling Breakpoints}. | |
70b88761 RP |
2617 | |
2618 | @item rbreak @var{regex} | |
2619 | @kindex rbreak | |
2620 | @cindex regular expression | |
4906534f | 2621 | @c FIXME what kind of regexp? |
70b88761 | 2622 | Set breakpoints on all functions matching the regular expression |
b80282d5 | 2623 | @var{regex}. This command |
70b88761 RP |
2624 | sets an unconditional breakpoint on all matches, printing a list of all |
2625 | breakpoints it set. Once these breakpoints are set, they are treated | |
2626 | just like the breakpoints set with the @code{break} command. They can | |
2627 | be deleted, disabled, made conditional, etc., in the standard ways. | |
2628 | ||
18fae2a8 | 2629 | @ifclear CONLY |
b80282d5 RP |
2630 | When debugging C++ programs, @code{rbreak} is useful for setting |
2631 | breakpoints on overloaded functions that are not members of any special | |
2632 | classes. | |
18fae2a8 | 2633 | @end ifclear |
b80282d5 | 2634 | |
70b88761 | 2635 | @kindex info breakpoints |
c338a2fd | 2636 | @cindex @code{$_} and @code{info breakpoints} |
70b88761 | 2637 | @item info breakpoints @r{[}@var{n}@r{]} |
6ca72cc6 RP |
2638 | @itemx info break @r{[}@var{n}@r{]} |
2639 | @itemx info watchpoints @r{[}@var{n}@r{]} | |
2640 | Print a table of all breakpoints and watchpoints set and not | |
2641 | deleted, with the following columns for each breakpoint: | |
2642 | ||
2643 | @table @emph | |
2644 | @item Breakpoint Numbers | |
2645 | @item Type | |
2646 | Breakpoint or watchpoint. | |
2647 | @item Disposition | |
2648 | Whether the breakpoint is marked to be disabled or deleted when hit. | |
2649 | @item Enabled or Disabled | |
d24e0922 | 2650 | Enabled breakpoints are marked with @samp{y}. @samp{n} marks breakpoints |
6ca72cc6 RP |
2651 | that are not enabled. |
2652 | @item Address | |
2653 | Where the breakpoint is in your program, as a memory address | |
2654 | @item What | |
2655 | Where the breakpoint is in the source for your program, as a file and | |
2656 | line number. | |
2657 | @end table | |
2658 | ||
2659 | @noindent | |
2660 | Breakpoint commands, if any, are listed after the line for the | |
2661 | corresponding breakpoint. | |
2662 | ||
2663 | @noindent | |
2664 | @code{info break} with a breakpoint | |
29a2b744 RP |
2665 | number @var{n} as argument lists only that breakpoint. The |
2666 | convenience variable @code{$_} and the default examining-address for | |
2667 | the @code{x} command are set to the address of the last breakpoint | |
6ca72cc6 | 2668 | listed (@pxref{Memory, ,Examining Memory}). |
1041a570 | 2669 | @end table |
70b88761 | 2670 | |
18fae2a8 | 2671 | @value{GDBN} allows you to set any number of breakpoints at the same place in |
1041a570 RP |
2672 | your program. There is nothing silly or meaningless about this. When |
2673 | the breakpoints are conditional, this is even useful | |
29a2b744 | 2674 | (@pxref{Conditions, ,Break Conditions}). |
70b88761 | 2675 | |
6ca72cc6 | 2676 | @cindex negative breakpoint numbers |
18fae2a8 RP |
2677 | @cindex internal @value{GDBN} breakpoints |
2678 | @value{GDBN} itself sometimes sets breakpoints in your program for special | |
6ca72cc6 RP |
2679 | purposes, such as proper handling of @code{longjmp} (in C programs). |
2680 | These internal breakpoints are assigned negative numbers, starting with | |
5a2c1d85 | 2681 | @code{-1}; @samp{info breakpoints} does not display them. |
d48da190 | 2682 | |
18fae2a8 | 2683 | You can see these breakpoints with the @value{GDBN} maintenance command |
5a2c1d85 | 2684 | @samp{maint info breakpoints}. |
6ca72cc6 RP |
2685 | |
2686 | @table @code | |
d48da190 RP |
2687 | @kindex maint info breakpoints |
2688 | @item maint info breakpoints | |
6ca72cc6 | 2689 | Using the same format as @samp{info breakpoints}, display both the |
18fae2a8 | 2690 | breakpoints you've set explicitly, and those @value{GDBN} is using for |
6ca72cc6 RP |
2691 | internal purposes. Internal breakpoints are shown with negative |
2692 | breakpoint numbers. The type column identifies what kind of breakpoint | |
2693 | is shown: | |
2694 | ||
2695 | @table @code | |
2696 | @item breakpoint | |
2697 | Normal, explicitly set breakpoint. | |
2698 | ||
2699 | @item watchpoint | |
2700 | Normal, explicitly set watchpoint. | |
2701 | ||
2702 | @item longjmp | |
2703 | Internal breakpoint, used to handle correctly stepping through | |
2704 | @code{longjmp} calls. | |
2705 | ||
2706 | @item longjmp resume | |
2707 | Internal breakpoint at the target of a @code{longjmp}. | |
2708 | ||
2709 | @item until | |
18fae2a8 | 2710 | Temporary internal breakpoint used by the @value{GDBN} @code{until} command. |
6ca72cc6 RP |
2711 | |
2712 | @item finish | |
18fae2a8 | 2713 | Temporary internal breakpoint used by the @value{GDBN} @code{finish} command. |
6ca72cc6 RP |
2714 | @end table |
2715 | ||
2716 | @end table | |
2717 | ||
2718 | ||
4eb4cf57 | 2719 | @node Set Watchpoints |
70b88761 RP |
2720 | @subsection Setting Watchpoints |
2721 | @cindex setting watchpoints | |
1041a570 | 2722 | |
70b88761 | 2723 | You can use a watchpoint to stop execution whenever the value of an |
e251e767 | 2724 | expression changes, without having to predict a particular place |
70b88761 RP |
2725 | where this may happen. |
2726 | ||
2727 | Watchpoints currently execute two orders of magnitude more slowly than | |
2728 | other breakpoints, but this can well be worth it to catch errors where | |
2729 | you have no clue what part of your program is the culprit. Some | |
2730 | processors provide special hardware to support watchpoint evaluation; future | |
18fae2a8 | 2731 | releases of @value{GDBN} will use such hardware if it is available. |
70b88761 RP |
2732 | |
2733 | @table @code | |
e251e767 | 2734 | @kindex watch |
70b88761 RP |
2735 | @item watch @var{expr} |
2736 | Set a watchpoint for an expression. | |
2737 | ||
2738 | @kindex info watchpoints | |
2739 | @item info watchpoints | |
6ca72cc6 RP |
2740 | This command prints a list of watchpoints and breakpoints; it is the |
2741 | same as @code{info break}. | |
70b88761 RP |
2742 | @end table |
2743 | ||
4eb4cf57 | 2744 | @node Exception Handling |
70b88761 RP |
2745 | @subsection Breakpoints and Exceptions |
2746 | @cindex exception handlers | |
2747 | ||
b80282d5 | 2748 | Some languages, such as GNU C++, implement exception handling. You can |
18fae2a8 | 2749 | use @value{GDBN} to examine what caused your program to raise an exception, |
29a2b744 | 2750 | and to list the exceptions your program is prepared to handle at a |
70b88761 RP |
2751 | given point in time. |
2752 | ||
2753 | @table @code | |
2754 | @item catch @var{exceptions} | |
2755 | @kindex catch | |
2756 | You can set breakpoints at active exception handlers by using the | |
2757 | @code{catch} command. @var{exceptions} is a list of names of exceptions | |
2758 | to catch. | |
2759 | @end table | |
2760 | ||
29a2b744 RP |
2761 | You can use @code{info catch} to list active exception handlers. |
2762 | @xref{Frame Info, ,Information About a Frame}. | |
70b88761 | 2763 | |
18fae2a8 | 2764 | There are currently some limitations to exception handling in @value{GDBN}. |
70b88761 RP |
2765 | These will be corrected in a future release. |
2766 | ||
2767 | @itemize @bullet | |
2768 | @item | |
18fae2a8 | 2769 | If you call a function interactively, @value{GDBN} normally returns |
70b88761 RP |
2770 | control to you when the function has finished executing. If the call |
2771 | raises an exception, however, the call may bypass the mechanism that | |
29a2b744 | 2772 | returns control to you and cause your program to simply continue |
18fae2a8 | 2773 | running until it hits a breakpoint, catches a signal that @value{GDBN} is |
70b88761 RP |
2774 | listening for, or exits. |
2775 | @item | |
2776 | You cannot raise an exception interactively. | |
2777 | @item | |
2778 | You cannot interactively install an exception handler. | |
2779 | @end itemize | |
2780 | ||
2781 | @cindex raise exceptions | |
2782 | Sometimes @code{catch} is not the best way to debug exception handling: | |
29a2b744 | 2783 | if you need to know exactly where an exception is raised, it is better to |
70b88761 RP |
2784 | stop @emph{before} the exception handler is called, since that way you |
2785 | can see the stack before any unwinding takes place. If you set a | |
2786 | breakpoint in an exception handler instead, it may not be easy to find | |
2787 | out where the exception was raised. | |
2788 | ||
2789 | To stop just before an exception handler is called, you need some | |
b80282d5 | 2790 | knowledge of the implementation. In the case of GNU C++, exceptions are |
70b88761 RP |
2791 | raised by calling a library function named @code{__raise_exception} |
2792 | which has the following ANSI C interface: | |
2793 | ||
2794 | @example | |
b80282d5 | 2795 | /* @var{addr} is where the exception identifier is stored. |
70b88761 RP |
2796 | ID is the exception identifier. */ |
2797 | void __raise_exception (void **@var{addr}, void *@var{id}); | |
2798 | @end example | |
2799 | ||
2800 | @noindent | |
2801 | To make the debugger catch all exceptions before any stack | |
2802 | unwinding takes place, set a breakpoint on @code{__raise_exception} | |
29a2b744 | 2803 | (@pxref{Breakpoints, ,Breakpoints Watchpoints and Exceptions}). |
70b88761 | 2804 | |
29a2b744 RP |
2805 | With a conditional breakpoint (@pxref{Conditions, ,Break Conditions}) |
2806 | that depends on the value of @var{id}, you can stop your program when | |
2807 | a specific exception is raised. You can use multiple conditional | |
2808 | breakpoints to stop your program when any of a number of exceptions are | |
2809 | raised. | |
70b88761 | 2810 | |
4eb4cf57 | 2811 | @node Delete Breaks |
70b88761 RP |
2812 | @subsection Deleting Breakpoints |
2813 | ||
2814 | @cindex clearing breakpoints, watchpoints | |
2815 | @cindex deleting breakpoints, watchpoints | |
2816 | It is often necessary to eliminate a breakpoint or watchpoint once it | |
29a2b744 | 2817 | has done its job and you no longer want your program to stop there. This |
70b88761 RP |
2818 | is called @dfn{deleting} the breakpoint. A breakpoint that has been |
2819 | deleted no longer exists; it is forgotten. | |
2820 | ||
2821 | With the @code{clear} command you can delete breakpoints according to | |
29a2b744 | 2822 | where they are in your program. With the @code{delete} command you can |
70b88761 RP |
2823 | delete individual breakpoints or watchpoints by specifying their |
2824 | breakpoint numbers. | |
2825 | ||
18fae2a8 | 2826 | It is not necessary to delete a breakpoint to proceed past it. @value{GDBN} |
70b88761 RP |
2827 | automatically ignores breakpoints on the first instruction to be executed |
2828 | when you continue execution without changing the execution address. | |
2829 | ||
2830 | @table @code | |
2831 | @item clear | |
2832 | @kindex clear | |
2833 | Delete any breakpoints at the next instruction to be executed in the | |
29a2b744 RP |
2834 | selected stack frame (@pxref{Selection, ,Selecting a Frame}). When |
2835 | the innermost frame is selected, this is a good way to delete a | |
2836 | breakpoint where your program just stopped. | |
70b88761 RP |
2837 | |
2838 | @item clear @var{function} | |
2839 | @itemx clear @var{filename}:@var{function} | |
2840 | Delete any breakpoints set at entry to the function @var{function}. | |
2841 | ||
2842 | @item clear @var{linenum} | |
2843 | @itemx clear @var{filename}:@var{linenum} | |
2844 | Delete any breakpoints set at or within the code of the specified line. | |
2845 | ||
2846 | @item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} | |
2847 | @cindex delete breakpoints | |
2848 | @kindex delete | |
2849 | @kindex d | |
2850 | Delete the breakpoints or watchpoints of the numbers specified as | |
18fae2a8 | 2851 | arguments. If no argument is specified, delete all breakpoints (@value{GDBN} |
1041a570 | 2852 | asks confirmation, unless you have @code{set confirm off}). You |
70b88761 RP |
2853 | can abbreviate this command as @code{d}. |
2854 | @end table | |
2855 | ||
4eb4cf57 | 2856 | @node Disabling |
70b88761 RP |
2857 | @subsection Disabling Breakpoints |
2858 | ||
2859 | @cindex disabled breakpoints | |
2860 | @cindex enabled breakpoints | |
2861 | Rather than deleting a breakpoint or watchpoint, you might prefer to | |
2862 | @dfn{disable} it. This makes the breakpoint inoperative as if it had | |
2863 | been deleted, but remembers the information on the breakpoint so that | |
2864 | you can @dfn{enable} it again later. | |
2865 | ||
2866 | You disable and enable breakpoints and watchpoints with the | |
2867 | @code{enable} and @code{disable} commands, optionally specifying one or | |
2868 | more breakpoint numbers as arguments. Use @code{info break} or | |
2869 | @code{info watch} to print a list of breakpoints or watchpoints if you | |
29a2b744 | 2870 | do not know which numbers to use. |
70b88761 RP |
2871 | |
2872 | A breakpoint or watchpoint can have any of four different states of | |
2873 | enablement: | |
2874 | ||
2875 | @itemize @bullet | |
2876 | @item | |
29a2b744 | 2877 | Enabled. The breakpoint will stop your program. A breakpoint set |
70b88761 RP |
2878 | with the @code{break} command starts out in this state. |
2879 | @item | |
29a2b744 | 2880 | Disabled. The breakpoint has no effect on your program. |
70b88761 | 2881 | @item |
29a2b744 | 2882 | Enabled once. The breakpoint will stop your program, but |
70b88761 RP |
2883 | when it does so it will become disabled. A breakpoint set |
2884 | with the @code{tbreak} command starts out in this state. | |
2885 | @item | |
29a2b744 | 2886 | Enabled for deletion. The breakpoint will stop your program, but |
70b88761 RP |
2887 | immediately after it does so it will be deleted permanently. |
2888 | @end itemize | |
2889 | ||
2890 | You can use the following commands to enable or disable breakpoints and | |
2891 | watchpoints: | |
2892 | ||
2893 | @table @code | |
2894 | @item disable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} | |
2895 | @kindex disable breakpoints | |
2896 | @kindex disable | |
2897 | @kindex dis | |
2898 | Disable the specified breakpoints---or all breakpoints, if none are | |
2899 | listed. A disabled breakpoint has no effect but is not forgotten. All | |
2900 | options such as ignore-counts, conditions and commands are remembered in | |
2901 | case the breakpoint is enabled again later. You may abbreviate | |
2902 | @code{disable} as @code{dis}. | |
2903 | ||
2904 | @item enable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} | |
2905 | @kindex enable breakpoints | |
2906 | @kindex enable | |
2907 | Enable the specified breakpoints (or all defined breakpoints). They | |
29a2b744 | 2908 | become effective once again in stopping your program. |
70b88761 RP |
2909 | |
2910 | @item enable @r{[}breakpoints@r{]} once @var{bnums}@dots{} | |
2911 | Enable the specified breakpoints temporarily. Each will be disabled | |
29a2b744 | 2912 | again the next time it stops your program. |
70b88761 RP |
2913 | |
2914 | @item enable @r{[}breakpoints@r{]} delete @var{bnums}@dots{} | |
2915 | Enable the specified breakpoints to work once and then die. Each of | |
29a2b744 | 2916 | the breakpoints will be deleted the next time it stops your program. |
70b88761 RP |
2917 | @end table |
2918 | ||
29a2b744 RP |
2919 | Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks, |
2920 | ,Setting Breakpoints}), breakpoints that you set are initially | |
2921 | enabled; subsequently, they become disabled or enabled only when you | |
2922 | use one of the commands above. (The command @code{until} can set and | |
2923 | delete a breakpoint of its own, but it will not change the state of | |
98fe4566 | 2924 | your other breakpoints; see @ref{Continuing and Stepping, ,Continuing and Stepping}.) |
70b88761 | 2925 | |
4eb4cf57 | 2926 | @node Conditions |
70b88761 RP |
2927 | @subsection Break Conditions |
2928 | @cindex conditional breakpoints | |
2929 | @cindex breakpoint conditions | |
2930 | ||
4906534f RP |
2931 | @c FIXME what is scope of break condition expr? Context where wanted? |
2932 | @c in particular for a watchpoint? | |
29a2b744 | 2933 | The simplest sort of breakpoint breaks every time your program reaches a |
70b88761 RP |
2934 | specified place. You can also specify a @dfn{condition} for a |
2935 | breakpoint. A condition is just a Boolean expression in your | |
1041a570 RP |
2936 | programming language (@pxref{Expressions, ,Expressions}). A breakpoint with |
2937 | a condition evaluates the expression each time your program reaches it, | |
2938 | and your program stops only if the condition is @emph{true}. | |
3d3ab540 RP |
2939 | |
2940 | This is the converse of using assertions for program validation; in that | |
2941 | situation, you want to stop when the assertion is violated---that is, | |
2942 | when the condition is false. In C, if you want to test an assertion expressed | |
e251e767 | 2943 | by the condition @var{assert}, you should set the condition |
3d3ab540 | 2944 | @samp{! @var{assert}} on the appropriate breakpoint. |
70b88761 RP |
2945 | |
2946 | Conditions are also accepted for watchpoints; you may not need them, | |
2947 | since a watchpoint is inspecting the value of an expression anyhow---but | |
2948 | it might be simpler, say, to just set a watchpoint on a variable name, | |
2949 | and specify a condition that tests whether the new value is an interesting | |
e251e767 | 2950 | one. |
70b88761 | 2951 | |
29a2b744 | 2952 | Break conditions can have side effects, and may even call functions in |
70b88761 | 2953 | your program. This can be useful, for example, to activate functions |
29a2b744 RP |
2954 | that log program progress, or to use your own print functions to |
2955 | format special data structures. The effects are completely predictable | |
2956 | unless there is another enabled breakpoint at the same address. (In | |
18fae2a8 | 2957 | that case, @value{GDBN} might see the other breakpoint first and stop your |
29a2b744 RP |
2958 | program without checking the condition of this one.) Note that |
2959 | breakpoint commands are usually more convenient and flexible for the | |
2960 | purpose of performing side effects when a breakpoint is reached | |
2961 | (@pxref{Break Commands, ,Breakpoint Command Lists}). | |
70b88761 RP |
2962 | |
2963 | Break conditions can be specified when a breakpoint is set, by using | |
29a2b744 RP |
2964 | @samp{if} in the arguments to the @code{break} command. @xref{Set |
2965 | Breaks, ,Setting Breakpoints}. They can also be changed at any time | |
2966 | with the @code{condition} command. The @code{watch} command does not | |
2967 | recognize the @code{if} keyword; @code{condition} is the only way to | |
2968 | impose a further condition on a watchpoint. | |
70b88761 | 2969 | |
e251e767 RP |
2970 | @table @code |
2971 | @item condition @var{bnum} @var{expression} | |
2972 | @kindex condition | |
70b88761 RP |
2973 | Specify @var{expression} as the break condition for breakpoint or |
2974 | watchpoint number @var{bnum}. From now on, this breakpoint will stop | |
29a2b744 | 2975 | your program only if the value of @var{expression} is true (nonzero, in |
18fae2a8 | 2976 | C). When you use @code{condition}, @value{GDBN} checks @var{expression} |
70b88761 | 2977 | immediately for syntactic correctness, and to determine whether symbols |
1041a570 | 2978 | in it have referents in the context of your breakpoint. |
29a2b744 | 2979 | @c FIXME so what does GDB do if there is no referent? Moreover, what |
4906534f | 2980 | @c about watchpoints? |
18fae2a8 | 2981 | @value{GDBN} does |
70b88761 | 2982 | not actually evaluate @var{expression} at the time the @code{condition} |
1041a570 | 2983 | command is given, however. @xref{Expressions, ,Expressions}. |
70b88761 RP |
2984 | |
2985 | @item condition @var{bnum} | |
2986 | Remove the condition from breakpoint number @var{bnum}. It becomes | |
2987 | an ordinary unconditional breakpoint. | |
2988 | @end table | |
2989 | ||
2990 | @cindex ignore count (of breakpoint) | |
2991 | A special case of a breakpoint condition is to stop only when the | |
2992 | breakpoint has been reached a certain number of times. This is so | |
2993 | useful that there is a special way to do it, using the @dfn{ignore | |
2994 | count} of the breakpoint. Every breakpoint has an ignore count, which | |
2995 | is an integer. Most of the time, the ignore count is zero, and | |
29a2b744 | 2996 | therefore has no effect. But if your program reaches a breakpoint whose |
70b88761 RP |
2997 | ignore count is positive, then instead of stopping, it just decrements |
2998 | the ignore count by one and continues. As a result, if the ignore count | |
2999 | value is @var{n}, the breakpoint will not stop the next @var{n} times it | |
3000 | is reached. | |
3001 | ||
3002 | @table @code | |
3003 | @item ignore @var{bnum} @var{count} | |
3004 | @kindex ignore | |
3005 | Set the ignore count of breakpoint number @var{bnum} to @var{count}. | |
3006 | The next @var{count} times the breakpoint is reached, your program's | |
18fae2a8 | 3007 | execution will not stop; other than to decrement the ignore count, @value{GDBN} |
70b88761 RP |
3008 | takes no action. |
3009 | ||
3010 | To make the breakpoint stop the next time it is reached, specify | |
3011 | a count of zero. | |
3012 | ||
3013 | @item continue @var{count} | |
3014 | @itemx c @var{count} | |
3015 | @itemx fg @var{count} | |
3016 | @kindex continue @var{count} | |
29a2b744 RP |
3017 | Continue execution of your program, setting the ignore count of the |
3018 | breakpoint where your program stopped to @var{count} minus one. | |
3019 | Thus, your program will not stop at this breakpoint until the | |
70b88761 RP |
3020 | @var{count}'th time it is reached. |
3021 | ||
29a2b744 | 3022 | An argument to this command is meaningful only when your program stopped |
70b88761 RP |
3023 | due to a breakpoint. At other times, the argument to @code{continue} is |
3024 | ignored. | |
3025 | ||
3026 | The synonym @code{fg} is provided purely for convenience, and has | |
3027 | exactly the same behavior as other forms of the command. | |
3028 | @end table | |
3029 | ||
3030 | If a breakpoint has a positive ignore count and a condition, the condition | |
3031 | is not checked. Once the ignore count reaches zero, the condition will | |
3032 | be checked. | |
3033 | ||
29a2b744 | 3034 | You could achieve the effect of the ignore count with a condition such |
18fae2a8 | 3035 | as @w{@samp{$foo-- <= 0}} using a debugger convenience variable that |
1041a570 RP |
3036 | is decremented each time. @xref{Convenience Vars, ,Convenience |
3037 | Variables}. | |
70b88761 | 3038 | |
4eb4cf57 | 3039 | @node Break Commands |
70b88761 RP |
3040 | @subsection Breakpoint Command Lists |
3041 | ||
3042 | @cindex breakpoint commands | |
3043 | You can give any breakpoint (or watchpoint) a series of commands to | |
29a2b744 | 3044 | execute when your program stops due to that breakpoint. For example, you |
70b88761 RP |
3045 | might want to print the values of certain expressions, or enable other |
3046 | breakpoints. | |
3047 | ||
3048 | @table @code | |
3049 | @item commands @r{[}@var{bnum}@r{]} | |
3050 | @itemx @dots{} @var{command-list} @dots{} | |
3051 | @itemx end | |
3052 | @kindex commands | |
3053 | @kindex end | |
3054 | Specify a list of commands for breakpoint number @var{bnum}. The commands | |
3055 | themselves appear on the following lines. Type a line containing just | |
3056 | @code{end} to terminate the commands. | |
3057 | ||
203eea5d RP |
3058 | To remove all commands from a breakpoint, type @code{commands} and |
3059 | follow it immediately with @code{end}; that is, give no commands. | |
70b88761 RP |
3060 | |
3061 | With no @var{bnum} argument, @code{commands} refers to the last | |
3062 | breakpoint or watchpoint set (not to the breakpoint most recently | |
3063 | encountered). | |
3064 | @end table | |
3065 | ||
18fae2a8 | 3066 | Pressing @key{RET} as a means of repeating the last @value{GDBN} command is |
70b88761 RP |
3067 | disabled within a @var{command-list}. |
3068 | ||
29a2b744 | 3069 | You can use breakpoint commands to start your program up again. Simply |
70b88761 RP |
3070 | use the @code{continue} command, or @code{step}, or any other command |
3071 | that resumes execution. Subsequent commands in the command list are | |
3072 | ignored. | |
3073 | ||
3074 | @kindex silent | |
3075 | If the first command specified is @code{silent}, the usual message about | |
3076 | stopping at a breakpoint is not printed. This may be desirable for | |
3077 | breakpoints that are to print a specific message and then continue. | |
3078 | If the remaining commands too print nothing, you will see no sign that | |
e251e767 | 3079 | the breakpoint was reached at all. @code{silent} is meaningful only |
70b88761 RP |
3080 | at the beginning of a breakpoint command list. |
3081 | ||
29a2b744 RP |
3082 | The commands @code{echo} and @code{output} that allow you to print |
3083 | precisely controlled output are often useful in silent breakpoints. | |
3084 | @xref{Output, ,Commands for Controlled Output}. | |
70b88761 RP |
3085 | |
3086 | For example, here is how you could use breakpoint commands to print the | |
3087 | value of @code{x} at entry to @code{foo} whenever @code{x} is positive. | |
3088 | ||
18fae2a8 | 3089 | @example |
70b88761 RP |
3090 | break foo if x>0 |
3091 | commands | |
3092 | silent | |
3093 | echo x is\040 | |
3094 | output x | |
3095 | echo \n | |
3096 | cont | |
3097 | end | |
18fae2a8 | 3098 | @end example |
70b88761 RP |
3099 | |
3100 | One application for breakpoint commands is to compensate for one bug so | |
3101 | you can test for another. Put a breakpoint just after the erroneous line | |
3102 | of code, give it a condition to detect the case in which something | |
3103 | erroneous has been done, and give it commands to assign correct values | |
3104 | to any variables that need them. End with the @code{continue} command | |
29a2b744 | 3105 | so that your program does not stop, and start with the @code{silent} |
70b88761 RP |
3106 | command so that no output is produced. Here is an example: |
3107 | ||
3108 | @example | |
3109 | break 403 | |
3110 | commands | |
3111 | silent | |
3112 | set x = y + 4 | |
3113 | cont | |
3114 | end | |
3115 | @end example | |
3116 | ||
3117 | @cindex lost output | |
3118 | One deficiency in the operation of automatically continuing breakpoints | |
3119 | under Unix appears when your program uses raw mode for the terminal. | |
18fae2a8 | 3120 | @value{GDBN} switches back to its own terminal modes (not raw) before executing |
70b88761 | 3121 | commands, and then must switch back to raw mode when your program is |
e251e767 | 3122 | continued. This causes any pending terminal input to be lost. |
70b88761 RP |
3123 | @c FIXME: revisit below when GNU sys avail. |
3124 | @c In the GNU system, this will be fixed by changing the behavior of | |
3125 | @c terminal modes. | |
3126 | ||
3127 | Under Unix, you can get around this problem by writing actions into | |
3128 | the breakpoint condition rather than in commands. For example | |
3129 | ||
3130 | @example | |
3131 | condition 5 (x = y + 4), 0 | |
3132 | @end example | |
3133 | ||
3134 | @noindent | |
1041a570 RP |
3135 | specifies a condition expression (@pxref{Expressions, ,Expressions}) that will |
3136 | change @code{x} as needed, then always have the value zero so your | |
18fae2a8 | 3137 | program will not stop. No input is lost here, because @value{GDBN} evaluates |
1041a570 RP |
3138 | break conditions without changing the terminal modes. When you want |
3139 | to have nontrivial conditions for performing the side effects, the | |
3140 | operators @samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful. | |
70b88761 | 3141 | |
4eb4cf57 | 3142 | @node Breakpoint Menus |
70b88761 | 3143 | @subsection Breakpoint Menus |
b80282d5 | 3144 | @cindex overloading |
e251e767 | 3145 | @cindex symbol overloading |
70b88761 RP |
3146 | |
3147 | Some programming languages (notably C++) permit a single function name | |
3148 | to be defined several times, for application in different contexts. | |
3149 | This is called @dfn{overloading}. When a function name is overloaded, | |
18fae2a8 | 3150 | @samp{break @var{function}} is not enough to tell @value{GDBN} where you want |
6f3ec223 RP |
3151 | a breakpoint. If you realize this will be a problem, you can use |
3152 | something like @samp{break @var{function}(@var{types})} to specify which | |
18fae2a8 | 3153 | particular version of the function you want. Otherwise, @value{GDBN} offers |
6f3ec223 RP |
3154 | you a menu of numbered choices for different possible breakpoints, and |
3155 | waits for your selection with the prompt @samp{>}. The first two | |
3156 | options are always @samp{[0] cancel} and @samp{[1] all}. Typing @kbd{1} | |
3157 | sets a breakpoint at each definition of @var{function}, and typing | |
3158 | @kbd{0} aborts the @code{break} command without setting any new | |
3159 | breakpoints. | |
70b88761 RP |
3160 | |
3161 | For example, the following session excerpt shows an attempt to set a | |
e251e767 | 3162 | breakpoint at the overloaded symbol @code{String::after}. |
70b88761 RP |
3163 | We choose three particular definitions of that function name: |
3164 | ||
6f3ec223 | 3165 | @c FIXME! This is likely to change to show arg type lists, at least |
70b88761 | 3166 | @example |
18fae2a8 | 3167 | (@value{GDBP}) b String::after |
70b88761 RP |
3168 | [0] cancel |
3169 | [1] all | |
3170 | [2] file:String.cc; line number:867 | |
3171 | [3] file:String.cc; line number:860 | |
3172 | [4] file:String.cc; line number:875 | |
3173 | [5] file:String.cc; line number:853 | |
3174 | [6] file:String.cc; line number:846 | |
3175 | [7] file:String.cc; line number:735 | |
3176 | > 2 4 6 | |
3177 | Breakpoint 1 at 0xb26c: file String.cc, line 867. | |
3178 | Breakpoint 2 at 0xb344: file String.cc, line 875. | |
3179 | Breakpoint 3 at 0xafcc: file String.cc, line 846. | |
3180 | Multiple breakpoints were set. | |
3181 | Use the "delete" command to delete unwanted breakpoints. | |
18fae2a8 | 3182 | (@value{GDBP}) |
70b88761 RP |
3183 | @end example |
3184 | ||
4eb4cf57 | 3185 | @node Error in Breakpoints |
70b88761 RP |
3186 | @subsection ``Cannot Insert Breakpoints'' |
3187 | ||
e251e767 | 3188 | @c FIXME: "cannot insert breakpoints" error, v unclear. |
70b88761 | 3189 | @c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91 |
e251e767 | 3190 | @c some light may be shed by looking at instances of |
d24e0922 | 3191 | @c ONE_PROCESS_WRITETEXT. But error message seems possible otherwise |
c338a2fd | 3192 | @c too. pesch, 20sep91 |
70b88761 RP |
3193 | Under some operating systems, breakpoints cannot be used in a program if |
3194 | any other process is running that program. In this situation, | |
18fae2a8 | 3195 | attempting to run or continue a program with a breakpoint causes @value{GDBN} |
70b88761 RP |
3196 | to stop the other process. |
3197 | ||
3198 | When this happens, you have three ways to proceed: | |
3199 | ||
3200 | @enumerate | |
3201 | @item | |
3202 | Remove or disable the breakpoints, then continue. | |
3203 | ||
3204 | @item | |
18fae2a8 RP |
3205 | Suspend @value{GDBN}, and copy the file containing your program to a new name. |
3206 | Resume @value{GDBN} and use the @code{exec-file} command to specify that @value{GDBN} | |
29a2b744 | 3207 | should run your program under that name. Then start your program again. |
70b88761 RP |
3208 | |
3209 | @c FIXME: RMS commented here "Show example". Maybe when someone | |
3210 | @c explains the first FIXME: in this section... | |
3211 | ||
3212 | @item | |
29a2b744 | 3213 | Relink your program so that the text segment is nonsharable, using the |
70b88761 RP |
3214 | linker option @samp{-N}. The operating system limitation may not apply |
3215 | to nonsharable executables. | |
3216 | @end enumerate | |
3217 | ||
4eb4cf57 | 3218 | @node Continuing and Stepping |
3d3ab540 | 3219 | @section Continuing and Stepping |
70b88761 RP |
3220 | |
3221 | @cindex stepping | |
7463aadd RP |
3222 | @cindex continuing |
3223 | @cindex resuming execution | |
3d3ab540 | 3224 | @dfn{Continuing} means resuming program execution until your program |
cedaf8bc RP |
3225 | completes normally. In contrast, @dfn{stepping} means executing just |
3226 | one more ``step'' of your program, where ``step'' may mean either one | |
3227 | line of source code, or one machine instruction (depending on what | |
3228 | particular command you use). Either when continuing | |
4eb4cf57 | 3229 | or when stepping, your program may stop even sooner, due to |
18fae2a8 | 3230 | @ifset BARETARGET |
4eb4cf57 | 3231 | a breakpoint. |
18fae2a8 RP |
3232 | @end ifset |
3233 | @ifclear BARETARGET | |
4eb4cf57 RP |
3234 | a breakpoint or to a signal. (If due to a signal, you may want to use |
3235 | @code{handle}, or use @samp{signal 0} to resume execution. | |
3236 | @xref{Signals, ,Signals}.) | |
18fae2a8 | 3237 | @end ifclear |
3d3ab540 RP |
3238 | |
3239 | @table @code | |
3240 | @item continue @r{[}@var{ignore-count}@r{]} | |
3241 | @kindex continue | |
29a2b744 | 3242 | Resume program execution, at the address where your program last stopped; |
3d3ab540 RP |
3243 | any breakpoints set at that address are bypassed. The optional argument |
3244 | @var{ignore-count} allows you to specify a further number of times to | |
3245 | ignore a breakpoint at this location; its effect is like that of | |
29a2b744 | 3246 | @code{ignore} (@pxref{Conditions, ,Break Conditions}). |
3d3ab540 RP |
3247 | |
3248 | To resume execution at a different place, you can use @code{return} | |
29a2b744 RP |
3249 | (@pxref{Returning, ,Returning from a Function}) to go back to the |
3250 | calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a | |
1041a570 | 3251 | Different Address}) to go to an arbitrary location in your program. |
3d3ab540 | 3252 | @end table |
7463aadd RP |
3253 | |
3254 | A typical technique for using stepping is to set a breakpoint | |
29a2b744 RP |
3255 | (@pxref{Breakpoints, ,Breakpoints Watchpoints and Exceptions}) at the |
3256 | beginning of the function or the section of your program where a | |
3257 | problem is believed to lie, run your program until it stops at that | |
3258 | breakpoint, and then step through the suspect area, examining the | |
3259 | variables that are interesting, until you see the problem happen. | |
70b88761 RP |
3260 | |
3261 | @table @code | |
3262 | @item step | |
3263 | @kindex step | |
3264 | @kindex s | |
29a2b744 | 3265 | Continue running your program until control reaches a different source |
18fae2a8 | 3266 | line, then stop it and return control to @value{GDBN}. This command is |
70b88761 RP |
3267 | abbreviated @code{s}. |
3268 | ||
3d3ab540 RP |
3269 | @quotation |
3270 | @emph{Warning:} If you use the @code{step} command while control is | |
3271 | within a function that was compiled without debugging information, | |
3272 | execution will proceed until control reaches another function. | |
3273 | @end quotation | |
70b88761 RP |
3274 | |
3275 | @item step @var{count} | |
3276 | Continue running as in @code{step}, but do so @var{count} times. If a | |
3277 | breakpoint is reached or a signal not related to stepping occurs before | |
3278 | @var{count} steps, stepping stops right away. | |
3279 | ||
7463aadd | 3280 | @item next @r{[}@var{count}@r{]} |
70b88761 RP |
3281 | @kindex next |
3282 | @kindex n | |
7463aadd RP |
3283 | Continue to the next source line in the current (innermost) stack frame. |
3284 | Similar to @code{step}, but any function calls appearing within the line | |
3285 | of code are executed without stopping. Execution stops when control | |
3286 | reaches a different line of code at the stack level which was executing | |
3287 | when the @code{next} command was given. This command is abbreviated | |
3288 | @code{n}. | |
70b88761 | 3289 | |
7463aadd | 3290 | An argument @var{count} is a repeat count, as for @code{step}. |
70b88761 RP |
3291 | |
3292 | @code{next} within a function that lacks debugging information acts like | |
3293 | @code{step}, but any function calls appearing within the code of the | |
3294 | function are executed without stopping. | |
3295 | ||
3296 | @item finish | |
3297 | @kindex finish | |
7463aadd RP |
3298 | Continue running until just after function in the selected stack frame |
3299 | returns. Print the returned value (if any). | |
70b88761 | 3300 | |
29a2b744 | 3301 | Contrast this with the @code{return} command (@pxref{Returning, |
1041a570 | 3302 | ,Returning from a Function}). |
70b88761 RP |
3303 | |
3304 | @item until | |
3305 | @kindex until | |
3306 | @item u | |
3307 | @kindex u | |
3308 | Continue running until a source line past the current line, in the | |
3309 | current stack frame, is reached. This command is used to avoid single | |
3310 | stepping through a loop more than once. It is like the @code{next} | |
3311 | command, except that when @code{until} encounters a jump, it | |
3312 | automatically continues execution until the program counter is greater | |
3313 | than the address of the jump. | |
3314 | ||
3315 | This means that when you reach the end of a loop after single stepping | |
29a2b744 | 3316 | though it, @code{until} will cause your program to continue execution |
70b88761 RP |
3317 | until the loop is exited. In contrast, a @code{next} command at the end |
3318 | of a loop will simply step back to the beginning of the loop, which | |
3319 | would force you to step through the next iteration. | |
3320 | ||
29a2b744 | 3321 | @code{until} always stops your program if it attempts to exit the current |
70b88761 RP |
3322 | stack frame. |
3323 | ||
3324 | @code{until} may produce somewhat counterintuitive results if the order | |
7463aadd | 3325 | of machine code does not match the order of the source lines. For |
70b88761 RP |
3326 | example, in the following excerpt from a debugging session, the @code{f} |
3327 | (@code{frame}) command shows that execution is stopped at line | |
3328 | @code{206}; yet when we use @code{until}, we get to line @code{195}: | |
3329 | ||
3330 | @example | |
18fae2a8 | 3331 | (@value{GDBP}) f |
70b88761 | 3332 | #0 main (argc=4, argv=0xf7fffae8) at m4.c:206 |
b80282d5 | 3333 | 206 expand_input(); |
18fae2a8 | 3334 | (@value{GDBP}) until |
b80282d5 | 3335 | 195 for ( ; argc > 0; NEXTARG) @{ |
70b88761 RP |
3336 | @end example |
3337 | ||
7463aadd RP |
3338 | This happened because, for execution efficiency, the compiler had |
3339 | generated code for the loop closure test at the end, rather than the | |
3340 | start, of the loop---even though the test in a C @code{for}-loop is | |
3341 | written before the body of the loop. The @code{until} command appeared | |
3342 | to step back to the beginning of the loop when it advanced to this | |
3343 | expression; however, it has not really gone to an earlier | |
3344 | statement---not in terms of the actual machine code. | |
70b88761 RP |
3345 | |
3346 | @code{until} with no argument works by means of single | |
3347 | instruction stepping, and hence is slower than @code{until} with an | |
3348 | argument. | |
3349 | ||
3350 | @item until @var{location} | |
3351 | @item u @var{location} | |
29a2b744 RP |
3352 | Continue running your program until either the specified location is |
3353 | reached, or the current stack frame returns. @var{location} is any of | |
3354 | the forms of argument acceptable to @code{break} (@pxref{Set Breaks, | |
3355 | ,Setting Breakpoints}). This form of the command uses breakpoints, | |
1041a570 | 3356 | and hence is quicker than @code{until} without an argument. |
70b88761 RP |
3357 | |
3358 | @item stepi | |
3359 | @itemx si | |
3360 | @kindex stepi | |
3361 | @kindex si | |
3362 | Execute one machine instruction, then stop and return to the debugger. | |
3363 | ||
3364 | It is often useful to do @samp{display/i $pc} when stepping by machine | |
3365 | instructions. This will cause the next instruction to be executed to | |
29a2b744 RP |
3366 | be displayed automatically at each stop. @xref{Auto Display, |
3367 | ,Automatic Display}. | |
70b88761 RP |
3368 | |
3369 | An argument is a repeat count, as in @code{step}. | |
3370 | ||
3371 | @item nexti | |
3372 | @itemx ni | |
3373 | @kindex nexti | |
3374 | @kindex ni | |
3375 | Execute one machine instruction, but if it is a function call, | |
3376 | proceed until the function returns. | |
3377 | ||
3378 | An argument is a repeat count, as in @code{next}. | |
70b88761 RP |
3379 | @end table |
3380 | ||
18fae2a8 | 3381 | @ifset POSIX |
4eb4cf57 | 3382 | @node Signals |
70b88761 RP |
3383 | @section Signals |
3384 | @cindex signals | |
3385 | ||
3386 | A signal is an asynchronous event that can happen in a program. The | |
3387 | operating system defines the possible kinds of signals, and gives each | |
3388 | kind a name and a number. For example, in Unix @code{SIGINT} is the | |
3389 | signal a program gets when you type an interrupt (often @kbd{C-c}); | |
3390 | @code{SIGSEGV} is the signal a program gets from referencing a place in | |
3391 | memory far away from all the areas in use; @code{SIGALRM} occurs when | |
29a2b744 | 3392 | the alarm clock timer goes off (which happens only if your program has |
70b88761 RP |
3393 | requested an alarm). |
3394 | ||
3395 | @cindex fatal signals | |
3396 | Some signals, including @code{SIGALRM}, are a normal part of the | |
29a2b744 RP |
3397 | functioning of your program. Others, such as @code{SIGSEGV}, indicate |
3398 | errors; these signals are @dfn{fatal} (kill your program immediately) if the | |
70b88761 | 3399 | program has not specified in advance some other way to handle the signal. |
29a2b744 | 3400 | @code{SIGINT} does not indicate an error in your program, but it is normally |
70b88761 RP |
3401 | fatal so it can carry out the purpose of the interrupt: to kill the program. |
3402 | ||
18fae2a8 RP |
3403 | @value{GDBN} has the ability to detect any occurrence of a signal in your |
3404 | program. You can tell @value{GDBN} in advance what to do for each kind of | |
29a2b744 | 3405 | signal. |
70b88761 RP |
3406 | |
3407 | @cindex handling signals | |
18fae2a8 | 3408 | Normally, @value{GDBN} is set up to ignore non-erroneous signals like @code{SIGALRM} |
29a2b744 RP |
3409 | (so as not to interfere with their role in the functioning of your program) |
3410 | but to stop your program immediately whenever an error signal happens. | |
70b88761 RP |
3411 | You can change these settings with the @code{handle} command. |
3412 | ||
3413 | @table @code | |
3414 | @item info signals | |
3415 | @kindex info signals | |
18fae2a8 | 3416 | Print a table of all the kinds of signals and how @value{GDBN} has been told to |
70b88761 RP |
3417 | handle each one. You can use this to see the signal numbers of all |
3418 | the defined types of signals. | |
3419 | ||
3420 | @item handle @var{signal} @var{keywords}@dots{} | |
3421 | @kindex handle | |
18fae2a8 | 3422 | Change the way @value{GDBN} handles signal @var{signal}. @var{signal} can be the |
70b88761 RP |
3423 | number of a signal or its name (with or without the @samp{SIG} at the |
3424 | beginning). The @var{keywords} say what change to make. | |
3425 | @end table | |
3426 | ||
3427 | @c @group | |
3428 | The keywords allowed by the @code{handle} command can be abbreviated. | |
3429 | Their full names are: | |
3430 | ||
3431 | @table @code | |
3432 | @item nostop | |
18fae2a8 | 3433 | @value{GDBN} should not stop your program when this signal happens. It may |
70b88761 RP |
3434 | still print a message telling you that the signal has come in. |
3435 | ||
3436 | @item stop | |
18fae2a8 | 3437 | @value{GDBN} should stop your program when this signal happens. This implies |
70b88761 RP |
3438 | the @code{print} keyword as well. |
3439 | ||
3440 | @item print | |
18fae2a8 | 3441 | @value{GDBN} should print a message when this signal happens. |
70b88761 RP |
3442 | |
3443 | @item noprint | |
18fae2a8 | 3444 | @value{GDBN} should not mention the occurrence of the signal at all. This |
70b88761 RP |
3445 | implies the @code{nostop} keyword as well. |
3446 | ||
3447 | @item pass | |
18fae2a8 | 3448 | @value{GDBN} should allow your program to see this signal; your program will be |
70b88761 RP |
3449 | able to handle the signal, or may be terminated if the signal is fatal |
3450 | and not handled. | |
3451 | ||
3452 | @item nopass | |
18fae2a8 | 3453 | @value{GDBN} should not allow your program to see this signal. |
70b88761 RP |
3454 | @end table |
3455 | @c @end group | |
3456 | ||
29a2b744 | 3457 | When a signal has been set to stop your program, your program cannot see the |
70b88761 | 3458 | signal until you continue. It will see the signal then, if @code{pass} is |
6ca72cc6 | 3459 | in effect for the signal in question @emph{at that time}. In other words, |
18fae2a8 | 3460 | after @value{GDBN} reports a signal, you can use the @code{handle} command with |
70b88761 | 3461 | @code{pass} or @code{nopass} to control whether that signal will be seen by |
29a2b744 | 3462 | your program when you later continue it. |
70b88761 | 3463 | |
29a2b744 | 3464 | You can also use the @code{signal} command to prevent your program from |
70b88761 | 3465 | seeing a signal, or cause it to see a signal it normally would not see, |
29a2b744 | 3466 | or to give it any signal at any time. For example, if your program stopped |
7463aadd RP |
3467 | due to some sort of memory reference error, you might store correct |
3468 | values into the erroneous variables and continue, hoping to see more | |
29a2b744 RP |
3469 | execution; but your program would probably terminate immediately as |
3470 | a result of the fatal signal once it saw the signal. To prevent this, | |
3471 | you can continue with @samp{signal 0}. @xref{Signaling, ,Giving your | |
3472 | Program a Signal}. | |
18fae2a8 | 3473 | @end ifset |
70b88761 | 3474 | |
4eb4cf57 | 3475 | @node Stack |
70b88761 RP |
3476 | @chapter Examining the Stack |
3477 | ||
3478 | When your program has stopped, the first thing you need to know is where it | |
3479 | stopped and how it got there. | |
3480 | ||
3481 | @cindex call stack | |
3482 | Each time your program performs a function call, the information about | |
29a2b744 | 3483 | where in your program the call was made from is saved in a block of data |
70b88761 RP |
3484 | called a @dfn{stack frame}. The frame also contains the arguments of the |
3485 | call and the local variables of the function that was called. All the | |
3486 | stack frames are allocated in a region of memory called the @dfn{call | |
3487 | stack}. | |
3488 | ||
18fae2a8 | 3489 | When your program stops, the @value{GDBN} commands for examining the stack allow you |
70b88761 RP |
3490 | to see all of this information. |
3491 | ||
3492 | @cindex selected frame | |
18fae2a8 | 3493 | One of the stack frames is @dfn{selected} by @value{GDBN} and many @value{GDBN} commands |
70b88761 | 3494 | refer implicitly to the selected frame. In particular, whenever you ask |
18fae2a8 RP |
3495 | @value{GDBN} for the value of a variable in your program, the value is found in the |
3496 | selected frame. There are special @value{GDBN} commands to select whichever frame | |
70b88761 RP |
3497 | you are interested in. |
3498 | ||
18fae2a8 | 3499 | When your program stops, @value{GDBN} automatically selects the currently executing |
70b88761 | 3500 | frame and describes it briefly as the @code{frame} command does |
29a2b744 | 3501 | (@pxref{Frame Info, ,Information About a Frame}). |
70b88761 RP |
3502 | |
3503 | @menu | |
b80282d5 RP |
3504 | * Frames:: Stack Frames |
3505 | * Backtrace:: Backtraces | |
3506 | * Selection:: Selecting a Frame | |
3507 | * Frame Info:: Information on a Frame | |
70b88761 RP |
3508 | @end menu |
3509 | ||
4eb4cf57 | 3510 | @node Frames |
70b88761 RP |
3511 | @section Stack Frames |
3512 | ||
3513 | @cindex frame | |
3514 | @cindex stack frame | |
3515 | The call stack is divided up into contiguous pieces called @dfn{stack | |
3516 | frames}, or @dfn{frames} for short; each frame is the data associated | |
3517 | with one call to one function. The frame contains the arguments given | |
3518 | to the function, the function's local variables, and the address at | |
3519 | which the function is executing. | |
3520 | ||
3521 | @cindex initial frame | |
3522 | @cindex outermost frame | |
3523 | @cindex innermost frame | |
3524 | When your program is started, the stack has only one frame, that of the | |
3525 | function @code{main}. This is called the @dfn{initial} frame or the | |
3526 | @dfn{outermost} frame. Each time a function is called, a new frame is | |
3527 | made. Each time a function returns, the frame for that function invocation | |
3528 | is eliminated. If a function is recursive, there can be many frames for | |
3529 | the same function. The frame for the function in which execution is | |
3530 | actually occurring is called the @dfn{innermost} frame. This is the most | |
3531 | recently created of all the stack frames that still exist. | |
3532 | ||
3533 | @cindex frame pointer | |
3534 | Inside your program, stack frames are identified by their addresses. A | |
3535 | stack frame consists of many bytes, each of which has its own address; each | |
3536 | kind of computer has a convention for choosing one of those bytes whose | |
3537 | address serves as the address of the frame. Usually this address is kept | |
3538 | in a register called the @dfn{frame pointer register} while execution is | |
3539 | going on in that frame. | |
3540 | ||
3541 | @cindex frame number | |
18fae2a8 | 3542 | @value{GDBN} assigns numbers to all existing stack frames, starting with |
70b88761 RP |
3543 | zero for the innermost frame, one for the frame that called it, |
3544 | and so on upward. These numbers do not really exist in your program; | |
18fae2a8 RP |
3545 | they are assigned by @value{GDBN} to give you a way of designating stack |
3546 | frames in @value{GDBN} commands. | |
70b88761 RP |
3547 | |
3548 | @cindex frameless execution | |
3549 | Some compilers allow functions to be compiled so that they operate | |
18fae2a8 | 3550 | without stack frames. (For example, the @code{@value{GCC}} option |
70b88761 RP |
3551 | @samp{-fomit-frame-pointer} will generate functions without a frame.) |
3552 | This is occasionally done with heavily used library functions to save | |
18fae2a8 | 3553 | the frame setup time. @value{GDBN} has limited facilities for dealing with |
70b88761 | 3554 | these function invocations. If the innermost function invocation has no |
18fae2a8 | 3555 | stack frame, @value{GDBN} will nevertheless regard it as though it had a |
70b88761 | 3556 | separate frame, which is numbered zero as usual, allowing correct |
18fae2a8 | 3557 | tracing of the function call chain. However, @value{GDBN} has no provision |
70b88761 RP |
3558 | for frameless functions elsewhere in the stack. |
3559 | ||
4eb4cf57 | 3560 | @node Backtrace |
70b88761 RP |
3561 | @section Backtraces |
3562 | ||
29a2b744 | 3563 | A backtrace is a summary of how your program got where it is. It shows one |
70b88761 RP |
3564 | line per frame, for many frames, starting with the currently executing |
3565 | frame (frame zero), followed by its caller (frame one), and on up the | |
3566 | stack. | |
3567 | ||
3568 | @table @code | |
3569 | @item backtrace | |
3570 | @itemx bt | |
3571 | @kindex backtrace | |
3572 | @kindex bt | |
3573 | Print a backtrace of the entire stack: one line per frame for all | |
3574 | frames in the stack. | |
3575 | ||
3576 | You can stop the backtrace at any time by typing the system interrupt | |
3577 | character, normally @kbd{C-c}. | |
3578 | ||
3579 | @item backtrace @var{n} | |
3580 | @itemx bt @var{n} | |
3581 | Similar, but print only the innermost @var{n} frames. | |
3582 | ||
3583 | @item backtrace -@var{n} | |
3584 | @itemx bt -@var{n} | |
3585 | Similar, but print only the outermost @var{n} frames. | |
3586 | @end table | |
3587 | ||
3588 | @kindex where | |
3589 | @kindex info stack | |
3590 | @kindex info s | |
3591 | The names @code{where} and @code{info stack} (abbreviated @code{info s}) | |
3592 | are additional aliases for @code{backtrace}. | |
3593 | ||
3594 | Each line in the backtrace shows the frame number and the function name. | |
3595 | The program counter value is also shown---unless you use @code{set | |
3596 | print address off}. The backtrace also shows the source file name and | |
3597 | line number, as well as the arguments to the function. The program | |
3598 | counter value is omitted if it is at the beginning of the code for that | |
3599 | line number. | |
3600 | ||
3601 | Here is an example of a backtrace. It was made with the command | |
3602 | @samp{bt 3}, so it shows the innermost three frames. | |
3603 | ||
3604 | @smallexample | |
3605 | @group | |
203eea5d RP |
3606 | #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) |
3607 | at builtin.c:993 | |
70b88761 RP |
3608 | #1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242 |
3609 | #2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08) | |
3610 | at macro.c:71 | |
3611 | (More stack frames follow...) | |
3612 | @end group | |
3613 | @end smallexample | |
3614 | ||
3615 | @noindent | |
29a2b744 RP |
3616 | The display for frame zero does not begin with a program counter |
3617 | value, indicating that your program has stopped at the beginning of the | |
70b88761 RP |
3618 | code for line @code{993} of @code{builtin.c}. |
3619 | ||
4eb4cf57 | 3620 | @node Selection |
70b88761 RP |
3621 | @section Selecting a Frame |
3622 | ||
29a2b744 | 3623 | Most commands for examining the stack and other data in your program work on |
70b88761 RP |
3624 | whichever stack frame is selected at the moment. Here are the commands for |
3625 | selecting a stack frame; all of them finish by printing a brief description | |
3626 | of the stack frame just selected. | |
3627 | ||
3628 | @table @code | |
3629 | @item frame @var{n} | |
3630 | @itemx f @var{n} | |
3631 | @kindex frame | |
3632 | @kindex f | |
3633 | Select frame number @var{n}. Recall that frame zero is the innermost | |
3634 | (currently executing) frame, frame one is the frame that called the | |
3635 | innermost one, and so on. The highest-numbered frame is @code{main}'s | |
3636 | frame. | |
3637 | ||
3638 | @item frame @var{addr} | |
3639 | @itemx f @var{addr} | |
3640 | Select the frame at address @var{addr}. This is useful mainly if the | |
3641 | chaining of stack frames has been damaged by a bug, making it | |
18fae2a8 | 3642 | impossible for @value{GDBN} to assign numbers properly to all frames. In |
29a2b744 | 3643 | addition, this can be useful when your program has multiple stacks and |
70b88761 RP |
3644 | switches between them. |
3645 | ||
18fae2a8 | 3646 | @ifset SPARC |
70b88761 | 3647 | On the SPARC architecture, @code{frame} needs two addresses to |
e251e767 | 3648 | select an arbitrary frame: a frame pointer and a stack pointer. |
70b88761 RP |
3649 | @c note to future updaters: this is conditioned on a flag |
3650 | @c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used | |
3651 | @c by SPARC, hence the specific attribution. Generalize or list all | |
3652 | @c possibilities if more supported machines start doing this. | |
18fae2a8 | 3653 | @end ifset |
70b88761 RP |
3654 | |
3655 | @item up @var{n} | |
3656 | @kindex up | |
3657 | Move @var{n} frames up the stack. For positive numbers @var{n}, this | |
3658 | advances toward the outermost frame, to higher frame numbers, to frames | |
3659 | that have existed longer. @var{n} defaults to one. | |
3660 | ||
3661 | @item down @var{n} | |
3662 | @kindex down | |
3663 | @kindex do | |
3664 | Move @var{n} frames down the stack. For positive numbers @var{n}, this | |
3665 | advances toward the innermost frame, to lower frame numbers, to frames | |
3666 | that were created more recently. @var{n} defaults to one. You may | |
3667 | abbreviate @code{down} as @code{do}. | |
3668 | @end table | |
3669 | ||
3670 | All of these commands end by printing two lines of output describing the | |
3671 | frame. The first line shows the frame number, the function name, the | |
3672 | arguments, and the source file and line number of execution in that | |
3673 | frame. The second line shows the text of that source line. For | |
3674 | example: | |
3675 | ||
3676 | @smallexample | |
29a2b744 | 3677 | @group |
18fae2a8 | 3678 | (@value{GDBP}) up |
203eea5d RP |
3679 | #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) |
3680 | at env.c:10 | |
70b88761 | 3681 | 10 read_input_file (argv[i]); |
29a2b744 | 3682 | @end group |
70b88761 RP |
3683 | @end smallexample |
3684 | ||
29a2b744 RP |
3685 | After such a printout, the @code{list} command with no arguments will |
3686 | print ten lines centered on the point of execution in the frame. | |
3687 | @xref{List, ,Printing Source Lines}. | |
70b88761 RP |
3688 | |
3689 | @table @code | |
3690 | @item up-silently @var{n} | |
3691 | @itemx down-silently @var{n} | |
3692 | @kindex down-silently | |
3693 | @kindex up-silently | |
3694 | These two commands are variants of @code{up} and @code{down}, | |
3695 | respectively; they differ in that they do their work silently, without | |
3696 | causing display of the new frame. They are intended primarily for use | |
18fae2a8 | 3697 | in @value{GDBN} command scripts, where the output might be unnecessary and |
e251e767 | 3698 | distracting. |
70b88761 RP |
3699 | @end table |
3700 | ||
4eb4cf57 | 3701 | @node Frame Info |
70b88761 RP |
3702 | @section Information About a Frame |
3703 | ||
3704 | There are several other commands to print information about the selected | |
3705 | stack frame. | |
3706 | ||
3707 | @table @code | |
3708 | @item frame | |
3709 | @itemx f | |
29a2b744 RP |
3710 | When used without any argument, this command does not change which |
3711 | frame is selected, but prints a brief description of the currently | |
70b88761 | 3712 | selected stack frame. It can be abbreviated @code{f}. With an |
29a2b744 RP |
3713 | argument, this command is used to select a stack frame |
3714 | (@pxref{Selection, ,Selecting a Frame}). | |
70b88761 RP |
3715 | |
3716 | @item info frame | |
70b88761 | 3717 | @itemx info f |
29a2b744 | 3718 | @kindex info frame |
70b88761 RP |
3719 | @kindex info f |
3720 | This command prints a verbose description of the selected stack frame, | |
3721 | including the address of the frame, the addresses of the next frame down | |
c2bbbb22 RP |
3722 | (called by this frame) and the next frame up (caller of this frame), the |
3723 | language that the source code corresponding to this frame was written in, | |
70b88761 RP |
3724 | the address of the frame's arguments, the program counter saved in it |
3725 | (the address of execution in the caller frame), and which registers | |
3726 | were saved in the frame. The verbose description is useful when | |
3727 | something has gone wrong that has made the stack format fail to fit | |
3728 | the usual conventions. | |
3729 | ||
3730 | @item info frame @var{addr} | |
3731 | @itemx info f @var{addr} | |
3732 | Print a verbose description of the frame at address @var{addr}, | |
3733 | without selecting that frame. The selected frame remains unchanged by | |
3734 | this command. | |
3735 | ||
3736 | @item info args | |
3737 | @kindex info args | |
3738 | Print the arguments of the selected frame, each on a separate line. | |
3739 | ||
3740 | @item info locals | |
3741 | @kindex info locals | |
3742 | Print the local variables of the selected frame, each on a separate | |
3743 | line. These are all variables declared static or automatic within all | |
3744 | program blocks that execution in this frame is currently inside of. | |
3745 | ||
3746 | @item info catch | |
3747 | @kindex info catch | |
3748 | @cindex catch exceptions | |
3749 | @cindex exception handlers | |
3750 | Print a list of all the exception handlers that are active in the | |
3751 | current stack frame at the current point of execution. To see other | |
3752 | exception handlers, visit the associated frame (using the @code{up}, | |
3753 | @code{down}, or @code{frame} commands); then type @code{info catch}. | |
1041a570 | 3754 | @xref{Exception Handling, ,Breakpoints and Exceptions}. |
70b88761 RP |
3755 | @end table |
3756 | ||
4eb4cf57 | 3757 | @node Source |
70b88761 RP |
3758 | @chapter Examining Source Files |
3759 | ||
18fae2a8 RP |
3760 | @value{GDBN} can print parts of your program's source, since the debugging |
3761 | information recorded in your program tells @value{GDBN} what source files were | |
3762 | used to build it. When your program stops, @value{GDBN} spontaneously prints | |
1041a570 | 3763 | the line where it stopped. Likewise, when you select a stack frame |
18fae2a8 | 3764 | (@pxref{Selection, ,Selecting a Frame}), @value{GDBN} prints the line where |
1041a570 RP |
3765 | execution in that frame has stopped. You can print other portions of |
3766 | source files by explicit command. | |
70b88761 | 3767 | |
18fae2a8 RP |
3768 | @ifclear DOSHOST |
3769 | If you use @value{GDBN} through its GNU Emacs interface, you may prefer to use | |
3770 | Emacs facilities to view source; @pxref{Emacs, ,Using @value{GDBN} under GNU | |
1041a570 | 3771 | Emacs}. |
18fae2a8 | 3772 | @end ifclear |
70b88761 | 3773 | |
18fae2a8 RP |
3774 | @ignore |
3775 | @c pre-unfolded menu | |
70b88761 | 3776 | @menu |
b80282d5 | 3777 | * List:: Printing Source Lines |
18fae2a8 | 3778 | @ifclear DOSHOST |
b80282d5 | 3779 | * Search:: Searching Source Files |
18fae2a8 | 3780 | @end ifclear |
b80282d5 RP |
3781 | * Source Path:: Specifying Source Directories |
3782 | * Machine Code:: Source and Machine Code | |
70b88761 | 3783 | @end menu |
18fae2a8 RP |
3784 | @end ignore |
3785 | ||
3786 | @ifclear DOSHOST | |
3787 | @menu | |
3788 | * List:: Printing Source Lines | |
3789 | * Search:: Searching Source Files | |
3790 | * Source Path:: Specifying Source Directories | |
3791 | * Machine Code:: Source and Machine Code | |
3792 | @end menu | |
3793 | @end ifclear | |
3794 | ||
3795 | @ifset DOSHOST | |
3796 | @menu | |
3797 | * List:: Printing Source Lines | |
3798 | * Source Path:: Specifying Source Directories | |
3799 | * Machine Code:: Source and Machine Code | |
3800 | @end menu | |
3801 | @end ifset | |
70b88761 | 3802 | |
4eb4cf57 | 3803 | @node List |
70b88761 RP |
3804 | @section Printing Source Lines |
3805 | ||
3806 | @kindex list | |
3807 | @kindex l | |
3808 | To print lines from a source file, use the @code{list} command | |
3809 | (abbreviated @code{l}). There are several ways to specify what part | |
3810 | of the file you want to print. | |
3811 | ||
3812 | Here are the forms of the @code{list} command most commonly used: | |
3813 | ||
3814 | @table @code | |
3815 | @item list @var{linenum} | |
c338a2fd | 3816 | Print lines centered around line number @var{linenum} in the |
70b88761 RP |
3817 | current source file. |
3818 | ||
3819 | @item list @var{function} | |
c338a2fd | 3820 | Print lines centered around the beginning of function |
70b88761 RP |
3821 | @var{function}. |
3822 | ||
3823 | @item list | |
c338a2fd RP |
3824 | Print more lines. If the last lines printed were printed with a |
3825 | @code{list} command, this prints lines following the last lines | |
70b88761 | 3826 | printed; however, if the last line printed was a solitary line printed |
29a2b744 | 3827 | as part of displaying a stack frame (@pxref{Stack, ,Examining the |
1041a570 | 3828 | Stack}), this prints lines centered around that line. |
70b88761 RP |
3829 | |
3830 | @item list - | |
c338a2fd RP |
3831 | Print lines just before the lines last printed. |
3832 | @end table | |
3833 | ||
18fae2a8 | 3834 | By default, @value{GDBN} prints ten source lines with any of these forms of |
c338a2fd RP |
3835 | the @code{list} command. You can change this using @code{set listsize}: |
3836 | ||
3837 | @table @code | |
3838 | @item set listsize @var{count} | |
3839 | @kindex set listsize | |
3840 | Make the @code{list} command display @var{count} source lines (unless | |
3841 | the @code{list} argument explicitly specifies some other number). | |
3842 | ||
3843 | @item show listsize | |
3844 | @kindex show listsize | |
3845 | Display the number of lines that @code{list} will currently display by | |
e251e767 | 3846 | default. |
70b88761 RP |
3847 | @end table |
3848 | ||
3849 | Repeating a @code{list} command with @key{RET} discards the argument, | |
3850 | so it is equivalent to typing just @code{list}. This is more useful | |
3851 | than listing the same lines again. An exception is made for an | |
3852 | argument of @samp{-}; that argument is preserved in repetition so that | |
3853 | each repetition moves up in the source file. | |
3854 | ||
3855 | @cindex linespec | |
3856 | In general, the @code{list} command expects you to supply zero, one or two | |
3857 | @dfn{linespecs}. Linespecs specify source lines; there are several ways | |
3858 | of writing them but the effect is always to specify some source line. | |
3859 | Here is a complete description of the possible arguments for @code{list}: | |
3860 | ||
3861 | @table @code | |
3862 | @item list @var{linespec} | |
c338a2fd | 3863 | Print lines centered around the line specified by @var{linespec}. |
70b88761 RP |
3864 | |
3865 | @item list @var{first},@var{last} | |
3866 | Print lines from @var{first} to @var{last}. Both arguments are | |
3867 | linespecs. | |
3868 | ||
3869 | @item list ,@var{last} | |
c338a2fd | 3870 | Print lines ending with @var{last}. |
70b88761 RP |
3871 | |
3872 | @item list @var{first}, | |
c338a2fd | 3873 | Print lines starting with @var{first}. |
70b88761 RP |
3874 | |
3875 | @item list + | |
c338a2fd | 3876 | Print lines just after the lines last printed. |
70b88761 RP |
3877 | |
3878 | @item list - | |
c338a2fd | 3879 | Print lines just before the lines last printed. |
70b88761 RP |
3880 | |
3881 | @item list | |
3882 | As described in the preceding table. | |
3883 | @end table | |
3884 | ||
3885 | Here are the ways of specifying a single source line---all the | |
3886 | kinds of linespec. | |
3887 | ||
3888 | @table @code | |
3889 | @item @var{number} | |
3890 | Specifies line @var{number} of the current source file. | |
3891 | When a @code{list} command has two linespecs, this refers to | |
3892 | the same source file as the first linespec. | |
3893 | ||
3894 | @item +@var{offset} | |
3895 | Specifies the line @var{offset} lines after the last line printed. | |
3896 | When used as the second linespec in a @code{list} command that has | |
3897 | two, this specifies the line @var{offset} lines down from the | |
3898 | first linespec. | |
3899 | ||
3900 | @item -@var{offset} | |
3901 | Specifies the line @var{offset} lines before the last line printed. | |
3902 | ||
3903 | @item @var{filename}:@var{number} | |
3904 | Specifies line @var{number} in the source file @var{filename}. | |
3905 | ||
3906 | @item @var{function} | |
3907 | @c FIXME: "of the open-brace" is C-centric. When we add other langs... | |
3908 | Specifies the line of the open-brace that begins the body of the | |
3909 | function @var{function}. | |
3910 | ||
3911 | @item @var{filename}:@var{function} | |
3912 | Specifies the line of the open-brace that begins the body of the | |
3913 | function @var{function} in the file @var{filename}. You only need the | |
3914 | file name with a function name to avoid ambiguity when there are | |
3915 | identically named functions in different source files. | |
3916 | ||
3917 | @item *@var{address} | |
3918 | Specifies the line containing the program address @var{address}. | |
3919 | @var{address} may be any expression. | |
3920 | @end table | |
3921 | ||
18fae2a8 | 3922 | @ifclear DOSHOST |
4eb4cf57 | 3923 | @node Search |
70b88761 RP |
3924 | @section Searching Source Files |
3925 | @cindex searching | |
3926 | @kindex reverse-search | |
3927 | ||
3928 | There are two commands for searching through the current source file for a | |
3929 | regular expression. | |
3930 | ||
3931 | @table @code | |
3932 | @item forward-search @var{regexp} | |
3933 | @itemx search @var{regexp} | |
3934 | @kindex search | |
3935 | @kindex forward-search | |
1041a570 RP |
3936 | The command @samp{forward-search @var{regexp}} checks each line, |
3937 | starting with the one following the last line listed, for a match for | |
3938 | @var{regexp}. It lists the line that is found. You can use | |
3939 | synonym @samp{search @var{regexp}} or abbreviate the command name as | |
3940 | @code{fo}. | |
70b88761 RP |
3941 | |
3942 | @item reverse-search @var{regexp} | |
3943 | The command @samp{reverse-search @var{regexp}} checks each line, starting | |
3944 | with the one before the last line listed and going backward, for a match | |
3945 | for @var{regexp}. It lists the line that is found. You can abbreviate | |
3946 | this command as @code{rev}. | |
3947 | @end table | |
18fae2a8 | 3948 | @end ifclear |
70b88761 | 3949 | |
4eb4cf57 | 3950 | @node Source Path |
70b88761 RP |
3951 | @section Specifying Source Directories |
3952 | ||
3953 | @cindex source path | |
3954 | @cindex directories for source files | |
3955 | Executable programs sometimes do not record the directories of the source | |
3956 | files from which they were compiled, just the names. Even when they do, | |
3957 | the directories could be moved between the compilation and your debugging | |
18fae2a8 RP |
3958 | session. @value{GDBN} has a list of directories to search for source files; |
3959 | this is called the @dfn{source path}. Each time @value{GDBN} wants a source file, | |
70b88761 RP |
3960 | it tries all the directories in the list, in the order they are present |
3961 | in the list, until it finds a file with the desired name. Note that | |
3962 | the executable search path is @emph{not} used for this purpose. Neither is | |
3963 | the current working directory, unless it happens to be in the source | |
3964 | path. | |
3965 | ||
18fae2a8 RP |
3966 | If @value{GDBN} cannot find a source file in the source path, and the object |
3967 | program records a directory, @value{GDBN} tries that directory too. If the | |
70b88761 | 3968 | source path is empty, and there is no record of the compilation |
18fae2a8 | 3969 | directory, @value{GDBN} will, as a last resort, look in the current |
70b88761 RP |
3970 | directory. |
3971 | ||
18fae2a8 | 3972 | Whenever you reset or rearrange the source path, @value{GDBN} will clear out |
70b88761 RP |
3973 | any information it has cached about where source files are found, where |
3974 | each line is in the file, etc. | |
3975 | ||
3976 | @kindex directory | |
18fae2a8 | 3977 | When you start @value{GDBN}, its source path is empty. |
70b88761 RP |
3978 | To add other directories, use the @code{directory} command. |
3979 | ||
3980 | @table @code | |
3981 | @item directory @var{dirname} @dots{} | |
3982 | Add directory @var{dirname} to the front of the source path. Several | |
3983 | directory names may be given to this command, separated by @samp{:} or | |
3984 | whitespace. You may specify a directory that is already in the source | |
e251e767 | 3985 | path; this moves it forward, so it will be searched sooner. |
7463aadd RP |
3986 | |
3987 | You can use the string @samp{$cdir} to refer to the compilation | |
3988 | directory (if one is recorded), and @samp{$cwd} to refer to the current | |
3989 | working directory. @samp{$cwd} is not the same as @samp{.}---the former | |
18fae2a8 | 3990 | tracks the current working directory as it changes during your @value{GDBN} |
7463aadd RP |
3991 | session, while the latter is immediately expanded to the current |
3992 | directory at the time you add an entry to the source path. | |
70b88761 RP |
3993 | |
3994 | @item directory | |
3995 | Reset the source path to empty again. This requires confirmation. | |
3996 | ||
3997 | @c RET-repeat for @code{directory} is explicitly disabled, but since | |
29a2b744 | 3998 | @c repeating it would be a no-op we do not say that. (thanks to RMS) |
70b88761 RP |
3999 | |
4000 | @item show directories | |
4001 | @kindex show directories | |
4002 | Print the source path: show which directories it contains. | |
4003 | @end table | |
4004 | ||
4005 | If your source path is cluttered with directories that are no longer of | |
18fae2a8 | 4006 | interest, @value{GDBN} may sometimes cause confusion by finding the wrong |
70b88761 RP |
4007 | versions of source. You can correct the situation as follows: |
4008 | ||
4009 | @enumerate | |
4010 | @item | |
4011 | Use @code{directory} with no argument to reset the source path to empty. | |
4012 | ||
4013 | @item | |
4014 | Use @code{directory} with suitable arguments to reinstall the | |
4015 | directories you want in the source path. You can add all the | |
4016 | directories in one command. | |
4017 | @end enumerate | |
4018 | ||
4eb4cf57 | 4019 | @node Machine Code |
70b88761 | 4020 | @section Source and Machine Code |
1041a570 | 4021 | |
70b88761 RP |
4022 | You can use the command @code{info line} to map source lines to program |
4023 | addresses (and viceversa), and the command @code{disassemble} to display | |
4024 | a range of addresses as machine instructions. | |
4025 | ||
4026 | @table @code | |
4027 | @item info line @var{linespec} | |
4028 | @kindex info line | |
4029 | Print the starting and ending addresses of the compiled code for | |
1041a570 RP |
4030 | source line @var{linespec}. You can specify source lines in any of |
4031 | the ways understood by the @code{list} command (@pxref{List, ,Printing | |
4032 | Source Lines}). | |
70b88761 RP |
4033 | @end table |
4034 | ||
1041a570 RP |
4035 | For example, we can use @code{info line} to discover the location of |
4036 | the object code for the first line of function | |
4037 | @code{m4_changequote}: | |
4038 | ||
70b88761 | 4039 | @smallexample |
18fae2a8 | 4040 | (@value{GDBP}) info line m4_changecom |
70b88761 RP |
4041 | Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350. |
4042 | @end smallexample | |
4043 | ||
4044 | @noindent | |
4045 | We can also inquire (using @code{*@var{addr}} as the form for | |
4046 | @var{linespec}) what source line covers a particular address: | |
4047 | @smallexample | |
18fae2a8 | 4048 | (@value{GDBP}) info line *0x63ff |
70b88761 RP |
4049 | Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404. |
4050 | @end smallexample | |
4051 | ||
c338a2fd | 4052 | @cindex @code{$_} and @code{info line} |
29a2b744 RP |
4053 | After @code{info line}, the default address for the @code{x} command |
4054 | is changed to the starting address of the line, so that @samp{x/i} is | |
4055 | sufficient to begin examining the machine code (@pxref{Memory, | |
4056 | ,Examining Memory}). Also, this address is saved as the value of the | |
4057 | convenience variable @code{$_} (@pxref{Convenience Vars, ,Convenience | |
4058 | Variables}). | |
70b88761 RP |
4059 | |
4060 | @table @code | |
4061 | @kindex disassemble | |
4062 | @item disassemble | |
e94b4a2b RP |
4063 | This specialized command dumps a range of memory as machine |
4064 | instructions. The default memory range is the function surrounding the | |
4065 | program counter of the selected frame. A single argument to this | |
4066 | command is a program counter value; the function surrounding this value | |
4067 | will be dumped. Two arguments specify a range of addresses (first | |
4068 | inclusive, second exclusive) to dump. | |
70b88761 RP |
4069 | @end table |
4070 | ||
18fae2a8 | 4071 | @ifclear HviiiEXCLUSIVE |
70b88761 | 4072 | We can use @code{disassemble} to inspect the object code |
4eb4cf57 RP |
4073 | range shown in the last @code{info line} example (the example |
4074 | shows SPARC machine instructions): | |
70b88761 | 4075 | |
18fae2a8 | 4076 | |
70b88761 | 4077 | @smallexample |
18fae2a8 | 4078 | (@value{GDBP}) disas 0x63e4 0x6404 |
70b88761 | 4079 | Dump of assembler code from 0x63e4 to 0x6404: |
b80282d5 RP |
4080 | 0x63e4 <builtin_init+5340>: ble 0x63f8 <builtin_init+5360> |
4081 | 0x63e8 <builtin_init+5344>: sethi %hi(0x4c00), %o0 | |
4082 | 0x63ec <builtin_init+5348>: ld [%i1+4], %o0 | |
4083 | 0x63f0 <builtin_init+5352>: b 0x63fc <builtin_init+5364> | |
4084 | 0x63f4 <builtin_init+5356>: ld [%o0+4], %o0 | |
4085 | 0x63f8 <builtin_init+5360>: or %o0, 0x1a4, %o0 | |
4086 | 0x63fc <builtin_init+5364>: call 0x9288 <path_search> | |
e251e767 | 4087 | 0x6400 <builtin_init+5368>: nop |
70b88761 | 4088 | End of assembler dump. |
70b88761 | 4089 | @end smallexample |
18fae2a8 | 4090 | @end ifclear |
4eb4cf57 | 4091 | |
18fae2a8 | 4092 | @ifset HviiiEXCLUSIVE |
4eb4cf57 RP |
4093 | For example, here is the beginning of the output for the |
4094 | disassembly of a function @code{fact}: | |
70b88761 | 4095 | |
18fae2a8 | 4096 | |
4eb4cf57 | 4097 | @smallexample |
18fae2a8 | 4098 | (@value{GDBP}) disas fact |
4eb4cf57 RP |
4099 | Dump of assembler code for function fact: |
4100 | to 0x808c: | |
4101 | 0x802c <fact>: 6d f2 mov.w r2,@@-r7 | |
4102 | 0x802e <fact+2>: 6d f3 mov.w r3,@@-r7 | |
4103 | 0x8030 <fact+4>: 6d f6 mov.w r6,@@-r7 | |
4104 | 0x8032 <fact+6>: 0d 76 mov.w r7,r6 | |
4105 | 0x8034 <fact+8>: 6f 70 00 08 mov.w @@(0x8,r7),r0 | |
4106 | 0x8038 <fact+12> 19 11 sub.w r1,r1 | |
4107 | . | |
4108 | . | |
4109 | . | |
4110 | @end smallexample | |
18fae2a8 | 4111 | @end ifset |
4eb4cf57 RP |
4112 | |
4113 | @node Data | |
70b88761 RP |
4114 | @chapter Examining Data |
4115 | ||
4116 | @cindex printing data | |
4117 | @cindex examining data | |
4118 | @kindex print | |
4119 | @kindex inspect | |
1041a570 | 4120 | @c "inspect" is not quite a synonym if you are using Epoch, which we do not |
29a2b744 | 4121 | @c document because it is nonstandard... Under Epoch it displays in a |
70b88761 RP |
4122 | @c different window or something like that. |
4123 | The usual way to examine data in your program is with the @code{print} | |
4eb4cf57 | 4124 | command (abbreviated @code{p}), or its synonym @code{inspect}. |
18fae2a8 | 4125 | @ifclear CONLY |
4eb4cf57 | 4126 | It evaluates and prints the value of an expression of the language your |
18fae2a8 | 4127 | program is written in (@pxref{Languages, ,Using @value{GDBN} with Different |
4eb4cf57 | 4128 | Languages}). |
18fae2a8 | 4129 | @end ifclear |
70b88761 | 4130 | |
e0dacfd1 RP |
4131 | @table @code |
4132 | @item print @var{exp} | |
4133 | @itemx print /@var{f} @var{exp} | |
4134 | @var{exp} is an expression (in the source language). By default | |
70b88761 | 4135 | the value of @var{exp} is printed in a format appropriate to its data |
e0dacfd1 RP |
4136 | type; you can choose a different format by specifying @samp{/@var{f}}, |
4137 | where @var{f} is a letter specifying the format; @pxref{Output formats}. | |
4138 | ||
4139 | @item print | |
4140 | @itemx print /@var{f} | |
18fae2a8 | 4141 | If you omit @var{exp}, @value{GDBN} displays the last value again (from the |
1041a570 | 4142 | @dfn{value history}; @pxref{Value History, ,Value History}). This allows you to |
e0dacfd1 RP |
4143 | conveniently inspect the same value in an alternative format. |
4144 | @end table | |
70b88761 RP |
4145 | |
4146 | A more low-level way of examining data is with the @code{x} command. | |
4147 | It examines data in memory at a specified address and prints it in a | |
29a2b744 | 4148 | specified format. @xref{Memory, ,Examining Memory}. |
70b88761 | 4149 | |
29a2b744 | 4150 | If you are interested in information about types, or about how the fields |
b80282d5 | 4151 | of a struct or class are declared, use the @code{ptype @var{exp}} |
1041a570 | 4152 | command rather than @code{print}. @xref{Symbols, ,Examining the Symbol Table}. |
b80282d5 | 4153 | |
18fae2a8 RP |
4154 | @ignore |
4155 | @c pre-unfold | |
4156 | @menu | |
4157 | * Expressions:: Expressions | |
4158 | * Variables:: Program Variables | |
4159 | * Arrays:: Artificial Arrays | |
4160 | * Output formats:: Output formats | |
4161 | * Memory:: Examining Memory | |
4162 | * Auto Display:: Automatic Display | |
4163 | * Print Settings:: Print Settings | |
4164 | * Value History:: Value History | |
4165 | * Convenience Vars:: Convenience Variables | |
4166 | * Registers:: Registers | |
4167 | @ifclear HviiiEXCLUSIVE | |
4168 | * Floating Point Hardware:: Floating Point Hardware | |
4169 | @end ifclear | |
4170 | @end menu | |
4171 | @end ignore | |
4172 | ||
4173 | @ifclear HviiiEXCLUSIVE | |
70b88761 | 4174 | @menu |
b80282d5 RP |
4175 | * Expressions:: Expressions |
4176 | * Variables:: Program Variables | |
4177 | * Arrays:: Artificial Arrays | |
4178 | * Output formats:: Output formats | |
4179 | * Memory:: Examining Memory | |
4180 | * Auto Display:: Automatic Display | |
4181 | * Print Settings:: Print Settings | |
4182 | * Value History:: Value History | |
4183 | * Convenience Vars:: Convenience Variables | |
4184 | * Registers:: Registers | |
4185 | * Floating Point Hardware:: Floating Point Hardware | |
70b88761 | 4186 | @end menu |
18fae2a8 RP |
4187 | @end ifclear |
4188 | ||
4189 | @ifset HviiiEXCLUSIVE | |
4190 | @menu | |
4191 | * Expressions:: Expressions | |
4192 | * Variables:: Program Variables | |
4193 | * Arrays:: Artificial Arrays | |
4194 | * Output formats:: Output formats | |
4195 | * Memory:: Examining Memory | |
4196 | * Auto Display:: Automatic Display | |
4197 | * Print Settings:: Print Settings | |
4198 | * Value History:: Value History | |
4199 | * Convenience Vars:: Convenience Variables | |
4200 | * Registers:: Registers | |
4201 | @end menu | |
4202 | @end ifset | |
70b88761 | 4203 | |
4eb4cf57 | 4204 | @node Expressions |
70b88761 RP |
4205 | @section Expressions |
4206 | ||
4207 | @cindex expressions | |
18fae2a8 | 4208 | @code{print} and many other @value{GDBN} commands accept an expression and |
70b88761 RP |
4209 | compute its value. Any kind of constant, variable or operator defined |
4210 | by the programming language you are using is legal in an expression in | |
18fae2a8 | 4211 | @value{GDBN}. This includes conditional expressions, function calls, casts |
70b88761 | 4212 | and string constants. It unfortunately does not include symbols defined |
b80282d5 | 4213 | by preprocessor @code{#define} commands. |
70b88761 | 4214 | |
18fae2a8 | 4215 | @ifclear CONLY |
c2bbbb22 | 4216 | Because C is so widespread, most of the expressions shown in examples in |
18fae2a8 | 4217 | this manual are in C. @xref{Languages, , Using @value{GDBN} with Different |
c2bbbb22 | 4218 | Languages}, for information on how to use expressions in other |
e251e767 | 4219 | languages. |
c2bbbb22 | 4220 | |
18fae2a8 | 4221 | In this section, we discuss operators that you can use in @value{GDBN} |
e251e767 | 4222 | expressions regardless of your programming language. |
c2bbbb22 | 4223 | |
70b88761 RP |
4224 | Casts are supported in all languages, not just in C, because it is so |
4225 | useful to cast a number into a pointer so as to examine a structure | |
4226 | at that address in memory. | |
c2bbbb22 | 4227 | @c FIXME: casts supported---Mod2 true? |
18fae2a8 | 4228 | @end ifclear |
70b88761 | 4229 | |
18fae2a8 | 4230 | @value{GDBN} supports these operators in addition to those of programming |
70b88761 RP |
4231 | languages: |
4232 | ||
4233 | @table @code | |
4234 | @item @@ | |
4235 | @samp{@@} is a binary operator for treating parts of memory as arrays. | |
1041a570 | 4236 | @xref{Arrays, ,Artificial Arrays}, for more information. |
70b88761 RP |
4237 | |
4238 | @item :: | |
4239 | @samp{::} allows you to specify a variable in terms of the file or | |
1041a570 | 4240 | function where it is defined. @xref{Variables, ,Program Variables}. |
70b88761 RP |
4241 | |
4242 | @item @{@var{type}@} @var{addr} | |
4243 | Refers to an object of type @var{type} stored at address @var{addr} in | |
4244 | memory. @var{addr} may be any expression whose value is an integer or | |
4245 | pointer (but parentheses are required around binary operators, just as in | |
4246 | a cast). This construct is allowed regardless of what kind of data is | |
1041a570 | 4247 | normally supposed to reside at @var{addr}. |
70b88761 RP |
4248 | @end table |
4249 | ||
4eb4cf57 | 4250 | @node Variables |
70b88761 RP |
4251 | @section Program Variables |
4252 | ||
4253 | The most common kind of expression to use is the name of a variable | |
4254 | in your program. | |
4255 | ||
4256 | Variables in expressions are understood in the selected stack frame | |
29a2b744 RP |
4257 | (@pxref{Selection, ,Selecting a Frame}); they must either be global |
4258 | (or static) or be visible according to the scope rules of the | |
4259 | programming language from the point of execution in that frame. This | |
4260 | means that in the function | |
70b88761 RP |
4261 | |
4262 | @example | |
4263 | foo (a) | |
4264 | int a; | |
4265 | @{ | |
4266 | bar (a); | |
4267 | @{ | |
4268 | int b = test (); | |
4269 | bar (b); | |
4270 | @} | |
4271 | @} | |
4272 | @end example | |
4273 | ||
4274 | @noindent | |
29a2b744 | 4275 | the variable @code{a} is usable whenever your program is executing |
70b88761 | 4276 | within the function @code{foo}, but the variable @code{b} is visible |
29a2b744 | 4277 | only while your program is executing inside the block in which @code{b} |
70b88761 RP |
4278 | is declared. |
4279 | ||
4280 | @cindex variable name conflict | |
4281 | There is an exception: you can refer to a variable or function whose | |
4282 | scope is a single source file even if the current execution point is not | |
4283 | in this file. But it is possible to have more than one such variable or | |
6ca72cc6 RP |
4284 | function with the same name (in different source files). If that |
4285 | happens, referring to that name has unpredictable effects. If you wish, | |
4286 | you can specify a static variable in a particular function or file, | |
4287 | using the colon-colon notation: | |
70b88761 RP |
4288 | |
4289 | @cindex colon-colon | |
a6d0b6d3 | 4290 | @iftex |
29a2b744 | 4291 | @c info cannot cope with a :: index entry, but why deprive hard copy readers? |
70b88761 | 4292 | @kindex :: |
a6d0b6d3 | 4293 | @end iftex |
70b88761 RP |
4294 | @example |
4295 | @var{file}::@var{variable} | |
6ca72cc6 | 4296 | @var{function}::@var{variable} |
70b88761 RP |
4297 | @end example |
4298 | ||
4299 | @noindent | |
6ca72cc6 | 4300 | Here @var{file} or @var{function} is the name of the context for the |
6c380b13 | 4301 | static @var{variable}. In the case of file names, you can use quotes to |
18fae2a8 | 4302 | make sure @value{GDBN} parses the file name as a single word---for example, |
6c380b13 RP |
4303 | to print a global value of @code{x} defined in @file{f2.c}: |
4304 | ||
4305 | @example | |
18fae2a8 | 4306 | (@value{GDBP}) p 'f2.c'::x |
6c380b13 | 4307 | @end example |
70b88761 | 4308 | |
18fae2a8 | 4309 | @ifclear CONLY |
c2bbbb22 | 4310 | @cindex C++ scope resolution |
70b88761 | 4311 | This use of @samp{::} is very rarely in conflict with the very similar |
18fae2a8 RP |
4312 | use of the same notation in C++. @value{GDBN} also supports use of the C++ |
4313 | scope resolution operator in @value{GDBN} expressions. | |
4314 | @end ifclear | |
70b88761 | 4315 | |
3d3ab540 RP |
4316 | @cindex wrong values |
4317 | @cindex variable values, wrong | |
4318 | @quotation | |
4319 | @emph{Warning:} Occasionally, a local variable may appear to have the | |
4320 | wrong value at certain points in a function---just after entry to the | |
29a2b744 | 4321 | function, and just before exit. You may see this problem when you are |
3d3ab540 RP |
4322 | stepping by machine instructions. This is because on most machines, it |
4323 | takes more than one instruction to set up a stack frame (including local | |
29a2b744 | 4324 | variable definitions); if you are stepping by machine instructions, |
3d3ab540 RP |
4325 | variables may appear to have the wrong values until the stack frame is |
4326 | completely built. On function exit, it usually also takes more than one | |
4327 | machine instruction to destroy a stack frame; after you begin stepping | |
4328 | through that group of instructions, local variable definitions may be | |
4329 | gone. | |
4330 | @end quotation | |
4331 | ||
4eb4cf57 | 4332 | @node Arrays |
70b88761 RP |
4333 | @section Artificial Arrays |
4334 | ||
4335 | @cindex artificial array | |
4336 | @kindex @@ | |
4337 | It is often useful to print out several successive objects of the | |
4338 | same type in memory; a section of an array, or an array of | |
4339 | dynamically determined size for which only a pointer exists in the | |
4340 | program. | |
4341 | ||
4342 | This can be done by constructing an @dfn{artificial array} with the | |
4343 | binary operator @samp{@@}. The left operand of @samp{@@} should be | |
4344 | the first element of the desired array, as an individual object. | |
4345 | The right operand should be the desired length of the array. The result is | |
4346 | an array value whose elements are all of the type of the left argument. | |
4347 | The first element is actually the left argument; the second element | |
4348 | comes from bytes of memory immediately following those that hold the | |
4349 | first element, and so on. Here is an example. If a program says | |
4350 | ||
4351 | @example | |
4352 | int *array = (int *) malloc (len * sizeof (int)); | |
4353 | @end example | |
4354 | ||
4355 | @noindent | |
4356 | you can print the contents of @code{array} with | |
4357 | ||
4358 | @example | |
4359 | p *array@@len | |
4360 | @end example | |
4361 | ||
4362 | The left operand of @samp{@@} must reside in memory. Array values made | |
4363 | with @samp{@@} in this way behave just like other arrays in terms of | |
4364 | subscripting, and are coerced to pointers when used in expressions. | |
4365 | Artificial arrays most often appear in expressions via the value history | |
1041a570 | 4366 | (@pxref{Value History, ,Value History}), after printing one out.) |
70b88761 | 4367 | |
1041a570 | 4368 | Sometimes the artificial array mechanism is not quite enough; in |
3d3ab540 | 4369 | moderately complex data structures, the elements of interest may not |
1041a570 RP |
4370 | actually be adjacent---for example, if you are interested in the values |
4371 | of pointers in an array. One useful work-around in this situation is | |
4372 | to use a convenience variable (@pxref{Convenience Vars, ,Convenience | |
4373 | Variables}) as a counter in an expression that prints the first | |
4374 | interesting value, and then repeat that expression via @key{RET}. For | |
4375 | instance, suppose you have an array @code{dtab} of pointers to | |
4376 | structures, and you are interested in the values of a field @code{fv} | |
4377 | in each structure. Here is an example of what you might type: | |
4378 | ||
3d3ab540 RP |
4379 | @example |
4380 | set $i = 0 | |
4381 | p dtab[$i++]->fv | |
4382 | @key{RET} | |
4383 | @key{RET} | |
4384 | @dots{} | |
4385 | @end example | |
4386 | ||
4eb4cf57 | 4387 | @node Output formats |
70b88761 RP |
4388 | @section Output formats |
4389 | ||
4390 | @cindex formatted output | |
4391 | @cindex output formats | |
18fae2a8 | 4392 | By default, @value{GDBN} prints a value according to its data type. Sometimes |
70b88761 RP |
4393 | this is not what you want. For example, you might want to print a number |
4394 | in hex, or a pointer in decimal. Or you might want to view data in memory | |
4395 | at a certain address as a character string or as an instruction. To do | |
4396 | these things, specify an @dfn{output format} when you print a value. | |
4397 | ||
4398 | The simplest use of output formats is to say how to print a value | |
4399 | already computed. This is done by starting the arguments of the | |
4400 | @code{print} command with a slash and a format letter. The format | |
4401 | letters supported are: | |
4402 | ||
4403 | @table @code | |
4404 | @item x | |
4405 | Regard the bits of the value as an integer, and print the integer in | |
4406 | hexadecimal. | |
4407 | ||
4408 | @item d | |
4409 | Print as integer in signed decimal. | |
4410 | ||
4411 | @item u | |
4412 | Print as integer in unsigned decimal. | |
4413 | ||
4414 | @item o | |
4415 | Print as integer in octal. | |
4416 | ||
4417 | @item t | |
4418 | Print as integer in binary. The letter @samp{t} stands for ``two''. | |
4419 | ||
4420 | @item a | |
4421 | Print as an address, both absolute in hex and as an offset from the | |
4422 | nearest preceding symbol. This format can be used to discover where (in | |
4423 | what function) an unknown address is located: | |
1041a570 | 4424 | |
70b88761 | 4425 | @example |
18fae2a8 RP |
4426 | (@value{GDBP}) p/a 0x54320 |
4427 | $3 = 0x54320 <_initialize_vx+396> | |
70b88761 RP |
4428 | @end example |
4429 | ||
70b88761 RP |
4430 | @item c |
4431 | Regard as an integer and print it as a character constant. | |
4432 | ||
4433 | @item f | |
4434 | Regard the bits of the value as a floating point number and print | |
4435 | using typical floating point syntax. | |
4436 | @end table | |
4437 | ||
4438 | For example, to print the program counter in hex (@pxref{Registers}), type | |
4439 | ||
4440 | @example | |
4441 | p/x $pc | |
4442 | @end example | |
4443 | ||
4444 | @noindent | |
4445 | Note that no space is required before the slash; this is because command | |
18fae2a8 | 4446 | names in @value{GDBN} cannot contain a slash. |
70b88761 RP |
4447 | |
4448 | To reprint the last value in the value history with a different format, | |
4449 | you can use the @code{print} command with just a format and no | |
4450 | expression. For example, @samp{p/x} reprints the last value in hex. | |
4451 | ||
4eb4cf57 | 4452 | @node Memory |
70b88761 RP |
4453 | @section Examining Memory |
4454 | ||
1041a570 RP |
4455 | You can use the command @code{x} (for ``examine'') to examine memory in |
4456 | any of several formats, independently of your program's data types. | |
4457 | ||
70b88761 RP |
4458 | @cindex examining memory |
4459 | @table @code | |
4460 | @kindex x | |
cedaf8bc RP |
4461 | @item x/@var{nfu} @var{addr} |
4462 | @itemx x @var{addr} | |
4463 | @itemx x | |
1041a570 RP |
4464 | Use the command @code{x} to examine memory. |
4465 | @end table | |
4466 | ||
4467 | @var{n}, @var{f}, and @var{u} are all optional parameters that specify how | |
4468 | much memory to display and how to format it; @var{addr} is an | |
cedaf8bc RP |
4469 | expression giving the address where you want to start displaying memory. |
4470 | If you use defaults for @var{nfu}, you need not type the slash @samp{/}. | |
4471 | Several commands set convenient defaults for @var{addr}. | |
70b88761 | 4472 | |
1041a570 RP |
4473 | @table @r |
4474 | @item @var{n}, the repeat count | |
4475 | The repeat count is a decimal integer; the default is 1. It specifies | |
4476 | how much memory (counting by units @var{u}) to display. | |
cedaf8bc RP |
4477 | @c This really is **decimal**; unaffected by 'set radix' as of GDB |
4478 | @c 4.1.2. | |
70b88761 | 4479 | |
1041a570 RP |
4480 | @item @var{f}, the display format |
4481 | The display format is one of the formats used by @code{print}, | |
cedaf8bc RP |
4482 | or @samp{s} (null-terminated string) or @samp{i} (machine instruction). |
4483 | The default is @samp{x} (hexadecimal) initially, or the format from the | |
4484 | last time you used either @code{x} or @code{print}. | |
70b88761 | 4485 | |
1041a570 RP |
4486 | @item @var{u}, the unit size |
4487 | The unit size is any of | |
70b88761 RP |
4488 | @table @code |
4489 | @item b | |
cedaf8bc | 4490 | Bytes. |
70b88761 | 4491 | @item h |
cedaf8bc | 4492 | Halfwords (two bytes). |
70b88761 | 4493 | @item w |
cedaf8bc | 4494 | Words (four bytes). This is the initial default. |
70b88761 | 4495 | @item g |
cedaf8bc | 4496 | Giant words (eight bytes). |
70b88761 RP |
4497 | @end table |
4498 | ||
cedaf8bc RP |
4499 | Each time you specify a unit size with @code{x}, that size becomes the |
4500 | default unit the next time you use @code{x}. (For the @samp{s} and | |
4501 | @samp{i} formats, the unit size is ignored and is normally not written.) | |
4502 | ||
1041a570 | 4503 | @item @var{addr}, starting display address |
18fae2a8 | 4504 | @var{addr} is the address where you want @value{GDBN} to begin displaying |
cedaf8bc RP |
4505 | memory. The expression need not have a pointer value (though it may); |
4506 | it is always interpreted as an integer address of a byte of memory. | |
1041a570 | 4507 | @xref{Expressions, ,Expressions}, for more information on expressions. The default for |
cedaf8bc RP |
4508 | @var{addr} is usually just after the last address examined---but several |
4509 | other commands also set the default address: @code{info breakpoints} (to | |
4510 | the address of the last breakpoint listed), @code{info line} (to the | |
4511 | starting address of a line), and @code{print} (if you use it to display | |
4512 | a value from memory). | |
1041a570 | 4513 | @end table |
70b88761 | 4514 | |
cedaf8bc RP |
4515 | For example, @samp{x/3uh 0x54320} is a request to display three halfwords |
4516 | (@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}), | |
4517 | starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four | |
4518 | words (@samp{w}) of memory above the stack pointer (here, @samp{$sp}; | |
4519 | @pxref{Registers}) in hexadecimal (@samp{x}). | |
70b88761 | 4520 | |
cedaf8bc | 4521 | Since the letters indicating unit sizes are all distinct from the |
29a2b744 | 4522 | letters specifying output formats, you do not have to remember whether |
cedaf8bc RP |
4523 | unit size or format comes first; either order will work. The output |
4524 | specifications @samp{4xw} and @samp{4wx} mean exactly the same thing. | |
4525 | (However, the count @var{n} must come first; @samp{wx4} will not work.) | |
4526 | ||
4527 | Even though the unit size @var{u} is ignored for the formats @samp{s} | |
4528 | and @samp{i}, you might still want to use a count @var{n}; for example, | |
4529 | @samp{3i} specifies that you want to see three machine instructions, | |
4530 | including any operands. The command @code{disassemble} gives an | |
4531 | alternative way of inspecting machine instructions; @pxref{Machine | |
4532 | Code}. | |
4533 | ||
4534 | All the defaults for the arguments to @code{x} are designed to make it | |
4535 | easy to continue scanning memory with minimal specifications each time | |
1041a570 | 4536 | you use @code{x}. For example, after you have inspected three machine |
cedaf8bc RP |
4537 | instructions with @samp{x/3i @var{addr}}, you can inspect the next seven |
4538 | with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command, | |
4539 | the repeat count @var{n} is used again; the other arguments default as | |
4540 | for successive uses of @code{x}. | |
70b88761 | 4541 | |
c338a2fd | 4542 | @cindex @code{$_}, @code{$__}, and value history |
cedaf8bc | 4543 | The addresses and contents printed by the @code{x} command are not saved |
70b88761 | 4544 | in the value history because there is often too much of them and they |
18fae2a8 | 4545 | would get in the way. Instead, @value{GDBN} makes these values available for |
70b88761 RP |
4546 | subsequent use in expressions as values of the convenience variables |
4547 | @code{$_} and @code{$__}. After an @code{x} command, the last address | |
4548 | examined is available for use in expressions in the convenience variable | |
4549 | @code{$_}. The contents of that address, as examined, are available in | |
4550 | the convenience variable @code{$__}. | |
4551 | ||
4552 | If the @code{x} command has a repeat count, the address and contents saved | |
4553 | are from the last memory unit printed; this is not the same as the last | |
4554 | address printed if several units were printed on the last line of output. | |
4555 | ||
4eb4cf57 | 4556 | @node Auto Display |
70b88761 RP |
4557 | @section Automatic Display |
4558 | @cindex automatic display | |
4559 | @cindex display of expressions | |
4560 | ||
4561 | If you find that you want to print the value of an expression frequently | |
4562 | (to see how it changes), you might want to add it to the @dfn{automatic | |
18fae2a8 | 4563 | display list} so that @value{GDBN} will print its value each time your program stops. |
70b88761 RP |
4564 | Each expression added to the list is given a number to identify it; |
4565 | to remove an expression from the list, you specify that number. | |
4566 | The automatic display looks like this: | |
4567 | ||
4568 | @example | |
4569 | 2: foo = 38 | |
4570 | 3: bar[5] = (struct hack *) 0x3804 | |
4571 | @end example | |
4572 | ||
4573 | @noindent | |
4574 | showing item numbers, expressions and their current values. As with | |
4575 | displays you request manually using @code{x} or @code{print}, you can | |
4576 | specify the output format you prefer; in fact, @code{display} decides | |
4577 | whether to use @code{print} or @code{x} depending on how elaborate your | |
4578 | format specification is---it uses @code{x} if you specify a unit size, | |
4579 | or one of the two formats (@samp{i} and @samp{s}) that are only | |
4580 | supported by @code{x}; otherwise it uses @code{print}. | |
4581 | ||
4582 | @table @code | |
4583 | @item display @var{exp} | |
4584 | @kindex display | |
4585 | Add the expression @var{exp} to the list of expressions to display | |
1041a570 | 4586 | each time your program stops. @xref{Expressions, ,Expressions}. |
70b88761 RP |
4587 | |
4588 | @code{display} will not repeat if you press @key{RET} again after using it. | |
4589 | ||
4590 | @item display/@var{fmt} @var{exp} | |
4591 | For @var{fmt} specifying only a display format and not a size or | |
4592 | count, add the expression @var{exp} to the auto-display list but | |
4593 | arranges to display it each time in the specified format @var{fmt}. | |
4594 | @xref{Output formats}. | |
4595 | ||
4596 | @item display/@var{fmt} @var{addr} | |
4597 | For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a | |
4598 | number of units, add the expression @var{addr} as a memory address to | |
29a2b744 RP |
4599 | be examined each time your program stops. Examining means in effect |
4600 | doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory, ,Examining Memory}. | |
70b88761 RP |
4601 | @end table |
4602 | ||
4603 | For example, @samp{display/i $pc} can be helpful, to see the machine | |
4604 | instruction about to be executed each time execution stops (@samp{$pc} | |
4605 | is a common name for the program counter; @pxref{Registers}). | |
4606 | ||
4607 | @table @code | |
4608 | @item undisplay @var{dnums}@dots{} | |
4609 | @itemx delete display @var{dnums}@dots{} | |
4610 | @kindex delete display | |
4611 | @kindex undisplay | |
4612 | Remove item numbers @var{dnums} from the list of expressions to display. | |
4613 | ||
4614 | @code{undisplay} will not repeat if you press @key{RET} after using it. | |
4615 | (Otherwise you would just get the error @samp{No display number @dots{}}.) | |
4616 | ||
4617 | @item disable display @var{dnums}@dots{} | |
4618 | @kindex disable display | |
4619 | Disable the display of item numbers @var{dnums}. A disabled display | |
4620 | item is not printed automatically, but is not forgotten. It may be | |
4621 | enabled again later. | |
4622 | ||
4623 | @item enable display @var{dnums}@dots{} | |
4624 | @kindex enable display | |
4625 | Enable display of item numbers @var{dnums}. It becomes effective once | |
4626 | again in auto display of its expression, until you specify otherwise. | |
4627 | ||
4628 | @item display | |
4629 | Display the current values of the expressions on the list, just as is | |
29a2b744 | 4630 | done when your program stops. |
70b88761 RP |
4631 | |
4632 | @item info display | |
4633 | @kindex info display | |
4634 | Print the list of expressions previously set up to display | |
4635 | automatically, each one with its item number, but without showing the | |
4636 | values. This includes disabled expressions, which are marked as such. | |
4637 | It also includes expressions which would not be displayed right now | |
4638 | because they refer to automatic variables not currently available. | |
4639 | @end table | |
4640 | ||
4641 | If a display expression refers to local variables, then it does not make | |
4642 | sense outside the lexical context for which it was set up. Such an | |
4643 | expression is disabled when execution enters a context where one of its | |
4644 | variables is not defined. For example, if you give the command | |
4645 | @code{display last_char} while inside a function with an argument | |
29a2b744 | 4646 | @code{last_char}, then this argument will be displayed while your program |
70b88761 RP |
4647 | continues to stop inside that function. When it stops elsewhere---where |
4648 | there is no variable @code{last_char}---display is disabled. The next time | |
4649 | your program stops where @code{last_char} is meaningful, you can enable the | |
4650 | display expression once again. | |
4651 | ||
4eb4cf57 | 4652 | @node Print Settings |
70b88761 RP |
4653 | @section Print Settings |
4654 | ||
4655 | @cindex format options | |
4656 | @cindex print settings | |
18fae2a8 | 4657 | @value{GDBN} provides the following ways to control how arrays, structures, |
e251e767 | 4658 | and symbols are printed. |
70b88761 RP |
4659 | |
4660 | @noindent | |
4661 | These settings are useful for debugging programs in any language: | |
4662 | ||
4663 | @table @code | |
4664 | @item set print address | |
4665 | @item set print address on | |
4666 | @kindex set print address | |
18fae2a8 | 4667 | @value{GDBN} will print memory addresses showing the location of stack |
70b88761 RP |
4668 | traces, structure values, pointer values, breakpoints, and so forth, |
4669 | even when it also displays the contents of those addresses. The default | |
4670 | is on. For example, this is what a stack frame display looks like, with | |
4671 | @code{set print address on}: | |
1041a570 | 4672 | |
70b88761 | 4673 | @smallexample |
1041a570 | 4674 | @group |
18fae2a8 | 4675 | (@value{GDBP}) f |
e251e767 | 4676 | #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") |
70b88761 | 4677 | at input.c:530 |
b80282d5 | 4678 | 530 if (lquote != def_lquote) |
1041a570 | 4679 | @end group |
70b88761 RP |
4680 | @end smallexample |
4681 | ||
4682 | @item set print address off | |
4683 | Do not print addresses when displaying their contents. For example, | |
4684 | this is the same stack frame displayed with @code{set print address off}: | |
1041a570 | 4685 | |
70b88761 | 4686 | @example |
1041a570 | 4687 | @group |
18fae2a8 RP |
4688 | (@value{GDBP}) set print addr off |
4689 | (@value{GDBP}) f | |
70b88761 | 4690 | #0 set_quotes (lq="<<", rq=">>") at input.c:530 |
b80282d5 | 4691 | 530 if (lquote != def_lquote) |
1041a570 | 4692 | @end group |
70b88761 RP |
4693 | @end example |
4694 | ||
4695 | @item show print address | |
4696 | @kindex show print address | |
4697 | Show whether or not addresses are to be printed. | |
4698 | ||
4699 | @item set print array | |
4700 | @itemx set print array on | |
4701 | @kindex set print array | |
18fae2a8 | 4702 | @value{GDBN} will pretty print arrays. This format is more convenient to read, |
70b88761 RP |
4703 | but uses more space. The default is off. |
4704 | ||
4705 | @item set print array off. | |
4706 | Return to compressed format for arrays. | |
4707 | ||
4708 | @item show print array | |
4709 | @kindex show print array | |
4710 | Show whether compressed or pretty format is selected for displaying | |
e251e767 | 4711 | arrays. |
70b88761 RP |
4712 | |
4713 | @item set print elements @var{number-of-elements} | |
4714 | @kindex set print elements | |
18fae2a8 | 4715 | If @value{GDBN} is printing a large array, it will stop printing after it has |
70b88761 RP |
4716 | printed the number of elements set by the @code{set print elements} command. |
4717 | This limit also applies to the display of strings. | |
4718 | ||
4719 | @item show print elements | |
4720 | @kindex show print elements | |
18fae2a8 | 4721 | Display the number of elements of a large array that @value{GDBN} will print |
70b88761 RP |
4722 | before losing patience. |
4723 | ||
4724 | @item set print pretty on | |
4725 | @kindex set print pretty | |
18fae2a8 | 4726 | Cause @value{GDBN} to print structures in an indented format with one member per |
70b88761 RP |
4727 | line, like this: |
4728 | ||
4729 | @example | |
1041a570 | 4730 | @group |
70b88761 RP |
4731 | $1 = @{ |
4732 | next = 0x0, | |
4733 | flags = @{ | |
4734 | sweet = 1, | |
4735 | sour = 1 | |
4736 | @}, | |
4737 | meat = 0x54 "Pork" | |
4738 | @} | |
1041a570 | 4739 | @end group |
70b88761 RP |
4740 | @end example |
4741 | ||
4742 | @item set print pretty off | |
18fae2a8 | 4743 | Cause @value{GDBN} to print structures in a compact format, like this: |
70b88761 RP |
4744 | |
4745 | @smallexample | |
1041a570 | 4746 | @group |
38962738 RP |
4747 | $1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, \ |
4748 | meat = 0x54 "Pork"@} | |
1041a570 | 4749 | @end group |
70b88761 RP |
4750 | @end smallexample |
4751 | ||
4752 | @noindent | |
4753 | This is the default format. | |
4754 | ||
4755 | @item show print pretty | |
4756 | @kindex show print pretty | |
18fae2a8 | 4757 | Show which format @value{GDBN} will use to print structures. |
70b88761 RP |
4758 | |
4759 | @item set print sevenbit-strings on | |
f2857bd9 | 4760 | @kindex set print sevenbit-strings |
e251e767 | 4761 | Print using only seven-bit characters; if this option is set, |
18fae2a8 | 4762 | @value{GDBN} will display any eight-bit characters (in strings or character |
70b88761 RP |
4763 | values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is |
4764 | displayed as @code{\341}. | |
4765 | ||
4766 | @item set print sevenbit-strings off | |
4767 | Print using either seven-bit or eight-bit characters, as required. This | |
4768 | is the default. | |
4769 | ||
4770 | @item show print sevenbit-strings | |
f2857bd9 | 4771 | @kindex show print sevenbit-strings |
18fae2a8 | 4772 | Show whether or not @value{GDBN} will print only seven-bit characters. |
70b88761 RP |
4773 | |
4774 | @item set print union on | |
4775 | @kindex set print union | |
18fae2a8 | 4776 | Tell @value{GDBN} to print unions which are contained in structures. This is the |
70b88761 RP |
4777 | default setting. |
4778 | ||
4779 | @item set print union off | |
18fae2a8 | 4780 | Tell @value{GDBN} not to print unions which are contained in structures. |
70b88761 RP |
4781 | |
4782 | @item show print union | |
4783 | @kindex show print union | |
18fae2a8 | 4784 | Ask @value{GDBN} whether or not it will print unions which are contained in |
e251e767 | 4785 | structures. |
70b88761 RP |
4786 | |
4787 | For example, given the declarations | |
4788 | ||
4789 | @smallexample | |
4790 | typedef enum @{Tree, Bug@} Species; | |
4791 | typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms; | |
203eea5d RP |
4792 | typedef enum @{Caterpillar, Cocoon, Butterfly@} |
4793 | Bug_forms; | |
70b88761 RP |
4794 | |
4795 | struct thing @{ | |
4796 | Species it; | |
4797 | union @{ | |
4798 | Tree_forms tree; | |
4799 | Bug_forms bug; | |
4800 | @} form; | |
4801 | @}; | |
4802 | ||
4803 | struct thing foo = @{Tree, @{Acorn@}@}; | |
4804 | @end smallexample | |
4805 | ||
4806 | @noindent | |
4807 | with @code{set print union on} in effect @samp{p foo} would print | |
4808 | ||
4809 | @smallexample | |
4810 | $1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@} | |
4811 | @end smallexample | |
4812 | ||
4813 | @noindent | |
4814 | and with @code{set print union off} in effect it would print | |
4815 | ||
4816 | @smallexample | |
4817 | $1 = @{it = Tree, form = @{...@}@} | |
4818 | @end smallexample | |
4819 | @end table | |
4820 | ||
4821 | @noindent | |
4822 | These settings are of interest when debugging C++ programs: | |
4823 | ||
4824 | @table @code | |
e251e767 RP |
4825 | @item set print demangle |
4826 | @itemx set print demangle on | |
70b88761 RP |
4827 | @kindex set print demangle |
4828 | Print C++ names in their source form rather than in the mangled form | |
4829 | in which they are passed to the assembler and linker for type-safe linkage. | |
4830 | The default is on. | |
4831 | ||
4832 | @item show print demangle | |
4833 | @kindex show print demangle | |
4834 | Show whether C++ names will be printed in mangled or demangled form. | |
4835 | ||
e251e767 RP |
4836 | @item set print asm-demangle |
4837 | @itemx set print asm-demangle on | |
70b88761 RP |
4838 | @kindex set print asm-demangle |
4839 | Print C++ names in their source form rather than their mangled form, even | |
4840 | in assembler code printouts such as instruction disassemblies. | |
4841 | The default is off. | |
4842 | ||
4843 | @item show print asm-demangle | |
4844 | @kindex show print asm-demangle | |
4845 | Show whether C++ names in assembly listings will be printed in mangled | |
4846 | or demangled form. | |
4847 | ||
4848 | @item set print object | |
4849 | @itemx set print object on | |
4850 | @kindex set print object | |
4851 | When displaying a pointer to an object, identify the @emph{actual} | |
4852 | (derived) type of the object rather than the @emph{declared} type, using | |
4853 | the virtual function table. | |
4854 | ||
4855 | @item set print object off | |
4856 | Display only the declared type of objects, without reference to the | |
4857 | virtual function table. This is the default setting. | |
4858 | ||
4859 | @item show print object | |
4860 | @kindex show print object | |
4861 | Show whether actual, or declared, object types will be displayed. | |
4862 | ||
e251e767 RP |
4863 | @item set print vtbl |
4864 | @itemx set print vtbl on | |
70b88761 RP |
4865 | @kindex set print vtbl |
4866 | Pretty print C++ virtual function tables. The default is off. | |
4867 | ||
4868 | @item set print vtbl off | |
4869 | Do not pretty print C++ virtual function tables. | |
4870 | ||
4871 | @item show print vtbl | |
4872 | @kindex show print vtbl | |
4873 | Show whether C++ virtual function tables are pretty printed, or not. | |
70b88761 RP |
4874 | @end table |
4875 | ||
4eb4cf57 | 4876 | @node Value History |
70b88761 RP |
4877 | @section Value History |
4878 | ||
4879 | @cindex value history | |
18fae2a8 | 4880 | Values printed by the @code{print} command are saved in @value{GDBN}'s @dfn{value |
70b88761 RP |
4881 | history} so that you can refer to them in other expressions. Values are |
4882 | kept until the symbol table is re-read or discarded (for example with | |
4883 | the @code{file} or @code{symbol-file} commands). When the symbol table | |
4884 | changes, the value history is discarded, since the values may contain | |
4885 | pointers back to the types defined in the symbol table. | |
4886 | ||
4887 | @cindex @code{$} | |
4888 | @cindex @code{$$} | |
4889 | @cindex history number | |
4890 | The values printed are given @dfn{history numbers} for you to refer to them | |
4891 | by. These are successive integers starting with one. @code{print} shows you | |
4892 | the history number assigned to a value by printing @samp{$@var{num} = } | |
4893 | before the value; here @var{num} is the history number. | |
4894 | ||
4895 | To refer to any previous value, use @samp{$} followed by the value's | |
4896 | history number. The way @code{print} labels its output is designed to | |
4897 | remind you of this. Just @code{$} refers to the most recent value in | |
4898 | the history, and @code{$$} refers to the value before that. | |
4899 | @code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2} | |
4900 | is the value just prior to @code{$$}, @code{$$1} is equivalent to | |
4901 | @code{$$}, and @code{$$0} is equivalent to @code{$}. | |
4902 | ||
4903 | For example, suppose you have just printed a pointer to a structure and | |
4904 | want to see the contents of the structure. It suffices to type | |
4905 | ||
4906 | @example | |
4907 | p *$ | |
4908 | @end example | |
4909 | ||
4910 | If you have a chain of structures where the component @code{next} points | |
4911 | to the next one, you can print the contents of the next one with this: | |
4912 | ||
4913 | @example | |
4914 | p *$.next | |
4915 | @end example | |
4916 | ||
4917 | @noindent | |
4918 | You can print successive links in the chain by repeating this | |
4919 | command---which you can do by just typing @key{RET}. | |
4920 | ||
4921 | Note that the history records values, not expressions. If the value of | |
4922 | @code{x} is 4 and you type these commands: | |
4923 | ||
4924 | @example | |
4925 | print x | |
4926 | set x=5 | |
4927 | @end example | |
4928 | ||
4929 | @noindent | |
4930 | then the value recorded in the value history by the @code{print} command | |
4931 | remains 4 even though the value of @code{x} has changed. | |
4932 | ||
4933 | @table @code | |
4934 | @kindex show values | |
4935 | @item show values | |
4936 | Print the last ten values in the value history, with their item numbers. | |
4937 | This is like @samp{p@ $$9} repeated ten times, except that @code{show | |
4938 | values} does not change the history. | |
4939 | ||
4940 | @item show values @var{n} | |
4941 | Print ten history values centered on history item number @var{n}. | |
4942 | ||
4943 | @item show values + | |
4944 | Print ten history values just after the values last printed. If no more | |
4945 | values are available, produces no display. | |
4946 | @end table | |
4947 | ||
4948 | Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the | |
e251e767 | 4949 | same effect as @samp{show values +}. |
70b88761 | 4950 | |
4eb4cf57 | 4951 | @node Convenience Vars |
70b88761 RP |
4952 | @section Convenience Variables |
4953 | ||
4954 | @cindex convenience variables | |
18fae2a8 RP |
4955 | @value{GDBN} provides @dfn{convenience variables} that you can use within |
4956 | @value{GDBN} to hold on to a value and refer to it later. These variables | |
4957 | exist entirely within @value{GDBN}; they are not part of your program, and | |
70b88761 | 4958 | setting a convenience variable has no direct effect on further execution |
1041a570 | 4959 | of your program. That is why you can use them freely. |
70b88761 RP |
4960 | |
4961 | Convenience variables are prefixed with @samp{$}. Any name preceded by | |
4962 | @samp{$} can be used for a convenience variable, unless it is one of | |
4963 | the predefined machine-specific register names (@pxref{Registers}). | |
4964 | (Value history references, in contrast, are @emph{numbers} preceded | |
1041a570 | 4965 | by @samp{$}. @xref{Value History, ,Value History}.) |
70b88761 RP |
4966 | |
4967 | You can save a value in a convenience variable with an assignment | |
4968 | expression, just as you would set a variable in your program. Example: | |
4969 | ||
4970 | @example | |
4971 | set $foo = *object_ptr | |
4972 | @end example | |
4973 | ||
4974 | @noindent | |
4975 | would save in @code{$foo} the value contained in the object pointed to by | |
4976 | @code{object_ptr}. | |
4977 | ||
4978 | Using a convenience variable for the first time creates it; but its value | |
4979 | is @code{void} until you assign a new value. You can alter the value with | |
4980 | another assignment at any time. | |
4981 | ||
4982 | Convenience variables have no fixed types. You can assign a convenience | |
4983 | variable any type of value, including structures and arrays, even if | |
4984 | that variable already has a value of a different type. The convenience | |
4985 | variable, when used as an expression, has the type of its current value. | |
4986 | ||
4987 | @table @code | |
4988 | @item show convenience | |
4989 | @kindex show convenience | |
4990 | Print a list of convenience variables used so far, and their values. | |
4991 | Abbreviated @code{show con}. | |
4992 | @end table | |
4993 | ||
4994 | One of the ways to use a convenience variable is as a counter to be | |
4995 | incremented or a pointer to be advanced. For example, to print | |
4996 | a field from successive elements of an array of structures: | |
4997 | ||
18fae2a8 | 4998 | @example |
70b88761 RP |
4999 | set $i = 0 |
5000 | print bar[$i++]->contents | |
5001 | @i{@dots{} repeat that command by typing @key{RET}.} | |
18fae2a8 | 5002 | @end example |
70b88761 | 5003 | |
18fae2a8 | 5004 | Some convenience variables are created automatically by @value{GDBN} and given |
70b88761 RP |
5005 | values likely to be useful. |
5006 | ||
5007 | @table @code | |
5008 | @item $_ | |
c338a2fd | 5009 | @kindex $_ |
70b88761 | 5010 | The variable @code{$_} is automatically set by the @code{x} command to |
29a2b744 RP |
5011 | the last address examined (@pxref{Memory, ,Examining Memory}). Other |
5012 | commands which provide a default address for @code{x} to examine also | |
5013 | set @code{$_} to that address; these commands include @code{info line} | |
5014 | and @code{info breakpoint}. The type of @code{$_} is @code{void *} | |
5015 | except when set by the @code{x} command, in which case it is a pointer | |
5016 | to the type of @code{$__}. | |
70b88761 RP |
5017 | |
5018 | @item $__ | |
c338a2fd | 5019 | @kindex $__ |
70b88761 | 5020 | The variable @code{$__} is automatically set by the @code{x} command |
c2bbbb22 RP |
5021 | to the value found in the last address examined. Its type is chosen |
5022 | to match the format in which the data was printed. | |
70b88761 RP |
5023 | @end table |
5024 | ||
4eb4cf57 | 5025 | @node Registers |
70b88761 RP |
5026 | @section Registers |
5027 | ||
5028 | @cindex registers | |
b80282d5 | 5029 | You can refer to machine register contents, in expressions, as variables |
70b88761 RP |
5030 | with names starting with @samp{$}. The names of registers are different |
5031 | for each machine; use @code{info registers} to see the names used on | |
e251e767 | 5032 | your machine. |
70b88761 RP |
5033 | |
5034 | @table @code | |
5035 | @item info registers | |
5036 | @kindex info registers | |
b80282d5 RP |
5037 | Print the names and values of all registers except floating-point |
5038 | registers (in the selected stack frame). | |
5039 | ||
5040 | @item info all-registers | |
5041 | @kindex info all-registers | |
5042 | @cindex floating point registers | |
5043 | Print the names and values of all registers, including floating-point | |
5044 | registers. | |
70b88761 | 5045 | |
4eb4cf57 | 5046 | @item info registers @var{regname} @dots{} |
0d1cd01e JG |
5047 | Print the relativized value of each specified register @var{regname}. |
5048 | @var{regname} may be any register name valid on the machine you are using, with | |
70b88761 RP |
5049 | or without the initial @samp{$}. |
5050 | @end table | |
5051 | ||
18fae2a8 | 5052 | @value{GDBN} has four ``standard'' register names that are available (in |
29a2b744 | 5053 | expressions) on most machines---whenever they do not conflict with an |
09267865 RP |
5054 | architecture's canonical mnemonics for registers. The register names |
5055 | @code{$pc} and @code{$sp} are used for the program counter register and | |
5056 | the stack pointer. @code{$fp} is used for a register that contains a | |
5057 | pointer to the current stack frame, and @code{$ps} is used for a | |
5058 | register that contains the processor status. For example, | |
70b88761 | 5059 | you could print the program counter in hex with |
1041a570 | 5060 | |
70b88761 RP |
5061 | @example |
5062 | p/x $pc | |
5063 | @end example | |
5064 | ||
5065 | @noindent | |
5066 | or print the instruction to be executed next with | |
1041a570 | 5067 | |
70b88761 RP |
5068 | @example |
5069 | x/i $pc | |
5070 | @end example | |
5071 | ||
5072 | @noindent | |
29a2b744 RP |
5073 | or add four to the stack pointer @footnote{This is a way of removing |
5074 | one word from the stack, on machines where stacks grow downward in | |
5075 | memory (most machines, nowadays). This assumes that the innermost | |
5076 | stack frame is selected; setting @code{$sp} is not allowed when other | |
5077 | stack frames are selected. To pop entire frames off the stack, | |
5078 | regardless of machine architecture, use @code{return}; | |
1041a570 RP |
5079 | @pxref{Returning, ,Returning from a Function}.} with |
5080 | ||
70b88761 RP |
5081 | @example |
5082 | set $sp += 4 | |
5083 | @end example | |
5084 | ||
09267865 RP |
5085 | Whenever possible, these four standard register names are available on |
5086 | your machine even though the machine has different canonical mnemonics, | |
5087 | so long as there is no conflict. The @code{info registers} command | |
5088 | shows the canonical names. For example, on the SPARC, @code{info | |
70b88761 RP |
5089 | registers} displays the processor status register as @code{$psr} but you |
5090 | can also refer to it as @code{$ps}. | |
5091 | ||
18fae2a8 | 5092 | @value{GDBN} always considers the contents of an ordinary register as an |
70b88761 RP |
5093 | integer when the register is examined in this way. Some machines have |
5094 | special registers which can hold nothing but floating point; these | |
5095 | registers are considered to have floating point values. There is no way | |
5096 | to refer to the contents of an ordinary register as floating point value | |
5097 | (although you can @emph{print} it as a floating point value with | |
5098 | @samp{print/f $@var{regname}}). | |
5099 | ||
5100 | Some registers have distinct ``raw'' and ``virtual'' data formats. This | |
5101 | means that the data format in which the register contents are saved by | |
5102 | the operating system is not the same one that your program normally | |
5103 | sees. For example, the registers of the 68881 floating point | |
5104 | coprocessor are always saved in ``extended'' (raw) format, but all C | |
5105 | programs expect to work with ``double'' (virtual) format. In such | |
18fae2a8 | 5106 | cases, @value{GDBN} normally works with the virtual format only (the format that |
70b88761 RP |
5107 | makes sense for your program), but the @code{info registers} command |
5108 | prints the data in both formats. | |
5109 | ||
5110 | Normally, register values are relative to the selected stack frame | |
29a2b744 RP |
5111 | (@pxref{Selection, ,Selecting a Frame}). This means that you get the |
5112 | value that the register would contain if all stack frames farther in | |
5113 | were exited and their saved registers restored. In order to see the | |
5114 | true contents of hardware registers, you must select the innermost | |
5115 | frame (with @samp{frame 0}). | |
70b88761 | 5116 | |
18fae2a8 | 5117 | However, @value{GDBN} must deduce where registers are saved, from the machine |
70b88761 | 5118 | code generated by your compiler. If some registers are not saved, or if |
18fae2a8 | 5119 | @value{GDBN} is unable to locate the saved registers, the selected stack |
70b88761 RP |
5120 | frame will make no difference. |
5121 | ||
18fae2a8 | 5122 | @ifset AMDxxixK |
03a77779 | 5123 | @table @code |
d8a68b28 JG |
5124 | @item set rstack_high_address @var{address} |
5125 | @kindex set rstack_high_address | |
03a77779 RP |
5126 | @cindex AMD 29K register stack |
5127 | @cindex register stack, AMD29K | |
5128 | On AMD 29000 family processors, registers are saved in a separate | |
18fae2a8 RP |
5129 | ``register stack''. There is no way for @value{GDBN} to determine the extent |
5130 | of this stack. Normally, @value{GDBN} just assumes that the stack is ``large | |
5131 | enough''. This may result in @value{GDBN} referencing memory locations that | |
03a77779 RP |
5132 | don't exist. If necessary, you can get around this problem by |
5133 | specifying the ending address of the register stack with the @code{set | |
5134 | rstack_high_address} command. The argument should be an address, which | |
5135 | you will probably want to precede with @samp{0x} to specify in | |
5136 | hexadecimal. | |
d8a68b28 JG |
5137 | |
5138 | @item show rstack_high_address | |
5139 | @kindex show rstack_high_address | |
03a77779 RP |
5140 | Display the current limit of the register stack, on AMD 29000 family |
5141 | processors. | |
5142 | @end table | |
18fae2a8 | 5143 | @end ifset |
d8a68b28 | 5144 | |
18fae2a8 | 5145 | @ifclear HviiiEXCLUSIVE |
4eb4cf57 | 5146 | @node Floating Point Hardware |
70b88761 RP |
5147 | @section Floating Point Hardware |
5148 | @cindex floating point | |
1041a570 | 5149 | |
18fae2a8 | 5150 | Depending on the host machine architecture, @value{GDBN} may be able to give |
70b88761 RP |
5151 | you more information about the status of the floating point hardware. |
5152 | ||
5153 | @table @code | |
5154 | @item info float | |
5155 | @kindex info float | |
5156 | If available, provides hardware-dependent information about the floating | |
5157 | point unit. The exact contents and layout vary depending on the | |
5158 | floating point chip. | |
5159 | @end table | |
5160 | @c FIXME: this is a cop-out. Try to get examples, explanations. Only | |
e251e767 RP |
5161 | @c FIXME...supported currently on arm's and 386's. Mark properly with |
5162 | @c FIXME... m4 macros to isolate general statements from hardware-dep, | |
70b88761 | 5163 | @c FIXME... at that point. |
18fae2a8 | 5164 | @end ifclear |
70b88761 | 5165 | |
18fae2a8 | 5166 | @ifclear CONLY |
4eb4cf57 | 5167 | @node Languages |
18fae2a8 | 5168 | @chapter Using @value{GDBN} with Different Languages |
c2bbbb22 RP |
5169 | @cindex languages |
5170 | ||
5171 | Although programming languages generally have common aspects, they are | |
5172 | rarely expressed in the same manner. For instance, in ANSI C, | |
5173 | dereferencing a pointer @code{p} is accomplished by @code{*p}, but in | |
5174 | Modula-2, it is accomplished by @code{p^}. Values can also be | |
5175 | represented (and displayed) differently. Hex numbers in C are written | |
5176 | like @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}. | |
5177 | ||
5178 | @cindex working language | |
18fae2a8 | 5179 | Language-specific information is built into @value{GDBN} for some languages, |
29a2b744 | 5180 | allowing you to express operations like the above in your program's |
18fae2a8 | 5181 | native language, and allowing @value{GDBN} to output values in a manner |
29a2b744 | 5182 | consistent with the syntax of your program's native language. The |
c2bbbb22 | 5183 | language you use to build expressions, called the @dfn{working |
18fae2a8 | 5184 | language}, can be selected manually, or @value{GDBN} can set it |
c2bbbb22 RP |
5185 | automatically. |
5186 | ||
5187 | @menu | |
5188 | * Setting:: Switching between source languages | |
5189 | * Show:: Displaying the language | |
5190 | * Checks:: Type and Range checks | |
5191 | * Support:: Supported languages | |
5192 | @end menu | |
5193 | ||
4eb4cf57 | 5194 | @node Setting |
c2bbbb22 RP |
5195 | @section Switching between source languages |
5196 | ||
18fae2a8 | 5197 | There are two ways to control the working language---either have @value{GDBN} |
c2bbbb22 | 5198 | set it automatically, or select it manually yourself. You can use the |
18fae2a8 | 5199 | @code{set language} command for either purpose. On startup, @value{GDBN} |
c2bbbb22 RP |
5200 | defaults to setting the language automatically. |
5201 | ||
5202 | @menu | |
5203 | * Manually:: Setting the working language manually | |
18fae2a8 | 5204 | * Automatically:: Having @value{GDBN} infer the source language |
c2bbbb22 RP |
5205 | @end menu |
5206 | ||
4eb4cf57 | 5207 | @node Manually |
c2bbbb22 RP |
5208 | @subsection Setting the working language |
5209 | ||
5210 | @kindex set language | |
5211 | To set the language, issue the command @samp{set language @var{lang}}, | |
c338a2fd RP |
5212 | where @var{lang} is the name of a language: @code{c} or @code{modula-2}. |
5213 | For a list of the supported languages, type @samp{set language}. | |
c2bbbb22 | 5214 | |
18fae2a8 | 5215 | Setting the language manually prevents @value{GDBN} from updating the working |
c2bbbb22 RP |
5216 | language automatically. This can lead to confusion if you try |
5217 | to debug a program when the working language is not the same as the | |
5218 | source language, when an expression is acceptable to both | |
5219 | languages---but means different things. For instance, if the current | |
18fae2a8 | 5220 | source file were written in C, and @value{GDBN} was parsing Modula-2, a |
c2bbbb22 RP |
5221 | command such as: |
5222 | ||
5223 | @example | |
5224 | print a = b + c | |
5225 | @end example | |
5226 | ||
5227 | @noindent | |
5228 | might not have the effect you intended. In C, this means to add | |
5229 | @code{b} and @code{c} and place the result in @code{a}. The result | |
5230 | printed would be the value of @code{a}. In Modula-2, this means to compare | |
5231 | @code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value. | |
5232 | ||
18fae2a8 | 5233 | If you allow @value{GDBN} to set the language automatically, then |
c2bbbb22 RP |
5234 | you can count on expressions evaluating the same way in your debugging |
5235 | session and in your program. | |
5236 | ||
4eb4cf57 | 5237 | @node Automatically |
18fae2a8 | 5238 | @subsection Having @value{GDBN} infer the source language |
c2bbbb22 | 5239 | |
18fae2a8 RP |
5240 | To have @value{GDBN} set the working language automatically, use @samp{set |
5241 | language local} or @samp{set language auto}. @value{GDBN} then infers the | |
c2bbbb22 RP |
5242 | language that a program was written in by looking at the name of its |
5243 | source files, and examining their extensions: | |
5244 | ||
5245 | @table @file | |
5246 | @item *.mod | |
5247 | Modula-2 source file | |
5248 | ||
5249 | @item *.c | |
5a2c1d85 RP |
5250 | C source file |
5251 | ||
5252 | @item *.C | |
c2bbbb22 | 5253 | @itemx *.cc |
5a2c1d85 | 5254 | C++ source file |
c2bbbb22 RP |
5255 | @end table |
5256 | ||
5257 | This information is recorded for each function or procedure in a source | |
5258 | file. When your program stops in a frame (usually by encountering a | |
18fae2a8 | 5259 | breakpoint), @value{GDBN} sets the working language to the language recorded |
c2bbbb22 RP |
5260 | for the function in that frame. If the language for a frame is unknown |
5261 | (that is, if the function or block corresponding to the frame was | |
5262 | defined in a source file that does not have a recognized extension), the | |
18fae2a8 | 5263 | current working language is not changed, and @value{GDBN} issues a warning. |
c2bbbb22 RP |
5264 | |
5265 | This may not seem necessary for most programs, which are written | |
5266 | entirely in one source language. However, program modules and libraries | |
5267 | written in one source language can be used by a main program written in | |
5268 | a different source language. Using @samp{set language auto} in this | |
5269 | case frees you from having to set the working language manually. | |
5270 | ||
4eb4cf57 | 5271 | @node Show |
c2bbbb22 RP |
5272 | @section Displaying the language |
5273 | ||
5274 | The following commands will help you find out which language is the | |
5275 | working language, and also what language source files were written in. | |
5276 | ||
5277 | @kindex show language | |
5278 | @kindex info frame | |
5279 | @kindex info source | |
5280 | @table @code | |
5281 | @item show language | |
5282 | Display the current working language. This is the | |
5283 | language you can use with commands such as @code{print} to | |
29a2b744 | 5284 | build and compute expressions that may involve variables in your program. |
c2bbbb22 RP |
5285 | |
5286 | @item info frame | |
1041a570 | 5287 | Among the other information listed here (@pxref{Frame Info, ,Information |
c2bbbb22 RP |
5288 | about a Frame}) is the source language for this frame. This is the |
5289 | language that will become the working language if you ever use an | |
5290 | identifier that is in this frame. | |
5291 | ||
5292 | @item info source | |
1041a570 | 5293 | Among the other information listed here (@pxref{Symbols, ,Examining the |
c2bbbb22 | 5294 | Symbol Table}) is the source language of this source file. |
c2bbbb22 RP |
5295 | @end table |
5296 | ||
4eb4cf57 | 5297 | @node Checks |
c2bbbb22 RP |
5298 | @section Type and range Checking |
5299 | ||
5300 | @quotation | |
18fae2a8 | 5301 | @emph{Warning:} In this release, the @value{GDBN} commands for type and range |
c2bbbb22 RP |
5302 | checking are included, but they do not yet have any effect. This |
5303 | section documents the intended facilities. | |
5304 | @end quotation | |
5305 | @c FIXME remove warning when type/range code added | |
5306 | ||
5307 | Some languages are designed to guard you against making seemingly common | |
5308 | errors through a series of compile- and run-time checks. These include | |
5309 | checking the type of arguments to functions and operators, and making | |
5310 | sure mathematical overflows are caught at run time. Checks such as | |
5311 | these help to ensure a program's correctness once it has been compiled | |
5312 | by eliminating type mismatches, and providing active checks for range | |
29a2b744 | 5313 | errors when your program is running. |
c2bbbb22 | 5314 | |
18fae2a8 RP |
5315 | @value{GDBN} can check for conditions like the above if you wish. |
5316 | Although @value{GDBN} will not check the statements in your program, it | |
5317 | can check expressions entered directly into @value{GDBN} for evaluation via | |
1041a570 | 5318 | the @code{print} command, for example. As with the working language, |
18fae2a8 | 5319 | @value{GDBN} can also decide whether or not to check automatically based on |
1041a570 RP |
5320 | your program's source language. @xref{Support, ,Supported Languages}, |
5321 | for the default settings of supported languages. | |
c2bbbb22 RP |
5322 | |
5323 | @menu | |
5324 | * Type Checking:: An overview of type checking | |
5325 | * Range Checking:: An overview of range checking | |
5326 | @end menu | |
5327 | ||
5328 | @cindex type checking | |
5329 | @cindex checks, type | |
4eb4cf57 | 5330 | @node Type Checking |
c2bbbb22 RP |
5331 | @subsection An overview of type checking |
5332 | ||
5333 | Some languages, such as Modula-2, are strongly typed, meaning that the | |
5334 | arguments to operators and functions have to be of the correct type, | |
5335 | otherwise an error occurs. These checks prevent type mismatch | |
5336 | errors from ever causing any run-time problems. For example, | |
5337 | ||
5338 | @example | |
5339 | 1 + 2 @result{} 3 | |
1041a570 | 5340 | @exdent but |
c2bbbb22 RP |
5341 | @error{} 1 + 2.3 |
5342 | @end example | |
5343 | ||
5344 | The second example fails because the @code{CARDINAL} 1 is not | |
5345 | type-compatible with the @code{REAL} 2.3. | |
5346 | ||
18fae2a8 | 5347 | For expressions you use in @value{GDBN} commands, you can tell the @value{GDBN} |
c2bbbb22 RP |
5348 | type checker to skip checking; to treat any mismatches as errors and |
5349 | abandon the expression; or only issue warnings when type mismatches | |
5350 | occur, but evaluate the expression anyway. When you choose the last of | |
18fae2a8 | 5351 | these, @value{GDBN} evaluates expressions like the second example above, but |
c2bbbb22 RP |
5352 | also issues a warning. |
5353 | ||
5354 | Even though you may turn type checking off, other type-based reasons may | |
18fae2a8 | 5355 | prevent @value{GDBN} from evaluating an expression. For instance, @value{GDBN} does not |
c2bbbb22 RP |
5356 | know how to add an @code{int} and a @code{struct foo}. These particular |
5357 | type errors have nothing to do with the language in use, and usually | |
5358 | arise from expressions, such as the one described above, which make | |
5359 | little sense to evaluate anyway. | |
5360 | ||
5361 | Each language defines to what degree it is strict about type. For | |
5362 | instance, both Modula-2 and C require the arguments to arithmetical | |
5363 | operators to be numbers. In C, enumerated types and pointers can be | |
5364 | represented as numbers, so that they are valid arguments to mathematical | |
1041a570 | 5365 | operators. @xref{Support, ,Supported Languages}, for further |
c2bbbb22 RP |
5366 | details on specific languages. |
5367 | ||
18fae2a8 | 5368 | @value{GDBN} provides some additional commands for controlling the type checker: |
c2bbbb22 RP |
5369 | |
5370 | @kindex set check | |
5371 | @kindex set check type | |
5372 | @kindex show check type | |
5373 | @table @code | |
5374 | @item set check type auto | |
e251e767 | 5375 | Set type checking on or off based on the current working language. |
1041a570 | 5376 | @xref{Support, ,Supported Languages}, for the default settings for |
c2bbbb22 RP |
5377 | each language. |
5378 | ||
5379 | @item set check type on | |
5380 | @itemx set check type off | |
5381 | Set type checking on or off, overriding the default setting for the | |
5382 | current working language. Issue a warning if the setting does not | |
5383 | match the language's default. If any type mismatches occur in | |
18fae2a8 | 5384 | evaluating an expression while typechecking is on, @value{GDBN} prints a |
c2bbbb22 RP |
5385 | message and aborts evaluation of the expression. |
5386 | ||
5387 | @item set check type warn | |
5388 | Cause the type checker to issue warnings, but to always attempt to | |
5389 | evaluate the expression. Evaluating the expression may still | |
18fae2a8 | 5390 | be impossible for other reasons. For example, @value{GDBN} cannot add |
c2bbbb22 RP |
5391 | numbers and structures. |
5392 | ||
5393 | @item show type | |
18fae2a8 | 5394 | Show the current setting of the type checker, and whether or not @value{GDBN} is |
c2bbbb22 RP |
5395 | setting it automatically. |
5396 | @end table | |
5397 | ||
5398 | @cindex range checking | |
5399 | @cindex checks, range | |
4eb4cf57 | 5400 | @node Range Checking |
c2bbbb22 RP |
5401 | @subsection An overview of Range Checking |
5402 | ||
5403 | In some languages (such as Modula-2), it is an error to exceed the | |
5404 | bounds of a type; this is enforced with run-time checks. Such range | |
5405 | checking is meant to ensure program correctness by making sure | |
5406 | computations do not overflow, or indices on an array element access do | |
5407 | not exceed the bounds of the array. | |
5408 | ||
18fae2a8 | 5409 | For expressions you use in @value{GDBN} commands, you can tell @value{GDBN} to |
c2bbbb22 RP |
5410 | ignore range errors; to always treat them as errors and abandon the |
5411 | expression; or to issue warnings when a range error occurs but evaluate | |
5412 | the expression anyway. | |
5413 | ||
5414 | A range error can result from numerical overflow, from exceeding an | |
5415 | array index bound, or when you type in a constant that is not a member | |
5416 | of any type. Some languages, however, do not treat overflows as an | |
5417 | error. In many implementations of C, mathematical overflow causes the | |
5418 | result to ``wrap around'' to lower values---for example, if @var{m} is | |
5419 | the largest integer value, and @var{s} is the smallest, then | |
1041a570 | 5420 | |
c2bbbb22 RP |
5421 | @example |
5422 | @var{m} + 1 @result{} @var{s} | |
5423 | @end example | |
5424 | ||
5425 | This, too, is specific to individual languages, and in some cases | |
1041a570 | 5426 | specific to individual compilers or machines. @xref{Support, , |
c2bbbb22 RP |
5427 | Supported Languages}, for further details on specific languages. |
5428 | ||
18fae2a8 | 5429 | @value{GDBN} provides some additional commands for controlling the range checker: |
c2bbbb22 RP |
5430 | |
5431 | @kindex set check | |
5432 | @kindex set check range | |
5433 | @kindex show check range | |
5434 | @table @code | |
5435 | @item set check range auto | |
e251e767 | 5436 | Set range checking on or off based on the current working language. |
1041a570 | 5437 | @xref{Support, ,Supported Languages}, for the default settings for |
c2bbbb22 RP |
5438 | each language. |
5439 | ||
5440 | @item set check range on | |
5441 | @itemx set check range off | |
5442 | Set range checking on or off, overriding the default setting for the | |
5443 | current working language. A warning is issued if the setting does not | |
5444 | match the language's default. If a range error occurs, then a message | |
5445 | is printed and evaluation of the expression is aborted. | |
5446 | ||
5447 | @item set check range warn | |
18fae2a8 | 5448 | Output messages when the @value{GDBN} range checker detects a range error, |
c2bbbb22 RP |
5449 | but attempt to evaluate the expression anyway. Evaluating the |
5450 | expression may still be impossible for other reasons, such as accessing | |
5451 | memory that the process does not own (a typical example from many UNIX | |
5452 | systems). | |
5453 | ||
5454 | @item show range | |
e251e767 | 5455 | Show the current setting of the range checker, and whether or not it is |
18fae2a8 | 5456 | being set automatically by @value{GDBN}. |
c2bbbb22 RP |
5457 | @end table |
5458 | ||
4eb4cf57 | 5459 | @node Support |
c2bbbb22 RP |
5460 | @section Supported Languages |
5461 | ||
18fae2a8 | 5462 | @value{GDBN} 4 supports C, C++, and Modula-2. Some @value{GDBN} |
1041a570 | 5463 | features may be used in expressions regardless of the language you |
18fae2a8 | 5464 | use: the @value{GDBN} @code{@@} and @code{::} operators, and the |
1041a570 RP |
5465 | @samp{@{type@}addr} construct (@pxref{Expressions, ,Expressions}) can be |
5466 | used with the constructs of any of the supported languages. | |
c2bbbb22 RP |
5467 | |
5468 | The following sections detail to what degree each of these | |
18fae2a8 | 5469 | source languages is supported by @value{GDBN}. These sections are |
c2bbbb22 | 5470 | not meant to be language tutorials or references, but serve only as a |
18fae2a8 | 5471 | reference guide to what the @value{GDBN} expression parser will accept, and |
c2bbbb22 RP |
5472 | what input and output formats should look like for different languages. |
5473 | There are many good books written on each of these languages; please | |
5474 | look to these for a language reference or tutorial. | |
5475 | ||
5476 | @menu | |
5477 | * C:: C and C++ | |
5478 | * Modula-2:: Modula-2 | |
5479 | @end menu | |
5480 | ||
4eb4cf57 | 5481 | @node C |
c2bbbb22 RP |
5482 | @subsection C and C++ |
5483 | @cindex C and C++ | |
c2bbbb22 | 5484 | @cindex expressions in C or C++ |
0f153e74 | 5485 | |
18fae2a8 | 5486 | Since C and C++ are so closely related, many features of @value{GDBN} apply |
5a2c1d85 RP |
5487 | to both languages. Whenever this is the case, we discuss both languages |
5488 | together. | |
b80282d5 RP |
5489 | |
5490 | @cindex C++ | |
5491 | @kindex g++ | |
5492 | @cindex GNU C++ | |
c2bbbb22 | 5493 | The C++ debugging facilities are jointly implemented by the GNU C++ |
18fae2a8 | 5494 | compiler and @value{GDBN}. Therefore, to debug your C++ code effectively, |
c2bbbb22 RP |
5495 | you must compile your C++ programs with the GNU C++ compiler, |
5496 | @code{g++}. | |
18fae2a8 RP |
5497 | @end ifclear |
5498 | @ifset CONLY | |
0f153e74 RP |
5499 | @node C |
5500 | @chapter C Language Support | |
5501 | @cindex C language | |
5502 | @cindex expressions in C | |
5503 | ||
18fae2a8 RP |
5504 | Information specific to the C language is built into @value{GDBN} so that you |
5505 | can use C expressions while degugging. This also permits @value{GDBN} to | |
0f153e74 | 5506 | output values in a manner consistent with C conventions. |
c2bbbb22 | 5507 | |
0f153e74 RP |
5508 | @menu |
5509 | * C Operators:: C Operators | |
5510 | * C Constants:: C Constants | |
18fae2a8 | 5511 | * Debugging C:: @value{GDBN} and C |
0f153e74 | 5512 | @end menu |
18fae2a8 RP |
5513 | @end ifset |
5514 | @ifclear CONLY | |
b80282d5 | 5515 | @menu |
c2bbbb22 RP |
5516 | * C Operators:: C and C++ Operators |
5517 | * C Constants:: C and C++ Constants | |
5518 | * Cplusplus expressions:: C++ Expressions | |
5519 | * C Defaults:: Default settings for C and C++ | |
5520 | * C Checks:: C and C++ Type and Range Checks | |
18fae2a8 | 5521 | * Debugging C:: @value{GDBN} and C |
c2bbbb22 | 5522 | * Debugging C plus plus:: Special features for C++ |
b80282d5 | 5523 | @end menu |
18fae2a8 | 5524 | @end ifclear |
b80282d5 | 5525 | |
18fae2a8 | 5526 | @ifclear CONLY |
c2bbbb22 | 5527 | @cindex C and C++ operators |
4eb4cf57 | 5528 | @node C Operators |
c2bbbb22 | 5529 | @subsubsection C and C++ Operators |
18fae2a8 RP |
5530 | @end ifclear |
5531 | @ifset CONLY | |
0f153e74 RP |
5532 | @cindex C operators |
5533 | @node C Operators | |
5534 | @section C Operators | |
18fae2a8 | 5535 | @end ifset |
c2bbbb22 RP |
5536 | |
5537 | Operators must be defined on values of specific types. For instance, | |
5538 | @code{+} is defined on numbers, but not on structures. Operators are | |
0f153e74 RP |
5539 | often defined on groups of types. |
5540 | ||
18fae2a8 | 5541 | @ifclear CONLY |
0f153e74 | 5542 | For the purposes of C and C++, the following definitions hold: |
18fae2a8 | 5543 | @end ifclear |
c2bbbb22 RP |
5544 | |
5545 | @itemize @bullet | |
e251e767 | 5546 | @item |
c2bbbb22 RP |
5547 | @emph{Integral types} include @code{int} with any of its storage-class |
5548 | specifiers, @code{char}, and @code{enum}s. | |
5549 | ||
5550 | @item | |
5551 | @emph{Floating-point types} include @code{float} and @code{double}. | |
5552 | ||
5553 | @item | |
5554 | @emph{Pointer types} include all types defined as @code{(@var{type} | |
5555 | *)}. | |
5556 | ||
e251e767 | 5557 | @item |
c2bbbb22 | 5558 | @emph{Scalar types} include all of the above. |
c2bbbb22 RP |
5559 | @end itemize |
5560 | ||
5561 | @noindent | |
5562 | The following operators are supported. They are listed here | |
5563 | in order of increasing precedence: | |
5564 | ||
5565 | @table @code | |
18fae2a8 | 5566 | @item , |
c2bbbb22 RP |
5567 | The comma or sequencing operator. Expressions in a comma-separated list |
5568 | are evaluated from left to right, with the result of the entire | |
5569 | expression being the last expression evaluated. | |
5570 | ||
5571 | @item = | |
5572 | Assignment. The value of an assignment expression is the value | |
5573 | assigned. Defined on scalar types. | |
5574 | ||
5575 | @item @var{op}= | |
1041a570 RP |
5576 | Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}}, |
5577 | and translated to @w{@code{@var{a} = @var{a op b}}}. | |
5578 | @w{@code{@var{op}=}} and @code{=} have the same precendence. | |
5579 | @var{op} is any one of the operators @code{|}, @code{^}, @code{&}, | |
5580 | @code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}. | |
c2bbbb22 RP |
5581 | |
5582 | @item ?: | |
5583 | The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought | |
5584 | of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an | |
5585 | integral type. | |
5586 | ||
5587 | @item || | |
1041a570 | 5588 | Logical @sc{or}. Defined on integral types. |
c2bbbb22 RP |
5589 | |
5590 | @item && | |
1041a570 | 5591 | Logical @sc{and}. Defined on integral types. |
c2bbbb22 RP |
5592 | |
5593 | @item | | |
1041a570 | 5594 | Bitwise @sc{or}. Defined on integral types. |
c2bbbb22 RP |
5595 | |
5596 | @item ^ | |
1041a570 | 5597 | Bitwise exclusive-@sc{or}. Defined on integral types. |
c2bbbb22 RP |
5598 | |
5599 | @item & | |
1041a570 | 5600 | Bitwise @sc{and}. Defined on integral types. |
c2bbbb22 RP |
5601 | |
5602 | @item ==@r{, }!= | |
5603 | Equality and inequality. Defined on scalar types. The value of these | |
5604 | expressions is 0 for false and non-zero for true. | |
5605 | ||
5606 | @item <@r{, }>@r{, }<=@r{, }>= | |
5607 | Less than, greater than, less than or equal, greater than or equal. | |
5608 | Defined on scalar types. The value of these expressions is 0 for false | |
5609 | and non-zero for true. | |
5610 | ||
5611 | @item <<@r{, }>> | |
18fae2a8 | 5612 | left shift, and right shift. Defined on integral types. |
c2bbbb22 | 5613 | |
e251e767 | 5614 | @item @@ |
18fae2a8 | 5615 | The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}). |
c2bbbb22 RP |
5616 | |
5617 | @item +@r{, }- | |
5618 | Addition and subtraction. Defined on integral types, floating-point types and | |
e251e767 | 5619 | pointer types. |
c2bbbb22 RP |
5620 | |
5621 | @item *@r{, }/@r{, }% | |
5622 | Multiplication, division, and modulus. Multiplication and division are | |
5623 | defined on integral and floating-point types. Modulus is defined on | |
5624 | integral types. | |
5625 | ||
5626 | @item ++@r{, }-- | |
5627 | Increment and decrement. When appearing before a variable, the | |
5628 | operation is performed before the variable is used in an expression; | |
5629 | when appearing after it, the variable's value is used before the | |
5630 | operation takes place. | |
5631 | ||
5632 | @item * | |
5633 | Pointer dereferencing. Defined on pointer types. Same precedence as | |
5634 | @code{++}. | |
5635 | ||
5636 | @item & | |
5637 | Address operator. Defined on variables. Same precedence as @code{++}. | |
5638 | ||
18fae2a8 RP |
5639 | @ifclear CONLY |
5640 | For debugging C++, @value{GDBN} implements a use of @samp{&} beyond what's | |
6ca72cc6 RP |
5641 | allowed in the C++ language itself: you can use @samp{&(&@var{ref})} |
5642 | (or, if you prefer, simply @samp{&&@var{ref}} to examine the address | |
5643 | where a C++ reference variable (declared with @samp{&@var{ref}}) is | |
5644 | stored. | |
18fae2a8 | 5645 | @end ifclear |
6ca72cc6 | 5646 | |
c2bbbb22 RP |
5647 | @item - |
5648 | Negative. Defined on integral and floating-point types. Same | |
5649 | precedence as @code{++}. | |
5650 | ||
5651 | @item ! | |
5652 | Logical negation. Defined on integral types. Same precedence as | |
5653 | @code{++}. | |
5654 | ||
5655 | @item ~ | |
5656 | Bitwise complement operator. Defined on integral types. Same precedence as | |
5657 | @code{++}. | |
5658 | ||
18fae2a8 | 5659 | |
c2bbbb22 RP |
5660 | @item .@r{, }-> |
5661 | Structure member, and pointer-to-structure member. For convenience, | |
18fae2a8 | 5662 | @value{GDBN} regards the two as equivalent, choosing whether to dereference a |
e251e767 | 5663 | pointer based on the stored type information. |
c2bbbb22 RP |
5664 | Defined on @code{struct}s and @code{union}s. |
5665 | ||
5666 | @item [] | |
5667 | Array indexing. @code{@var{a}[@var{i}]} is defined as | |
5668 | @code{*(@var{a}+@var{i})}. Same precedence as @code{->}. | |
5669 | ||
5670 | @item () | |
18fae2a8 | 5671 | Function parameter list. Same precedence as @code{->}. |
c2bbbb22 | 5672 | |
18fae2a8 | 5673 | @ifclear CONLY |
c2bbbb22 RP |
5674 | @item :: |
5675 | C++ scope resolution operator. Defined on | |
5676 | @code{struct}, @code{union}, and @code{class} types. | |
18fae2a8 | 5677 | @end ifclear |
c2bbbb22 RP |
5678 | |
5679 | @item :: | |
18fae2a8 RP |
5680 | The @value{GDBN} scope operator (@pxref{Expressions, ,Expressions}). |
5681 | @ifclear CONLY | |
0f153e74 | 5682 | Same precedence as @code{::}, above. |
18fae2a8 | 5683 | @end ifclear |
c2bbbb22 RP |
5684 | @end table |
5685 | ||
18fae2a8 | 5686 | @ifclear CONLY |
c2bbbb22 | 5687 | @cindex C and C++ constants |
4eb4cf57 | 5688 | @node C Constants |
c2bbbb22 | 5689 | @subsubsection C and C++ Constants |
0f153e74 | 5690 | |
18fae2a8 | 5691 | @value{GDBN} allows you to express the constants of C and C++ in the |
0f153e74 | 5692 | following ways: |
18fae2a8 RP |
5693 | @end ifclear |
5694 | @ifset CONLY | |
0f153e74 RP |
5695 | @cindex C constants |
5696 | @node C Constants | |
5697 | @section C Constants | |
c2bbbb22 | 5698 | |
18fae2a8 | 5699 | @value{GDBN} allows you to express the constants of C in the |
c2bbbb22 | 5700 | following ways: |
18fae2a8 | 5701 | @end ifset |
c2bbbb22 RP |
5702 | |
5703 | @itemize @bullet | |
c2bbbb22 RP |
5704 | @item |
5705 | Integer constants are a sequence of digits. Octal constants are | |
5706 | specified by a leading @samp{0} (ie. zero), and hexadecimal constants by | |
1041a570 | 5707 | a leading @samp{0x} or @samp{0X}. Constants may also end with a letter |
c2bbbb22 RP |
5708 | @samp{l}, specifying that the constant should be treated as a |
5709 | @code{long} value. | |
5710 | ||
5711 | @item | |
5712 | Floating point constants are a sequence of digits, followed by a decimal | |
5713 | point, followed by a sequence of digits, and optionally followed by an | |
5714 | exponent. An exponent is of the form: | |
5715 | @samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another | |
5716 | sequence of digits. The @samp{+} is optional for positive exponents. | |
5717 | ||
5718 | @item | |
5719 | Enumerated constants consist of enumerated identifiers, or their | |
5720 | integral equivalents. | |
5721 | ||
5722 | @item | |
5723 | Character constants are a single character surrounded by single quotes | |
5724 | (@code{'}), or a number---the ordinal value of the corresponding character | |
5725 | (usually its @sc{ASCII} value). Within quotes, the single character may | |
5726 | be represented by a letter or by @dfn{escape sequences}, which are of | |
5727 | the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation | |
5728 | of the character's ordinal value; or of the form @samp{\@var{x}}, where | |
5729 | @samp{@var{x}} is a predefined special character---for example, | |
5730 | @samp{\n} for newline. | |
5731 | ||
5732 | @item | |
5733 | String constants are a sequence of character constants surrounded | |
5734 | by double quotes (@code{"}). | |
5735 | ||
5736 | @item | |
5737 | Pointer constants are an integral value. | |
c2bbbb22 RP |
5738 | @end itemize |
5739 | ||
18fae2a8 | 5740 | @ifclear CONLY |
0f153e74 | 5741 | @node Cplusplus expressions |
c2bbbb22 | 5742 | @subsubsection C++ Expressions |
b80282d5 RP |
5743 | |
5744 | @cindex expressions in C++ | |
18fae2a8 | 5745 | @value{GDBN}'s expression handling has a number of extensions to |
b1385986 RP |
5746 | interpret a significant subset of C++ expressions. |
5747 | ||
5748 | @cindex C++ support, not in @sc{coff} | |
5749 | @cindex @sc{coff} versus C++ | |
5750 | @cindex C++ and object formats | |
5751 | @cindex object formats and C++ | |
5752 | @cindex a.out and C++ | |
5753 | @cindex @sc{ecoff} and C++ | |
5754 | @cindex @sc{xcoff} and C++ | |
5755 | @cindex @sc{elf}/stabs and C++ | |
5756 | @cindex @sc{elf}/@sc{dwarf} and C++ | |
5757 | @quotation | |
5758 | @emph{Warning:} Most of these extensions depend on the use of additional | |
5759 | debugging information in the symbol table, and thus require a rich, | |
5760 | extendable object code format. In particular, if your system uses | |
5761 | a.out, MIPS @sc{ecoff}, RS/6000 @sc{xcoff}, or Sun @sc{elf} with stabs | |
5762 | extensions to the symbol table, these facilities are all available. | |
5763 | Where the object code format is standard @sc{coff}, on the other hand, | |
18fae2a8 | 5764 | most of the C++ support in @value{GDBN} will @emph{not} work, nor can it. |
b1385986 | 5765 | For the standard SVr4 debugging format, @sc{dwarf} in @sc{elf}, the |
18fae2a8 | 5766 | standard is still evolving, so the C++ support in @value{GDBN} is still |
b1385986 RP |
5767 | fragile; when this debugging format stabilizes, however, C++ support |
5768 | will also be available on systems that use it. | |
5769 | @end quotation | |
b80282d5 RP |
5770 | |
5771 | @enumerate | |
5772 | ||
5773 | @cindex member functions | |
e251e767 | 5774 | @item |
b80282d5 | 5775 | Member function calls are allowed; you can use expressions like |
1041a570 | 5776 | |
b80282d5 RP |
5777 | @example |
5778 | count = aml->GetOriginal(x, y) | |
5779 | @end example | |
5780 | ||
5781 | @kindex this | |
5782 | @cindex namespace in C++ | |
e251e767 | 5783 | @item |
b80282d5 RP |
5784 | While a member function is active (in the selected stack frame), your |
5785 | expressions have the same namespace available as the member function; | |
18fae2a8 | 5786 | that is, @value{GDBN} allows implicit references to the class instance |
b80282d5 RP |
5787 | pointer @code{this} following the same rules as C++. |
5788 | ||
5789 | @cindex call overloaded functions | |
5790 | @cindex type conversions in C++ | |
e251e767 | 5791 | @item |
18fae2a8 | 5792 | You can call overloaded functions; @value{GDBN} will resolve the function |
b80282d5 RP |
5793 | call to the right definition, with one restriction---you must use |
5794 | arguments of the type required by the function that you want to call. | |
18fae2a8 | 5795 | @value{GDBN} will not perform conversions requiring constructors or |
b80282d5 RP |
5796 | user-defined type operators. |
5797 | ||
5798 | @cindex reference declarations | |
5799 | @item | |
18fae2a8 | 5800 | @value{GDBN} understands variables declared as C++ references; you can use them in |
b80282d5 | 5801 | expressions just as you do in C++ source---they are automatically |
e251e767 | 5802 | dereferenced. |
b80282d5 | 5803 | |
18fae2a8 | 5804 | In the parameter list shown when @value{GDBN} displays a frame, the values of |
b80282d5 RP |
5805 | reference variables are not displayed (unlike other variables); this |
5806 | avoids clutter, since references are often used for large structures. | |
5807 | The @emph{address} of a reference variable is always shown, unless | |
1041a570 | 5808 | you have specified @samp{set print address off}. |
b80282d5 RP |
5809 | |
5810 | @item | |
18fae2a8 | 5811 | @value{GDBN} supports the C++ name resolution operator @code{::}---your |
c2bbbb22 RP |
5812 | expressions can use it just as expressions in your program do. Since |
5813 | one scope may be defined in another, you can use @code{::} repeatedly if | |
5814 | necessary, for example in an expression like | |
18fae2a8 | 5815 | @samp{@var{scope1}::@var{scope2}::@var{name}}. @value{GDBN} also allows |
c2bbbb22 | 5816 | resolving name scope by reference to source files, in both C and C++ |
1041a570 | 5817 | debugging (@pxref{Variables, ,Program Variables}). |
b80282d5 RP |
5818 | @end enumerate |
5819 | ||
4eb4cf57 | 5820 | @node C Defaults |
c2bbbb22 RP |
5821 | @subsubsection C and C++ Defaults |
5822 | @cindex C and C++ defaults | |
5823 | ||
18fae2a8 | 5824 | If you allow @value{GDBN} to set type and range checking automatically, they |
e251e767 | 5825 | both default to @code{off} whenever the working language changes to |
18fae2a8 | 5826 | C or C++. This happens regardless of whether you, or @value{GDBN}, |
c2bbbb22 RP |
5827 | selected the working language. |
5828 | ||
18fae2a8 | 5829 | If you allow @value{GDBN} to set the language automatically, it sets the |
5a2c1d85 RP |
5830 | working language to C or C++ on entering code compiled from a source file |
5831 | whose name ends with @file{.c}, @file{.C}, or @file{.cc}. | |
18fae2a8 | 5832 | @xref{Automatically, ,Having @value{GDBN} infer the source language}, for |
c2bbbb22 RP |
5833 | further details. |
5834 | ||
4eb4cf57 | 5835 | @node C Checks |
c2bbbb22 RP |
5836 | @subsubsection C and C++ Type and Range Checks |
5837 | @cindex C and C++ checks | |
5838 | ||
5839 | @quotation | |
18fae2a8 | 5840 | @emph{Warning:} in this release, @value{GDBN} does not yet perform type or |
c2bbbb22 RP |
5841 | range checking. |
5842 | @end quotation | |
5843 | @c FIXME remove warning when type/range checks added | |
5844 | ||
18fae2a8 RP |
5845 | By default, when @value{GDBN} parses C or C++ expressions, type checking |
5846 | is not used. However, if you turn type checking on, @value{GDBN} will | |
c2bbbb22 RP |
5847 | consider two variables type equivalent if: |
5848 | ||
5849 | @itemize @bullet | |
5850 | @item | |
5851 | The two variables are structured and have the same structure, union, or | |
5852 | enumerated tag. | |
5853 | ||
e251e767 | 5854 | @item |
c2bbbb22 RP |
5855 | Two two variables have the same type name, or types that have been |
5856 | declared equivalent through @code{typedef}. | |
5857 | ||
5858 | @ignore | |
5859 | @c leaving this out because neither J Gilmore nor R Pesch understand it. | |
5860 | @c FIXME--beers? | |
5861 | @item | |
5862 | The two @code{struct}, @code{union}, or @code{enum} variables are | |
5863 | declared in the same declaration. (Note: this may not be true for all C | |
5864 | compilers.) | |
5865 | @end ignore | |
c2bbbb22 RP |
5866 | @end itemize |
5867 | ||
5868 | Range checking, if turned on, is done on mathematical operations. Array | |
5869 | indices are not checked, since they are often used to index a pointer | |
5870 | that is not itself an array. | |
18fae2a8 | 5871 | @end ifclear |
c2bbbb22 | 5872 | |
18fae2a8 | 5873 | @ifclear CONLY |
4eb4cf57 | 5874 | @node Debugging C |
18fae2a8 RP |
5875 | @subsubsection @value{GDBN} and C |
5876 | @end ifclear | |
5877 | @ifset CONLY | |
5878 | @node Debugging C | |
5879 | @section @value{GDBN} and C | |
5880 | @end ifset | |
c2bbbb22 RP |
5881 | |
5882 | The @code{set print union} and @code{show print union} commands apply to | |
5883 | the @code{union} type. When set to @samp{on}, any @code{union} that is | |
5884 | inside a @code{struct} or @code{class} will also be printed. | |
5885 | Otherwise, it will appear as @samp{@{...@}}. | |
5886 | ||
5887 | The @code{@@} operator aids in the debugging of dynamic arrays, formed | |
1041a570 | 5888 | with pointers and a memory allocation function. (@pxref{Expressions, ,Expressions}) |
c2bbbb22 | 5889 | |
18fae2a8 | 5890 | @ifclear CONLY |
4eb4cf57 | 5891 | @node Debugging C plus plus |
18fae2a8 | 5892 | @subsubsection @value{GDBN} Features for C++ |
b80282d5 RP |
5893 | |
5894 | @cindex commands for C++ | |
18fae2a8 | 5895 | Some @value{GDBN} commands are particularly useful with C++, and some are |
b80282d5 RP |
5896 | designed specifically for use with C++. Here is a summary: |
5897 | ||
5898 | @table @code | |
5899 | @cindex break in overloaded functions | |
5900 | @item @r{breakpoint menus} | |
5901 | When you want a breakpoint in a function whose name is overloaded, | |
18fae2a8 | 5902 | @value{GDBN}'s breakpoint menus help you specify which function definition |
b80282d5 RP |
5903 | you want. @xref{Breakpoint Menus}. |
5904 | ||
5905 | @cindex overloading in C++ | |
5906 | @item rbreak @var{regex} | |
5907 | Setting breakpoints using regular expressions is helpful for setting | |
5908 | breakpoints on overloaded functions that are not members of any special | |
e251e767 | 5909 | classes. |
29a2b744 | 5910 | @xref{Set Breaks, ,Setting Breakpoints}. |
b80282d5 RP |
5911 | |
5912 | @cindex C++ exception handling | |
5913 | @item catch @var{exceptions} | |
5914 | @itemx info catch | |
29a2b744 | 5915 | Debug C++ exception handling using these commands. @xref{Exception |
1041a570 | 5916 | Handling, ,Breakpoints and Exceptions}. |
b80282d5 | 5917 | |
e251e767 | 5918 | @cindex inheritance |
b80282d5 RP |
5919 | @item ptype @var{typename} |
5920 | Print inheritance relationships as well as other information for type | |
e251e767 | 5921 | @var{typename}. |
1041a570 | 5922 | @xref{Symbols, ,Examining the Symbol Table}. |
b80282d5 RP |
5923 | |
5924 | @cindex C++ symbol display | |
5925 | @item set print demangle | |
5926 | @itemx show print demangle | |
5927 | @itemx set print asm-demangle | |
5928 | @itemx show print asm-demangle | |
5929 | Control whether C++ symbols display in their source form, both when | |
5930 | displaying code as C++ source and when displaying disassemblies. | |
1041a570 | 5931 | @xref{Print Settings, ,Print Settings}. |
b80282d5 RP |
5932 | |
5933 | @item set print object | |
5934 | @itemx show print object | |
e251e767 | 5935 | Choose whether to print derived (actual) or declared types of objects. |
1041a570 | 5936 | @xref{Print Settings, ,Print Settings}. |
b80282d5 RP |
5937 | |
5938 | @item set print vtbl | |
5939 | @itemx show print vtbl | |
5940 | Control the format for printing virtual function tables. | |
1041a570 | 5941 | @xref{Print Settings, ,Print Settings}. |
6f3ec223 RP |
5942 | |
5943 | @item @r{Overloaded symbol names} | |
5944 | You can specify a particular definition of an overloaded symbol, using | |
5945 | the same notation that's used to declare such symbols in C++: type | |
5946 | @code{@var{symbol}(@var{types})} rather than just @var{symbol}. You can | |
18fae2a8 | 5947 | also use @value{GDBN}'s command-line word completion facilities to list the |
6f3ec223 RP |
5948 | available choices, or to finish the type list for you. |
5949 | @xref{Completion,, Command Completion}, for details on how to do this. | |
b80282d5 RP |
5950 | @end table |
5951 | ||
4eb4cf57 | 5952 | @node Modula-2 |
c2bbbb22 RP |
5953 | @subsection Modula-2 |
5954 | @cindex Modula-2 | |
5955 | ||
18fae2a8 | 5956 | The extensions made to @value{GDBN} to support Modula-2 support output |
c2bbbb22 RP |
5957 | from the GNU Modula-2 compiler (which is currently being developed). |
5958 | Other Modula-2 compilers are not currently supported, and attempting to | |
5959 | debug executables produced by them will most likely result in an error | |
18fae2a8 | 5960 | as @value{GDBN} reads in the executable's symbol table. |
c2bbbb22 RP |
5961 | |
5962 | @cindex expressions in Modula-2 | |
5963 | @menu | |
5964 | * M2 Operators:: Built-in operators | |
29a2b744 | 5965 | * Built-In Func/Proc:: Built-in Functions and Procedures |
c2bbbb22 RP |
5966 | * M2 Constants:: Modula-2 Constants |
5967 | * M2 Defaults:: Default settings for Modula-2 | |
5968 | * Deviations:: Deviations from standard Modula-2 | |
5969 | * M2 Checks:: Modula-2 Type and Range Checks | |
5970 | * M2 Scope:: The scope operators @code{::} and @code{.} | |
18fae2a8 | 5971 | * GDB/M2:: @value{GDBN} and Modula-2 |
c2bbbb22 RP |
5972 | @end menu |
5973 | ||
4eb4cf57 | 5974 | @node M2 Operators |
c2bbbb22 RP |
5975 | @subsubsection Operators |
5976 | @cindex Modula-2 operators | |
5977 | ||
5978 | Operators must be defined on values of specific types. For instance, | |
5979 | @code{+} is defined on numbers, but not on structures. Operators are | |
5980 | often defined on groups of types. For the purposes of Modula-2, the | |
5981 | following definitions hold: | |
5982 | ||
5983 | @itemize @bullet | |
5984 | ||
5985 | @item | |
5986 | @emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and | |
5987 | their subranges. | |
5988 | ||
5989 | @item | |
5990 | @emph{Character types} consist of @code{CHAR} and its subranges. | |
5991 | ||
5992 | @item | |
5993 | @emph{Floating-point types} consist of @code{REAL}. | |
5994 | ||
5995 | @item | |
5996 | @emph{Pointer types} consist of anything declared as @code{POINTER TO | |
5997 | @var{type}}. | |
5998 | ||
5999 | @item | |
6000 | @emph{Scalar types} consist of all of the above. | |
6001 | ||
6002 | @item | |
6003 | @emph{Set types} consist of @code{SET}s and @code{BITSET}s. | |
6004 | ||
6005 | @item | |
6006 | @emph{Boolean types} consist of @code{BOOLEAN}. | |
c2bbbb22 RP |
6007 | @end itemize |
6008 | ||
6009 | @noindent | |
6010 | The following operators are supported, and appear in order of | |
6011 | increasing precedence: | |
6012 | ||
6013 | @table @code | |
c2bbbb22 RP |
6014 | @item , |
6015 | Function argument or array index separator. | |
18fae2a8 | 6016 | |
c2bbbb22 RP |
6017 | @item := |
6018 | Assignment. The value of @var{var} @code{:=} @var{value} is | |
6019 | @var{value}. | |
6020 | ||
6021 | @item <@r{, }> | |
6022 | Less than, greater than on integral, floating-point, or enumerated | |
6023 | types. | |
6024 | ||
6025 | @item <=@r{, }>= | |
6026 | Less than, greater than, less than or equal to, greater than or equal to | |
6027 | on integral, floating-point and enumerated types, or set inclusion on | |
6028 | set types. Same precedence as @code{<}. | |
6029 | ||
6030 | @item =@r{, }<>@r{, }# | |
6031 | Equality and two ways of expressing inequality, valid on scalar types. | |
18fae2a8 | 6032 | Same precedence as @code{<}. In @value{GDBN} scripts, only @code{<>} is |
c2bbbb22 RP |
6033 | available for inequality, since @code{#} conflicts with the script |
6034 | comment character. | |
6035 | ||
6036 | @item IN | |
6037 | Set membership. Defined on set types and the types of their members. | |
6038 | Same precedence as @code{<}. | |
6039 | ||
6040 | @item OR | |
6041 | Boolean disjunction. Defined on boolean types. | |
6042 | ||
6043 | @item AND@r{, }& | |
6044 | Boolean conjuction. Defined on boolean types. | |
6045 | ||
6046 | @item @@ | |
18fae2a8 | 6047 | The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}). |
c2bbbb22 RP |
6048 | |
6049 | @item +@r{, }- | |
6050 | Addition and subtraction on integral and floating-point types, or union | |
6051 | and difference on set types. | |
6052 | ||
6053 | @item * | |
6054 | Multiplication on integral and floating-point types, or set intersection | |
6055 | on set types. | |
6056 | ||
6057 | @item / | |
6058 | Division on floating-point types, or symmetric set difference on set | |
6059 | types. Same precedence as @code{*}. | |
6060 | ||
6061 | @item DIV@r{, }MOD | |
6062 | Integer division and remainder. Defined on integral types. Same | |
6063 | precedence as @code{*}. | |
6064 | ||
6065 | @item - | |
6066 | Negative. Defined on @code{INTEGER}s and @code{REAL}s. | |
6067 | ||
6068 | @item ^ | |
e251e767 | 6069 | Pointer dereferencing. Defined on pointer types. |
c2bbbb22 RP |
6070 | |
6071 | @item NOT | |
6072 | Boolean negation. Defined on boolean types. Same precedence as | |
6073 | @code{^}. | |
6074 | ||
6075 | @item . | |
6076 | @code{RECORD} field selector. Defined on @code{RECORD}s. Same | |
6077 | precedence as @code{^}. | |
6078 | ||
6079 | @item [] | |
6080 | Array indexing. Defined on @code{ARRAY}s. Same precedence as @code{^}. | |
6081 | ||
6082 | @item () | |
6083 | Procedure argument list. Defined on @code{PROCEDURE}s. Same precedence | |
6084 | as @code{^}. | |
6085 | ||
6086 | @item ::@r{, }. | |
18fae2a8 | 6087 | @value{GDBN} and Modula-2 scope operators. |
c2bbbb22 RP |
6088 | @end table |
6089 | ||
6090 | @quotation | |
18fae2a8 | 6091 | @emph{Warning:} Sets and their operations are not yet supported, so @value{GDBN} |
c2bbbb22 RP |
6092 | will treat the use of the operator @code{IN}, or the use of operators |
6093 | @code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#}, | |
6094 | @code{<=}, and @code{>=} on sets as an error. | |
6095 | @end quotation | |
18fae2a8 | 6096 | |
29a2b744 | 6097 | @cindex Modula-2 built-ins |
4eb4cf57 | 6098 | @node Built-In Func/Proc |
c2bbbb22 RP |
6099 | @subsubsection Built-in Functions and Procedures |
6100 | ||
6101 | Modula-2 also makes available several built-in procedures and functions. | |
6102 | In describing these, the following metavariables are used: | |
6103 | ||
6104 | @table @var | |
6105 | ||
6106 | @item a | |
6107 | represents an @code{ARRAY} variable. | |
6108 | ||
6109 | @item c | |
6110 | represents a @code{CHAR} constant or variable. | |
6111 | ||
6112 | @item i | |
6113 | represents a variable or constant of integral type. | |
6114 | ||
6115 | @item m | |
6116 | represents an identifier that belongs to a set. Generally used in the | |
6117 | same function with the metavariable @var{s}. The type of @var{s} should | |
6118 | be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}. | |
6119 | ||
6120 | @item n | |
6121 | represents a variable or constant of integral or floating-point type. | |
6122 | ||
6123 | @item r | |
6124 | represents a variable or constant of floating-point type. | |
6125 | ||
6126 | @item t | |
6127 | represents a type. | |
6128 | ||
6129 | @item v | |
6130 | represents a variable. | |
6131 | ||
6132 | @item x | |
6133 | represents a variable or constant of one of many types. See the | |
6134 | explanation of the function for details. | |
c2bbbb22 RP |
6135 | @end table |
6136 | ||
6137 | All Modula-2 built-in procedures also return a result, described below. | |
6138 | ||
6139 | @table @code | |
6140 | @item ABS(@var{n}) | |
6141 | Returns the absolute value of @var{n}. | |
6142 | ||
6143 | @item CAP(@var{c}) | |
6144 | If @var{c} is a lower case letter, it returns its upper case | |
6145 | equivalent, otherwise it returns its argument | |
6146 | ||
6147 | @item CHR(@var{i}) | |
6148 | Returns the character whose ordinal value is @var{i}. | |
6149 | ||
6150 | @item DEC(@var{v}) | |
6151 | Decrements the value in the variable @var{v}. Returns the new value. | |
6152 | ||
6153 | @item DEC(@var{v},@var{i}) | |
6154 | Decrements the value in the variable @var{v} by @var{i}. Returns the | |
6155 | new value. | |
6156 | ||
6157 | @item EXCL(@var{m},@var{s}) | |
6158 | Removes the element @var{m} from the set @var{s}. Returns the new | |
6159 | set. | |
6160 | ||
6161 | @item FLOAT(@var{i}) | |
6162 | Returns the floating point equivalent of the integer @var{i}. | |
6163 | ||
6164 | @item HIGH(@var{a}) | |
6165 | Returns the index of the last member of @var{a}. | |
6166 | ||
6167 | @item INC(@var{v}) | |
6168 | Increments the value in the variable @var{v}. Returns the new value. | |
6169 | ||
6170 | @item INC(@var{v},@var{i}) | |
6171 | Increments the value in the variable @var{v} by @var{i}. Returns the | |
6172 | new value. | |
6173 | ||
6174 | @item INCL(@var{m},@var{s}) | |
6175 | Adds the element @var{m} to the set @var{s} if it is not already | |
6176 | there. Returns the new set. | |
6177 | ||
6178 | @item MAX(@var{t}) | |
6179 | Returns the maximum value of the type @var{t}. | |
6180 | ||
6181 | @item MIN(@var{t}) | |
6182 | Returns the minimum value of the type @var{t}. | |
6183 | ||
6184 | @item ODD(@var{i}) | |
6185 | Returns boolean TRUE if @var{i} is an odd number. | |
6186 | ||
6187 | @item ORD(@var{x}) | |
6188 | Returns the ordinal value of its argument. For example, the ordinal | |
6189 | value of a character is its ASCII value (on machines supporting the | |
6190 | ASCII character set). @var{x} must be of an ordered type, which include | |
6191 | integral, character and enumerated types. | |
6192 | ||
6193 | @item SIZE(@var{x}) | |
6194 | Returns the size of its argument. @var{x} can be a variable or a type. | |
6195 | ||
6196 | @item TRUNC(@var{r}) | |
6197 | Returns the integral part of @var{r}. | |
6198 | ||
6199 | @item VAL(@var{t},@var{i}) | |
6200 | Returns the member of the type @var{t} whose ordinal value is @var{i}. | |
6201 | @end table | |
6202 | ||
6203 | @quotation | |
6204 | @emph{Warning:} Sets and their operations are not yet supported, so | |
18fae2a8 | 6205 | @value{GDBN} will treat the use of procedures @code{INCL} and @code{EXCL} as |
c2bbbb22 RP |
6206 | an error. |
6207 | @end quotation | |
6208 | ||
6209 | @cindex Modula-2 constants | |
4eb4cf57 | 6210 | @node M2 Constants |
c2bbbb22 RP |
6211 | @subsubsection Constants |
6212 | ||
18fae2a8 | 6213 | @value{GDBN} allows you to express the constants of Modula-2 in the following |
c2bbbb22 RP |
6214 | ways: |
6215 | ||
6216 | @itemize @bullet | |
6217 | ||
6218 | @item | |
6219 | Integer constants are simply a sequence of digits. When used in an | |
6220 | expression, a constant is interpreted to be type-compatible with the | |
6221 | rest of the expression. Hexadecimal integers are specified by a | |
6222 | trailing @samp{H}, and octal integers by a trailing @samp{B}. | |
6223 | ||
6224 | @item | |
6225 | Floating point constants appear as a sequence of digits, followed by a | |
6226 | decimal point and another sequence of digits. An optional exponent can | |
6227 | then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where | |
6228 | @samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the | |
6229 | digits of the floating point constant must be valid decimal (base 10) | |
6230 | digits. | |
6231 | ||
6232 | @item | |
6233 | Character constants consist of a single character enclosed by a pair of | |
6234 | like quotes, either single (@code{'}) or double (@code{"}). They may | |
6235 | also be expressed by their ordinal value (their ASCII value, usually) | |
6236 | followed by a @samp{C}. | |
6237 | ||
6238 | @item | |
1041a570 RP |
6239 | String constants consist of a sequence of characters enclosed by a |
6240 | pair of like quotes, either single (@code{'}) or double (@code{"}). | |
6241 | Escape sequences in the style of C are also allowed. @xref{C | |
6242 | Constants, ,C and C++ Constants}, for a brief explanation of escape | |
6243 | sequences. | |
c2bbbb22 RP |
6244 | |
6245 | @item | |
6246 | Enumerated constants consist of an enumerated identifier. | |
6247 | ||
6248 | @item | |
6249 | Boolean constants consist of the identifiers @code{TRUE} and | |
6250 | @code{FALSE}. | |
6251 | ||
6252 | @item | |
6253 | Pointer constants consist of integral values only. | |
6254 | ||
6255 | @item | |
6256 | Set constants are not yet supported. | |
c2bbbb22 RP |
6257 | @end itemize |
6258 | ||
4eb4cf57 | 6259 | @node M2 Defaults |
c2bbbb22 RP |
6260 | @subsubsection Modula-2 Defaults |
6261 | @cindex Modula-2 defaults | |
6262 | ||
18fae2a8 | 6263 | If type and range checking are set automatically by @value{GDBN}, they |
e251e767 | 6264 | both default to @code{on} whenever the working language changes to |
18fae2a8 | 6265 | Modula-2. This happens regardless of whether you, or @value{GDBN}, |
c2bbbb22 RP |
6266 | selected the working language. |
6267 | ||
18fae2a8 | 6268 | If you allow @value{GDBN} to set the language automatically, then entering |
c2bbbb22 | 6269 | code compiled from a file whose name ends with @file{.mod} will set the |
18fae2a8 | 6270 | working language to Modula-2. @xref{Automatically, ,Having @value{GDBN} set |
c2bbbb22 RP |
6271 | the language automatically}, for further details. |
6272 | ||
4eb4cf57 | 6273 | @node Deviations |
c2bbbb22 RP |
6274 | @subsubsection Deviations from Standard Modula-2 |
6275 | @cindex Modula-2, deviations from | |
6276 | ||
6277 | A few changes have been made to make Modula-2 programs easier to debug. | |
6278 | This is done primarily via loosening its type strictness: | |
6279 | ||
6280 | @itemize @bullet | |
e251e767 | 6281 | @item |
c2bbbb22 RP |
6282 | Unlike in standard Modula-2, pointer constants can be formed by |
6283 | integers. This allows you to modify pointer variables during | |
6284 | debugging. (In standard Modula-2, the actual address contained in a | |
6285 | pointer variable is hidden from you; it can only be modified | |
6286 | through direct assignment to another pointer variable or expression that | |
6287 | returned a pointer.) | |
6288 | ||
e251e767 | 6289 | @item |
c2bbbb22 | 6290 | C escape sequences can be used in strings and characters to represent |
18fae2a8 | 6291 | non-printable characters. @value{GDBN} will print out strings with these |
c2bbbb22 RP |
6292 | escape sequences embedded. Single non-printable characters are |
6293 | printed using the @samp{CHR(@var{nnn})} format. | |
6294 | ||
6295 | @item | |
6296 | The assignment operator (@code{:=}) returns the value of its right-hand | |
6297 | argument. | |
6298 | ||
6299 | @item | |
29a2b744 | 6300 | All built-in procedures both modify @emph{and} return their argument. |
e251e767 | 6301 | @end itemize |
c2bbbb22 | 6302 | |
4eb4cf57 | 6303 | @node M2 Checks |
c2bbbb22 RP |
6304 | @subsubsection Modula-2 Type and Range Checks |
6305 | @cindex Modula-2 checks | |
6306 | ||
6307 | @quotation | |
18fae2a8 | 6308 | @emph{Warning:} in this release, @value{GDBN} does not yet perform type or |
c2bbbb22 RP |
6309 | range checking. |
6310 | @end quotation | |
6311 | @c FIXME remove warning when type/range checks added | |
6312 | ||
18fae2a8 | 6313 | @value{GDBN} considers two Modula-2 variables type equivalent if: |
c2bbbb22 RP |
6314 | |
6315 | @itemize @bullet | |
6316 | @item | |
6317 | They are of types that have been declared equivalent via a @code{TYPE | |
6318 | @var{t1} = @var{t2}} statement | |
6319 | ||
6320 | @item | |
6321 | They have been declared on the same line. (Note: This is true of the | |
6322 | GNU Modula-2 compiler, but it may not be true of other compilers.) | |
c2bbbb22 RP |
6323 | @end itemize |
6324 | ||
6325 | As long as type checking is enabled, any attempt to combine variables | |
6326 | whose types are not equivalent is an error. | |
6327 | ||
6328 | Range checking is done on all mathematical operations, assignment, array | |
29a2b744 | 6329 | index bounds, and all built-in functions and procedures. |
c2bbbb22 | 6330 | |
4eb4cf57 | 6331 | @node M2 Scope |
c2bbbb22 RP |
6332 | @subsubsection The scope operators @code{::} and @code{.} |
6333 | @cindex scope | |
6334 | @kindex . | |
e94b4a2b | 6335 | @cindex colon, doubled as scope operator |
1041a570 RP |
6336 | @ifinfo |
6337 | @kindex colon-colon | |
6338 | @c Info cannot handoe :: but TeX can. | |
6339 | @end ifinfo | |
6340 | @iftex | |
c2bbbb22 | 6341 | @kindex :: |
1041a570 | 6342 | @end iftex |
c2bbbb22 RP |
6343 | |
6344 | There are a few subtle differences between the Modula-2 scope operator | |
18fae2a8 | 6345 | (@code{.}) and the @value{GDBN} scope operator (@code{::}). The two have |
c2bbbb22 RP |
6346 | similar syntax: |
6347 | ||
6348 | @example | |
6349 | ||
6350 | @var{module} . @var{id} | |
6351 | @var{scope} :: @var{id} | |
c2bbbb22 RP |
6352 | @end example |
6353 | ||
6354 | @noindent | |
6355 | where @var{scope} is the name of a module or a procedure, | |
29a2b744 RP |
6356 | @var{module} the name of a module, and @var{id} is any declared |
6357 | identifier within your program, except another module. | |
c2bbbb22 | 6358 | |
18fae2a8 | 6359 | Using the @code{::} operator makes @value{GDBN} search the scope |
c2bbbb22 | 6360 | specified by @var{scope} for the identifier @var{id}. If it is not |
18fae2a8 | 6361 | found in the specified scope, then @value{GDBN} will search all scopes |
c2bbbb22 RP |
6362 | enclosing the one specified by @var{scope}. |
6363 | ||
18fae2a8 | 6364 | Using the @code{.} operator makes @value{GDBN} search the current scope for |
c2bbbb22 RP |
6365 | the identifier specified by @var{id} that was imported from the |
6366 | definition module specified by @var{module}. With this operator, it is | |
6367 | an error if the identifier @var{id} was not imported from definition | |
6368 | module @var{module}, or if @var{id} is not an identifier in | |
6369 | @var{module}. | |
6370 | ||
4eb4cf57 | 6371 | @node GDB/M2 |
18fae2a8 | 6372 | @subsubsection @value{GDBN} and Modula-2 |
c2bbbb22 | 6373 | |
18fae2a8 | 6374 | Some @value{GDBN} commands have little use when debugging Modula-2 programs. |
c2bbbb22 RP |
6375 | Five subcommands of @code{set print} and @code{show print} apply |
6376 | specifically to C and C++: @samp{vtbl}, @samp{demangle}, | |
6377 | @samp{asm-demangle}, @samp{object}, and @samp{union}. The first four | |
6378 | apply to C++, and the last to C's @code{union} type, which has no direct | |
6379 | analogue in Modula-2. | |
6380 | ||
1041a570 | 6381 | The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available |
c2bbbb22 RP |
6382 | while using any language, is not useful with Modula-2. Its |
6383 | intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be | |
6384 | created in Modula-2 as they can in C or C++. However, because an | |
6385 | address can be specified by an integral constant, the construct | |
1041a570 | 6386 | @samp{@{@var{type}@}@var{adrexp}} is still useful. (@pxref{Expressions, ,Expressions}) |
18fae2a8 | 6387 | |
c2bbbb22 | 6388 | @cindex @code{#} in Modula-2 |
18fae2a8 | 6389 | In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is |
c2bbbb22 | 6390 | interpreted as the beginning of a comment. Use @code{<>} instead. |
18fae2a8 RP |
6391 | |
6392 | @end ifclear | |
4eb4cf57 RP |
6393 | |
6394 | @node Symbols | |
70b88761 RP |
6395 | @chapter Examining the Symbol Table |
6396 | ||
6397 | The commands described in this section allow you to inquire about the | |
6398 | symbols (names of variables, functions and types) defined in your | |
6399 | program. This information is inherent in the text of your program and | |
18fae2a8 RP |
6400 | does not change as your program executes. @value{GDBN} finds it in your |
6401 | program's symbol table, in the file indicated when you started @value{GDBN} | |
1041a570 RP |
6402 | (@pxref{File Options, ,Choosing Files}), or by one of the |
6403 | file-management commands (@pxref{Files, ,Commands to Specify Files}). | |
70b88761 | 6404 | |
6c380b13 RP |
6405 | @c FIXME! This might be intentionally specific to C and C++; if so, move |
6406 | @c to someplace in C section of lang chapter. | |
6407 | @cindex symbol names | |
6408 | @cindex names of symbols | |
6409 | @cindex quoting names | |
6410 | Occasionally, you may need to refer to symbols that contain unusual | |
18fae2a8 | 6411 | characters, which @value{GDBN} ordinarily treats as word delimiters. The |
6c380b13 RP |
6412 | most frequent case is in referring to static variables in other |
6413 | source files (@pxref{Variables,,Program Variables}). File names | |
18fae2a8 | 6414 | are recorded in object files as debugging symbols, but @value{GDBN} would |
6c380b13 | 6415 | ordinarily parse a typical file name, like @file{foo.c}, as the three words |
18fae2a8 | 6416 | @samp{foo} @samp{.} @samp{c}. To allow @value{GDBN} to recognize |
6c380b13 RP |
6417 | @samp{foo.c} as a single symbol, enclose it in single quotes; for example, |
6418 | ||
6419 | @example | |
6420 | p 'foo.c'::x | |
6421 | @end example | |
6422 | ||
6423 | @noindent | |
6424 | looks up the value of @code{x} in the scope of the file @file{foo.c}. | |
6425 | ||
70b88761 RP |
6426 | @table @code |
6427 | @item info address @var{symbol} | |
6428 | @kindex info address | |
6429 | Describe where the data for @var{symbol} is stored. For a register | |
6430 | variable, this says which register it is kept in. For a non-register | |
6431 | local variable, this prints the stack-frame offset at which the variable | |
6432 | is always stored. | |
6433 | ||
6434 | Note the contrast with @samp{print &@var{symbol}}, which does not work | |
6435 | at all for a register variables, and for a stack local variable prints | |
6436 | the exact address of the current instantiation of the variable. | |
6437 | ||
6438 | @item whatis @var{exp} | |
6439 | @kindex whatis | |
6440 | Print the data type of expression @var{exp}. @var{exp} is not | |
6441 | actually evaluated, and any side-effecting operations (such as | |
6442 | assignments or function calls) inside it do not take place. | |
1041a570 | 6443 | @xref{Expressions, ,Expressions}. |
70b88761 RP |
6444 | |
6445 | @item whatis | |
6446 | Print the data type of @code{$}, the last value in the value history. | |
6447 | ||
6448 | @item ptype @var{typename} | |
6449 | @kindex ptype | |
6450 | Print a description of data type @var{typename}. @var{typename} may be | |
6451 | the name of a type, or for C code it may have the form | |
6452 | @samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or | |
1041a570 | 6453 | @samp{enum @var{enum-tag}}. |
70b88761 RP |
6454 | |
6455 | @item ptype @var{exp} | |
e0dacfd1 | 6456 | @itemx ptype |
70b88761 | 6457 | Print a description of the type of expression @var{exp}. @code{ptype} |
1041a570 RP |
6458 | differs from @code{whatis} by printing a detailed description, instead |
6459 | of just the name of the type. For example, if your program declares a | |
6460 | variable as | |
6461 | ||
70b88761 RP |
6462 | @example |
6463 | struct complex @{double real; double imag;@} v; | |
6464 | @end example | |
1041a570 | 6465 | |
70b88761 RP |
6466 | @noindent |
6467 | compare the output of the two commands: | |
1041a570 | 6468 | |
70b88761 | 6469 | @example |
1041a570 | 6470 | @group |
18fae2a8 | 6471 | (@value{GDBP}) whatis v |
70b88761 | 6472 | type = struct complex |
18fae2a8 | 6473 | (@value{GDBP}) ptype v |
70b88761 RP |
6474 | type = struct complex @{ |
6475 | double real; | |
6476 | double imag; | |
6477 | @} | |
1041a570 | 6478 | @end group |
70b88761 | 6479 | @end example |
1041a570 | 6480 | |
e0dacfd1 RP |
6481 | @noindent |
6482 | As with @code{whatis}, using @code{ptype} without an argument refers to | |
6483 | the type of @code{$}, the last value in the value history. | |
70b88761 RP |
6484 | |
6485 | @item info types @var{regexp} | |
6486 | @itemx info types | |
e251e767 | 6487 | @kindex info types |
70b88761 RP |
6488 | Print a brief description of all types whose name matches @var{regexp} |
6489 | (or all types in your program, if you supply no argument). Each | |
6490 | complete typename is matched as though it were a complete line; thus, | |
6491 | @samp{i type value} gives information on all types in your program whose | |
6492 | name includes the string @code{value}, but @samp{i type ^value$} gives | |
6493 | information only on types whose complete name is @code{value}. | |
6494 | ||
6495 | This command differs from @code{ptype} in two ways: first, like | |
6496 | @code{whatis}, it does not print a detailed description; second, it | |
6497 | lists all source files where a type is defined. | |
6498 | ||
6499 | @item info source | |
6500 | @kindex info source | |
6501 | Show the name of the current source file---that is, the source file for | |
c2bbbb22 RP |
6502 | the function containing the current point of execution---and the language |
6503 | it was written in. | |
70b88761 RP |
6504 | |
6505 | @item info sources | |
6506 | @kindex info sources | |
29a2b744 | 6507 | Print the names of all source files in your program for which there is |
b80282d5 RP |
6508 | debugging information, organized into two lists: files whose symbols |
6509 | have already been read, and files whose symbols will be read when needed. | |
70b88761 RP |
6510 | |
6511 | @item info functions | |
6512 | @kindex info functions | |
6513 | Print the names and data types of all defined functions. | |
6514 | ||
6515 | @item info functions @var{regexp} | |
6516 | Print the names and data types of all defined functions | |
6517 | whose names contain a match for regular expression @var{regexp}. | |
6518 | Thus, @samp{info fun step} finds all functions whose names | |
6519 | include @code{step}; @samp{info fun ^step} finds those whose names | |
6520 | start with @code{step}. | |
6521 | ||
6522 | @item info variables | |
6523 | @kindex info variables | |
6524 | Print the names and data types of all variables that are declared | |
6525 | outside of functions (i.e., excluding local variables). | |
6526 | ||
6527 | @item info variables @var{regexp} | |
6528 | Print the names and data types of all variables (except for local | |
6529 | variables) whose names contain a match for regular expression | |
6530 | @var{regexp}. | |
6531 | ||
70b88761 RP |
6532 | @ignore |
6533 | This was never implemented. | |
6534 | @item info methods | |
6535 | @itemx info methods @var{regexp} | |
6536 | @kindex info methods | |
6537 | The @code{info methods} command permits the user to examine all defined | |
6538 | methods within C++ program, or (with the @var{regexp} argument) a | |
6539 | specific set of methods found in the various C++ classes. Many | |
6540 | C++ classes provide a large number of methods. Thus, the output | |
6541 | from the @code{ptype} command can be overwhelming and hard to use. The | |
6542 | @code{info-methods} command filters the methods, printing only those | |
6543 | which match the regular-expression @var{regexp}. | |
6544 | @end ignore | |
6545 | ||
d48da190 RP |
6546 | @item maint print symbols @var{filename} |
6547 | @itemx maint print psymbols @var{filename} | |
6548 | @itemx maint print msymbols @var{filename} | |
6549 | @kindex maint print symbols | |
440d9834 | 6550 | @cindex symbol dump |
d48da190 | 6551 | @kindex maint print psymbols |
440d9834 RP |
6552 | @cindex partial symbol dump |
6553 | Write a dump of debugging symbol data into the file @var{filename}. | |
18fae2a8 | 6554 | These commands are used to debug the @value{GDBN} symbol-reading code. Only |
d48da190 | 6555 | symbols with debugging data are included. If you use @samp{maint print |
18fae2a8 | 6556 | symbols}, @value{GDBN} includes all the symbols for which it has already |
d48da190 | 6557 | collected full details: that is, @var{filename} reflects symbols for |
18fae2a8 | 6558 | only those files whose symbols @value{GDBN} has read. You can use the |
d48da190 RP |
6559 | command @code{info sources} to find out which files these are. If you |
6560 | use @samp{maint print psymbols} instead, the dump shows information about | |
18fae2a8 RP |
6561 | symbols that @value{GDBN} only knows partially---that is, symbols defined in |
6562 | files that @value{GDBN} has skimmed, but not yet read completely. Finally, | |
d48da190 | 6563 | @samp{maint print msymbols} dumps just the minimal symbol information |
18fae2a8 RP |
6564 | required for each object file from which @value{GDBN} has read some symbols. |
6565 | The description of @code{symbol-file} explains how @value{GDBN} reads | |
d48da190 RP |
6566 | symbols; both @code{info source} and @code{symbol-file} are described in |
6567 | @ref{Files, ,Commands to Specify Files}. | |
70b88761 RP |
6568 | @end table |
6569 | ||
4eb4cf57 | 6570 | @node Altering |
70b88761 RP |
6571 | @chapter Altering Execution |
6572 | ||
29a2b744 | 6573 | Once you think you have found an error in your program, you might want to |
70b88761 RP |
6574 | find out for certain whether correcting the apparent error would lead to |
6575 | correct results in the rest of the run. You can find the answer by | |
18fae2a8 | 6576 | experiment, using the @value{GDBN} features for altering execution of the |
70b88761 RP |
6577 | program. |
6578 | ||
6579 | For example, you can store new values into variables or memory | |
29a2b744 | 6580 | locations, give your program a signal, restart it at a different address, |
70b88761 RP |
6581 | or even return prematurely from a function to its caller. |
6582 | ||
18fae2a8 RP |
6583 | @ignore |
6584 | @c pre-unfold | |
70b88761 | 6585 | @menu |
b80282d5 RP |
6586 | * Assignment:: Assignment to Variables |
6587 | * Jumping:: Continuing at a Different Address | |
18fae2a8 | 6588 | @ifclear BARETARGET |
29a2b744 | 6589 | * Signaling:: Giving your program a Signal |
18fae2a8 | 6590 | @end ifclear |
b80282d5 RP |
6591 | * Returning:: Returning from a Function |
6592 | * Calling:: Calling your Program's Functions | |
c338a2fd | 6593 | * Patching:: Patching your Program |
70b88761 | 6594 | @end menu |
18fae2a8 RP |
6595 | @end ignore |
6596 | ||
6597 | @ifclear BARETARGET | |
6598 | @menu | |
6599 | * Assignment:: Assignment to Variables | |
6600 | * Jumping:: Continuing at a Different Address | |
6601 | * Signaling:: Giving your program a Signal | |
6602 | * Returning:: Returning from a Function | |
6603 | * Calling:: Calling your Program's Functions | |
6604 | * Patching:: Patching your Program | |
6605 | @end menu | |
6606 | @end ifclear | |
6607 | ||
6608 | @ifset BARETARGET | |
6609 | @menu | |
6610 | * Assignment:: Assignment to Variables | |
6611 | * Jumping:: Continuing at a Different Address | |
6612 | * Returning:: Returning from a Function | |
6613 | * Calling:: Calling your Program's Functions | |
6614 | * Patching:: Patching your Program | |
6615 | @end menu | |
6616 | @end ifset | |
70b88761 | 6617 | |
4eb4cf57 | 6618 | @node Assignment |
70b88761 RP |
6619 | @section Assignment to Variables |
6620 | ||
6621 | @cindex assignment | |
6622 | @cindex setting variables | |
6623 | To alter the value of a variable, evaluate an assignment expression. | |
1041a570 | 6624 | @xref{Expressions, ,Expressions}. For example, |
70b88761 RP |
6625 | |
6626 | @example | |
6627 | print x=4 | |
6628 | @end example | |
6629 | ||
6630 | @noindent | |
1041a570 | 6631 | stores the value 4 into the variable @code{x}, and then prints the |
4eb4cf57 | 6632 | value of the assignment expression (which is 4). |
18fae2a8 RP |
6633 | @ifclear CONLY |
6634 | @xref{Languages, ,Using @value{GDBN} with Different Languages}, for more | |
4eb4cf57 | 6635 | information on operators in supported languages. |
18fae2a8 | 6636 | @end ifclear |
70b88761 | 6637 | |
70b88761 RP |
6638 | @kindex set variable |
6639 | @cindex variables, setting | |
6640 | If you are not interested in seeing the value of the assignment, use the | |
6641 | @code{set} command instead of the @code{print} command. @code{set} is | |
6642 | really the same as @code{print} except that the expression's value is not | |
1041a570 | 6643 | printed and is not put in the value history (@pxref{Value History, ,Value History}). The |
70b88761 RP |
6644 | expression is evaluated only for its effects. |
6645 | ||
6646 | If the beginning of the argument string of the @code{set} command | |
6647 | appears identical to a @code{set} subcommand, use the @code{set | |
6648 | variable} command instead of just @code{set}. This command is identical | |
6649 | to @code{set} except for its lack of subcommands. For example, a | |
6650 | program might well have a variable @code{width}---which leads to | |
6651 | an error if we try to set a new value with just @samp{set width=13}, as | |
18fae2a8 | 6652 | we might if @code{set width} did not happen to be a @value{GDBN} command: |
1041a570 | 6653 | |
70b88761 | 6654 | @example |
18fae2a8 | 6655 | (@value{GDBP}) whatis width |
70b88761 | 6656 | type = double |
18fae2a8 | 6657 | (@value{GDBP}) p width |
70b88761 | 6658 | $4 = 13 |
18fae2a8 | 6659 | (@value{GDBP}) set width=47 |
70b88761 RP |
6660 | Invalid syntax in expression. |
6661 | @end example | |
1041a570 | 6662 | |
70b88761 RP |
6663 | @noindent |
6664 | The invalid expression, of course, is @samp{=47}. What we can do in | |
e251e767 | 6665 | order to actually set our program's variable @code{width} is |
1041a570 | 6666 | |
70b88761 | 6667 | @example |
18fae2a8 | 6668 | (@value{GDBP}) set var width=47 |
70b88761 RP |
6669 | @end example |
6670 | ||
18fae2a8 | 6671 | @value{GDBN} allows more implicit conversions in assignments than C; you can |
1041a570 RP |
6672 | freely store an integer value into a pointer variable or vice versa, |
6673 | and any structure can be converted to any other structure that is the | |
6674 | same length or shorter. | |
e251e767 | 6675 | @comment FIXME: how do structs align/pad in these conversions? |
70b88761 RP |
6676 | @comment /pesch@cygnus.com 18dec1990 |
6677 | ||
6678 | To store values into arbitrary places in memory, use the @samp{@{@dots{}@}} | |
6679 | construct to generate a value of specified type at a specified address | |
1041a570 | 6680 | (@pxref{Expressions, ,Expressions}). For example, @code{@{int@}0x83040} refers |
70b88761 RP |
6681 | to memory location @code{0x83040} as an integer (which implies a certain size |
6682 | and representation in memory), and | |
6683 | ||
6684 | @example | |
6685 | set @{int@}0x83040 = 4 | |
6686 | @end example | |
6687 | ||
6688 | @noindent | |
6689 | stores the value 4 into that memory location. | |
6690 | ||
4eb4cf57 | 6691 | @node Jumping |
70b88761 RP |
6692 | @section Continuing at a Different Address |
6693 | ||
29a2b744 | 6694 | Ordinarily, when you continue your program, you do so at the place where |
70b88761 RP |
6695 | it stopped, with the @code{continue} command. You can instead continue at |
6696 | an address of your own choosing, with the following commands: | |
6697 | ||
6698 | @table @code | |
6699 | @item jump @var{linespec} | |
6700 | @kindex jump | |
6701 | Resume execution at line @var{linespec}. Execution will stop | |
29a2b744 RP |
6702 | immediately if there is a breakpoint there. @xref{List, ,Printing |
6703 | Source Lines}, for a description of the different forms of | |
6704 | @var{linespec}. | |
70b88761 RP |
6705 | |
6706 | The @code{jump} command does not change the current stack frame, or | |
6707 | the stack pointer, or the contents of any memory location or any | |
6708 | register other than the program counter. If line @var{linespec} is in | |
6709 | a different function from the one currently executing, the results may | |
6710 | be bizarre if the two functions expect different patterns of arguments or | |
6711 | of local variables. For this reason, the @code{jump} command requests | |
6712 | confirmation if the specified line is not in the function currently | |
6713 | executing. However, even bizarre results are predictable if you are | |
29a2b744 | 6714 | well acquainted with the machine-language code of your program. |
70b88761 RP |
6715 | |
6716 | @item jump *@var{address} | |
6717 | Resume execution at the instruction at address @var{address}. | |
6718 | @end table | |
6719 | ||
6720 | You can get much the same effect as the @code{jump} command by storing a | |
6721 | new value into the register @code{$pc}. The difference is that this | |
29a2b744 | 6722 | does not start your program running; it only changes the address where it |
70b88761 RP |
6723 | @emph{will} run when it is continued. For example, |
6724 | ||
6725 | @example | |
6726 | set $pc = 0x485 | |
6727 | @end example | |
6728 | ||
6729 | @noindent | |
6730 | causes the next @code{continue} command or stepping command to execute at | |
1041a570 RP |
6731 | address @code{0x485}, rather than at the address where your program stopped. |
6732 | @xref{Continuing and Stepping, ,Continuing and Stepping}. | |
70b88761 RP |
6733 | |
6734 | The most common occasion to use the @code{jump} command is to back up, | |
6735 | perhaps with more breakpoints set, over a portion of a program that has | |
6736 | already executed, in order to examine its execution in more detail. | |
6737 | ||
18fae2a8 | 6738 | @ifclear BARETARGET |
4eb4cf57 | 6739 | @node Signaling |
70b88761 | 6740 | @c @group |
29a2b744 | 6741 | @section Giving your program a Signal |
70b88761 RP |
6742 | |
6743 | @table @code | |
6744 | @item signal @var{signalnum} | |
6745 | @kindex signal | |
29a2b744 | 6746 | Resume execution where your program stopped, but give it immediately the |
70b88761 RP |
6747 | signal number @var{signalnum}. |
6748 | ||
6749 | Alternatively, if @var{signalnum} is zero, continue execution without | |
29a2b744 | 6750 | giving a signal. This is useful when your program stopped on account of |
70b88761 RP |
6751 | a signal and would ordinary see the signal when resumed with the |
6752 | @code{continue} command; @samp{signal 0} causes it to resume without a | |
6753 | signal. | |
6754 | ||
6755 | @code{signal} does not repeat when you press @key{RET} a second time | |
6756 | after executing the command. | |
6757 | @end table | |
6758 | @c @end group | |
18fae2a8 | 6759 | @end ifclear |
70b88761 | 6760 | |
4eb4cf57 | 6761 | @node Returning |
70b88761 RP |
6762 | @section Returning from a Function |
6763 | ||
6764 | @table @code | |
6765 | @item return | |
6766 | @itemx return @var{expression} | |
6767 | @cindex returning from a function | |
6768 | @kindex return | |
6769 | You can cancel execution of a function call with the @code{return} | |
6770 | command. If you give an | |
6771 | @var{expression} argument, its value is used as the function's return | |
e251e767 | 6772 | value. |
70b88761 RP |
6773 | @end table |
6774 | ||
18fae2a8 | 6775 | When you use @code{return}, @value{GDBN} discards the selected stack frame |
70b88761 RP |
6776 | (and all frames within it). You can think of this as making the |
6777 | discarded frame return prematurely. If you wish to specify a value to | |
6778 | be returned, give that value as the argument to @code{return}. | |
6779 | ||
29a2b744 RP |
6780 | This pops the selected stack frame (@pxref{Selection, ,Selecting a |
6781 | Frame}), and any other frames inside of it, leaving its caller as the | |
6782 | innermost remaining frame. That frame becomes selected. The | |
6783 | specified value is stored in the registers used for returning values | |
6784 | of functions. | |
70b88761 RP |
6785 | |
6786 | The @code{return} command does not resume execution; it leaves the | |
6787 | program stopped in the state that would exist if the function had just | |
1041a570 RP |
6788 | returned. In contrast, the @code{finish} command (@pxref{Continuing |
6789 | and Stepping, ,Continuing and Stepping}) resumes execution until the | |
6790 | selected stack frame returns naturally. | |
70b88761 | 6791 | |
4eb4cf57 | 6792 | @node Calling |
70b88761 RP |
6793 | @section Calling your Program's Functions |
6794 | ||
6795 | @cindex calling functions | |
6796 | @kindex call | |
6797 | @table @code | |
6798 | @item call @var{expr} | |
6799 | Evaluate the expression @var{expr} without displaying @code{void} | |
6800 | returned values. | |
6801 | @end table | |
6802 | ||
6803 | You can use this variant of the @code{print} command if you want to | |
6804 | execute a function from your program, but without cluttering the output | |
6805 | with @code{void} returned values. The result is printed and saved in | |
6806 | the value history, if it is not void. | |
6807 | ||
4eb4cf57 | 6808 | @node Patching |
c338a2fd RP |
6809 | @section Patching your Program |
6810 | @cindex patching binaries | |
6811 | @cindex writing into executables | |
6812 | @cindex writing into corefiles | |
1041a570 | 6813 | |
18fae2a8 | 6814 | By default, @value{GDBN} opens the file containing your program's executable |
c338a2fd RP |
6815 | code (or the corefile) read-only. This prevents accidental alterations |
6816 | to machine code; but it also prevents you from intentionally patching | |
6817 | your program's binary. | |
6818 | ||
6819 | If you'd like to be able to patch the binary, you can specify that | |
6820 | explicitly with the @code{set write} command. For example, you might | |
6821 | want to turn on internal debugging flags, or even to make emergency | |
e251e767 | 6822 | repairs. |
c338a2fd RP |
6823 | |
6824 | @table @code | |
6825 | @item set write on | |
6826 | @itemx set write off | |
6827 | @kindex set write | |
18fae2a8 RP |
6828 | If you specify @samp{set write on}, @value{GDBN} will open executable |
6829 | @ifclear BARETARGET | |
0f153e74 | 6830 | and core |
18fae2a8 | 6831 | @end ifclear |
0f153e74 | 6832 | files for both reading and writing; if you specify @samp{set write |
18fae2a8 | 6833 | off} (the default), @value{GDBN} will open them read-only. |
c338a2fd | 6834 | |
1041a570 | 6835 | If you have already loaded a file, you must load it |
c338a2fd RP |
6836 | again (using the @code{exec-file} or @code{core-file} command) after |
6837 | changing @code{set write}, for your new setting to take effect. | |
6838 | ||
6839 | @item show write | |
7d7ff5f6 | 6840 | @kindex show write |
0f153e74 | 6841 | Display whether executable files |
18fae2a8 | 6842 | @ifclear BARETARGET |
0f153e74 | 6843 | and core files |
18fae2a8 | 6844 | @end ifclear |
0f153e74 | 6845 | will be opened for writing as well as reading. |
c338a2fd RP |
6846 | @end table |
6847 | ||
18fae2a8 RP |
6848 | @node GDB Files |
6849 | @chapter @value{GDBN}'s Files | |
70b88761 | 6850 | |
18fae2a8 | 6851 | @value{GDBN} needs to know the file name of the program to be debugged, both in |
4eb4cf57 | 6852 | order to read its symbol table and in order to start your program. |
18fae2a8 RP |
6853 | @ifclear BARETARGET |
6854 | To debug a core dump of a previous run, @value{GDBN} must be told the file | |
4eb4cf57 | 6855 | name of the core dump. |
18fae2a8 | 6856 | @end ifclear |
1041a570 | 6857 | |
70b88761 | 6858 | @menu |
b80282d5 RP |
6859 | * Files:: Commands to Specify Files |
6860 | * Symbol Errors:: Errors Reading Symbol Files | |
70b88761 RP |
6861 | @end menu |
6862 | ||
4eb4cf57 | 6863 | @node Files |
70b88761 | 6864 | @section Commands to Specify Files |
70b88761 | 6865 | @cindex symbol table |
70b88761 | 6866 | |
18fae2a8 | 6867 | @ifclear BARETARGET |
0f153e74 | 6868 | @cindex core dump file |
1041a570 | 6869 | The usual way to specify executable and core dump file names is with |
18fae2a8 RP |
6870 | the command arguments given when you start @value{GDBN}, (@pxref{Invocation, |
6871 | ,Getting In and Out of @value{GDBN}}. | |
6872 | @end ifclear | |
6873 | @ifset BARETARGET | |
4eb4cf57 | 6874 | The usual way to specify an executable file name is with |
18fae2a8 RP |
6875 | the command argument given when you start @value{GDBN}, (@pxref{Invocation, |
6876 | ,Getting In and Out of @value{GDBN}}. | |
6877 | @end ifset | |
70b88761 RP |
6878 | |
6879 | Occasionally it is necessary to change to a different file during a | |
18fae2a8 RP |
6880 | @value{GDBN} session. Or you may run @value{GDBN} and forget to specify a file you |
6881 | want to use. In these situations the @value{GDBN} commands to specify new files | |
70b88761 RP |
6882 | are useful. |
6883 | ||
6884 | @table @code | |
6885 | @item file @var{filename} | |
6886 | @cindex executable file | |
6887 | @kindex file | |
6888 | Use @var{filename} as the program to be debugged. It is read for its | |
6889 | symbols and for the contents of pure memory. It is also the program | |
6890 | executed when you use the @code{run} command. If you do not specify a | |
18fae2a8 | 6891 | directory and the file is not found in @value{GDBN}'s working directory, @value{GDBN} |
1041a570 RP |
6892 | uses the environment variable @code{PATH} as a list of directories to |
6893 | search, just as the shell does when looking for a program to run. You | |
18fae2a8 | 6894 | can change the value of this variable, for both @value{GDBN} and your program, |
1041a570 | 6895 | using the @code{path} command. |
70b88761 | 6896 | |
14d01801 RP |
6897 | On systems with memory-mapped files, an auxiliary symbol table file |
6898 | @file{@var{filename}.syms} may be available for @var{filename}. If it | |
18fae2a8 | 6899 | is, @value{GDBN} will map in the symbol table from |
14d01801 | 6900 | @file{@var{filename}.syms}, starting up more quickly. See the |
95d5ceb9 | 6901 | descriptions of the options @samp{-mapped} and @samp{-readnow} (available |
77b46d13 JG |
6902 | on the command line, and with the commands @code{file}, @code{symbol-file}, |
6903 | or @code{add-symbol-file}), for more information. | |
14d01801 | 6904 | |
e0dacfd1 | 6905 | @item file |
18fae2a8 | 6906 | @code{file} with no argument makes @value{GDBN} discard any information it |
70b88761 RP |
6907 | has on both executable file and the symbol table. |
6908 | ||
e0dacfd1 | 6909 | @item exec-file @r{[} @var{filename} @r{]} |
70b88761 RP |
6910 | @kindex exec-file |
6911 | Specify that the program to be run (but not the symbol table) is found | |
18fae2a8 | 6912 | in @var{filename}. @value{GDBN} will search the environment variable @code{PATH} |
29a2b744 | 6913 | if necessary to locate your program. Omitting @var{filename} means to |
e0dacfd1 | 6914 | discard information on the executable file. |
70b88761 | 6915 | |
e0dacfd1 | 6916 | @item symbol-file @r{[} @var{filename} @r{]} |
70b88761 RP |
6917 | @kindex symbol-file |
6918 | Read symbol table information from file @var{filename}. @code{PATH} is | |
6919 | searched when necessary. Use the @code{file} command to get both symbol | |
6920 | table and program to run from the same file. | |
6921 | ||
18fae2a8 | 6922 | @code{symbol-file} with no argument clears out @value{GDBN}'s information on your |
70b88761 RP |
6923 | program's symbol table. |
6924 | ||
18fae2a8 | 6925 | The @code{symbol-file} command causes @value{GDBN} to forget the contents of its |
70b88761 RP |
6926 | convenience variables, the value history, and all breakpoints and |
6927 | auto-display expressions. This is because they may contain pointers to | |
6928 | the internal data recording symbols and data types, which are part of | |
18fae2a8 | 6929 | the old symbol table data being discarded inside @value{GDBN}. |
70b88761 RP |
6930 | |
6931 | @code{symbol-file} will not repeat if you press @key{RET} again after | |
6932 | executing it once. | |
6933 | ||
18fae2a8 | 6934 | When @value{GDBN} is configured for a particular environment, it will |
14d01801 RP |
6935 | understand debugging information in whatever format is the standard |
6936 | generated for that environment; you may use either a GNU compiler, or | |
6937 | other compilers that adhere to the local conventions. Best results are | |
18fae2a8 | 6938 | usually obtained from GNU compilers; for example, using @code{@value{GCC}} |
14d01801 RP |
6939 | you can generate debugging information for optimized code. |
6940 | ||
70b88761 | 6941 | On some kinds of object files, the @code{symbol-file} command does not |
14d01801 | 6942 | normally read the symbol table in full right away. Instead, it scans |
70b88761 RP |
6943 | the symbol table quickly to find which source files and which symbols |
6944 | are present. The details are read later, one source file at a time, | |
1041a570 | 6945 | as they are needed. |
70b88761 | 6946 | |
18fae2a8 | 6947 | The purpose of this two-stage reading strategy is to make @value{GDBN} start up |
1041a570 RP |
6948 | faster. For the most part, it is invisible except for occasional |
6949 | pauses while the symbol table details for a particular source file are | |
6950 | being read. (The @code{set verbose} command can turn these pauses | |
6951 | into messages if desired. @xref{Messages/Warnings, ,Optional Warnings | |
6952 | and Messages}.) | |
70b88761 RP |
6953 | |
6954 | When the symbol table is stored in COFF format, @code{symbol-file} does | |
1041a570 | 6955 | read the symbol table data in full right away. We have not implemented |
70b88761 RP |
6956 | the two-stage strategy for COFF yet. |
6957 | ||
95d5ceb9 RP |
6958 | @item symbol-file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]} |
6959 | @itemx file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]} | |
14d01801 RP |
6960 | @kindex readnow |
6961 | @cindex reading symbols immediately | |
6962 | @cindex symbols, reading immediately | |
6963 | @kindex mapped | |
6964 | @cindex memory-mapped symbol file | |
38962738 | 6965 | @cindex saving symbol table |
18fae2a8 | 6966 | You can override the @value{GDBN} two-stage strategy for reading symbol |
95d5ceb9 | 6967 | tables by using the @samp{-readnow} option with any of the commands that |
18fae2a8 | 6968 | load symbol table information, if you want to be sure @value{GDBN} has the |
14d01801 RP |
6969 | entire symbol table available. |
6970 | ||
18fae2a8 | 6971 | @ifclear BARETARGET |
14d01801 | 6972 | If memory-mapped files are available on your system through the |
95d5ceb9 | 6973 | @code{mmap} system call, you can use another option, @samp{-mapped}, to |
18fae2a8 RP |
6974 | cause @value{GDBN} to write the symbols for your program into a reusable |
6975 | file. Future @value{GDBN} debugging sessions will map in symbol information | |
77b46d13 JG |
6976 | from this auxiliary symbol file (if the program hasn't changed), rather |
6977 | than spending time reading the symbol table from the executable | |
6978 | program. Using the @samp{-mapped} option has the same effect as | |
18fae2a8 | 6979 | starting @value{GDBN} with the @samp{-mapped} command-line option. |
14d01801 | 6980 | |
95d5ceb9 | 6981 | You can use both options together, to make sure the auxiliary symbol |
14d01801 RP |
6982 | file has all the symbol information for your program. |
6983 | ||
77b46d13 JG |
6984 | The @code{.syms} file is specific to the host machine on which GDB is run. |
6985 | It holds an exact image of GDB's internal symbol table. It cannot be | |
6986 | shared across multiple host platforms. | |
6987 | ||
14d01801 RP |
6988 | The auxiliary symbol file for a program called @var{myprog} is called |
6989 | @samp{@var{myprog}.syms}. Once this file exists (so long as it is newer | |
18fae2a8 | 6990 | than the corresponding executable), @value{GDBN} will always attempt to use |
14d01801 RP |
6991 | it when you debug @var{myprog}; no special options or commands are |
6992 | needed. | |
6993 | @c FIXME: for now no mention of directories, since this seems to be in | |
6994 | @c flux. 13mar1992 status is that in theory GDB would look either in | |
6995 | @c current dir or in same dir as myprog; but issues like competing | |
6996 | @c GDB's, or clutter in system dirs, mean that in practice right now | |
6997 | @c only current dir is used. FFish says maybe a special GDB hierarchy | |
6998 | @c (eg rooted in val of env var GDBSYMS) could exist for mappable symbol | |
6999 | @c files. | |
70b88761 | 7000 | |
e0dacfd1 | 7001 | @item core-file @r{[} @var{filename} @r{]} |
70b88761 RP |
7002 | @kindex core |
7003 | @kindex core-file | |
7004 | Specify the whereabouts of a core dump file to be used as the ``contents | |
7005 | of memory''. Traditionally, core files contain only some parts of the | |
18fae2a8 | 7006 | address space of the process that generated them; @value{GDBN} can access the |
70b88761 RP |
7007 | executable file itself for other parts. |
7008 | ||
7009 | @code{core-file} with no argument specifies that no core file is | |
7010 | to be used. | |
7011 | ||
7012 | Note that the core file is ignored when your program is actually running | |
18fae2a8 | 7013 | under @value{GDBN}. So, if you have been running your program and you wish to |
70b88761 RP |
7014 | debug a core file instead, you must kill the subprocess in which the |
7015 | program is running. To do this, use the @code{kill} command | |
1041a570 | 7016 | (@pxref{Kill Process, ,Killing the Child Process}). |
18fae2a8 | 7017 | @end ifclear |
70b88761 RP |
7018 | |
7019 | @item load @var{filename} | |
7020 | @kindex load | |
18fae2a8 | 7021 | @ifset GENERIC |
70b88761 | 7022 | Depending on what remote debugging facilities are configured into |
18fae2a8 | 7023 | @value{GDBN}, the @code{load} command may be available. Where it exists, it |
70b88761 RP |
7024 | is meant to make @var{filename} (an executable) available for debugging |
7025 | on the remote system---by downloading, or dynamic linking, for example. | |
18fae2a8 | 7026 | @code{load} also records @var{filename}'s symbol table in @value{GDBN}, like |
70b88761 RP |
7027 | the @code{add-symbol-file} command. |
7028 | ||
18fae2a8 | 7029 | If @code{load} is not available on your @value{GDBN}, attempting to execute |
70b88761 | 7030 | it gets the error message ``@code{You can't do that when your target is |
e251e767 | 7031 | @dots{}}'' |
18fae2a8 | 7032 | @end ifset |
70b88761 | 7033 | |
18fae2a8 | 7034 | @ifset VXWORKS |
70b88761 | 7035 | On VxWorks, @code{load} will dynamically link @var{filename} on the |
18fae2a8 RP |
7036 | current target system as well as adding its symbols in @value{GDBN}. |
7037 | @end ifset | |
70b88761 | 7038 | |
18fae2a8 | 7039 | @ifset Icmlx |
70b88761 RP |
7040 | @cindex download to Nindy-960 |
7041 | With the Nindy interface to an Intel 960 board, @code{load} will | |
7042 | download @var{filename} to the 960 as well as adding its symbols in | |
18fae2a8 RP |
7043 | @value{GDBN}. |
7044 | @end ifset | |
70b88761 | 7045 | |
18fae2a8 | 7046 | @ifset Hviii |
c7cb8acb RP |
7047 | @cindex download to H8/300 |
7048 | @cindex H8/300 download | |
7049 | When you select remote debugging to a Hitachi H8/300 board (@pxref{Hitachi | |
18fae2a8 | 7050 | H8/300 Remote,,@value{GDBN} and the Hitachi H8/300}), the |
c7cb8acb | 7051 | @code{load} command downloads your program to the H8/300 and also opens |
18fae2a8 | 7052 | it as the current executable target for @value{GDBN} on your host (like the |
c7cb8acb | 7053 | @code{file} command). |
18fae2a8 | 7054 | @end ifset |
c7cb8acb | 7055 | |
70b88761 RP |
7056 | @code{load} will not repeat if you press @key{RET} again after using it. |
7057 | ||
18fae2a8 | 7058 | @ifclear BARETARGET |
70b88761 | 7059 | @item add-symbol-file @var{filename} @var{address} |
95d5ceb9 | 7060 | @itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]} @r{[} -mapped @r{]} |
70b88761 RP |
7061 | @kindex add-symbol-file |
7062 | @cindex dynamic linking | |
7063 | The @code{add-symbol-file} command reads additional symbol table information | |
b80282d5 | 7064 | from the file @var{filename}. You would use this command when @var{filename} |
70b88761 RP |
7065 | has been dynamically loaded (by some other means) into the program that |
7066 | is running. @var{address} should be the memory address at which the | |
18fae2a8 | 7067 | file has been loaded; @value{GDBN} cannot figure this out for itself. |
70b88761 RP |
7068 | |
7069 | The symbol table of the file @var{filename} is added to the symbol table | |
7070 | originally read with the @code{symbol-file} command. You can use the | |
7071 | @code{add-symbol-file} command any number of times; the new symbol data thus | |
7072 | read keeps adding to the old. To discard all old symbol data instead, | |
e251e767 | 7073 | use the @code{symbol-file} command. |
70b88761 RP |
7074 | |
7075 | @code{add-symbol-file} will not repeat if you press @key{RET} after using it. | |
7076 | ||
95d5ceb9 | 7077 | You can use the @samp{-mapped} and @samp{-readnow} options just as with |
18fae2a8 | 7078 | the @code{symbol-file} command, to change how @value{GDBN} manages the symbol |
0f153e74 | 7079 | table information for @var{filename}. |
18fae2a8 | 7080 | @end ifclear |
95d5ceb9 | 7081 | |
70b88761 RP |
7082 | @item info files |
7083 | @itemx info target | |
7084 | @kindex info files | |
7085 | @kindex info target | |
1041a570 RP |
7086 | @code{info files} and @code{info target} are synonymous; both print |
7087 | the current targets (@pxref{Targets, ,Specifying a Debugging Target}), | |
7088 | including the names of the executable and core dump files currently in | |
18fae2a8 | 7089 | use by @value{GDBN}, and the files from which symbols were loaded. The command |
1041a570 RP |
7090 | @code{help targets} lists all possible targets rather than current |
7091 | ones. | |
70b88761 RP |
7092 | |
7093 | @end table | |
7094 | ||
7095 | All file-specifying commands allow both absolute and relative file names | |
18fae2a8 | 7096 | as arguments. @value{GDBN} always converts the file name to an absolute path |
70b88761 RP |
7097 | name and remembers it that way. |
7098 | ||
18fae2a8 | 7099 | @ifclear BARETARGET |
70b88761 | 7100 | @cindex shared libraries |
18fae2a8 RP |
7101 | @value{GDBN} supports SunOS, SVR4, and IBM RS/6000 shared libraries. |
7102 | @value{GDBN} automatically loads symbol definitions from shared libraries | |
77b46d13 | 7103 | when you use the @code{run} command, or when you examine a core file. |
18fae2a8 | 7104 | (Before you issue the @code{run} command, @value{GDBN} will not understand |
77b46d13 JG |
7105 | references to a function in a shared library, however---unless you are |
7106 | debugging a core file). | |
18fae2a8 | 7107 | @c FIXME: next @value{GDBN} release should permit some refs to undef |
1041a570 | 7108 | @c FIXME...symbols---eg in a break cmd---assuming they are from a shared lib |
70b88761 RP |
7109 | |
7110 | @table @code | |
70b88761 RP |
7111 | @item info share |
7112 | @itemx info sharedlibrary | |
7113 | @kindex info sharedlibrary | |
7114 | @kindex info share | |
c338a2fd | 7115 | Print the names of the shared libraries which are currently loaded. |
70b88761 | 7116 | |
c338a2fd RP |
7117 | @item sharedlibrary @var{regex} |
7118 | @itemx share @var{regex} | |
7119 | @kindex sharedlibrary | |
7120 | @kindex share | |
7121 | This is an obsolescent command; you can use it to explicitly | |
7122 | load shared object library symbols for files matching a UNIX regular | |
7123 | expression, but as with files loaded automatically, it will only load | |
7124 | shared libraries required by your program for a core file or after | |
7125 | typing @code{run}. If @var{regex} is omitted all shared libraries | |
7126 | required by your program are loaded. | |
7127 | @end table | |
18fae2a8 | 7128 | @end ifclear |
70b88761 | 7129 | |
4eb4cf57 | 7130 | @node Symbol Errors |
70b88761 | 7131 | @section Errors Reading Symbol Files |
1041a570 | 7132 | |
18fae2a8 | 7133 | While reading a symbol file, @value{GDBN} will occasionally encounter problems, |
1041a570 | 7134 | such as symbol types it does not recognize, or known bugs in compiler |
18fae2a8 | 7135 | output. By default, @value{GDBN} does not notify you of such problems, since |
1041a570 RP |
7136 | they are relatively common and primarily of interest to people |
7137 | debugging compilers. If you are interested in seeing information | |
18fae2a8 | 7138 | about ill-constructed symbol tables, you can either ask @value{GDBN} to print |
b80282d5 | 7139 | only one message about each such type of problem, no matter how many |
18fae2a8 | 7140 | times the problem occurs; or you can ask @value{GDBN} to print more messages, |
1041a570 RP |
7141 | to see how many times the problems occur, with the @code{set |
7142 | complaints} command (@pxref{Messages/Warnings, ,Optional Warnings and | |
7143 | Messages}). | |
70b88761 RP |
7144 | |
7145 | The messages currently printed, and their meanings, are: | |
7146 | ||
7147 | @table @code | |
7148 | @item inner block not inside outer block in @var{symbol} | |
7149 | ||
7150 | The symbol information shows where symbol scopes begin and end | |
7151 | (such as at the start of a function or a block of statements). This | |
7152 | error indicates that an inner scope block is not fully contained | |
e251e767 | 7153 | in its outer scope blocks. |
70b88761 | 7154 | |
18fae2a8 | 7155 | @value{GDBN} circumvents the problem by treating the inner block as if it had |
70b88761 RP |
7156 | the same scope as the outer block. In the error message, @var{symbol} |
7157 | may be shown as ``@code{(don't know)}'' if the outer block is not a | |
7158 | function. | |
7159 | ||
7160 | @item block at @var{address} out of order | |
7161 | ||
e251e767 | 7162 | The symbol information for symbol scope blocks should occur in |
70b88761 | 7163 | order of increasing addresses. This error indicates that it does not |
e251e767 | 7164 | do so. |
70b88761 | 7165 | |
18fae2a8 | 7166 | @value{GDBN} does not circumvent this problem, and will have trouble locating |
70b88761 RP |
7167 | symbols in the source file whose symbols being read. (You can often |
7168 | determine what source file is affected by specifying @code{set verbose | |
29a2b744 | 7169 | on}. @xref{Messages/Warnings, ,Optional Warnings and Messages}.) |
70b88761 RP |
7170 | |
7171 | @item bad block start address patched | |
7172 | ||
7173 | The symbol information for a symbol scope block has a start address | |
7174 | smaller than the address of the preceding source line. This is known | |
e251e767 | 7175 | to occur in the SunOS 4.1.1 (and earlier) C compiler. |
70b88761 | 7176 | |
18fae2a8 | 7177 | @value{GDBN} circumvents the problem by treating the symbol scope block as |
70b88761 RP |
7178 | starting on the previous source line. |
7179 | ||
70b88761 RP |
7180 | @item bad string table offset in symbol @var{n} |
7181 | ||
7182 | @cindex foo | |
7183 | Symbol number @var{n} contains a pointer into the string table which is | |
e251e767 | 7184 | larger than the size of the string table. |
70b88761 | 7185 | |
18fae2a8 | 7186 | @value{GDBN} circumvents the problem by considering the symbol to have the |
70b88761 RP |
7187 | name @code{foo}, which may cause other problems if many symbols end up |
7188 | with this name. | |
7189 | ||
7190 | @item unknown symbol type @code{0x@var{nn}} | |
7191 | ||
18fae2a8 | 7192 | The symbol information contains new data types that @value{GDBN} does not yet |
70b88761 | 7193 | know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood |
e251e767 | 7194 | information, in hexadecimal. |
70b88761 | 7195 | |
18fae2a8 | 7196 | @value{GDBN} circumvents the error by ignoring this symbol information. This |
29a2b744 | 7197 | will usually allow your program to be debugged, though certain symbols |
70b88761 | 7198 | will not be accessible. If you encounter such a problem and feel like |
18fae2a8 | 7199 | debugging it, you can debug @code{@value{GDBP}} with itself, breakpoint on |
70b88761 RP |
7200 | @code{complain}, then go up to the function @code{read_dbx_symtab} and |
7201 | examine @code{*bufp} to see the symbol. | |
7202 | ||
7203 | @item stub type has NULL name | |
18fae2a8 | 7204 | @value{GDBN} could not find the full definition for a struct or class. |
70b88761 | 7205 | |
440d9834 | 7206 | @item const/volatile indicator missing (ok if using g++ v1.x), got@dots{} |
70b88761 RP |
7207 | |
7208 | The symbol information for a C++ member function is missing some | |
440d9834 RP |
7209 | information that recent versions of the compiler should have output |
7210 | for it. | |
70b88761 | 7211 | |
440d9834 | 7212 | @item info mismatch between compiler and debugger |
70b88761 | 7213 | |
18fae2a8 | 7214 | @value{GDBN} could not parse a type specification output by the compiler. |
70b88761 RP |
7215 | @end table |
7216 | ||
4eb4cf57 | 7217 | @node Targets |
e251e767 | 7218 | @chapter Specifying a Debugging Target |
70b88761 RP |
7219 | @cindex debugging target |
7220 | @kindex target | |
1041a570 | 7221 | |
cedaf8bc | 7222 | A @dfn{target} is the execution environment occupied by your program. |
18fae2a8 RP |
7223 | @ifclear BARETARGET |
7224 | Often, @value{GDBN} runs in the same host environment as your program; in | |
1041a570 RP |
7225 | that case, the debugging target is specified as a side effect when you |
7226 | use the @code{file} or @code{core} commands. When you need more | |
18fae2a8 | 7227 | flexibility---for example, running @value{GDBN} on a physically separate |
1041a570 | 7228 | host, or controlling a standalone system over a serial port or a |
0f153e74 | 7229 | realtime system over a TCP/IP connection---you |
18fae2a8 RP |
7230 | @end ifclear |
7231 | @ifset BARETARGET | |
0f153e74 | 7232 | You |
18fae2a8 | 7233 | @end ifset |
0f153e74 | 7234 | can use the @code{target} command to specify one of the target types |
18fae2a8 | 7235 | configured for @value{GDBN} (@pxref{Target Commands, ,Commands for Managing |
0f153e74 | 7236 | Targets}). |
70b88761 RP |
7237 | |
7238 | @menu | |
b80282d5 RP |
7239 | * Active Targets:: Active Targets |
7240 | * Target Commands:: Commands for Managing Targets | |
7241 | * Remote:: Remote Debugging | |
70b88761 RP |
7242 | @end menu |
7243 | ||
4eb4cf57 | 7244 | @node Active Targets |
70b88761 RP |
7245 | @section Active Targets |
7246 | @cindex stacking targets | |
7247 | @cindex active targets | |
7248 | @cindex multiple targets | |
7249 | ||
18fae2a8 | 7250 | @ifclear BARETARGET |
cedaf8bc | 7251 | There are three classes of targets: processes, core files, and |
18fae2a8 | 7252 | executable files. @value{GDBN} can work concurrently on up to three active |
cedaf8bc RP |
7253 | targets, one in each class. This allows you to (for example) start a |
7254 | process and inspect its activity without abandoning your work on a core | |
7255 | file. | |
70b88761 | 7256 | |
cedaf8bc RP |
7257 | If, for example, you execute @samp{gdb a.out}, then the executable file |
7258 | @code{a.out} is the only active target. If you designate a core file as | |
7259 | well---presumably from a prior run that crashed and coredumped---then | |
18fae2a8 | 7260 | @value{GDBN} has two active targets and will use them in tandem, looking |
cedaf8bc RP |
7261 | first in the corefile target, then in the executable file, to satisfy |
7262 | requests for memory addresses. (Typically, these two classes of target | |
29a2b744 | 7263 | are complementary, since core files contain only a program's |
cedaf8bc RP |
7264 | read-write memory---variables and so on---plus machine status, while |
7265 | executable files contain only the program text and initialized data.) | |
18fae2a8 | 7266 | @end ifclear |
cedaf8bc RP |
7267 | |
7268 | When you type @code{run}, your executable file becomes an active process | |
18fae2a8 | 7269 | target as well. When a process target is active, all @value{GDBN} commands |
0f153e74 | 7270 | requesting memory addresses refer to that target; addresses in an |
18fae2a8 | 7271 | @ifclear BARETARGET |
0f153e74 | 7272 | active core file or |
18fae2a8 | 7273 | @end ifclear |
0f153e74 | 7274 | executable file target are obscured while the process |
cedaf8bc RP |
7275 | target is active. |
7276 | ||
18fae2a8 | 7277 | @ifset BARETARGET |
4eb4cf57 RP |
7278 | Use the @code{exec-file} command to select a |
7279 | new executable target (@pxref{Files, ,Commands to Specify | |
7280 | Files}). | |
18fae2a8 RP |
7281 | @end ifset |
7282 | @ifclear BARETARGET | |
1041a570 RP |
7283 | Use the @code{core-file} and @code{exec-file} commands to select a |
7284 | new core file or executable target (@pxref{Files, ,Commands to Specify | |
7285 | Files}). To specify as a target a process that is already running, use | |
7286 | the @code{attach} command (@pxref{Attach, ,Debugging an | |
7287 | Already-Running Process}.). | |
18fae2a8 | 7288 | @end ifclear |
70b88761 | 7289 | |
4eb4cf57 | 7290 | @node Target Commands |
70b88761 RP |
7291 | @section Commands for Managing Targets |
7292 | ||
7293 | @table @code | |
7294 | @item target @var{type} @var{parameters} | |
18fae2a8 | 7295 | Connects the @value{GDBN} host environment to a target machine or process. A |
70b88761 RP |
7296 | target is typically a protocol for talking to debugging facilities. You |
7297 | use the argument @var{type} to specify the type or protocol of the | |
7298 | target machine. | |
7299 | ||
7300 | Further @var{parameters} are interpreted by the target protocol, but | |
7301 | typically include things like device names or host names to connect | |
e251e767 | 7302 | with, process numbers, and baud rates. |
70b88761 RP |
7303 | |
7304 | The @code{target} command will not repeat if you press @key{RET} again | |
7305 | after executing the command. | |
7306 | ||
7307 | @item help target | |
7308 | @kindex help target | |
7309 | Displays the names of all targets available. To display targets | |
7310 | currently selected, use either @code{info target} or @code{info files} | |
29a2b744 | 7311 | (@pxref{Files, ,Commands to Specify Files}). |
70b88761 RP |
7312 | |
7313 | @item help target @var{name} | |
7314 | Describe a particular target, including any parameters necessary to | |
7315 | select it. | |
7316 | @end table | |
7317 | ||
c7cb8acb | 7318 | Here are some common targets (available, or not, depending on the GDB |
70b88761 RP |
7319 | configuration): |
7320 | ||
7321 | @table @code | |
7322 | @item target exec @var{prog} | |
7323 | @kindex target exec | |
7324 | An executable file. @samp{target exec @var{prog}} is the same as | |
7325 | @samp{exec-file @var{prog}}. | |
7326 | ||
7327 | @item target core @var{filename} | |
7328 | @kindex target core | |
7329 | A core dump file. @samp{target core @var{filename}} is the same as | |
7330 | @samp{core-file @var{filename}}. | |
7331 | ||
18fae2a8 | 7332 | @ifset REMOTESTUB |
70b88761 RP |
7333 | @item target remote @var{dev} |
7334 | @kindex target remote | |
c7cb8acb | 7335 | Remote serial target in GDB-specific protocol. The argument @var{dev} |
70b88761 | 7336 | specifies what serial device to use for the connection (e.g. |
1041a570 | 7337 | @file{/dev/ttya}). @xref{Remote, ,Remote Debugging}. |
18fae2a8 | 7338 | @end ifset |
70b88761 | 7339 | |
18fae2a8 | 7340 | @ifset AMDxxixK |
70b88761 RP |
7341 | @item target amd-eb @var{dev} @var{speed} @var{PROG} |
7342 | @kindex target amd-eb | |
7343 | @cindex AMD EB29K | |
7344 | Remote PC-resident AMD EB29K board, attached over serial lines. | |
7345 | @var{dev} is the serial device, as for @code{target remote}; | |
7346 | @var{speed} allows you to specify the linespeed; and @var{PROG} is the | |
7347 | name of the program to be debugged, as it appears to DOS on the PC. | |
18fae2a8 | 7348 | @xref{EB29K Remote, ,@value{GDBN} with a Remote EB29K}. |
77fe5411 | 7349 | |
18fae2a8 RP |
7350 | @end ifset |
7351 | @ifset Hviii | |
c7cb8acb RP |
7352 | @item target hms |
7353 | @kindex target hms | |
7354 | A Hitachi H8/300 board, attached via serial line to your host. Use | |
7355 | special commands @code{device} and @code{speed} to control the serial | |
7356 | line and the communications speed used. @xref{Hitachi H8/300 | |
18fae2a8 | 7357 | Remote,,@value{GDBN} and the Hitachi H8/300}. |
c7cb8acb | 7358 | |
18fae2a8 RP |
7359 | @end ifset |
7360 | @ifset Icmlx | |
70b88761 RP |
7361 | @item target nindy @var{devicename} |
7362 | @kindex target nindy | |
7363 | An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is | |
7364 | the name of the serial device to use for the connection, e.g. | |
18fae2a8 | 7365 | @file{/dev/ttya}. @xref{i960-Nindy Remote, ,@value{GDBN} with a Remote i960 (Nindy)}. |
70b88761 | 7366 | |
18fae2a8 RP |
7367 | @end ifset |
7368 | @ifset STmm | |
77fe5411 RP |
7369 | @item target st2000 @var{dev} @var{speed} |
7370 | @kindex target st2000 | |
7371 | A Tandem ST2000 phone switch, running Tandem's STDBUG protocol. @var{dev} | |
7372 | is the name of the device attached to the ST2000 serial line; | |
7373 | @var{speed} is the communication line speed. The arguments are not used | |
18fae2a8 RP |
7374 | if @value{GDBN} is configured to connect to the ST2000 using TCP or Telnet. |
7375 | @xref{ST2000 Remote,,@value{GDBN} with a Tandem ST2000}. | |
77fe5411 | 7376 | |
18fae2a8 RP |
7377 | @end ifset |
7378 | @ifset VXWORKS | |
70b88761 RP |
7379 | @item target vxworks @var{machinename} |
7380 | @kindex target vxworks | |
7381 | A VxWorks system, attached via TCP/IP. The argument @var{machinename} | |
7382 | is the target system's machine name or IP address. | |
18fae2a8 RP |
7383 | @xref{VxWorks Remote, ,@value{GDBN} and VxWorks}. |
7384 | @end ifset | |
70b88761 RP |
7385 | @end table |
7386 | ||
18fae2a8 RP |
7387 | @ifset GENERIC |
7388 | Different targets are available on different configurations of @value{GDBN}; your | |
70b88761 | 7389 | configuration may have more or fewer targets. |
18fae2a8 | 7390 | @end ifset |
70b88761 | 7391 | |
4eb4cf57 | 7392 | @node Remote |
70b88761 RP |
7393 | @section Remote Debugging |
7394 | @cindex remote debugging | |
7395 | ||
29a2b744 | 7396 | If you are trying to debug a program running on a machine that cannot run |
c7cb8acb | 7397 | GDB in the usual way, it is often useful to use remote debugging. For |
70b88761 RP |
7398 | example, you might use remote debugging on an operating system kernel, or on |
7399 | a small system which does not have a general purpose operating system | |
e251e767 | 7400 | powerful enough to run a full-featured debugger. |
70b88761 | 7401 | |
c7cb8acb | 7402 | Some configurations of GDB have special serial or TCP/IP interfaces |
70b88761 | 7403 | to make this work with particular debugging targets. In addition, |
c7cb8acb | 7404 | GDB comes with a generic serial protocol (specific to GDB, but |
70b88761 RP |
7405 | not specific to any particular target system) which you can use if you |
7406 | write the remote stubs---the code that will run on the remote system to | |
c7cb8acb | 7407 | communicate with GDB. |
70b88761 | 7408 | |
70b88761 | 7409 | Other remote targets may be available in your |
c7cb8acb | 7410 | configuration of GDB; use @code{help targets} to list them. |
70b88761 | 7411 | |
18fae2a8 RP |
7412 | @ifset GENERIC |
7413 | @c Text on starting up GDB in various specific cases; it goes up front | |
7414 | @c in manuals configured for any of those particular situations, here | |
7415 | @c otherwise. | |
7416 | @ignore | |
7417 | @c original, intended form of this menu (pre-unfolding): | |
7418 | @menu | |
7419 | @ifset REMOTESTUB | |
7420 | * Remote Serial:: @value{GDBN} remote serial protocol | |
7421 | @end ifset | |
7422 | @ifset Icmlx | |
7423 | * i960-Nindy Remote:: @value{GDBN} with a remote i960 (Nindy) | |
7424 | @end ifset | |
7425 | @ifset AMDxxixK | |
7426 | * EB29K Remote:: @value{GDBN} with a remote EB29K | |
7427 | @end ifset | |
7428 | @ifset VXWORKS | |
7429 | * VxWorks Remote:: @value{GDBN} and VxWorks | |
7430 | @end ifset | |
7431 | @ifset STmm | |
7432 | * ST2000 Remote:: @value{GDBN} with a Tandem ST2000 | |
7433 | @end ifset | |
7434 | @ifset Hviii | |
7435 | * Hitachi H8/300 Remote:: @value{GDBN} and the Hitachi H8/300 | |
7436 | @end ifset | |
7437 | @ifset ZviiiK | |
7438 | * Z8000 Simulator:: @value{GDBN} and its Zilog Z8000 Simulator | |
7439 | @end ifset | |
7440 | @end menu | |
7441 | @end ignore | |
7442 | ||
7443 | @c Unfolded menus: | |
7444 | @c add as configs require, while unfolding remains necessary. | |
7445 | @c | |
7446 | @c All target details: | |
1041a570 | 7447 | @menu |
18fae2a8 RP |
7448 | * Remote Serial:: @value{GDBN} remote serial protocol |
7449 | * i960-Nindy Remote:: @value{GDBN} with a remote i960 (Nindy) | |
7450 | * EB29K Remote:: @value{GDBN} with a remote EB29K | |
7451 | * VxWorks Remote:: @value{GDBN} and VxWorks | |
7452 | * ST2000 Remote:: @value{GDBN} with a Tandem ST2000 | |
7453 | * Hitachi H8/300 Remote:: @value{GDBN} and the Hitachi H8/300 | |
7454 | * Z8000 Simulator:: @value{GDBN} and its Zilog Z8000 Simulator | |
1041a570 | 7455 | @end menu |
70b88761 | 7456 | |
18fae2a8 RP |
7457 | @include gdbinv-s.texi |
7458 | @end ifset | |
7459 | ||
7460 | @node Controlling GDB | |
7461 | @chapter Controlling @value{GDBN} | |
70b88761 | 7462 | |
18fae2a8 RP |
7463 | You can alter many aspects of @value{GDBN}'s interaction with you by using |
7464 | the @code{set} command. For commands controlling how @value{GDBN} displays | |
1041a570 | 7465 | data, @pxref{Print Settings, ,Print Settings}; other settings are described here. |
70b88761 RP |
7466 | |
7467 | @menu | |
b80282d5 RP |
7468 | * Prompt:: Prompt |
7469 | * Editing:: Command Editing | |
7470 | * History:: Command History | |
7471 | * Screen Size:: Screen Size | |
7472 | * Numbers:: Numbers | |
7473 | * Messages/Warnings:: Optional Warnings and Messages | |
70b88761 RP |
7474 | @end menu |
7475 | ||
4eb4cf57 | 7476 | @node Prompt |
70b88761 RP |
7477 | @section Prompt |
7478 | @cindex prompt | |
1041a570 | 7479 | |
18fae2a8 RP |
7480 | @value{GDBN} indicates its readiness to read a command by printing a string |
7481 | called the @dfn{prompt}. This string is normally @samp{(@value{GDBP})}. You | |
70b88761 | 7482 | can change the prompt string with the @code{set prompt} command. For |
18fae2a8 RP |
7483 | instance, when debugging @value{GDBN} with @value{GDBN}, it is useful to change |
7484 | the prompt in one of the @value{GDBN}s so that you can always tell which | |
70b88761 RP |
7485 | one you are talking to. |
7486 | ||
7487 | @table @code | |
7488 | @item set prompt @var{newprompt} | |
7489 | @kindex set prompt | |
18fae2a8 | 7490 | Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth. |
70b88761 RP |
7491 | @kindex show prompt |
7492 | @item show prompt | |
7493 | Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} | |
7494 | @end table | |
7495 | ||
4eb4cf57 | 7496 | @node Editing |
70b88761 RP |
7497 | @section Command Editing |
7498 | @cindex readline | |
7499 | @cindex command line editing | |
1041a570 | 7500 | |
18fae2a8 | 7501 | @value{GDBN} reads its input commands via the @dfn{readline} interface. This |
70b88761 RP |
7502 | GNU library provides consistent behavior for programs which provide a |
7503 | command line interface to the user. Advantages are @code{emacs}-style | |
7504 | or @code{vi}-style inline editing of commands, @code{csh}-like history | |
7505 | substitution, and a storage and recall of command history across | |
7506 | debugging sessions. | |
7507 | ||
18fae2a8 | 7508 | You may control the behavior of command line editing in @value{GDBN} with the |
e251e767 | 7509 | command @code{set}. |
70b88761 RP |
7510 | |
7511 | @table @code | |
7512 | @kindex set editing | |
7513 | @cindex editing | |
7514 | @item set editing | |
7515 | @itemx set editing on | |
7516 | Enable command line editing (enabled by default). | |
7517 | ||
7518 | @item set editing off | |
7519 | Disable command line editing. | |
7520 | ||
7521 | @kindex show editing | |
7522 | @item show editing | |
7523 | Show whether command line editing is enabled. | |
7524 | @end table | |
7525 | ||
4eb4cf57 | 7526 | @node History |
70b88761 | 7527 | @section Command History |
1041a570 | 7528 | |
70b88761 RP |
7529 | @table @code |
7530 | @cindex history substitution | |
7531 | @cindex history file | |
7532 | @kindex set history filename | |
7533 | @item set history filename @var{fname} | |
18fae2a8 RP |
7534 | Set the name of the @value{GDBN} command history file to @var{fname}. This is |
7535 | the file from which @value{GDBN} will read an initial command history | |
70b88761 RP |
7536 | list or to which it will write this list when it exits. This list is |
7537 | accessed through history expansion or through the history | |
7538 | command editing characters listed below. This file defaults to the | |
7539 | value of the environment variable @code{GDBHISTFILE}, or to | |
7540 | @file{./.gdb_history} if this variable is not set. | |
7541 | ||
7542 | @cindex history save | |
7543 | @kindex set history save | |
7544 | @item set history save | |
7545 | @itemx set history save on | |
7546 | Record command history in a file, whose name may be specified with the | |
7547 | @code{set history filename} command. By default, this option is disabled. | |
7548 | ||
7549 | @item set history save off | |
7550 | Stop recording command history in a file. | |
7551 | ||
7552 | @cindex history size | |
7553 | @kindex set history size | |
7554 | @item set history size @var{size} | |
18fae2a8 | 7555 | Set the number of commands which @value{GDBN} will keep in its history list. |
70b88761 RP |
7556 | This defaults to the value of the environment variable |
7557 | @code{HISTSIZE}, or to 256 if this variable is not set. | |
7558 | @end table | |
7559 | ||
7560 | @cindex history expansion | |
7561 | History expansion assigns special meaning to the character @kbd{!}. | |
7562 | @iftex | |
1041a570 | 7563 | @xref{Event Designators}. |
70b88761 RP |
7564 | @end iftex |
7565 | Since @kbd{!} is also the logical not operator in C, history expansion | |
7566 | is off by default. If you decide to enable history expansion with the | |
7567 | @code{set history expansion on} command, you may sometimes need to | |
7568 | follow @kbd{!} (when it is used as logical not, in an expression) with | |
7569 | a space or a tab to prevent it from being expanded. The readline | |
7570 | history facilities will not attempt substitution on the strings | |
7571 | @kbd{!=} and @kbd{!(}, even when history expansion is enabled. | |
7572 | ||
7573 | The commands to control history expansion are: | |
7574 | ||
7575 | @table @code | |
7576 | ||
7577 | @kindex set history expansion | |
7578 | @item set history expansion on | |
7579 | @itemx set history expansion | |
7580 | Enable history expansion. History expansion is off by default. | |
7581 | ||
7582 | @item set history expansion off | |
7583 | Disable history expansion. | |
7584 | ||
7585 | The readline code comes with more complete documentation of | |
7586 | editing and history expansion features. Users unfamiliar with @code{emacs} | |
e251e767 | 7587 | or @code{vi} may wish to read it. |
70b88761 RP |
7588 | @iftex |
7589 | @xref{Command Line Editing}. | |
7590 | @end iftex | |
7591 | ||
7592 | @c @group | |
7593 | @kindex show history | |
7594 | @item show history | |
7595 | @itemx show history filename | |
7596 | @itemx show history save | |
7597 | @itemx show history size | |
7598 | @itemx show history expansion | |
18fae2a8 | 7599 | These commands display the state of the @value{GDBN} history parameters. |
70b88761 RP |
7600 | @code{show history} by itself displays all four states. |
7601 | @c @end group | |
70b88761 RP |
7602 | @end table |
7603 | ||
7604 | @table @code | |
7605 | @kindex show commands | |
7606 | @item show commands | |
7607 | Display the last ten commands in the command history. | |
7608 | ||
7609 | @item show commands @var{n} | |
7610 | Print ten commands centered on command number @var{n}. | |
7611 | ||
7612 | @item show commands + | |
7613 | Print ten commands just after the commands last printed. | |
70b88761 RP |
7614 | @end table |
7615 | ||
4eb4cf57 | 7616 | @node Screen Size |
70b88761 RP |
7617 | @section Screen Size |
7618 | @cindex size of screen | |
7619 | @cindex pauses in output | |
1041a570 | 7620 | |
18fae2a8 RP |
7621 | Certain commands to @value{GDBN} may produce large amounts of information |
7622 | output to the screen. To help you read all of it, @value{GDBN} pauses and | |
70b88761 | 7623 | asks you for input at the end of each page of output. Type @key{RET} |
18fae2a8 | 7624 | when you want to continue the output. @value{GDBN} also uses the screen |
70b88761 RP |
7625 | width setting to determine when to wrap lines of output. Depending on |
7626 | what is being printed, it tries to break the line at a readable place, | |
7627 | rather than simply letting it overflow onto the following line. | |
7628 | ||
18fae2a8 | 7629 | Normally @value{GDBN} knows the size of the screen from the termcap data base |
70b88761 RP |
7630 | together with the value of the @code{TERM} environment variable and the |
7631 | @code{stty rows} and @code{stty cols} settings. If this is not correct, | |
7632 | you can override it with the @code{set height} and @code{set | |
7633 | width} commands: | |
7634 | ||
7635 | @table @code | |
7636 | @item set height @var{lpp} | |
7637 | @itemx show height | |
7638 | @itemx set width @var{cpl} | |
7639 | @itemx show width | |
7640 | @kindex set height | |
7641 | @kindex set width | |
7642 | @kindex show width | |
7643 | @kindex show height | |
7644 | These @code{set} commands specify a screen height of @var{lpp} lines and | |
7645 | a screen width of @var{cpl} characters. The associated @code{show} | |
7646 | commands display the current settings. | |
7647 | ||
18fae2a8 | 7648 | If you specify a height of zero lines, @value{GDBN} will not pause during output |
70b88761 RP |
7649 | no matter how long the output is. This is useful if output is to a file |
7650 | or to an editor buffer. | |
7651 | @end table | |
7652 | ||
4eb4cf57 | 7653 | @node Numbers |
70b88761 RP |
7654 | @section Numbers |
7655 | @cindex number representation | |
7656 | @cindex entering numbers | |
1041a570 | 7657 | |
18fae2a8 | 7658 | You can always enter numbers in octal, decimal, or hexadecimal in @value{GDBN} by |
70b88761 RP |
7659 | the usual conventions: octal numbers begin with @samp{0}, decimal |
7660 | numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}. | |
7661 | Numbers that begin with none of these are, by default, entered in base | |
7662 | 10; likewise, the default display for numbers---when no particular | |
7663 | format is specified---is base 10. You can change the default base for | |
7664 | both input and output with the @code{set radix} command. | |
7665 | ||
7666 | @table @code | |
7667 | @kindex set radix | |
7668 | @item set radix @var{base} | |
7669 | Set the default base for numeric input and display. Supported choices | |
c2bbbb22 | 7670 | for @var{base} are decimal 2, 8, 10, 16. @var{base} must itself be |
70b88761 RP |
7671 | specified either unambiguously or using the current default radix; for |
7672 | example, any of | |
7673 | ||
7674 | @example | |
c2bbbb22 | 7675 | set radix 1010 |
70b88761 RP |
7676 | set radix 012 |
7677 | set radix 10. | |
7678 | set radix 0xa | |
7679 | @end example | |
7680 | ||
7681 | @noindent | |
7682 | will set the base to decimal. On the other hand, @samp{set radix 10} | |
7683 | will leave the radix unchanged no matter what it was. | |
7684 | ||
7685 | @kindex show radix | |
7686 | @item show radix | |
7687 | Display the current default base for numeric input and display. | |
70b88761 RP |
7688 | @end table |
7689 | ||
4eb4cf57 | 7690 | @node Messages/Warnings |
70b88761 | 7691 | @section Optional Warnings and Messages |
1041a570 | 7692 | |
18fae2a8 | 7693 | By default, @value{GDBN} is silent about its inner workings. If you are running |
70b88761 | 7694 | on a slow machine, you may want to use the @code{set verbose} command. |
18fae2a8 | 7695 | It will make @value{GDBN} tell you when it does a lengthy internal operation, so |
1041a570 | 7696 | you will not think it has crashed. |
70b88761 | 7697 | |
1041a570 | 7698 | Currently, the messages controlled by @code{set verbose} are those |
d48da190 RP |
7699 | which announce that the symbol table for a source file is being read; |
7700 | see @code{symbol-file} in @ref{Files, ,Commands to Specify Files}. | |
70b88761 RP |
7701 | |
7702 | @table @code | |
7703 | @kindex set verbose | |
7704 | @item set verbose on | |
18fae2a8 | 7705 | Enables @value{GDBN}'s output of certain informational messages. |
70b88761 RP |
7706 | |
7707 | @item set verbose off | |
18fae2a8 | 7708 | Disables @value{GDBN}'s output of certain informational messages. |
70b88761 RP |
7709 | |
7710 | @kindex show verbose | |
7711 | @item show verbose | |
7712 | Displays whether @code{set verbose} is on or off. | |
7713 | @end table | |
7714 | ||
18fae2a8 | 7715 | By default, if @value{GDBN} encounters bugs in the symbol table of an object |
b80282d5 | 7716 | file, it is silent; but if you are debugging a compiler, you may find |
1041a570 | 7717 | this information useful (@pxref{Symbol Errors, ,Errors Reading Symbol Files}). |
70b88761 RP |
7718 | |
7719 | @table @code | |
7720 | @kindex set complaints | |
7721 | @item set complaints @var{limit} | |
18fae2a8 | 7722 | Permits @value{GDBN} to output @var{limit} complaints about each type of unusual |
70b88761 RP |
7723 | symbols before becoming silent about the problem. Set @var{limit} to |
7724 | zero to suppress all complaints; set it to a large number to prevent | |
7725 | complaints from being suppressed. | |
7726 | ||
7727 | @kindex show complaints | |
7728 | @item show complaints | |
18fae2a8 | 7729 | Displays how many symbol complaints @value{GDBN} is permitted to produce. |
70b88761 RP |
7730 | @end table |
7731 | ||
18fae2a8 | 7732 | By default, @value{GDBN} is cautious, and asks what sometimes seems to be a |
70b88761 RP |
7733 | lot of stupid questions to confirm certain commands. For example, if |
7734 | you try to run a program which is already running: | |
1041a570 | 7735 | |
70b88761 | 7736 | @example |
18fae2a8 | 7737 | (@value{GDBP}) run |
70b88761 | 7738 | The program being debugged has been started already. |
e251e767 | 7739 | Start it from the beginning? (y or n) |
70b88761 RP |
7740 | @end example |
7741 | ||
29a2b744 | 7742 | If you are willing to unflinchingly face the consequences of your own |
70b88761 RP |
7743 | commands, you can disable this ``feature'': |
7744 | ||
7745 | @table @code | |
7746 | @kindex set confirm | |
7747 | @cindex flinching | |
7748 | @cindex confirmation | |
7749 | @cindex stupid questions | |
7750 | @item set confirm off | |
7751 | Disables confirmation requests. | |
7752 | ||
7753 | @item set confirm on | |
7754 | Enables confirmation requests (the default). | |
7755 | ||
7756 | @item show confirm | |
7757 | @kindex show confirm | |
7758 | Displays state of confirmation requests. | |
7759 | @end table | |
7760 | ||
29a2b744 | 7761 | @c FIXME this does not really belong here. But where *does* it belong? |
b80282d5 RP |
7762 | @cindex reloading symbols |
7763 | Some systems allow individual object files that make up your program to | |
7764 | be replaced without stopping and restarting your program. | |
18fae2a8 | 7765 | @ifset VXWORKS |
b80282d5 RP |
7766 | For example, in VxWorks you can simply recompile a defective object file |
7767 | and keep on running. | |
18fae2a8 RP |
7768 | @end ifset |
7769 | If you are running on one of these systems, you can allow @value{GDBN} to | |
1041a570 RP |
7770 | reload the symbols for automatically relinked modules: |
7771 | ||
b80282d5 RP |
7772 | @table @code |
7773 | @kindex set symbol-reloading | |
7774 | @item set symbol-reloading on | |
7775 | Replace symbol definitions for the corresponding source file when an | |
7776 | object file with a particular name is seen again. | |
7777 | ||
7778 | @item set symbol-reloading off | |
1041a570 | 7779 | Do not replace symbol definitions when re-encountering object files of |
29a2b744 | 7780 | the same name. This is the default state; if you are not running on a |
b80282d5 | 7781 | system that permits automatically relinking modules, you should leave |
18fae2a8 | 7782 | @code{symbol-reloading} off, since otherwise @value{GDBN} may discard symbols |
b80282d5 RP |
7783 | when linking large programs, that may contain several modules (from |
7784 | different directories or libraries) with the same name. | |
7785 | ||
7786 | @item show symbol-reloading | |
7787 | Show the current @code{on} or @code{off} setting. | |
7788 | @end table | |
7789 | ||
4eb4cf57 | 7790 | @node Sequences |
70b88761 RP |
7791 | @chapter Canned Sequences of Commands |
7792 | ||
29a2b744 | 7793 | Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint |
18fae2a8 | 7794 | Command Lists}), @value{GDBN} provides two ways to store sequences of commands |
1041a570 | 7795 | for execution as a unit: user-defined commands and command files. |
70b88761 RP |
7796 | |
7797 | @menu | |
b80282d5 | 7798 | * Define:: User-Defined Commands |
35a15d60 | 7799 | * Hooks:: User-Defined Command Hooks |
b80282d5 RP |
7800 | * Command Files:: Command Files |
7801 | * Output:: Commands for Controlled Output | |
70b88761 RP |
7802 | @end menu |
7803 | ||
4eb4cf57 | 7804 | @node Define |
70b88761 RP |
7805 | @section User-Defined Commands |
7806 | ||
7807 | @cindex user-defined command | |
18fae2a8 | 7808 | A @dfn{user-defined command} is a sequence of @value{GDBN} commands to which you |
70b88761 RP |
7809 | assign a new name as a command. This is done with the @code{define} |
7810 | command. | |
7811 | ||
7812 | @table @code | |
7813 | @item define @var{commandname} | |
7814 | @kindex define | |
7815 | Define a command named @var{commandname}. If there is already a command | |
7816 | by that name, you are asked to confirm that you want to redefine it. | |
7817 | ||
18fae2a8 | 7818 | The definition of the command is made up of other @value{GDBN} command lines, |
70b88761 RP |
7819 | which are given following the @code{define} command. The end of these |
7820 | commands is marked by a line containing @code{end}. | |
7821 | ||
7822 | @item document @var{commandname} | |
7823 | @kindex document | |
7824 | Give documentation to the user-defined command @var{commandname}. The | |
7825 | command @var{commandname} must already be defined. This command reads | |
7826 | lines of documentation just as @code{define} reads the lines of the | |
7827 | command definition, ending with @code{end}. After the @code{document} | |
7828 | command is finished, @code{help} on command @var{commandname} will print | |
7829 | the documentation you have specified. | |
7830 | ||
7831 | You may use the @code{document} command again to change the | |
7832 | documentation of a command. Redefining the command with @code{define} | |
7833 | does not change the documentation. | |
7834 | ||
7835 | @item help user-defined | |
7836 | @kindex help user-defined | |
7837 | List all user-defined commands, with the first line of the documentation | |
7838 | (if any) for each. | |
7839 | ||
4768ba62 JG |
7840 | @item show user |
7841 | @itemx show user @var{commandname} | |
7842 | @kindex show user | |
18fae2a8 | 7843 | Display the @value{GDBN} commands used to define @var{commandname} (but not its |
70b88761 RP |
7844 | documentation). If no @var{commandname} is given, display the |
7845 | definitions for all user-defined commands. | |
7846 | @end table | |
7847 | ||
7848 | User-defined commands do not take arguments. When they are executed, the | |
7849 | commands of the definition are not printed. An error in any command | |
7850 | stops execution of the user-defined command. | |
7851 | ||
7852 | Commands that would ask for confirmation if used interactively proceed | |
18fae2a8 | 7853 | without asking when used inside a user-defined command. Many @value{GDBN} commands |
70b88761 RP |
7854 | that normally print messages to say what they are doing omit the messages |
7855 | when used in a user-defined command. | |
7856 | ||
35a15d60 JG |
7857 | @node Hooks |
7858 | @section User-Defined Command Hooks | |
7859 | @cindex command files | |
7860 | ||
7861 | You may define @emph{hooks}, which are a special kind of user-defined | |
7862 | command. Whenever you run the command @samp{foo}, if the user-defined | |
7863 | command @samp{hook-foo} exists, it is executed (with no arguments) | |
7864 | before that command. | |
7865 | ||
7866 | In addition, a pseudo-command, @samp{stop} exists. Hooking this command | |
7867 | will cause your hook to be executed every time execution stops in the | |
7868 | inferior program, before breakpoint commands are run, displays are | |
7869 | printed, or the stack frame is printed. | |
7870 | ||
7871 | For example, to cause @code{SIGALRM} signals to be ignored while | |
7872 | single-stepping, but cause them to be resumed during normal execution, | |
7873 | you could do: | |
7874 | ||
7875 | @example | |
7876 | define hook-stop | |
7877 | handle SIGALRM nopass | |
7878 | end | |
7879 | ||
7880 | define hook-run | |
7881 | handle SIGALRM pass | |
7882 | end | |
7883 | ||
7884 | define hook-continue | |
7885 | handle SIGLARM pass | |
7886 | end | |
7887 | @end example | |
7888 | ||
7889 | Any single-word command in GDB can be hooked. Aliases for other commands | |
7890 | cannot be hooked (you should hook the basic command name, e.g. @code{backtrace} | |
7891 | rather than @code{bt}). If an error occurs during the execution of your | |
7892 | hook, execution of GDB commands stops and you are returned to the GDB | |
7893 | prompt (before the command that you actually typed had a chance to run). | |
7894 | ||
7895 | If you try to define a hook which doesn't match any known command, you | |
7896 | will get a warning from the @code{define} command. | |
7897 | ||
4eb4cf57 | 7898 | @node Command Files |
70b88761 RP |
7899 | @section Command Files |
7900 | ||
7901 | @cindex command files | |
18fae2a8 | 7902 | A command file for @value{GDBN} is a file of lines that are @value{GDBN} commands. Comments |
70b88761 RP |
7903 | (lines starting with @kbd{#}) may also be included. An empty line in a |
7904 | command file does nothing; it does not mean to repeat the last command, as | |
7905 | it would from the terminal. | |
7906 | ||
7907 | @cindex init file | |
18fae2a8 RP |
7908 | @cindex @file{@value{GDBINIT}} |
7909 | When you start @value{GDBN}, it automatically executes commands from its | |
7910 | @dfn{init files}. These are files named @file{@value{GDBINIT}}. @value{GDBN} reads | |
1041a570 RP |
7911 | the init file (if any) in your home directory and then the init file |
7912 | (if any) in the current working directory. (The init files are not | |
7913 | executed if you use the @samp{-nx} option; @pxref{Mode Options, | |
7914 | ,Choosing Modes}.) You can also request the execution of a command | |
7915 | file with the @code{source} command: | |
70b88761 RP |
7916 | |
7917 | @table @code | |
7918 | @item source @var{filename} | |
7919 | @kindex source | |
7920 | Execute the command file @var{filename}. | |
7921 | @end table | |
7922 | ||
7923 | The lines in a command file are executed sequentially. They are not | |
7924 | printed as they are executed. An error in any command terminates execution | |
7925 | of the command file. | |
7926 | ||
7927 | Commands that would ask for confirmation if used interactively proceed | |
18fae2a8 | 7928 | without asking when used in a command file. Many @value{GDBN} commands that |
70b88761 RP |
7929 | normally print messages to say what they are doing omit the messages |
7930 | when called from command files. | |
7931 | ||
4eb4cf57 | 7932 | @node Output |
70b88761 RP |
7933 | @section Commands for Controlled Output |
7934 | ||
7935 | During the execution of a command file or a user-defined command, normal | |
18fae2a8 | 7936 | @value{GDBN} output is suppressed; the only output that appears is what is |
70b88761 RP |
7937 | explicitly printed by the commands in the definition. This section |
7938 | describes three commands useful for generating exactly the output you | |
7939 | want. | |
7940 | ||
7941 | @table @code | |
7942 | @item echo @var{text} | |
7943 | @kindex echo | |
29a2b744 RP |
7944 | @c I do not consider backslash-space a standard C escape sequence |
7945 | @c because it is not in ANSI. | |
1041a570 RP |
7946 | Print @var{text}. Nonprinting characters can be included in |
7947 | @var{text} using C escape sequences, such as @samp{\n} to print a | |
7948 | newline. @strong{No newline will be printed unless you specify one.} | |
7949 | In addition to the standard C escape sequences, a backslash followed | |
7950 | by a space stands for a space. This is useful for outputting a | |
7951 | string with spaces at the beginning or the end, since leading and | |
7952 | trailing spaces are otherwise trimmed from all arguments. | |
7953 | To print @samp{@w{ }and foo =@w{ }}, use the command | |
7954 | @samp{echo \@w{ }and foo = \@w{ }}. | |
70b88761 RP |
7955 | |
7956 | A backslash at the end of @var{text} can be used, as in C, to continue | |
7957 | the command onto subsequent lines. For example, | |
7958 | ||
7959 | @example | |
7960 | echo This is some text\n\ | |
7961 | which is continued\n\ | |
7962 | onto several lines.\n | |
7963 | @end example | |
7964 | ||
7965 | produces the same output as | |
7966 | ||
7967 | @example | |
7968 | echo This is some text\n | |
7969 | echo which is continued\n | |
7970 | echo onto several lines.\n | |
7971 | @end example | |
7972 | ||
7973 | @item output @var{expression} | |
7974 | @kindex output | |
7975 | Print the value of @var{expression} and nothing but that value: no | |
7976 | newlines, no @samp{$@var{nn} = }. The value is not entered in the | |
1041a570 | 7977 | value history either. @xref{Expressions, ,Expressions}, for more information on |
e251e767 | 7978 | expressions. |
70b88761 RP |
7979 | |
7980 | @item output/@var{fmt} @var{expression} | |
7981 | Print the value of @var{expression} in format @var{fmt}. You can use | |
7982 | the same formats as for @code{print}; @pxref{Output formats}, for more | |
7983 | information. | |
7984 | ||
7985 | @item printf @var{string}, @var{expressions}@dots{} | |
7986 | @kindex printf | |
7987 | Print the values of the @var{expressions} under the control of | |
7988 | @var{string}. The @var{expressions} are separated by commas and may | |
7989 | be either numbers or pointers. Their values are printed as specified | |
29a2b744 | 7990 | by @var{string}, exactly as if your program were to execute |
70b88761 RP |
7991 | |
7992 | @example | |
7993 | printf (@var{string}, @var{expressions}@dots{}); | |
7994 | @end example | |
7995 | ||
7996 | For example, you can print two values in hex like this: | |
7997 | ||
0fd24984 | 7998 | @smallexample |
70b88761 | 7999 | printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo |
0fd24984 | 8000 | @end smallexample |
70b88761 RP |
8001 | |
8002 | The only backslash-escape sequences that you can use in the format | |
8003 | string are the simple ones that consist of backslash followed by a | |
8004 | letter. | |
8005 | @end table | |
8006 | ||
18fae2a8 | 8007 | @ifclear DOSHOST |
4eb4cf57 | 8008 | @node Emacs |
18fae2a8 | 8009 | @chapter Using @value{GDBN} under GNU Emacs |
70b88761 RP |
8010 | |
8011 | @cindex emacs | |
8012 | A special interface allows you to use GNU Emacs to view (and | |
8013 | edit) the source files for the program you are debugging with | |
18fae2a8 | 8014 | @value{GDBN}. |
70b88761 RP |
8015 | |
8016 | To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the | |
8017 | executable file you want to debug as an argument. This command starts | |
18fae2a8 | 8018 | @value{GDBN} as a subprocess of Emacs, with input and output through a newly |
70b88761 RP |
8019 | created Emacs buffer. |
8020 | ||
18fae2a8 | 8021 | Using @value{GDBN} under Emacs is just like using @value{GDBN} normally except for two |
70b88761 RP |
8022 | things: |
8023 | ||
8024 | @itemize @bullet | |
8025 | @item | |
e251e767 | 8026 | All ``terminal'' input and output goes through the Emacs buffer. |
70b88761 RP |
8027 | @end itemize |
8028 | ||
18fae2a8 | 8029 | This applies both to @value{GDBN} commands and their output, and to the input |
70b88761 RP |
8030 | and output done by the program you are debugging. |
8031 | ||
8032 | This is useful because it means that you can copy the text of previous | |
8033 | commands and input them again; you can even use parts of the output | |
8034 | in this way. | |
8035 | ||
3d3ab540 RP |
8036 | All the facilities of Emacs' Shell mode are available for interacting |
8037 | with your program. In particular, you can send signals the usual | |
8038 | way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a | |
8039 | stop. | |
70b88761 RP |
8040 | |
8041 | @itemize @bullet | |
8042 | @item | |
18fae2a8 | 8043 | @value{GDBN} displays source code through Emacs. |
70b88761 RP |
8044 | @end itemize |
8045 | ||
18fae2a8 RP |
8046 | Each time @value{GDBN} displays a stack frame, Emacs automatically finds the |
8047 | source file for that frame and puts an arrow (@samp{=>}) at the | |
70b88761 | 8048 | left margin of the current line. Emacs uses a separate buffer for |
18fae2a8 | 8049 | source display, and splits the window to show both your @value{GDBN} session |
70b88761 RP |
8050 | and the source. |
8051 | ||
18fae2a8 | 8052 | Explicit @value{GDBN} @code{list} or search commands still produce output as |
70b88761 RP |
8053 | usual, but you probably will have no reason to use them. |
8054 | ||
8055 | @quotation | |
8056 | @emph{Warning:} If the directory where your program resides is not your | |
8057 | current directory, it can be easy to confuse Emacs about the location of | |
8058 | the source files, in which case the auxiliary display buffer will not | |
18fae2a8 RP |
8059 | appear to show your source. @value{GDBN} can find programs by searching your |
8060 | environment's @code{PATH} variable, so the @value{GDBN} input and output | |
29a2b744 | 8061 | session will proceed normally; but Emacs does not get enough information |
18fae2a8 RP |
8062 | back from @value{GDBN} to locate the source files in this situation. To |
8063 | avoid this problem, either start @value{GDBN} mode from the directory where | |
70b88761 RP |
8064 | your program resides, or specify a full path name when prompted for the |
8065 | @kbd{M-x gdb} argument. | |
8066 | ||
18fae2a8 | 8067 | A similar confusion can result if you use the @value{GDBN} @code{file} command to |
70b88761 | 8068 | switch to debugging a program in some other location, from an existing |
18fae2a8 | 8069 | @value{GDBN} buffer in Emacs. |
70b88761 RP |
8070 | @end quotation |
8071 | ||
8072 | By default, @kbd{M-x gdb} calls the program called @file{gdb}. If | |
18fae2a8 | 8073 | you need to call @value{GDBN} by a different name (for example, if you keep |
70b88761 RP |
8074 | several configurations around, with different names) you can set the |
8075 | Emacs variable @code{gdb-command-name}; for example, | |
1041a570 | 8076 | |
70b88761 RP |
8077 | @example |
8078 | (setq gdb-command-name "mygdb") | |
8079 | @end example | |
1041a570 | 8080 | |
70b88761 RP |
8081 | @noindent |
8082 | (preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or | |
8083 | in your @file{.emacs} file) will make Emacs call the program named | |
8084 | ``@code{mygdb}'' instead. | |
8085 | ||
18fae2a8 | 8086 | In the @value{GDBN} I/O buffer, you can use these special Emacs commands in |
70b88761 RP |
8087 | addition to the standard Shell mode commands: |
8088 | ||
8089 | @table @kbd | |
8090 | @item C-h m | |
18fae2a8 | 8091 | Describe the features of Emacs' @value{GDBN} Mode. |
70b88761 RP |
8092 | |
8093 | @item M-s | |
18fae2a8 | 8094 | Execute to another source line, like the @value{GDBN} @code{step} command; also |
70b88761 RP |
8095 | update the display window to show the current file and location. |
8096 | ||
8097 | @item M-n | |
8098 | Execute to next source line in this function, skipping all function | |
18fae2a8 | 8099 | calls, like the @value{GDBN} @code{next} command. Then update the display window |
70b88761 RP |
8100 | to show the current file and location. |
8101 | ||
8102 | @item M-i | |
18fae2a8 | 8103 | Execute one instruction, like the @value{GDBN} @code{stepi} command; update |
70b88761 RP |
8104 | display window accordingly. |
8105 | ||
8106 | @item M-x gdb-nexti | |
18fae2a8 | 8107 | Execute to next instruction, using the @value{GDBN} @code{nexti} command; update |
70b88761 RP |
8108 | display window accordingly. |
8109 | ||
8110 | @item C-c C-f | |
18fae2a8 | 8111 | Execute until exit from the selected stack frame, like the @value{GDBN} |
70b88761 RP |
8112 | @code{finish} command. |
8113 | ||
8114 | @item M-c | |
18fae2a8 | 8115 | Continue execution of your program, like the @value{GDBN} @code{continue} |
1041a570 | 8116 | command. |
203eea5d RP |
8117 | |
8118 | @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}. | |
70b88761 RP |
8119 | |
8120 | @item M-u | |
8121 | Go up the number of frames indicated by the numeric argument | |
8122 | (@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}), | |
18fae2a8 | 8123 | like the @value{GDBN} @code{up} command. |
203eea5d | 8124 | |
1041a570 | 8125 | @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-u}. |
70b88761 RP |
8126 | |
8127 | @item M-d | |
8128 | Go down the number of frames indicated by the numeric argument, like the | |
18fae2a8 | 8129 | @value{GDBN} @code{down} command. |
203eea5d RP |
8130 | |
8131 | @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-d}. | |
70b88761 RP |
8132 | |
8133 | @item C-x & | |
8134 | Read the number where the cursor is positioned, and insert it at the end | |
18fae2a8 | 8135 | of the @value{GDBN} I/O buffer. For example, if you wish to disassemble code |
70b88761 RP |
8136 | around an address that was displayed earlier, type @kbd{disassemble}; |
8137 | then move the cursor to the address display, and pick up the | |
e251e767 | 8138 | argument for @code{disassemble} by typing @kbd{C-x &}. |
70b88761 RP |
8139 | |
8140 | You can customize this further on the fly by defining elements of the list | |
8141 | @code{gdb-print-command}; once it is defined, you can format or | |
8142 | otherwise process numbers picked up by @kbd{C-x &} before they are | |
c2bbbb22 | 8143 | inserted. A numeric argument to @kbd{C-x &} will both indicate that you |
70b88761 RP |
8144 | wish special formatting, and act as an index to pick an element of the |
8145 | list. If the list element is a string, the number to be inserted is | |
8146 | formatted using the Emacs function @code{format}; otherwise the number | |
8147 | is passed as an argument to the corresponding list element. | |
70b88761 RP |
8148 | @end table |
8149 | ||
8150 | In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break}) | |
18fae2a8 | 8151 | tells @value{GDBN} to set a breakpoint on the source line point is on. |
70b88761 RP |
8152 | |
8153 | If you accidentally delete the source-display buffer, an easy way to get | |
18fae2a8 | 8154 | it back is to type the command @code{f} in the @value{GDBN} buffer, to |
70b88761 RP |
8155 | request a frame display; when you run under Emacs, this will recreate |
8156 | the source buffer if necessary to show you the context of the current | |
8157 | frame. | |
8158 | ||
8159 | The source files displayed in Emacs are in ordinary Emacs buffers | |
8160 | which are visiting the source files in the usual way. You can edit | |
18fae2a8 | 8161 | the files with these buffers if you wish; but keep in mind that @value{GDBN} |
70b88761 | 8162 | communicates with Emacs in terms of line numbers. If you add or |
18fae2a8 | 8163 | delete lines from the text, the line numbers that @value{GDBN} knows will cease |
70b88761 RP |
8164 | to correspond properly to the code. |
8165 | ||
8166 | @c The following dropped because Epoch is nonstandard. Reactivate | |
8167 | @c if/when v19 does something similar. ---pesch@cygnus.com 19dec1990 | |
8168 | @ignore | |
e251e767 | 8169 | @kindex emacs epoch environment |
70b88761 RP |
8170 | @kindex epoch |
8171 | @kindex inspect | |
8172 | ||
8173 | Version 18 of Emacs has a built-in window system called the @code{epoch} | |
8174 | environment. Users of this environment can use a new command, | |
8175 | @code{inspect} which performs identically to @code{print} except that | |
8176 | each value is printed in its own window. | |
8177 | @end ignore | |
18fae2a8 | 8178 | @end ifclear |
70b88761 | 8179 | |
18fae2a8 | 8180 | @ifset LUCID |
4eb4cf57 | 8181 | @node Energize |
18fae2a8 | 8182 | @chapter Using @value{GDBN} with Energize |
6ca72cc6 RP |
8183 | |
8184 | @cindex Energize | |
8185 | The Energize Programming System is an integrated development environment | |
8186 | that includes a point-and-click interface to many programming tools. | |
18fae2a8 RP |
8187 | When you use @value{GDBN} in this environment, you can use the standard |
8188 | Energize graphical interface to drive @value{GDBN}; you can also, if you | |
8189 | choose, type @value{GDBN} commands as usual in a debugging window. Even if | |
6ca72cc6 | 8190 | you use the graphical interface, the debugging window (which uses Emacs, |
18fae2a8 | 8191 | and resembles the standard Emacs interface to @value{GDBN}) displays the |
6ca72cc6 RP |
8192 | equivalent commands, so that the history of your debugging session is |
8193 | properly reflected. | |
8194 | ||
18fae2a8 | 8195 | When Energize starts up a @value{GDBN} session, it uses one of the |
6ca72cc6 RP |
8196 | command-line options @samp{-energize} or @samp{-cadillac} (``cadillac'' |
8197 | is the name of the communications protocol used by the Energize system). | |
18fae2a8 | 8198 | This option makes @value{GDBN} run as one of the tools in the Energize Tool |
6ca72cc6 RP |
8199 | Set: it sends all output to the Energize kernel, and accept input from |
8200 | it as well. | |
8201 | ||
8202 | See the user manual for the Energize Programming System for | |
8203 | information on how to use the Energize graphical interface and the other | |
18fae2a8 | 8204 | development tools that Energize integrates with @value{GDBN}. |
6ca72cc6 | 8205 | |
18fae2a8 | 8206 | @end ifset |
4eb4cf57 | 8207 | |
18fae2a8 RP |
8208 | @node GDB Bugs |
8209 | @chapter Reporting Bugs in @value{GDBN} | |
8210 | @cindex Bugs in @value{GDBN} | |
8211 | @cindex Reporting Bugs in @value{GDBN} | |
70b88761 | 8212 | |
18fae2a8 | 8213 | Your bug reports play an essential role in making @value{GDBN} reliable. |
70b88761 RP |
8214 | |
8215 | Reporting a bug may help you by bringing a solution to your problem, or it | |
8216 | may not. But in any case the principal function of a bug report is to help | |
18fae2a8 RP |
8217 | the entire community by making the next version of @value{GDBN} work better. Bug |
8218 | reports are your contribution to the maintenance of @value{GDBN}. | |
70b88761 RP |
8219 | |
8220 | In order for a bug report to serve its purpose, you must include the | |
8221 | information that enables us to fix the bug. | |
8222 | ||
8223 | @menu | |
b80282d5 RP |
8224 | * Bug Criteria:: Have You Found a Bug? |
8225 | * Bug Reporting:: How to Report Bugs | |
70b88761 RP |
8226 | @end menu |
8227 | ||
4eb4cf57 | 8228 | @node Bug Criteria |
70b88761 RP |
8229 | @section Have You Found a Bug? |
8230 | @cindex Bug Criteria | |
8231 | ||
8232 | If you are not sure whether you have found a bug, here are some guidelines: | |
8233 | ||
8234 | @itemize @bullet | |
8235 | @item | |
0f153e74 RP |
8236 | @cindex fatal signal |
8237 | @cindex core dump | |
70b88761 | 8238 | If the debugger gets a fatal signal, for any input whatever, that is a |
18fae2a8 | 8239 | @value{GDBN} bug. Reliable debuggers never crash. |
70b88761 RP |
8240 | |
8241 | @item | |
0f153e74 | 8242 | @cindex error on valid input |
18fae2a8 | 8243 | If @value{GDBN} produces an error message for valid input, that is a bug. |
70b88761 RP |
8244 | |
8245 | @item | |
8246 | @cindex Invalid Input | |
18fae2a8 | 8247 | If @value{GDBN} does not produce an error message for invalid input, |
70b88761 RP |
8248 | that is a bug. However, you should note that your idea of |
8249 | ``invalid input'' might be our idea of ``an extension'' or ``support | |
8250 | for traditional practice''. | |
8251 | ||
8252 | @item | |
8253 | If you are an experienced user of debugging tools, your suggestions | |
18fae2a8 | 8254 | for improvement of @value{GDBN} are welcome in any case. |
70b88761 RP |
8255 | @end itemize |
8256 | ||
4eb4cf57 | 8257 | @node Bug Reporting |
70b88761 | 8258 | @section How to Report Bugs |
0f153e74 | 8259 | @cindex bug reports |
18fae2a8 | 8260 | @cindex @value{GDBN} bugs, reporting |
70b88761 RP |
8261 | |
8262 | A number of companies and individuals offer support for GNU products. | |
18fae2a8 | 8263 | If you obtained @value{GDBN} from a support organization, we recommend you |
e251e767 | 8264 | contact that organization first. |
70b88761 RP |
8265 | |
8266 | Contact information for many support companies and individuals is | |
8267 | available in the file @file{etc/SERVICE} in the GNU Emacs distribution. | |
8268 | ||
18fae2a8 | 8269 | In any event, we also recommend that you send bug reports for @value{GDBN} to one |
70b88761 RP |
8270 | of these addresses: |
8271 | ||
8272 | @example | |
8273 | bug-gdb@@prep.ai.mit.edu | |
8274 | @{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb | |
8275 | @end example | |
8276 | ||
8277 | @strong{Do not send bug reports to @samp{info-gdb}, or to | |
18fae2a8 | 8278 | @samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do not want to |
70b88761 RP |
8279 | receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}. |
8280 | ||
3d3ab540 RP |
8281 | The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which |
8282 | serves as a repeater. The mailing list and the newsgroup carry exactly | |
8283 | the same messages. Often people think of posting bug reports to the | |
8284 | newsgroup instead of mailing them. This appears to work, but it has one | |
8285 | problem which can be crucial: a newsgroup posting often lacks a mail | |
8286 | path back to the sender. Thus, if we need to ask for more information, | |
8287 | we may be unable to reach you. For this reason, it is better to send | |
8288 | bug reports to the mailing list. | |
70b88761 RP |
8289 | |
8290 | As a last resort, send bug reports on paper to: | |
8291 | ||
8292 | @example | |
8293 | GNU Debugger Bugs | |
3d3ab540 | 8294 | Free Software Foundation |
70b88761 RP |
8295 | 545 Tech Square |
8296 | Cambridge, MA 02139 | |
8297 | @end example | |
8298 | ||
8299 | The fundamental principle of reporting bugs usefully is this: | |
8300 | @strong{report all the facts}. If you are not sure whether to state a | |
8301 | fact or leave it out, state it! | |
8302 | ||
8303 | Often people omit facts because they think they know what causes the | |
29a2b744 | 8304 | problem and assume that some details do not matter. Thus, you might |
70b88761 | 8305 | assume that the name of the variable you use in an example does not matter. |
29a2b744 | 8306 | Well, probably it does not, but one cannot be sure. Perhaps the bug is a |
70b88761 RP |
8307 | stray memory reference which happens to fetch from the location where that |
8308 | name is stored in memory; perhaps, if the name were different, the contents | |
8309 | of that location would fool the debugger into doing the right thing despite | |
8310 | the bug. Play it safe and give a specific, complete example. That is the | |
8311 | easiest thing for you to do, and the most helpful. | |
8312 | ||
8313 | Keep in mind that the purpose of a bug report is to enable us to fix | |
1041a570 | 8314 | the bug if it is new to us. It is not as important as what happens if |
70b88761 RP |
8315 | the bug is already known. Therefore, always write your bug reports on |
8316 | the assumption that the bug has not been reported previously. | |
8317 | ||
8318 | Sometimes people give a few sketchy facts and ask, ``Does this ring a | |
8319 | bell?'' Those bug reports are useless, and we urge everyone to | |
8320 | @emph{refuse to respond to them} except to chide the sender to report | |
8321 | bugs properly. | |
8322 | ||
8323 | To enable us to fix the bug, you should include all these things: | |
8324 | ||
8325 | @itemize @bullet | |
8326 | @item | |
18fae2a8 | 8327 | The version of @value{GDBN}. @value{GDBN} announces it if you start with no |
70b88761 RP |
8328 | arguments; you can also print it at any time using @code{show version}. |
8329 | ||
1041a570 | 8330 | Without this, we will not know whether there is any point in looking for |
18fae2a8 | 8331 | the bug in the current version of @value{GDBN}. |
70b88761 RP |
8332 | |
8333 | @item | |
ddf21240 JG |
8334 | The type of machine you are using, and the operating system name and |
8335 | version number. | |
70b88761 RP |
8336 | |
8337 | @item | |
18fae2a8 RP |
8338 | What compiler (and its version) was used to compile @value{GDBN}---e.g. |
8339 | ``@value{GCC}--2.0''. | |
70b88761 | 8340 | |
ddf21240 JG |
8341 | @item |
8342 | What compiler (and its version) was used to compile the program you | |
18fae2a8 | 8343 | are debugging---e.g. ``@value{GCC}--2.0''. |
ddf21240 | 8344 | |
70b88761 RP |
8345 | @item |
8346 | The command arguments you gave the compiler to compile your example and | |
8347 | observe the bug. For example, did you use @samp{-O}? To guarantee | |
1041a570 | 8348 | you will not omit something important, list them all. A copy of the |
ddf21240 | 8349 | Makefile (or the output from make) is sufficient. |
70b88761 RP |
8350 | |
8351 | If we were to try to guess the arguments, we would probably guess wrong | |
8352 | and then we might not encounter the bug. | |
8353 | ||
8354 | @item | |
ddf21240 JG |
8355 | A complete input script, and all necessary source files, that will |
8356 | reproduce the bug. | |
70b88761 RP |
8357 | |
8358 | @item | |
8359 | A description of what behavior you observe that you believe is | |
8360 | incorrect. For example, ``It gets a fatal signal.'' | |
8361 | ||
18fae2a8 | 8362 | Of course, if the bug is that @value{GDBN} gets a fatal signal, then we will |
70b88761 RP |
8363 | certainly notice it. But if the bug is incorrect output, we might not |
8364 | notice unless it is glaringly wrong. We are human, after all. You | |
8365 | might as well not give us a chance to make a mistake. | |
8366 | ||
8367 | Even if the problem you experience is a fatal signal, you should still | |
8368 | say so explicitly. Suppose something strange is going on, such as, | |
18fae2a8 | 8369 | your copy of @value{GDBN} is out of synch, or you have encountered a |
70b88761 RP |
8370 | bug in the C library on your system. (This has happened!) Your copy |
8371 | might crash and ours would not. If you told us to expect a crash, | |
8372 | then when ours fails to crash, we would know that the bug was not | |
8373 | happening for us. If you had not told us to expect a crash, then we | |
8374 | would not be able to draw any conclusion from our observations. | |
8375 | ||
8376 | @item | |
18fae2a8 RP |
8377 | If you wish to suggest changes to the @value{GDBN} source, send us context |
8378 | diffs. If you even discuss something in the @value{GDBN} source, refer to | |
70b88761 RP |
8379 | it by context, not by line number. |
8380 | ||
1041a570 | 8381 | The line numbers in our development sources will not match those in your |
70b88761 | 8382 | sources. Your line numbers would convey no useful information to us. |
70b88761 RP |
8383 | @end itemize |
8384 | ||
8385 | Here are some things that are not necessary: | |
8386 | ||
8387 | @itemize @bullet | |
8388 | @item | |
8389 | A description of the envelope of the bug. | |
8390 | ||
8391 | Often people who encounter a bug spend a lot of time investigating | |
8392 | which changes to the input file will make the bug go away and which | |
8393 | changes will not affect it. | |
8394 | ||
8395 | This is often time consuming and not very useful, because the way we | |
8396 | will find the bug is by running a single example under the debugger | |
8397 | with breakpoints, not by pure deduction from a series of examples. | |
8398 | We recommend that you save your time for something else. | |
8399 | ||
8400 | Of course, if you can find a simpler example to report @emph{instead} | |
8401 | of the original one, that is a convenience for us. Errors in the | |
8402 | output will be easier to spot, running under the debugger will take | |
e251e767 | 8403 | less time, etc. |
70b88761 | 8404 | |
29a2b744 | 8405 | However, simplification is not vital; if you do not want to do this, |
70b88761 RP |
8406 | report the bug anyway and send us the entire test case you used. |
8407 | ||
8408 | @item | |
8409 | A patch for the bug. | |
8410 | ||
29a2b744 | 8411 | A patch for the bug does help us if it is a good one. But do not omit |
70b88761 RP |
8412 | the necessary information, such as the test case, on the assumption that |
8413 | a patch is all we need. We might see problems with your patch and decide | |
8414 | to fix the problem another way, or we might not understand it at all. | |
8415 | ||
18fae2a8 | 8416 | Sometimes with a program as complicated as @value{GDBN} it is very hard to |
70b88761 | 8417 | construct an example that will make the program follow a certain path |
1041a570 RP |
8418 | through the code. If you do not send us the example, we will not be able |
8419 | to construct one, so we will not be able to verify that the bug is fixed. | |
70b88761 | 8420 | |
29a2b744 | 8421 | And if we cannot understand what bug you are trying to fix, or why your |
1041a570 | 8422 | patch should be an improvement, we will not install it. A test case will |
70b88761 RP |
8423 | help us to understand. |
8424 | ||
8425 | @item | |
8426 | A guess about what the bug is or what it depends on. | |
8427 | ||
29a2b744 | 8428 | Such guesses are usually wrong. Even we cannot guess right about such |
70b88761 RP |
8429 | things without first using the debugger to find the facts. |
8430 | @end itemize | |
8431 | ||
1041a570 RP |
8432 | @c Note: no need to update nodes for rdl-apps.texi since it appears |
8433 | @c *only* in the TeX version of the manual. | |
8434 | @c Note: eventually, make a cross reference to the readline Info nodes. | |
70b88761 | 8435 | @iftex |
cacf5942 RP |
8436 | @c appendices describing GNU readline. Distributed with readline code. |
8437 | @include rluser.texinfo | |
8438 | @include inc-hist.texi | |
70b88761 RP |
8439 | @end iftex |
8440 | ||
18fae2a8 | 8441 | @ifset NOVEL |
4eb4cf57 | 8442 | @node Renamed Commands |
70b88761 RP |
8443 | @appendix Renamed Commands |
8444 | ||
c7cb8acb | 8445 | The following commands were renamed in GDB 4, in order to make the |
70b88761 RP |
8446 | command set as a whole more consistent and easier to use and remember: |
8447 | ||
e251e767 RP |
8448 | @kindex add-syms |
8449 | @kindex delete environment | |
8450 | @kindex info copying | |
8451 | @kindex info convenience | |
8452 | @kindex info directories | |
8453 | @kindex info editing | |
8454 | @kindex info history | |
8455 | @kindex info targets | |
8456 | @kindex info values | |
8457 | @kindex info version | |
8458 | @kindex info warranty | |
8459 | @kindex set addressprint | |
8460 | @kindex set arrayprint | |
8461 | @kindex set prettyprint | |
8462 | @kindex set screen-height | |
8463 | @kindex set screen-width | |
8464 | @kindex set unionprint | |
8465 | @kindex set vtblprint | |
8466 | @kindex set demangle | |
8467 | @kindex set asm-demangle | |
8468 | @kindex set sevenbit-strings | |
8469 | @kindex set array-max | |
8470 | @kindex set caution | |
8471 | @kindex set history write | |
8472 | @kindex show addressprint | |
8473 | @kindex show arrayprint | |
8474 | @kindex show prettyprint | |
8475 | @kindex show screen-height | |
8476 | @kindex show screen-width | |
8477 | @kindex show unionprint | |
8478 | @kindex show vtblprint | |
8479 | @kindex show demangle | |
8480 | @kindex show asm-demangle | |
8481 | @kindex show sevenbit-strings | |
8482 | @kindex show array-max | |
8483 | @kindex show caution | |
8484 | @kindex show history write | |
8485 | @kindex unset | |
70b88761 | 8486 | |
92b73793 | 8487 | @c TEXI2ROFF-KILL |
70b88761 | 8488 | @ifinfo |
92b73793 | 8489 | @c END TEXI2ROFF-KILL |
cf496415 RP |
8490 | @example |
8491 | OLD COMMAND NEW COMMAND | |
92b73793 | 8492 | @c TEXI2ROFF-KILL |
cf496415 | 8493 | --------------- ------------------------------- |
92b73793 | 8494 | @c END TEXI2ROFF-KILL |
cf496415 RP |
8495 | add-syms add-symbol-file |
8496 | delete environment unset environment | |
8497 | info convenience show convenience | |
8498 | info copying show copying | |
e251e767 | 8499 | info directories show directories |
cf496415 RP |
8500 | info editing show commands |
8501 | info history show values | |
8502 | info targets help target | |
8503 | info values show values | |
8504 | info version show version | |
8505 | info warranty show warranty | |
8506 | set/show addressprint set/show print address | |
8507 | set/show array-max set/show print elements | |
8508 | set/show arrayprint set/show print array | |
8509 | set/show asm-demangle set/show print asm-demangle | |
8510 | set/show caution set/show confirm | |
8511 | set/show demangle set/show print demangle | |
8512 | set/show history write set/show history save | |
8513 | set/show prettyprint set/show print pretty | |
8514 | set/show screen-height set/show height | |
8515 | set/show screen-width set/show width | |
8516 | set/show sevenbit-strings set/show print sevenbit-strings | |
8517 | set/show unionprint set/show print union | |
8518 | set/show vtblprint set/show print vtbl | |
8519 | ||
8520 | unset [No longer an alias for delete] | |
8521 | @end example | |
92b73793 | 8522 | @c TEXI2ROFF-KILL |
70b88761 RP |
8523 | @end ifinfo |
8524 | ||
8525 | @tex | |
8526 | \vskip \parskip\vskip \baselineskip | |
8527 | \halign{\tt #\hfil &\qquad#&\tt #\hfil\cr | |
8528 | {\bf Old Command} &&{\bf New Command}\cr | |
8529 | add-syms &&add-symbol-file\cr | |
8530 | delete environment &&unset environment\cr | |
8531 | info convenience &&show convenience\cr | |
8532 | info copying &&show copying\cr | |
8533 | info directories &&show directories \cr | |
8534 | info editing &&show commands\cr | |
8535 | info history &&show values\cr | |
8536 | info targets &&help target\cr | |
8537 | info values &&show values\cr | |
8538 | info version &&show version\cr | |
8539 | info warranty &&show warranty\cr | |
8540 | set{\rm / }show addressprint &&set{\rm / }show print address\cr | |
8541 | set{\rm / }show array-max &&set{\rm / }show print elements\cr | |
8542 | set{\rm / }show arrayprint &&set{\rm / }show print array\cr | |
8543 | set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr | |
8544 | set{\rm / }show caution &&set{\rm / }show confirm\cr | |
8545 | set{\rm / }show demangle &&set{\rm / }show print demangle\cr | |
8546 | set{\rm / }show history write &&set{\rm / }show history save\cr | |
8547 | set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr | |
8548 | set{\rm / }show screen-height &&set{\rm / }show height\cr | |
8549 | set{\rm / }show screen-width &&set{\rm / }show width\cr | |
8550 | set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr | |
8551 | set{\rm / }show unionprint &&set{\rm / }show print union\cr | |
8552 | set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr | |
8553 | \cr | |
8554 | unset &&\rm(No longer an alias for delete)\cr | |
8555 | } | |
8556 | @end tex | |
92b73793 | 8557 | @c END TEXI2ROFF-KILL |
18fae2a8 | 8558 | @end ifset |
70b88761 | 8559 | |
18fae2a8 | 8560 | @ifclear PRECONFIGURED |
4eb4cf57 | 8561 | @node Formatting Documentation |
77b46d13 JG |
8562 | @appendix Formatting the Documentation |
8563 | ||
8564 | @cindex GDB reference card | |
8565 | @cindex reference card | |
8566 | The GDB 4 release includes an already-formatted reference card, ready | |
b1385986 | 8567 | for printing with PostScript or GhostScript, in the @file{gdb} |
77b46d13 | 8568 | subdirectory of the main source directory---in |
18fae2a8 | 8569 | @file{gdb-@value{GDBVN}/gdb/refcard.ps} of the version @value{GDBVN} release. |
b1385986 RP |
8570 | If you can use PostScript or GhostScript with your printer, you can |
8571 | print the reference card immediately with @file{refcard.ps}. | |
77b46d13 JG |
8572 | |
8573 | The release also includes the source for the reference card. You | |
8574 | can format it, using @TeX{}, by typing: | |
8575 | ||
8576 | @example | |
8577 | make refcard.dvi | |
8578 | @end example | |
8579 | ||
8580 | The GDB reference card is designed to print in landscape mode on US | |
8581 | ``letter'' size paper; that is, on a sheet 11 inches wide by 8.5 inches | |
8582 | high. You will need to specify this form of printing as an option to | |
8583 | your @sc{dvi} output program. | |
8584 | ||
8585 | @cindex documentation | |
8586 | ||
8587 | All the documentation for GDB comes as part of the machine-readable | |
8588 | distribution. The documentation is written in Texinfo format, which is | |
8589 | a documentation system that uses a single source file to produce both | |
8590 | on-line information and a printed manual. You can use one of the Info | |
8591 | formatting commands to create the on-line version of the documentation | |
8592 | and @TeX{} (or @code{texi2roff}) to typeset the printed version. | |
8593 | ||
8594 | GDB includes an already formatted copy of the on-line Info version of | |
8595 | this manual in the @file{gdb} subdirectory. The main Info file is | |
8596 | @file{gdb-@var{version-number}/gdb/gdb.info}, and it refers to | |
a89f94c2 RP |
8597 | subordinate files matching @samp{gdb.info*} in the same directory. If |
8598 | necessary, you can print out these files, or read them with any editor; | |
8599 | but they are easier to read using the @code{info} subsystem in GNU Emacs | |
8600 | or the standalone @code{info} program, available as part of the GNU | |
8601 | Texinfo distribution. | |
77b46d13 JG |
8602 | |
8603 | If you want to format these Info files yourself, you need one of the | |
8604 | Info formatting programs, such as @code{texinfo-format-buffer} or | |
8605 | @code{makeinfo}. | |
8606 | ||
8607 | If you have @code{makeinfo} installed, and are in the top level GDB | |
18fae2a8 | 8608 | source directory (@file{gdb-@value{GDBVN}}, in the case of version @value{GDBVN}), you can |
77b46d13 JG |
8609 | make the Info file by typing: |
8610 | ||
8611 | @example | |
8612 | cd gdb | |
8613 | make gdb.info | |
8614 | @end example | |
8615 | ||
8616 | If you want to typeset and print copies of this manual, you need | |
8617 | @TeX{}, a printing program such as @code{lpr}, and @file{texinfo.tex}, | |
8618 | the Texinfo definitions file. | |
8619 | ||
83bfcbae | 8620 | @TeX{} is a typesetting program; it does not print files directly, but |
77b46d13 JG |
8621 | produces output files called @sc{dvi} files. To print a typeset |
8622 | document, you need a program to print @sc{dvi} files. If your system | |
8623 | has @TeX{} installed, chances are it has such a program. The precise | |
8624 | command to use depends on your system; @kbd{lpr -d} is common; another | |
8625 | is @kbd{dvips}. The @sc{dvi} print command may require a file name | |
8626 | without any extension or a @samp{.dvi} extension. | |
8627 | ||
8628 | @TeX{} also requires a macro definitions file called | |
8629 | @file{texinfo.tex}. This file tells @TeX{} how to typeset a document | |
8630 | written in Texinfo format. On its own, @TeX{} cannot read, much less | |
8631 | typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB | |
8632 | and is located in the @file{gdb-@var{version-number}/texinfo} | |
8633 | directory. | |
8634 | ||
8635 | If you have @TeX{} and a @sc{dvi} printer program installed, you can | |
8636 | typeset and print this manual. First switch to the the @file{gdb} | |
8637 | subdirectory of the main source directory (for example, to | |
18fae2a8 | 8638 | @file{gdb-@value{GDBVN}/gdb}) and then type: |
77b46d13 JG |
8639 | |
8640 | @example | |
8641 | make gdb.dvi | |
8642 | @end example | |
8643 | ||
4eb4cf57 | 8644 | @node Installing GDB |
c7cb8acb RP |
8645 | @appendix Installing GDB |
8646 | @cindex configuring GDB | |
70b88761 RP |
8647 | @cindex installation |
8648 | ||
f672bb7f RP |
8649 | @iftex |
8650 | @c irrelevant in info file; it's as current as the code it lives with. | |
8651 | @quotation | |
8652 | @emph{Warning:} These installation instructions are current as of | |
18fae2a8 | 8653 | GDB version @value{GDBVN}. If you're installing a more recent release |
c7cb8acb | 8654 | of GDB, we may have improved the installation procedures since |
f672bb7f RP |
8655 | printing this manual; see the @file{README} file included in your |
8656 | release for the most recent instructions. | |
8657 | @end quotation | |
8658 | @end iftex | |
8659 | ||
c7cb8acb RP |
8660 | GDB comes with a @code{configure} script that automates the process |
8661 | of preparing GDB for installation; you can then use @code{make} to | |
8662 | build the program. | |
b80282d5 | 8663 | |
c7cb8acb | 8664 | The GDB distribution includes all the source code you need for GDB in |
1041a570 RP |
8665 | a single directory, whose name is usually composed by appending the |
8666 | version number to @samp{gdb}. | |
8667 | ||
18fae2a8 | 8668 | For example, the GDB version @value{GDBVN} distribution is in the @file{gdb-@value{GDBVN}} |
1041a570 | 8669 | directory. That directory contains: |
b80282d5 | 8670 | |
3d3ab540 | 8671 | @table @code |
18fae2a8 | 8672 | @item gdb-@value{GDBVN}/configure @r{(and supporting files)} |
c7cb8acb | 8673 | script for configuring GDB and all its supporting libraries. |
b80282d5 | 8674 | |
18fae2a8 | 8675 | @item gdb-@value{GDBVN}/gdb |
c7cb8acb | 8676 | the source specific to GDB itself |
3d3ab540 | 8677 | |
18fae2a8 | 8678 | @item gdb-@value{GDBVN}/bfd |
77b46d13 | 8679 | source for the Binary File Descriptor library |
3d3ab540 | 8680 | |
18fae2a8 | 8681 | @item gdb-@value{GDBVN}/include |
b80282d5 | 8682 | GNU include files |
3d3ab540 | 8683 | |
18fae2a8 | 8684 | @item gdb-@value{GDBVN}/libiberty |
3d3ab540 RP |
8685 | source for the @samp{-liberty} free software library |
8686 | ||
18fae2a8 | 8687 | @item gdb-@value{GDBVN}/opcodes |
3214c51c JG |
8688 | source for the library of opcode tables and disassemblers |
8689 | ||
18fae2a8 | 8690 | @item gdb-@value{GDBVN}/readline |
b80282d5 | 8691 | source for the GNU command-line interface |
77b46d13 | 8692 | |
18fae2a8 | 8693 | @item gdb-@value{GDBVN}/glob |
77b46d13 JG |
8694 | source for the GNU filename pattern-matching subroutine |
8695 | ||
18fae2a8 | 8696 | @item gdb-@value{GDBVN}/mmalloc |
77b46d13 | 8697 | source for the GNU memory-mapped malloc package |
3d3ab540 | 8698 | @end table |
1041a570 | 8699 | |
c7cb8acb | 8700 | The simplest way to configure and build GDB is to run @code{configure} |
1041a570 | 8701 | from the @file{gdb-@var{version-number}} source directory, which in |
18fae2a8 | 8702 | this example is the @file{gdb-@value{GDBVN}} directory. |
1041a570 RP |
8703 | |
8704 | First switch to the @file{gdb-@var{version-number}} source directory | |
8705 | if you are not already in it; then run @code{configure}. Pass the | |
c7cb8acb | 8706 | identifier for the platform on which GDB will run as an |
1041a570 RP |
8707 | argument. |
8708 | ||
8709 | For example: | |
8710 | ||
7463aadd | 8711 | @example |
18fae2a8 | 8712 | cd gdb-@value{GDBVN} |
3d3ab540 | 8713 | ./configure @var{host} |
7463aadd RP |
8714 | make |
8715 | @end example | |
1041a570 | 8716 | |
7463aadd | 8717 | @noindent |
1041a570 | 8718 | where @var{host} is an identifier such as @samp{sun4} or |
c7cb8acb | 8719 | @samp{decstation}, that identifies the platform where GDB will run. |
1041a570 | 8720 | |
38962738 RP |
8721 | Running @samp{configure @var{host}} followed by @code{make} builds the |
8722 | @file{bfd}, @file{readline}, @file{mmalloc}, and @file{libiberty} | |
8723 | libraries, then @code{gdb} itself. The configured source files, and the | |
8724 | binaries, are left in the corresponding source directories. | |
3d3ab540 | 8725 | |
e251e767 | 8726 | @code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your |
29a2b744 | 8727 | system does not recognize this automatically when you run a different |
1041a570 RP |
8728 | shell, you may need to run @code{sh} on it explicitly: |
8729 | ||
8730 | @example | |
8731 | sh configure @var{host} | |
8732 | @end example | |
e251e767 | 8733 | |
f672bb7f RP |
8734 | If you run @code{configure} from a directory that contains source |
8735 | directories for multiple libraries or programs, such as the | |
18fae2a8 | 8736 | @file{gdb-@value{GDBVN}} source directory for version @value{GDBVN}, @code{configure} |
f672bb7f | 8737 | creates configuration files for every directory level underneath (unless |
98349959 | 8738 | you tell it not to, with the @samp{--norecursion} option). |
f672bb7f RP |
8739 | |
8740 | You can run the @code{configure} script from any of the | |
c7cb8acb | 8741 | subordinate directories in the GDB distribution, if you only want to |
1041a570 RP |
8742 | configure that subdirectory; but be sure to specify a path to it. |
8743 | ||
18fae2a8 | 8744 | For example, with version @value{GDBVN}, type the following to configure only |
1041a570 RP |
8745 | the @code{bfd} subdirectory: |
8746 | ||
e251e767 | 8747 | @example |
203eea5d | 8748 | @group |
18fae2a8 | 8749 | cd gdb-@value{GDBVN}/bfd |
e251e767 | 8750 | ../configure @var{host} |
203eea5d | 8751 | @end group |
e251e767 RP |
8752 | @end example |
8753 | ||
18fae2a8 | 8754 | You can install @code{@value{GDBP}} anywhere; it has no hardwired paths. |
1041a570 RP |
8755 | However, you should make sure that the shell on your path (named by |
8756 | the @samp{SHELL} environment variable) is publicly readable. Remember | |
c7cb8acb RP |
8757 | that GDB uses the shell to start your program---some systems refuse to |
8758 | let GDB debug child processes whose programs are not readable. | |
3d3ab540 RP |
8759 | |
8760 | @menu | |
c7cb8acb | 8761 | * Separate Objdir:: Compiling GDB in another directory |
b80282d5 RP |
8762 | * Config Names:: Specifying names for hosts and targets |
8763 | * configure Options:: Summary of options for configure | |
3d3ab540 RP |
8764 | @end menu |
8765 | ||
4eb4cf57 | 8766 | @node Separate Objdir |
c7cb8acb | 8767 | @section Compiling GDB in Another Directory |
1041a570 | 8768 | |
c7cb8acb RP |
8769 | If you want to run GDB versions for several host or target machines, |
8770 | you'll need a different @code{gdb} compiled for each combination of | |
1041a570 | 8771 | host and target. @code{configure} is designed to make this easy by |
f672bb7f RP |
8772 | allowing you to generate each configuration in a separate subdirectory, |
8773 | rather than in the source directory. If your @code{make} program | |
8774 | handles the @samp{VPATH} feature (GNU @code{make} does), running | |
c7cb8acb | 8775 | @code{make} in each of these directories then builds the @code{gdb} |
f672bb7f | 8776 | program specified there. |
b80282d5 | 8777 | |
c7cb8acb | 8778 | To build @code{gdb} in a separate directory, run @code{configure} |
f672bb7f | 8779 | with the @samp{--srcdir} option to specify where to find the source. |
77b46d13 JG |
8780 | (You'll also need to specify a path to find @code{configure} |
8781 | itself from your working directory. If the path to @code{configure} | |
8782 | would be the same as the argument to @samp{--srcdir}, you can leave out | |
8783 | the @samp{--srcdir} option; it will be assumed.) | |
1041a570 | 8784 | |
18fae2a8 | 8785 | For example, with version @value{GDBVN}, you can build GDB in a separate |
f672bb7f | 8786 | directory for a Sun 4 like this: |
70b88761 RP |
8787 | |
8788 | @example | |
3d3ab540 | 8789 | @group |
18fae2a8 | 8790 | cd gdb-@value{GDBVN} |
f672bb7f RP |
8791 | mkdir ../gdb-sun4 |
8792 | cd ../gdb-sun4 | |
18fae2a8 | 8793 | ../gdb-@value{GDBVN}/configure sun4 |
70b88761 | 8794 | make |
3d3ab540 | 8795 | @end group |
70b88761 RP |
8796 | @end example |
8797 | ||
f672bb7f RP |
8798 | When @code{configure} builds a configuration using a remote source |
8799 | directory, it creates a tree for the binaries with the same structure | |
8800 | (and using the same names) as the tree under the source directory. In | |
8801 | the example, you'd find the Sun 4 library @file{libiberty.a} in the | |
c7cb8acb | 8802 | directory @file{gdb-sun4/libiberty}, and GDB itself in |
f672bb7f | 8803 | @file{gdb-sun4/gdb}. |
1041a570 | 8804 | |
38962738 | 8805 | One popular reason to build several GDB configurations in separate |
c7cb8acb | 8806 | directories is to configure GDB for cross-compiling (where GDB |
f672bb7f RP |
8807 | runs on one machine---the host---while debugging programs that run on |
8808 | another machine---the target). You specify a cross-debugging target by | |
8809 | giving the @samp{--target=@var{target}} option to @code{configure}. | |
c7637ea6 | 8810 | |
1041a570 | 8811 | When you run @code{make} to build a program or library, you must run |
f672bb7f RP |
8812 | it in a configured directory---whatever directory you were in when you |
8813 | called @code{configure} (or one of its subdirectories). | |
c7637ea6 RP |
8814 | |
8815 | The @code{Makefile} generated by @code{configure} for each source | |
f672bb7f | 8816 | directory also runs recursively. If you type @code{make} in a source |
18fae2a8 RP |
8817 | directory such as @file{gdb-@value{GDBVN}} (or in a separate configured |
8818 | directory configured with @samp{--srcdir=@var{path}/gdb-@value{GDBVN}}), you | |
c7cb8acb | 8819 | will build all the required libraries, then build GDB. |
3d3ab540 | 8820 | |
f672bb7f RP |
8821 | When you have multiple hosts or targets configured in separate |
8822 | directories, you can run @code{make} on them in parallel (for example, | |
8823 | if they are NFS-mounted on each of the hosts); they will not interfere | |
8824 | with each other. | |
3d3ab540 | 8825 | |
4eb4cf57 | 8826 | @node Config Names |
b80282d5 RP |
8827 | @section Specifying Names for Hosts and Targets |
8828 | ||
8829 | The specifications used for hosts and targets in the @code{configure} | |
8830 | script are based on a three-part naming scheme, but some short predefined | |
8831 | aliases are also supported. The full naming scheme encodes three pieces | |
e251e767 | 8832 | of information in the following pattern: |
1041a570 | 8833 | |
b80282d5 RP |
8834 | @example |
8835 | @var{architecture}-@var{vendor}-@var{os} | |
8836 | @end example | |
8837 | ||
8838 | For example, you can use the alias @code{sun4} as a @var{host} argument | |
5e3186ab | 8839 | or in a @code{--target=@var{target}} option, but the equivalent full name |
e251e767 | 8840 | is @samp{sparc-sun-sunos4}. |
b80282d5 | 8841 | |
c7cb8acb | 8842 | The @code{configure} script accompanying GDB does not provide |
b80282d5 RP |
8843 | any query facility to list all supported host and target names or |
8844 | aliases. @code{configure} calls the Bourne shell script | |
8845 | @code{config.sub} to map abbreviations to full names; you can read the | |
8846 | script, if you wish, or you can use it to test your guesses on | |
8847 | abbreviations---for example: | |
1041a570 | 8848 | |
b1385986 | 8849 | @smallexample |
b80282d5 | 8850 | % sh config.sub sun4 |
6a8cb0e7 | 8851 | sparc-sun-sunos411 |
b80282d5 | 8852 | % sh config.sub sun3 |
6a8cb0e7 | 8853 | m68k-sun-sunos411 |
b80282d5 | 8854 | % sh config.sub decstation |
6a8cb0e7 | 8855 | mips-dec-ultrix42 |
b80282d5 RP |
8856 | % sh config.sub hp300bsd |
8857 | m68k-hp-bsd | |
8858 | % sh config.sub i386v | |
6a8cb0e7 | 8859 | i386-unknown-sysv |
e94b4a2b | 8860 | % sh config.sub i786v |
6a8cb0e7 | 8861 | Invalid configuration `i786v': machine `i786v' not recognized |
b1385986 | 8862 | @end smallexample |
1041a570 | 8863 | |
c7637ea6 | 8864 | @noindent |
1041a570 | 8865 | @code{config.sub} is also distributed in the GDB source |
18fae2a8 | 8866 | directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}). |
b80282d5 | 8867 | |
4eb4cf57 | 8868 | @node configure Options |
3d3ab540 | 8869 | @section @code{configure} Options |
7463aadd | 8870 | |
d48da190 | 8871 | Here is a summary of the @code{configure} options and arguments that |
18fae2a8 | 8872 | are most often useful for building @value{GDBN}. @code{configure} also has |
d48da190 RP |
8873 | several other options not listed here. @inforef{What Configure |
8874 | Does,,configure.info}, for a full explanation of @code{configure}. | |
8875 | @c FIXME: Would this be more, or less, useful as an xref (ref to printed | |
8876 | @c manual in the printed manual, ref to info file only from the info file)? | |
7463aadd RP |
8877 | |
8878 | @example | |
d48da190 RP |
8879 | configure @r{[}--help@r{]} |
8880 | @r{[}--prefix=@var{dir}@r{]} | |
8881 | @r{[}--srcdir=@var{path}@r{]} | |
f672bb7f RP |
8882 | @r{[}--norecursion@r{]} @r{[}--rm@r{]} |
8883 | @r{[}--target=@var{target}@r{]} @var{host} | |
7463aadd | 8884 | @end example |
1041a570 | 8885 | |
3d3ab540 | 8886 | @noindent |
f672bb7f RP |
8887 | You may introduce options with a single @samp{-} rather than |
8888 | @samp{--} if you prefer; but you may abbreviate option names if you use | |
8889 | @samp{--}. | |
70b88761 RP |
8890 | |
8891 | @table @code | |
d48da190 RP |
8892 | @item --help |
8893 | Display a quick summary of how to invoke @code{configure}. | |
8894 | ||
8895 | @item -prefix=@var{dir} | |
8896 | Configure the source to install programs and files under directory | |
8897 | @file{@var{dir}}. | |
8898 | ||
f672bb7f | 8899 | @item --srcdir=@var{path} |
6ca72cc6 RP |
8900 | @strong{Warning: using this option requires GNU @code{make}, or another |
8901 | @code{make} that implements the @code{VPATH} feature.}@* | |
f672bb7f | 8902 | Use this option to make configurations in directories separate from the |
c7cb8acb | 8903 | GDB source directories. Among other things, you can use this to |
f672bb7f RP |
8904 | build (or maintain) several configurations simultaneously, in separate |
8905 | directories. @code{configure} writes configuration specific files in | |
8906 | the current directory, but arranges for them to use the source in the | |
8907 | directory @var{path}. @code{configure} will create directories under | |
8908 | the working directory in parallel to the source directories below | |
8909 | @var{path}. | |
8910 | ||
8911 | @item --norecursion | |
8912 | Configure only the directory level where @code{configure} is executed; do not | |
7463aadd RP |
8913 | propagate configuration to subdirectories. |
8914 | ||
f672bb7f | 8915 | @item --rm |
b80282d5 | 8916 | Remove the configuration that the other arguments specify. |
7463aadd | 8917 | |
29a2b744 | 8918 | @c This does not work (yet if ever). FIXME. |
f672bb7f | 8919 | @c @item --parse=@var{lang} @dots{} |
c7cb8acb RP |
8920 | @c Configure the GDB expression parser to parse the listed languages. |
8921 | @c @samp{all} configures GDB for all supported languages. To get a | |
d7b569d5 | 8922 | @c list of all supported languages, omit the argument. Without this |
c7cb8acb | 8923 | @c option, GDB is configured to parse all supported languages. |
c2bbbb22 | 8924 | |
f672bb7f | 8925 | @item --target=@var{target} |
c7cb8acb RP |
8926 | Configure GDB for cross-debugging programs running on the specified |
8927 | @var{target}. Without this option, GDB is configured to debug | |
8928 | programs that run on the same machine (@var{host}) as GDB itself. | |
b80282d5 RP |
8929 | |
8930 | There is no convenient way to generate a list of all available targets. | |
7463aadd RP |
8931 | |
8932 | @item @var{host} @dots{} | |
c7cb8acb | 8933 | Configure GDB to run on the specified @var{host}. |
b80282d5 RP |
8934 | |
8935 | There is no convenient way to generate a list of all available hosts. | |
70b88761 RP |
8936 | @end table |
8937 | ||
3d3ab540 RP |
8938 | @noindent |
8939 | @code{configure} accepts other options, for compatibility with | |
b80282d5 | 8940 | configuring other GNU tools recursively; but these are the only |
c7cb8acb | 8941 | options that affect GDB or its supporting libraries. |
18fae2a8 | 8942 | @end ifclear |
3d3ab540 | 8943 | |
18fae2a8 | 8944 | @ifclear AGGLOMERATION |
4eb4cf57 | 8945 | @node Copying |
70b88761 | 8946 | @unnumbered GNU GENERAL PUBLIC LICENSE |
7463aadd | 8947 | @center Version 2, June 1991 |
70b88761 RP |
8948 | |
8949 | @display | |
7463aadd | 8950 | Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. |
70b88761 RP |
8951 | 675 Mass Ave, Cambridge, MA 02139, USA |
8952 | ||
8953 | Everyone is permitted to copy and distribute verbatim copies | |
8954 | of this license document, but changing it is not allowed. | |
8955 | @end display | |
8956 | ||
8957 | @unnumberedsec Preamble | |
8958 | ||
7463aadd RP |
8959 | The licenses for most software are designed to take away your |
8960 | freedom to share and change it. By contrast, the GNU General Public | |
70b88761 | 8961 | License is intended to guarantee your freedom to share and change free |
7463aadd RP |
8962 | software---to make sure the software is free for all its users. This |
8963 | General Public License applies to most of the Free Software | |
8964 | Foundation's software and to any other program whose authors commit to | |
8965 | using it. (Some other Free Software Foundation software is covered by | |
8966 | the GNU Library General Public License instead.) You can apply it to | |
8967 | your programs, too. | |
70b88761 RP |
8968 | |
8969 | When we speak of free software, we are referring to freedom, not | |
7463aadd RP |
8970 | price. Our General Public Licenses are designed to make sure that you |
8971 | have the freedom to distribute copies of free software (and charge for | |
8972 | this service if you wish), that you receive source code or can get it | |
8973 | if you want it, that you can change the software or use pieces of it | |
8974 | in new free programs; and that you know you can do these things. | |
70b88761 RP |
8975 | |
8976 | To protect your rights, we need to make restrictions that forbid | |
8977 | anyone to deny you these rights or to ask you to surrender the rights. | |
8978 | These restrictions translate to certain responsibilities for you if you | |
8979 | distribute copies of the software, or if you modify it. | |
8980 | ||
7463aadd | 8981 | For example, if you distribute copies of such a program, whether |
70b88761 RP |
8982 | gratis or for a fee, you must give the recipients all the rights that |
8983 | you have. You must make sure that they, too, receive or can get the | |
7463aadd RP |
8984 | source code. And you must show them these terms so they know their |
8985 | rights. | |
70b88761 RP |
8986 | |
8987 | We protect your rights with two steps: (1) copyright the software, and | |
8988 | (2) offer you this license which gives you legal permission to copy, | |
8989 | distribute and/or modify the software. | |
8990 | ||
8991 | Also, for each author's protection and ours, we want to make certain | |
8992 | that everyone understands that there is no warranty for this free | |
8993 | software. If the software is modified by someone else and passed on, we | |
8994 | want its recipients to know that what they have is not the original, so | |
8995 | that any problems introduced by others will not reflect on the original | |
8996 | authors' reputations. | |
8997 | ||
7463aadd RP |
8998 | Finally, any free program is threatened constantly by software |
8999 | patents. We wish to avoid the danger that redistributors of a free | |
9000 | program will individually obtain patent licenses, in effect making the | |
9001 | program proprietary. To prevent this, we have made it clear that any | |
9002 | patent must be licensed for everyone's free use or not licensed at all. | |
9003 | ||
70b88761 RP |
9004 | The precise terms and conditions for copying, distribution and |
9005 | modification follow. | |
9006 | ||
9007 | @iftex | |
7463aadd | 9008 | @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
70b88761 RP |
9009 | @end iftex |
9010 | @ifinfo | |
7463aadd | 9011 | @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
70b88761 RP |
9012 | @end ifinfo |
9013 | ||
9014 | @enumerate | |
9015 | @item | |
7463aadd RP |
9016 | This License applies to any program or other work which contains |
9017 | a notice placed by the copyright holder saying it may be distributed | |
9018 | under the terms of this General Public License. The ``Program'', below, | |
9019 | refers to any such program or work, and a ``work based on the Program'' | |
9020 | means either the Program or any derivative work under copyright law: | |
9021 | that is to say, a work containing the Program or a portion of it, | |
9022 | either verbatim or with modifications and/or translated into another | |
9023 | language. (Hereinafter, translation is included without limitation in | |
9024 | the term ``modification''.) Each licensee is addressed as ``you''. | |
9025 | ||
9026 | Activities other than copying, distribution and modification are not | |
9027 | covered by this License; they are outside its scope. The act of | |
9028 | running the Program is not restricted, and the output from the Program | |
9029 | is covered only if its contents constitute a work based on the | |
9030 | Program (independent of having been made by running the Program). | |
9031 | Whether that is true depends on what the Program does. | |
70b88761 RP |
9032 | |
9033 | @item | |
7463aadd RP |
9034 | You may copy and distribute verbatim copies of the Program's |
9035 | source code as you receive it, in any medium, provided that you | |
9036 | conspicuously and appropriately publish on each copy an appropriate | |
9037 | copyright notice and disclaimer of warranty; keep intact all the | |
9038 | notices that refer to this License and to the absence of any warranty; | |
9039 | and give any other recipients of the Program a copy of this License | |
9040 | along with the Program. | |
70b88761 | 9041 | |
7463aadd RP |
9042 | You may charge a fee for the physical act of transferring a copy, and |
9043 | you may at your option offer warranty protection in exchange for a fee. | |
70b88761 | 9044 | |
70b88761 | 9045 | @item |
7463aadd RP |
9046 | You may modify your copy or copies of the Program or any portion |
9047 | of it, thus forming a work based on the Program, and copy and | |
9048 | distribute such modifications or work under the terms of Section 1 | |
9049 | above, provided that you also meet all of these conditions: | |
70b88761 | 9050 | |
1041a570 | 9051 | @enumerate a |
70b88761 | 9052 | @item |
7463aadd RP |
9053 | You must cause the modified files to carry prominent notices |
9054 | stating that you changed the files and the date of any change. | |
70b88761 RP |
9055 | |
9056 | @item | |
7463aadd RP |
9057 | You must cause any work that you distribute or publish, that in |
9058 | whole or in part contains or is derived from the Program or any | |
9059 | part thereof, to be licensed as a whole at no charge to all third | |
9060 | parties under the terms of this License. | |
70b88761 RP |
9061 | |
9062 | @item | |
7463aadd RP |
9063 | If the modified program normally reads commands interactively |
9064 | when run, you must cause it, when started running for such | |
9065 | interactive use in the most ordinary way, to print or display an | |
9066 | announcement including an appropriate copyright notice and a | |
9067 | notice that there is no warranty (or else, saying that you provide | |
9068 | a warranty) and that users may redistribute the program under | |
9069 | these conditions, and telling the user how to view a copy of this | |
9070 | License. (Exception: if the Program itself is interactive but | |
9071 | does not normally print such an announcement, your work based on | |
9072 | the Program is not required to print an announcement.) | |
1041a570 | 9073 | @end enumerate |
7463aadd RP |
9074 | |
9075 | These requirements apply to the modified work as a whole. If | |
9076 | identifiable sections of that work are not derived from the Program, | |
9077 | and can be reasonably considered independent and separate works in | |
9078 | themselves, then this License, and its terms, do not apply to those | |
9079 | sections when you distribute them as separate works. But when you | |
9080 | distribute the same sections as part of a whole which is a work based | |
9081 | on the Program, the distribution of the whole must be on the terms of | |
9082 | this License, whose permissions for other licensees extend to the | |
9083 | entire whole, and thus to each and every part regardless of who wrote it. | |
9084 | ||
9085 | Thus, it is not the intent of this section to claim rights or contest | |
9086 | your rights to work written entirely by you; rather, the intent is to | |
9087 | exercise the right to control the distribution of derivative or | |
9088 | collective works based on the Program. | |
9089 | ||
9090 | In addition, mere aggregation of another work not based on the Program | |
9091 | with the Program (or with a work based on the Program) on a volume of | |
9092 | a storage or distribution medium does not bring the other work under | |
9093 | the scope of this License. | |
70b88761 RP |
9094 | |
9095 | @item | |
7463aadd RP |
9096 | You may copy and distribute the Program (or a work based on it, |
9097 | under Section 2) in object code or executable form under the terms of | |
9098 | Sections 1 and 2 above provided that you also do one of the following: | |
70b88761 | 9099 | |
1041a570 | 9100 | @enumerate a |
70b88761 | 9101 | @item |
7463aadd RP |
9102 | Accompany it with the complete corresponding machine-readable |
9103 | source code, which must be distributed under the terms of Sections | |
9104 | 1 and 2 above on a medium customarily used for software interchange; or, | |
70b88761 RP |
9105 | |
9106 | @item | |
7463aadd RP |
9107 | Accompany it with a written offer, valid for at least three |
9108 | years, to give any third party, for a charge no more than your | |
9109 | cost of physically performing source distribution, a complete | |
9110 | machine-readable copy of the corresponding source code, to be | |
9111 | distributed under the terms of Sections 1 and 2 above on a medium | |
9112 | customarily used for software interchange; or, | |
70b88761 RP |
9113 | |
9114 | @item | |
7463aadd RP |
9115 | Accompany it with the information you received as to the offer |
9116 | to distribute corresponding source code. (This alternative is | |
70b88761 | 9117 | allowed only for noncommercial distribution and only if you |
7463aadd RP |
9118 | received the program in object code or executable form with such |
9119 | an offer, in accord with Subsection b above.) | |
1041a570 | 9120 | @end enumerate |
7463aadd RP |
9121 | |
9122 | The source code for a work means the preferred form of the work for | |
9123 | making modifications to it. For an executable work, complete source | |
9124 | code means all the source code for all modules it contains, plus any | |
9125 | associated interface definition files, plus the scripts used to | |
9126 | control compilation and installation of the executable. However, as a | |
9127 | special exception, the source code distributed need not include | |
9128 | anything that is normally distributed (in either source or binary | |
9129 | form) with the major components (compiler, kernel, and so on) of the | |
9130 | operating system on which the executable runs, unless that component | |
9131 | itself accompanies the executable. | |
9132 | ||
9133 | If distribution of executable or object code is made by offering | |
9134 | access to copy from a designated place, then offering equivalent | |
9135 | access to copy the source code from the same place counts as | |
9136 | distribution of the source code, even though third parties are not | |
9137 | compelled to copy the source along with the object code. | |
70b88761 RP |
9138 | |
9139 | @item | |
7463aadd RP |
9140 | You may not copy, modify, sublicense, or distribute the Program |
9141 | except as expressly provided under this License. Any attempt | |
9142 | otherwise to copy, modify, sublicense or distribute the Program is | |
9143 | void, and will automatically terminate your rights under this License. | |
9144 | However, parties who have received copies, or rights, from you under | |
9145 | this License will not have their licenses terminated so long as such | |
9146 | parties remain in full compliance. | |
70b88761 RP |
9147 | |
9148 | @item | |
7463aadd RP |
9149 | You are not required to accept this License, since you have not |
9150 | signed it. However, nothing else grants you permission to modify or | |
9151 | distribute the Program or its derivative works. These actions are | |
9152 | prohibited by law if you do not accept this License. Therefore, by | |
9153 | modifying or distributing the Program (or any work based on the | |
9154 | Program), you indicate your acceptance of this License to do so, and | |
9155 | all its terms and conditions for copying, distributing or modifying | |
9156 | the Program or works based on it. | |
70b88761 RP |
9157 | |
9158 | @item | |
9159 | Each time you redistribute the Program (or any work based on the | |
7463aadd RP |
9160 | Program), the recipient automatically receives a license from the |
9161 | original licensor to copy, distribute or modify the Program subject to | |
9162 | these terms and conditions. You may not impose any further | |
9163 | restrictions on the recipients' exercise of the rights granted herein. | |
9164 | You are not responsible for enforcing compliance by third parties to | |
9165 | this License. | |
9166 | ||
9167 | @item | |
9168 | If, as a consequence of a court judgment or allegation of patent | |
9169 | infringement or for any other reason (not limited to patent issues), | |
9170 | conditions are imposed on you (whether by court order, agreement or | |
9171 | otherwise) that contradict the conditions of this License, they do not | |
9172 | excuse you from the conditions of this License. If you cannot | |
9173 | distribute so as to satisfy simultaneously your obligations under this | |
9174 | License and any other pertinent obligations, then as a consequence you | |
9175 | may not distribute the Program at all. For example, if a patent | |
9176 | license would not permit royalty-free redistribution of the Program by | |
9177 | all those who receive copies directly or indirectly through you, then | |
9178 | the only way you could satisfy both it and this License would be to | |
9179 | refrain entirely from distribution of the Program. | |
9180 | ||
9181 | If any portion of this section is held invalid or unenforceable under | |
9182 | any particular circumstance, the balance of the section is intended to | |
9183 | apply and the section as a whole is intended to apply in other | |
9184 | circumstances. | |
9185 | ||
9186 | It is not the purpose of this section to induce you to infringe any | |
9187 | patents or other property right claims or to contest validity of any | |
9188 | such claims; this section has the sole purpose of protecting the | |
9189 | integrity of the free software distribution system, which is | |
9190 | implemented by public license practices. Many people have made | |
9191 | generous contributions to the wide range of software distributed | |
9192 | through that system in reliance on consistent application of that | |
9193 | system; it is up to the author/donor to decide if he or she is willing | |
9194 | to distribute software through any other system and a licensee cannot | |
9195 | impose that choice. | |
9196 | ||
9197 | This section is intended to make thoroughly clear what is believed to | |
9198 | be a consequence of the rest of this License. | |
9199 | ||
9200 | @item | |
9201 | If the distribution and/or use of the Program is restricted in | |
9202 | certain countries either by patents or by copyrighted interfaces, the | |
9203 | original copyright holder who places the Program under this License | |
9204 | may add an explicit geographical distribution limitation excluding | |
9205 | those countries, so that distribution is permitted only in or among | |
9206 | countries not thus excluded. In such case, this License incorporates | |
9207 | the limitation as if written in the body of this License. | |
70b88761 RP |
9208 | |
9209 | @item | |
9210 | The Free Software Foundation may publish revised and/or new versions | |
9211 | of the General Public License from time to time. Such new versions will | |
9212 | be similar in spirit to the present version, but may differ in detail to | |
9213 | address new problems or concerns. | |
9214 | ||
9215 | Each version is given a distinguishing version number. If the Program | |
7463aadd | 9216 | specifies a version number of this License which applies to it and ``any |
70b88761 RP |
9217 | later version'', you have the option of following the terms and conditions |
9218 | either of that version or of any later version published by the Free | |
9219 | Software Foundation. If the Program does not specify a version number of | |
7463aadd | 9220 | this License, you may choose any version ever published by the Free Software |
70b88761 RP |
9221 | Foundation. |
9222 | ||
9223 | @item | |
9224 | If you wish to incorporate parts of the Program into other free | |
9225 | programs whose distribution conditions are different, write to the author | |
9226 | to ask for permission. For software which is copyrighted by the Free | |
9227 | Software Foundation, write to the Free Software Foundation; we sometimes | |
9228 | make exceptions for this. Our decision will be guided by the two goals | |
9229 | of preserving the free status of all derivatives of our free software and | |
9230 | of promoting the sharing and reuse of software generally. | |
9231 | ||
9232 | @iftex | |
9233 | @heading NO WARRANTY | |
9234 | @end iftex | |
9235 | @ifinfo | |
9236 | @center NO WARRANTY | |
9237 | @end ifinfo | |
9238 | ||
9239 | @item | |
9240 | BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | |
9241 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | |
9242 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | |
9243 | PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | |
9244 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
9245 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | |
9246 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | |
9247 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | |
9248 | REPAIR OR CORRECTION. | |
9249 | ||
9250 | @item | |
7463aadd RP |
9251 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
9252 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | |
70b88761 | 9253 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
7463aadd RP |
9254 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
9255 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | |
9256 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | |
9257 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | |
9258 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | |
9259 | POSSIBILITY OF SUCH DAMAGES. | |
70b88761 RP |
9260 | @end enumerate |
9261 | ||
9262 | @iftex | |
9263 | @heading END OF TERMS AND CONDITIONS | |
9264 | @end iftex | |
9265 | @ifinfo | |
9266 | @center END OF TERMS AND CONDITIONS | |
9267 | @end ifinfo | |
9268 | ||
9269 | @page | |
54e6b3c3 | 9270 | @unnumberedsec Applying These Terms to Your New Programs |
70b88761 RP |
9271 | |
9272 | If you develop a new program, and you want it to be of the greatest | |
7463aadd RP |
9273 | possible use to the public, the best way to achieve this is to make it |
9274 | free software which everyone can redistribute and change under these terms. | |
70b88761 | 9275 | |
7463aadd RP |
9276 | To do so, attach the following notices to the program. It is safest |
9277 | to attach them to the start of each source file to most effectively | |
9278 | convey the exclusion of warranty; and each file should have at least | |
9279 | the ``copyright'' line and a pointer to where the full notice is found. | |
70b88761 RP |
9280 | |
9281 | @smallexample | |
203eea5d | 9282 | @var{one line to give the program's name and an idea of what it does.} |
70b88761 RP |
9283 | Copyright (C) 19@var{yy} @var{name of author} |
9284 | ||
203eea5d RP |
9285 | This program is free software; you can redistribute it and/or |
9286 | modify it under the terms of the GNU General Public License | |
9287 | as published by the Free Software Foundation; either version 2 | |
9288 | of the License, or (at your option) any later version. | |
70b88761 RP |
9289 | |
9290 | This program is distributed in the hope that it will be useful, | |
9291 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9292 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9293 | GNU General Public License for more details. | |
9294 | ||
9295 | You should have received a copy of the GNU General Public License | |
203eea5d RP |
9296 | along with this program; if not, write to the |
9297 | Free Software Foundation, Inc., 675 Mass Ave, | |
9298 | Cambridge, MA 02139, USA. | |
70b88761 RP |
9299 | @end smallexample |
9300 | ||
9301 | Also add information on how to contact you by electronic and paper mail. | |
9302 | ||
9303 | If the program is interactive, make it output a short notice like this | |
9304 | when it starts in an interactive mode: | |
9305 | ||
9306 | @smallexample | |
9307 | Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} | |
203eea5d RP |
9308 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details |
9309 | type `show w'. This is free software, and you are welcome | |
9310 | to redistribute it under certain conditions; type `show c' | |
9311 | for details. | |
70b88761 RP |
9312 | @end smallexample |
9313 | ||
7463aadd RP |
9314 | The hypothetical commands @samp{show w} and @samp{show c} should show |
9315 | the appropriate parts of the General Public License. Of course, the | |
9316 | commands you use may be called something other than @samp{show w} and | |
9317 | @samp{show c}; they could even be mouse-clicks or menu items---whatever | |
9318 | suits your program. | |
70b88761 RP |
9319 | |
9320 | You should also get your employer (if you work as a programmer) or your | |
9321 | school, if any, to sign a ``copyright disclaimer'' for the program, if | |
9322 | necessary. Here is a sample; alter the names: | |
9323 | ||
1041a570 RP |
9324 | @example |
9325 | Yoyodyne, Inc., hereby disclaims all copyright | |
9326 | interest in the program `Gnomovision' | |
9327 | (which makes passes at compilers) written | |
9328 | by James Hacker. | |
70b88761 RP |
9329 | |
9330 | @var{signature of Ty Coon}, 1 April 1989 | |
9331 | Ty Coon, President of Vice | |
1041a570 | 9332 | @end example |
7463aadd RP |
9333 | |
9334 | This General Public License does not permit incorporating your program into | |
9335 | proprietary programs. If your program is a subroutine library, you may | |
9336 | consider it more useful to permit linking proprietary applications with the | |
9337 | library. If this is what you want to do, use the GNU Library General | |
9338 | Public License instead of this License. | |
18fae2a8 | 9339 | @end ifclear |
70b88761 | 9340 | |
4eb4cf57 | 9341 | @node Index |
d2e08421 | 9342 | @unnumbered Index |
e91b87a3 | 9343 | |
9344 | @printindex cp | |
9345 | ||
fe3f5fc8 RP |
9346 | @tex |
9347 | % I think something like @colophon should be in texinfo. In the | |
9348 | % meantime: | |
9349 | \long\def\colophon{\hbox to0pt{}\vfill | |
9350 | \centerline{The body of this manual is set in} | |
9351 | \centerline{\fontname\tenrm,} | |
9352 | \centerline{with headings in {\bf\fontname\tenbf}} | |
9353 | \centerline{and examples in {\tt\fontname\tentt}.} | |
a6d0b6d3 RP |
9354 | \centerline{{\it\fontname\tenit\/},} |
9355 | \centerline{{\bf\fontname\tenbf}, and} | |
fe3f5fc8 RP |
9356 | \centerline{{\sl\fontname\tensl\/}} |
9357 | \centerline{are used for emphasis.}\vfill} | |
9358 | \page\colophon | |
a6d0b6d3 | 9359 | % Blame: pesch@cygnus.com, 1991. |
fe3f5fc8 RP |
9360 | @end tex |
9361 | ||
e91b87a3 | 9362 | @contents |
9363 | @bye |