list

Display lines of source code.

Syntax

Use one of the following forms:

GDB Mode:

list
list [ file_name:]line_expression
list begin,end
list begin,
list ,end
list +[num]
list -[num]
list *address

IDB Mode:

list [ line_expression ]
list  begin , end 
list  begin : num  

Parameters

line_expression

An expression that evaluates to an integer or the name of a function whose source code you want to display. The syntax of the command and the expression determine how the debugger evaluates line_expression.

When this expression is an integer, it can be the line number of the source code you want to display or any of the following parameters:

begin

end

+num

-num

begin

An expression that evaluates to the line number at the beginning of the range of source code you want to display.

end

An expression that evaluates to the line number at the end of the range of source code you want to display.

num

The number of lines to print.

GDB Mode:

Default is 10.

file_name

The name of the file containing the source code you want to print.

line_number

The line number of the source code you want to display.

function

The name of the function whose source code you want to display.

address

The address of the instruction that the compiler outputs from a line of source code.

Description

This command displays lines of source code, as specified by one of the following items:

GDB Mode:

If you do not specify a parameter, the debugger prints the ten lines surrounding the current line. If the last line that the debugger printed was the output of this command, the debugger prints the lines following the last line it printed. If the last line it printed was a single line that the debugger printed as part of a stack frame, the debugger prints the lines centered around that line.

If you specify only line_number or function, the debugger prints the lines centered around the specified line or the beginning of the function. By default, the debugger prints ten lines.

If you specify begin and end, the debugger prints the lines beginning with begin and ending with end. If you specify only begin or end, the debugger prints the ten lines either following begin or preceding end.

list + prints num lines after the last printed. list - prints num lines before the last printed. If you do not include num, the debugger prints ten lines.

If you specify *address, the debugger prints the line that was compiled to an instruction at the specified program address.

IDB Mode:

If you specify only line_number or function, the debugger prints the lines starting with the specified line or the beginning of the function. By default, the debugger prints ten lines.

If you specify begin , end, the debugger prints the lines beginning with begin and ending with end. If you specify begin : num, the debugger prints num lines, beginning with begin.

If you do not specify end or num, the debugger shows 20 lines, or fewer if it reaches the end of source file.

Example

For example, to list lines 16 through 20:

(idb) list 16,20
16 
17 class Node { 
18 public: 
19 Node (); 
20 

To list 6 lines, beginning with line 16:

GDB Mode:

(idb) list 16,+6
16 
17 class Node { 
18 public: 
19 Node (); 
20 
21 virtual void printNodeData() const = 0; 

Here are some other examples of the list command:

list -2,
list ,+2
list -2,+2
list myfile:2
list myfile:2,
list ,myfile:2
list myfile:2,myfile:3
list myfile:bar
list myfile:bar,
list ,myfile:bar
list myfile:bar,myfile:foo
list *0x123

IDB Mode:

(idb) list 16:6
16 
17 class Node { 
18 public: 
19 Node (); 
20 
21 virtual void printNodeData() const = 0; 

See Also


Submit feedback on this help topic

Copyright © 1996-2010, Intel Corporation. All rights reserved.