Go to the previous, next section.
_GDBN__ can print parts of your program's source, since the debugging information recorded in your program tells _GDBN__ what source files were used to build it. When your program stops, _GDBN__ spontaneously prints the line where it stopped. Likewise, when you select a stack frame (see section Selecting a Frame), _GDBN__ prints the line where execution in that frame has stopped. You can print other portions of source files by explicit command.
_if__(!_DOSHOST__) If you use _GDBN__ through its GNU Emacs interface, you may prefer to use Emacs facilities to view source; see section Using _GDBN__ under GNU Emacs. _fi__(!_DOSHOST__)
To print lines from a source file, use the list
command
(abbreviated l
). There are several ways to specify what part
of the file you want to print.
Here are the forms of the list
command most commonly used:
list linenum
list function
list
list
command, this prints lines following the last lines
printed; however, if the last line printed was a solitary line printed
as part of displaying a stack frame (see section Examining the Stack), this prints lines centered around that line.
list -
By default, _GDBN__ prints ten source lines with any of these forms of
the list
command. You can change this using set listsize
:
set listsize count
list
command display count source lines (unless
the list
argument explicitly specifies some other number).
show listsize
list
will currently display by
default.
Repeating a list
command with RET discards the argument,
so it is equivalent to typing just list
. This is more useful
than listing the same lines again. An exception is made for an
argument of `-'; that argument is preserved in repetition so that
each repetition moves up in the source file.
In general, the list
command expects you to supply zero, one or two
linespecs. Linespecs specify source lines; there are several ways
of writing them but the effect is always to specify some source line.
Here is a complete description of the possible arguments for list
:
list linespec
list first,last
list ,last
list first,
list +
list -
list
Here are the ways of specifying a single source line--all the kinds of linespec.
number
list
command has two linespecs, this refers to
the same source file as the first linespec.
+offset
list
command that has
two, this specifies the line offset lines down from the
first linespec.
-offset
filename:number
function
filename:function
*address
_if__(_GENERIC__ || !_H8__)
There are two commands for searching through the current source file for a regular expression.
forward-search regexp
search regexp
fo
.
reverse-search regexp