Getting Started with GDB137
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping
the program
user-defined -- User-defined commands
Type "help" followed by a class name for a list of commands in
that class.
Type "help" followed by command name for full documentation.
Command name abbreviations are allowed if unambiguous.
(gdb)
You can stop
gdb
using
quit
command on
(gdb)
prompt. You can also stop
gdb
or the
current running command by pressing the
Ctrl
and
C
keys simultaneously.
You need to open a file for debugging after starting
gdb
using
file
command. You can
also start
gdb
by providing a file name on the command line. The following command starts
gdb
and uses
a.out
file for debugging purpose.
gdb a.out
Please note that
a.out
must be compiled using the –
g
command line switch with
gcc
compiler. If you don’t use the command line switch –
g
, no debug information will be stored in
the
a.out
file. The typical command line to compile a file with debug support is as follows:
gcc –g hello.c –o hello
The above command creates an output file
hello
that can be used to debug
hello.c
program using the following command:
gdb hello
If you have started
gdb
without any command line argument, you can load a file into
gdb
at any time using
file
command at the
(gdb)
prompt.
5.2.1Most Commonly Used gdb Commands
The most commonly used GDB commands are listed in Table 5-1. These commands are
used to start and stop
gdb
debugging, executing a program and displaying results. Note that you
start
gdb
using the
gdb [filename]
command and then you get the
(gdb)
prompt where
you can use these commands.
Note that there is a difference between the
next
and the
step
commands. The
next
command will move you to the next line in the current function. If the current line is a function
Next Page >>
<< Previous Page
Back to the Table of Contents