1GDB(1)                       GNU Development Tools                      GDB(1)
2
3
4

NAME

6       gdb - The GNU Debugger
7

SYNOPSIS

9       gdb [-help] [-nh] [-nx] [-q] [-batch] [-cd=dir] [-f] [-b bps]
10           [-tty=dev] [-s symfile] [-e prog] [-se prog] [-c core] [-p procID]
11           [-x cmds] [-d dir] [prog|prog procID|prog core]
12

DESCRIPTION

14       The purpose of a debugger such as GDB is to allow you to see what is
15       going on "inside" another program while it executes -- or what another
16       program was doing at the moment it crashed.
17
18       GDB can do four main kinds of things (plus other things in support of
19       these) to help you catch bugs in the act:
20
21       ·   Start your program, specifying anything that might affect its
22           behavior.
23
24       ·   Make your program stop on specified conditions.
25
26       ·   Examine what has happened, when your program has stopped.
27
28       ·   Change things in your program, so you can experiment with
29           correcting the effects of one bug and go on to learn about another.
30
31       You can use GDB to debug programs written in C, C@t{++}, Fortran and
32       Modula-2.
33
34       GDB is invoked with the shell command "gdb".  Once started, it reads
35       commands from the terminal until you tell it to exit with the GDB
36       command "quit".  You can get online help from GDB itself by using the
37       command "help".
38
39       You can run "gdb" with no arguments or options; but the most usual way
40       to start GDB is with one argument or two, specifying an executable
41       program as the argument:
42
43               gdb program
44
45       You can also start with both an executable program and a core file
46       specified:
47
48               gdb program core
49
50       You can, instead, specify a process ID as a second argument, if you
51       want to debug a running process:
52
53               gdb program 1234
54               gdb -p 1234
55
56       would attach GDB to process 1234 (unless you also have a file named
57       1234; GDB does check for a core file first).  With option -p you can
58       omit the program filename.
59
60       Here are some of the most frequently needed GDB commands:
61
62       break [file:]function
63           Set a breakpoint at function (in file).
64
65       run [arglist]
66           Start your program (with arglist, if specified).
67
68       bt  Backtrace: display the program stack.
69
70       print expr
71           Display the value of an expression.
72
73       c   Continue running your program (after stopping, e.g. at a
74           breakpoint).
75
76       next
77           Execute next program line (after stopping); step over any function
78           calls in the line.
79
80       edit [file:]function
81           look at the program line where it is presently stopped.
82
83       list [file:]function
84           type the text of the program in the vicinity of where it is
85           presently stopped.
86
87       step
88           Execute next program line (after stopping); step into any function
89           calls in the line.
90
91       help [name]
92           Show information about GDB command name, or general information
93           about using GDB.
94
95       quit
96           Exit from GDB.
97
98       For full details on GDB, see Using GDB: A Guide to the GNU Source-Level
99       Debugger, by Richard M. Stallman and Roland H. Pesch.  The same text is
100       available online as the "gdb" entry in the "info" program.
101

OPTIONS

103       Any arguments other than options specify an executable file and core
104       file (or process ID); that is, the first argument encountered with no
105       associated option flag is equivalent to a -se option, and the second,
106       if any, is equivalent to a -c option if it's the name of a file.  Many
107       options have both long and short forms; both are shown here.  The long
108       forms are also recognized if you truncate them, so long as enough of
109       the option is present to be unambiguous.  (If you prefer, you can flag
110       option arguments with + rather than -, though we illustrate the more
111       usual convention.)
112
113       All the options and command line arguments you give are processed in
114       sequential order.  The order makes a difference when the -x option is
115       used.
116
117       -help
118       -h  List all options, with brief explanations.
119
120       -symbols=file
121       -s file
122           Read symbol table from file file.
123
124       -write
125           Enable writing into executable and core files.
126
127       -exec=file
128       -e file
129           Use file file as the executable file to execute when appropriate,
130           and for examining pure data in conjunction with a core dump.
131
132       -se=file
133           Read symbol table from file file and use it as the executable file.
134
135       -core=file
136       -c file
137           Use file file as a core dump to examine.
138
139       -command=file
140       -x file
141           Execute GDB commands from file file.
142
143       -ex command
144           Execute given GDB command.
145
146       -directory=directory
147       -d directory
148           Add directory to the path to search for source files.
149
150       -nh Do not execute commands from ~/.gdbinit.
151
152       -nx
153       -n  Do not execute commands from any .gdbinit initialization files.
154
155       -quiet
156       -q  "Quiet".  Do not print the introductory and copyright messages.
157           These messages are also suppressed in batch mode.
158
159       -batch
160           Run in batch mode.  Exit with status 0 after processing all the
161           command files specified with -x (and .gdbinit, if not inhibited).
162           Exit with nonzero status if an error occurs in executing the GDB
163           commands in the command files.
164
165           Batch mode may be useful for running GDB as a filter, for example
166           to download and run a program on another computer; in order to make
167           this more useful, the message
168
169                   Program exited normally.
170
171           (which is ordinarily issued whenever a program running under GDB
172           control terminates) is not issued when running in batch mode.
173
174       -cd=directory
175           Run GDB using directory as its working directory, instead of the
176           current directory.
177
178       -fullname
179       -f  Emacs sets this option when it runs GDB as a subprocess.  It tells
180           GDB to output the full file name and line number in a standard,
181           recognizable fashion each time a stack frame is displayed (which
182           includes each time the program stops).  This recognizable format
183           looks like two \032 characters, followed by the file name, line
184           number and character position separated by colons, and a newline.
185           The Emacs-to-GDB interface program uses the two \032 characters as
186           a signal to display the source code for the frame.
187
188       -b bps
189           Set the line speed (baud rate or bits per second) of any serial
190           interface used by GDB for remote debugging.
191
192       -tty=device
193           Run using device for your program's standard input and output.
194

SEE ALSO

196       The full documentation for GDB is maintained as a Texinfo manual.  If
197       the "info" and "gdb" programs and GDB's Texinfo documentation are
198       properly installed at your site, the command
199
200               info gdb
201
202       should give you access to the complete manual.
203
204       Using GDB: A Guide to the GNU Source-Level Debugger, Richard M.
205       Stallman and Roland H. Pesch, July 1991.
206
208       Copyright (c) 1988-2018 Free Software Foundation, Inc.
209
210       Permission is granted to copy, distribute and/or modify this document
211       under the terms of the GNU Free Documentation License, Version 1.3 or
212       any later version published by the Free Software Foundation; with the
213       Invariant Sections being "Free Software" and "Free Software Needs Free
214       Documentation", with the Front-Cover Texts being "A GNU Manual," and
215       with the Back-Cover Texts as in (a) below.
216
217       (a) The FSF's Back-Cover Text is: "You are free to copy and modify this
218       GNU Manual.  Buying copies from GNU Press supports the FSF in
219       developing GNU and promoting software freedom."
220
221
222
223gdb-Red Hat Enterprise Linux 8.2-6.2e0l189_-007-01                            GDB(1)
Impressum