1 .\" Copyright (c) 1991 Free Software Foundation
2 .\" See section COPYING for conditions for redistribution
4 .TH gdb 1 "4nov1991" "GNU Tools" "GNU Tools"
6 gdb \- The GNU Debugger
11 .RB "[\|" \-help "\|]"
14 .RB "[\|" \-batch "\|]"
20 .RB "[\|" \-wcore "\|]"
46 .IR core \||\| procID\c
50 The purpose of a debugger such as GDB is to allow you to see what is
51 going on ``inside'' another program while it executes\(em\&or what another
52 program was doing at the moment it crashed.
54 GDB can do four main kinds of things (plus other things in support of
55 these) to help you catch bugs in the act:
59 Start your program, specifying anything that might affect its behavior.
63 Make your program stop on specified conditions.
67 Examine what has happened, when your program has stopped.
71 Change things in your program, so you can experiment with correcting the
72 effects of one bug and go on to learn about another.
75 You can use GDB to debug programs written in C, C++, and Modula-2.
76 Fortran support will be added when a GNU Fortran compiler is ready.
78 GDB is invoked with the shell command \c
80 \&. Once started, it reads
81 commands from the terminal until you tell it to exit with the GDB
84 \&. You can get online help from \c
87 by using the command \c
93 \& with no arguments or options; but the most
94 usual way to start GDB is with one argument or two, specifying an
95 executable program as the argument:
102 You can also start with both an executable program and a core file specified:
109 You can, instead, specify a process ID as a second argument, if you want
110 to debug a running process:
117 would attach GDB to process \c
119 \& (unless you also have a file
122 \&\|'; GDB does check for a core file first).
124 Here are some of the most frequently needed GDB commands:
126 .B break \fR[\|\fIfile\fB:\fR\|]\fIfunction
128 Set a breakpoint at \c
134 .B run \fR[\|\fIarglist\fR\|]
135 Start your program (with \c
140 Backtrace: display the program stack.
144 Display the value of an expression.
147 Continue running your program (after stopping, e.g. at a breakpoint).
150 Execute next program line (after stopping); step \c
153 function calls in the line.
156 Execute next program line (after stopping); step \c
159 function calls in the line.
161 .B help \fR[\|\fIname\fR\|]
162 Show information about GDB command \c
164 \&, or general information
170 For full details on GDB, see \c
172 Using GDB: A Guide to the GNU Source-Level Debugger\c
173 \&, by Richard M. Stallman and Roland H. Pesch. The same text is available online
180 Any arguments other than options specify an executable
181 file and core file (or process ID); that is, the first argument
183 associated option flag is equivalent to a `\|\c
185 \&\|' option, and the
186 second, if any, is equivalent to a `\|\c
188 \&\|' option if it's the name of a file. Many options have
189 both long and short forms; both are shown here. The long forms are also
190 recognized if you truncate them, so long as enough of the option is
191 present to be unambiguous. (If you prefer, you can flag option
194 \&\|' rather than `\|\c
196 \&\|', though we illustrate the
197 more usual convention.)
199 All the options and command line arguments you give are processed
200 in sequential order. The order makes a difference when the
203 \&\|' option is used.
209 List all options, with brief explanations.
212 .BI "\-symbols=" "file"\c
216 Read symbol table from file \c
221 .BI "\-exec=" "file"\c
227 \& as the executable file to execute when
228 appropriate, and for examining pure data in conjunction with a core
234 Read symbol table from file \c
236 \& and use it as the executable
240 .BI "\-core=" "file"\c
246 \& as a core dump to examine.
249 .BI "\-command=" "file"\c
253 Execute GDB commands from file \c
258 .BI "\-directory=" "directory"\c
260 .BI "\-d " "directory"\c
264 \& to the path to search for source files.
271 Do not execute commands from any `\|\c
273 \&\|' initialization files.
274 Normally, the commands in these files are executed after all the
275 command options and arguments have been processed.
282 ``Quiet''. Do not print the introductory and copyright messages. These
283 messages are also suppressed in batch mode.
287 Run in batch mode. Exit with status \c
289 \& after processing all the command
290 files specified with `\|\c
294 \&\|', if not inhibited).
295 Exit with nonzero status if an error occurs in executing the GDB
296 commands in the command files.
298 Batch mode may be useful for running GDB as a filter, for example to
299 download and run a program on another computer; in order to make this
300 more useful, the message
303 Program\ exited\ normally.
307 (which is ordinarily issued whenever a program running under GDB control
308 terminates) is not issued when running in batch mode.
311 .BI "\-cd=" "directory"\c
315 \& as its working directory,
316 instead of the current directory.
322 Emacs sets this option when it runs GDB as a subprocess. It tells GDB
323 to output the full file name and line number in a standard,
324 recognizable fashion each time a stack frame is displayed (which
325 includes each time the program stops). This recognizable format looks
328 \&\|' characters, followed by the file name, line number
329 and character position separated by colons, and a newline. The
330 Emacs-to-GDB interface program uses the two `\|\c
333 a signal to display the source code for the frame.
339 Use gdb in kernel debugging mode. The prompt is set to ``(kgdb)''.
343 This option may only be used in kernel debugging mode while
344 debugging a ``live'' kernel and makes the corefile (/dev/mem)
350 Set the line speed (baud rate or bits per second) of any serial
351 interface used by GDB for remote debugging.
354 .BI "\-tty=" "device"\c
358 \& for your program's standard input and output.
367 Using GDB: A Guide to the GNU Source-Level Debugger\c
368 , Richard M. Stallman and Roland H. Pesch, July 1991.
370 Copyright (c) 1991 Free Software Foundation, Inc.
372 Permission is granted to make and distribute verbatim copies of
373 this manual provided the copyright notice and this permission notice
374 are preserved on all copies.
376 Permission is granted to copy and distribute modified versions of this
377 manual under the conditions for verbatim copying, provided that the
378 entire resulting derived work is distributed under the terms of a
379 permission notice identical to this one.
381 Permission is granted to copy and distribute translations of this
382 manual into another language, under the above conditions for modified
383 versions, except that this permission notice may be included in
384 translations approved by the Free Software Foundation instead of in
385 the original English.