To print lines from a source file, use the
l). By default, ten lines are printed.
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:
listcommand, 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.
By default, GDB prints ten source lines with any of these forms of
list command. You can change this using
set listsize count
listcommand display count source lines (unless the
listargument explicitly specifies some other number).
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
Here are the ways of specifying a single source line--all the kinds of linespec.
listcommand has two linespecs, this refers to the same source file as the first linespec.
listcommand that has two, this specifies the line offset lines down from the first linespec.
Go to the first, previous, next, last section, table of contents.