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 or use
51       option "-p", if you want to debug a running process:
52
53               gdb program 1234
54               gdb -p 1234
55
56       would attach GDB to process 1234.  With option -p you can omit the
57       program filename.
58
59       Here are some of the most frequently needed GDB commands:
60
61       break [file:]function
62           Set a breakpoint at function (in file).
63
64       run [arglist]
65           Start your program (with arglist, if specified).
66
67       bt  Backtrace: display the program stack.
68
69       print expr
70           Display the value of an expression.
71
72       c   Continue running your program (after stopping, e.g. at a
73           breakpoint).
74
75       next
76           Execute next program line (after stopping); step over any function
77           calls in the line.
78
79       edit [file:]function
80           look at the program line where it is presently stopped.
81
82       list [file:]function
83           type the text of the program in the vicinity of where it is
84           presently stopped.
85
86       step
87           Execute next program line (after stopping); step into any function
88           calls in the line.
89
90       help [name]
91           Show information about GDB command name, or general information
92           about using GDB.
93
94       quit
95           Exit from GDB.
96
97       For full details on GDB, see Using GDB: A Guide to the GNU Source-Level
98       Debugger, by Richard M. Stallman and Roland H. Pesch.  The same text is
99       available online as the "gdb" entry in the "info" program.
100

OPTIONS

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

SEE ALSO

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