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