Debugging with GDB (February 2008)

Table Of Contents
58 Debugging with GDB
list linespec
Print lines centered around the line specified by linespec.
list first,last
Print lines from first to last. Both arguments must be linespecs.
list ,last
Print lines ending with last.
list first,
Print lines starting with first.
list + Print lines just after the lines last printed.
list - Print lines just before the lines last printed.
list As described in the preceding table.
A single source line can be specified in the following ways:
number Specifies line number of the current source file. When a list command has
two linespecs, this refers to the same source file as the first linespec.
+offset Specifies the line offset lines after the last line printed. When used as the second
linespec in a list command that has two, this specifies the line offset lines down
from the first linespec.
-offset Specifies the line offset lines before the last line printed.
filename :number
Specifies line number in the source file filename.
function Specifies the line that begins the body of the function function. For example:
in C, this is the line with the open brace.
filename :function
Specifies the line of the open-brace that begins the body of the function function
in the file filename. You only need the file name with a function name to avoid
ambiguity when there are identically named functions in different source files.
*address Specifies the line containing the program address address. address may be any
expression.
7.2 Searching source files
There are two commands for searching through the current source file for a regular
expression.
forward-search regexp
search regexp
The command ‘forward-search regexp checks each line, starting with one of
the following in the last line listed, for a match of the regexp. It lists the line
that is found. You can use the synonym search regexp or abbreviate the
command name as fo.