version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
gdb |
|
|
2 |
!!!gdb |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
OPTIONS |
|
|
7 |
SEE ALSO |
|
|
8 |
COPYING |
|
|
9 |
---- |
|
|
10 |
!!NAME |
|
|
11 |
|
|
|
12 |
|
|
|
13 |
gdb - The GNU Debugger |
|
|
14 |
!!SYNOPSIS |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
__gdb__ |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
[[__-help__] [[__-nx__] [[__-q__] [[__-batch__] |
|
|
21 |
[[__-cd=__''dir''] [[__-f__] [[__-b__ ''bps''] |
|
|
22 |
[[__-tty=__''dev''] [[__-s__ ''symfile''] |
|
|
23 |
[[__-e__ ''prog''] [[__-se__ ''prog''] [[__-c__ |
|
|
24 |
''core''] [[__-x__ ''cmds''] [[__-d__ ''dir''] |
|
|
25 |
[[''prog''[[''core''|''procID]]'' |
|
|
26 |
!!DESCRIPTION |
|
|
27 |
|
|
|
28 |
|
|
|
29 |
The purpose of a debugger such as GDB is to allow you to see |
|
|
30 |
what is going on ``inside'' another program while it |
|
|
31 |
executes--or what another program was doing at the moment it |
|
|
32 |
crashed. |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
GDB can do four main kinds of things (plus other things in |
|
|
36 |
support of these) to help you catch bugs in the |
|
|
37 |
act: |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
Start your program, specifying anything that might affect |
|
|
41 |
its behavior. |
|
|
42 |
|
|
|
43 |
|
|
|
44 |
Make your program stop on specified conditions. |
|
|
45 |
|
|
|
46 |
|
|
|
47 |
Examine what has happened, when your program has |
|
|
48 |
stopped. |
|
|
49 |
|
|
|
50 |
|
|
|
51 |
Change things in your program, so you can experiment with |
|
|
52 |
correcting the effects of one bug and go on to learn about |
|
|
53 |
another. |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
You can use GDB to debug programs written in C, C++, and |
|
|
57 |
Modula-2. Fortran support will be added when a GNU Fortran |
|
|
58 |
compiler is ready. |
|
|
59 |
|
|
|
60 |
|
|
|
61 |
GDB is invoked with the shell command __gdb__. Once |
|
|
62 |
started, it reads commands from the terminal until you tell |
|
|
63 |
it to exit with the GDB command __quit__. You can get |
|
|
64 |
online help from __gdb__ itself by using the command |
|
|
65 |
__help__. |
|
|
66 |
|
|
|
67 |
|
|
|
68 |
You can run __gdb__ with no arguments or options; but the |
|
|
69 |
most usual way to start GDB is with one argument or two, |
|
|
70 |
specifying an executable program as the |
|
|
71 |
argument: |
|
|
72 |
|
|
|
73 |
|
|
|
74 |
gdb program |
|
|
75 |
|
|
|
76 |
|
|
|
77 |
You can also start with both an executable program and a |
|
|
78 |
core file specified: |
|
|
79 |
|
|
|
80 |
|
|
|
81 |
gdb program core |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
You can, instead, specify a process ID as a second argument, |
|
|
85 |
if you want to debug a running process: |
|
|
86 |
|
|
|
87 |
|
|
|
88 |
gdb program 1234 |
|
|
89 |
|
|
|
90 |
|
|
|
91 |
would attach GDB to process __1234__ (unless you also |
|
|
92 |
have a file named `__1234__'; GDB does check for a core |
|
|
93 |
file first). |
|
|
94 |
|
|
|
95 |
|
|
|
96 |
Here are some of the most frequently needed GDB |
|
|
97 |
commands: |
|
|
98 |
|
|
|
99 |
|
|
|
100 |
__break__ |
|
|
101 |
[[''file''__:__]''function'' |
|
|
102 |
|
|
|
103 |
|
|
|
104 |
Set a breakpoint at ''function'' (in |
|
|
105 |
''file''). |
|
|
106 |
|
|
|
107 |
|
|
|
108 |
__run__ [[''arglist''] |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
Start your program (with ''arglist'', if |
|
|
112 |
specified). |
|
|
113 |
|
|
|
114 |
|
|
|
115 |
__bt__ |
|
|
116 |
|
|
|
117 |
|
|
|
118 |
Backtrace: display the program stack. |
|
|
119 |
|
|
|
120 |
|
|
|
121 |
__print__ ''expr'' |
|
|
122 |
|
|
|
123 |
|
|
|
124 |
Display the value of an expression. |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
__c__ |
|
|
128 |
|
|
|
129 |
|
|
|
130 |
Continue running your program (after stopping, e.g. at a |
|
|
131 |
breakpoint). |
|
|
132 |
|
|
|
133 |
|
|
|
134 |
__next__ |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
Execute next program line (after stopping); step ''over'' |
|
|
138 |
any function calls in the line. |
|
|
139 |
|
|
|
140 |
|
|
|
141 |
__step__ |
|
|
142 |
|
|
|
143 |
|
|
|
144 |
Execute next program line (after stopping); step ''into'' |
|
|
145 |
any function calls in the line. |
|
|
146 |
|
|
|
147 |
|
|
|
148 |
__help__ [[''name''] |
|
|
149 |
|
|
|
150 |
|
|
|
151 |
Show information about GDB command ''name'', or general |
|
|
152 |
information about using GDB. |
|
|
153 |
|
|
|
154 |
|
|
|
155 |
__quit__ |
|
|
156 |
|
|
|
157 |
|
|
|
158 |
Exit from GDB. |
|
|
159 |
|
|
|
160 |
|
|
|
161 |
For full details on GDB, see ''Using GDB: A Guide to the |
|
|
162 |
GNU Source-Level Debugger'', by Richard M. Stallman and |
|
|
163 |
Roland H. Pesch. The same text is available online as the |
|
|
164 |
__gdb__ entry in the __info__ program. |
|
|
165 |
!!OPTIONS |
|
|
166 |
|
|
|
167 |
|
|
|
168 |
Any arguments other than options specify an executable file |
|
|
169 |
and core file (or process ID); that is, the first argument |
|
|
170 |
encountered with no associated option flag is equivalent to |
|
|
171 |
a `__-se__' option, and the second, if any, is equivalent |
|
|
172 |
to a `__-c__' option if it's the name of a file. Many |
|
|
173 |
options have both long and short forms; both are shown here. |
|
|
174 |
The long forms are also recognized if you truncate them, so |
|
|
175 |
long as enough of the option is present to be unambiguous. |
|
|
176 |
(If you prefer, you can flag option arguments with |
|
|
177 |
`__+__' rather than `__-__', though we illustrate the |
|
|
178 |
more usual convention.) |
|
|
179 |
|
|
|
180 |
|
|
|
181 |
All the options and command line arguments you give are |
|
|
182 |
processed in sequential order. The order makes a difference |
|
|
183 |
when the `__-x__' option is used. |
|
|
184 |
|
|
|
185 |
|
|
|
186 |
__-help__ |
|
|
187 |
|
|
|
188 |
|
|
|
189 |
__-h__ |
|
|
190 |
|
|
|
191 |
|
|
|
192 |
List all options, with brief explanations. |
|
|
193 |
|
|
|
194 |
|
|
|
195 |
__-symbols=__''file'' |
|
|
196 |
|
|
|
197 |
|
|
|
198 |
__-s__ ''file'' |
|
|
199 |
|
|
|
200 |
|
|
|
201 |
Read symbol table from file ''file''. |
|
|
202 |
|
|
|
203 |
|
|
|
204 |
__-write__ |
|
|
205 |
|
|
|
206 |
|
|
|
207 |
Enable writing into executable and core files. |
|
|
208 |
|
|
|
209 |
|
|
|
210 |
__-exec=__''file'' |
|
|
211 |
|
|
|
212 |
|
|
|
213 |
__-e__ ''file'' |
|
|
214 |
|
|
|
215 |
|
|
|
216 |
Use file ''file'' as the executable file to execute when |
|
|
217 |
appropriate, and for examining pure data in conjunction with |
|
|
218 |
a core dump. |
|
|
219 |
|
|
|
220 |
|
|
|
221 |
__-se=__''file'' |
|
|
222 |
|
|
|
223 |
|
|
|
224 |
Read symbol table from file ''file'' and use it as the |
|
|
225 |
executable file. |
|
|
226 |
|
|
|
227 |
|
|
|
228 |
__-core=__''file'' |
|
|
229 |
|
|
|
230 |
|
|
|
231 |
__-c__ ''file'' |
|
|
232 |
|
|
|
233 |
|
|
|
234 |
Use file ''file'' as a core dump to examine. |
|
|
235 |
|
|
|
236 |
|
|
|
237 |
__-command=__''file'' |
|
|
238 |
|
|
|
239 |
|
|
|
240 |
__-x__ ''file'' |
|
|
241 |
|
|
|
242 |
|
|
|
243 |
Execute GDB commands from file ''file''. |
|
|
244 |
|
|
|
245 |
|
|
|
246 |
__-directory=__''directory'' |
|
|
247 |
|
|
|
248 |
|
|
|
249 |
__-d__ ''directory'' |
|
|
250 |
|
|
|
251 |
|
|
|
252 |
Add ''directory'' to the path to search for source |
|
|
253 |
files. |
|
|
254 |
|
|
|
255 |
|
|
|
256 |
__-nx__ |
|
|
257 |
|
|
|
258 |
|
|
|
259 |
__-n__ |
|
|
260 |
|
|
|
261 |
|
|
|
262 |
Do not execute commands from any `__.gdbinit__' |
|
|
263 |
initialization files. Normally, the commands in these files |
|
|
264 |
are executed after all the command options and arguments |
|
|
265 |
have been processed. |
|
|
266 |
|
|
|
267 |
|
|
|
268 |
__-quiet__ |
|
|
269 |
|
|
|
270 |
|
|
|
271 |
__-q__ |
|
|
272 |
|
|
|
273 |
|
|
|
274 |
``Quiet''. Do not print the introductory and copyright |
|
|
275 |
messages. These messages are also suppressed in batch |
|
|
276 |
mode. |
|
|
277 |
|
|
|
278 |
|
|
|
279 |
__-batch__ |
|
|
280 |
|
|
|
281 |
|
|
|
282 |
Run in batch mode. Exit with status __0__ after |
|
|
283 |
processing all the command files specified with `__-x__' |
|
|
284 |
(and `__.gdbinit__', if not inhibited). Exit with nonzero |
|
|
285 |
status if an error occurs in executing the GDB commands in |
|
|
286 |
the command files. |
|
|
287 |
|
|
|
288 |
|
|
|
289 |
Batch mode may be useful for running GDB as a filter, for |
|
|
290 |
example to download and run a program on another computer; |
|
|
291 |
in order to make this more useful, the message |
|
|
292 |
|
|
|
293 |
|
|
|
294 |
Program exited normally. |
|
|
295 |
|
|
|
296 |
|
|
|
297 |
(which is ordinarily issued whenever a program running under |
|
|
298 |
GDB control terminates) is not issued when running in batch |
|
|
299 |
mode. |
|
|
300 |
|
|
|
301 |
|
|
|
302 |
__-cd=__''directory'' |
|
|
303 |
|
|
|
304 |
|
|
|
305 |
Run GDB using ''directory'' as its working directory, |
|
|
306 |
instead of the current directory. |
|
|
307 |
|
|
|
308 |
|
|
|
309 |
__-fullname__ |
|
|
310 |
|
|
|
311 |
|
|
|
312 |
__-f__ |
|
|
313 |
|
|
|
314 |
|
|
|
315 |
Emacs sets this option when it runs GDB as a subprocess. It |
|
|
316 |
tells GDB to output the full file name and line number in a |
|
|
317 |
standard, recognizable fashion each time a stack frame is |
|
|
318 |
displayed (which includes each time the program stops). This |
|
|
319 |
recognizable format looks like two ` __32__' characters, |
|
|
320 |
followed by the file name, line number and character |
|
|
321 |
position separated by colons, and a newline. The |
|
|
322 |
Emacs-to-GDB interface program uses the two ` __32__' |
|
|
323 |
characters as a signal to display the source code for the |
|
|
324 |
frame. |
|
|
325 |
|
|
|
326 |
|
|
|
327 |
__-b__ ''bps'' |
|
|
328 |
|
|
|
329 |
|
|
|
330 |
Set the line speed (baud rate or bits per second) of any |
|
|
331 |
serial interface used by GDB for remote |
|
|
332 |
debugging. |
|
|
333 |
|
|
|
334 |
|
|
|
335 |
__-tty=__''device'' |
|
|
336 |
|
|
|
337 |
|
|
|
338 |
Run using ''device'' for your program's standard input |
|
|
339 |
and output. |
|
|
340 |
!!SEE ALSO |
|
|
341 |
|
|
|
342 |
|
|
|
343 |
`__gdb__' entry in __info__; ''Using GDB: A Guide to |
|
|
344 |
the GNU Source-Level Debugger'', Richard M. Stallman and |
|
|
345 |
Roland H. Pesch, July 1991. |
|
|
346 |
!!COPYING |
|
|
347 |
|
|
|
348 |
|
|
|
349 |
Copyright (c) 1991 Free Software Foundation, |
|
|
350 |
Inc. |
|
|
351 |
|
|
|
352 |
|
|
|
353 |
Permission is granted to make and distribute verbatim copies |
|
|
354 |
of this manual provided the copyright notice and this |
|
|
355 |
permission notice are preserved on all copies. |
|
|
356 |
|
|
|
357 |
|
|
|
358 |
Permission is granted to copy and distribute modified |
|
|
359 |
versions of this manual under the conditions for verbatim |
|
|
360 |
copying, provided that the entire resulting derived work is |
|
|
361 |
distributed under the terms of a permission notice identical |
|
|
362 |
to this one. |
|
|
363 |
|
|
|
364 |
|
|
|
365 |
Permission is granted to copy and distribute translations of |
|
|
366 |
this manual into another language, under the above |
|
|
367 |
conditions for modified versions, except that this |
|
|
368 |
permission notice may be included in translations approved |
|
|
369 |
by the Free Software Foundation instead of in the original |
|
|
370 |
English. |
|
|
371 |
---- |