Chapter 9. Examining Source Files
61
9.2. Editing source files
To edit the lines in a source file, use the
edit
command. The editing program of your choice is
invoked with the current line set to the active line in the program. Alternatively, there are several ways
to specify what part of the file you want to print if you want to see other parts of the program.
Here are the forms of the
edit
command most commonly used:
edit
Edit the current source file at the active line number in the program.
edit
number
Edit the current source file with
number
as the active line number.
edit
function
Edit the file containing
function
at the beginning of its definition.
edit
filename
:
number
Specifies line
number
in the source file
filename
.
edit
filename
:
function
Specifies the line 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.
edit *
address
Specifies the line containing the program address
address
.
address
may be any expression.
9.2.1. Choosing your editor
You can customize gdb to use any editor you want
1
. By default, it is /bin/ex, but you can change this
by setting the environment variable
EDITOR
before using gdb. For example, to configure gdb to use
the
vi
editor, you could use these commands with the
sh
shell:
EDITOR=/usr/bin/vi
export EDITOR
gdb ...
or in the
csh
shell,
setenv EDITOR /usr/bin/vi
gdb ...
9.3. Searching source files
There are two commands for searching through the current source file for a regular expression.
1. The only restriction is that your editor (say
ex
), recognizes the following command-line syntax:
ex +
number
file
The optional numeric value +
number
designates the active line in the file.
Summary of Contents for ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Page 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......