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