36
Chapter 7. Stopping and Continuing
7.1.1. Setting breakpoints
Breakpoints are set with the
break
command (abbreviated
b
). The debugger convenience variable
$bpnum
records the number of the breakpoint you’ve set most recently; refer to Section 10.9
Conve-
nience variables
, for a discussion of what you can do with convenience variables.
You have several ways to say where the breakpoint should go.
break
function
Set a breakpoint at entry to function
function
. When using source languages that permit over-
loading of symbols, such as C
++
,
function
may refer to more than one possible place to break.
Refer to Section 7.1.8
Breakpoint menus
, for a discussion of that situation.
break +
offset
break -
offset
Set a breakpoint some number of lines forward or back from the position at which execution
stopped in the currently selected
stack frame
. Refer to Section 8.1
Stack frames
for a description
of stack frames.)
break
linenum
Set a breakpoint at line
linenum
in the current source file. The current source file is the last file
whose source text was printed. The breakpoint will stop your program just before it executes any
of the code on that line.
break
filename
:
linenum
Set a breakpoint at line
linenum
in source file
filename
.
break
filename
:
function
Set a breakpoint at entry to function
function
found in file
filename
. Specifying a file name
as well as a function name is superfluous except when multiple files contain similarly named
functions.
break *
address
Set a breakpoint at address
address
. You can use this to set breakpoints in parts of your program
which do not have debugging information or source files.
break
When called without any arguments,
break
sets a breakpoint at the next instruction to be exe-
cuted in the selected stack frame (refer to Chapter 8
Examining the Stack
). In any selected frame
but the innermost, this makes your program stop as soon as control returns to that frame. This is
similar to the effect of a
finish
command in the frame inside the selected frame--except that
finish
does not leave an active breakpoint. If you use
break
without an argument in the in-
nermost frame, gdb stops the next time it reaches the current location; this may be useful inside
loops.
gdb normally ignores breakpoints when it resumes execution, until at least one instruction has
been executed. If it did not do this, you would be unable to proceed past a breakpoint without first
disabling the breakpoint. This rule applies whether or not the breakpoint already existed when
your program stopped.
break ... if
cond
Set a breakpoint with condition
cond
; evaluate the expression
cond
each time the breakpoint
is reached, and stop only if the value is nonzero--that is, if
cond
evaluates as true.
...
stands
Содержание ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Страница 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Страница 12: ...2 Chapter 1 Debugging with gdb ...
Страница 28: ...18 Chapter 4 Getting In and Out of gdb ...
Страница 34: ...24 Chapter 5 gdb Commands ...
Страница 44: ...34 Chapter 6 Running Programs Under gdb ...
Страница 68: ...58 Chapter 8 Examining the Stack ...
Страница 98: ...88 Chapter 10 Examining Data ...
Страница 112: ...102 Chapter 12 Tracepoints ...
Страница 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Страница 138: ...128 Chapter 14 Using gdb with Different Languages ...
Страница 144: ...134 Chapter 15 Examining the Symbol Table ...
Страница 170: ...160 Chapter 19 Debugging remote programs ...
Страница 198: ...188 Chapter 21 Controlling gdb ...
Страница 204: ...194 Chapter 22 Canned Sequences of Commands ...
Страница 206: ...196 Chapter 23 Command Interpreters ...
Страница 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Страница 296: ...286 Chapter 27 gdb Annotations ...
Страница 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Страница 322: ...312 Chapter 30 Using History Interactively ...
Страница 362: ...352 Appendix D gdb Remote Serial Protocol ...
Страница 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Страница 386: ...376 Appendix G GNU Free Documentation License ...
Страница 410: ......