
Chapter 7.
Stopping and Continuing
The principal purposes of using a debugger are so that you can stop your program before it terminates;
or so that, if your program runs into trouble, you can investigate and find out why.
Inside gdb, your program may stop for any of several reasons, such as a signal, a breakpoint, or
reaching a new line after a gdb command such as
step
. You may then examine and change variables,
set new breakpoints or remove old ones, and then continue execution. Usually, the messages shown
by gdb provide ample explanation of the status of your program--but you can also explicitly request
this information at any time.
info program
Display information about the status of your program: whether it is running or not, what process
it is, and why it stopped.
7.1. Breakpoints, watchpoints, and catchpoints
A
breakpoint
makes your program stop whenever a certain point in the program is reached. For each
breakpoint, you can add conditions to control in finer detail whether your program stops. You can set
breakpoints with the
break
command and its variants (refer to Section 7.1.1
Setting breakpoints
), to
specify the place where your program should stop by line number, function name or exact address in
the program.
In HP-UX, SunOS 4.x, SVR4, and Alpha OSF/1 configurations, you can set breakpoints in shared
libraries before the executable is run. There is a minor limitation on HP-UX systems: you must wait
until the executable is run in order to set breakpoints in shared library routines that are not called
directly by the program (for example, routines that are arguments in a
pthread_create
call).
A
watchpoint
is a special breakpoint that stops your program when the value of an expression changes.
You must use a different command to set watchpoints (refer to Section 7.1.2
Setting watchpoints
), but
aside from that, you can manage a watchpoint like any other breakpoint: you enable, disable, and
delete both breakpoints and watchpoints using the same commands.
You can arrange to have values from your program displayed automatically whenever gdb stops at a
breakpoint. Refer to Section 10.6
Automatic display
.
A
catchpoint
is another special breakpoint that stops your program when a certain kind of event
occurs, such as the throwing of a C
++
exception or the loading of a library. As with watchpoints, you
use a different command to set a catchpoint (refer to Section 7.1.3
Setting catchpoints
), but aside from
that, you can manage a catchpoint like any other breakpoint. (To stop when your program receives a
signal, use the
handle
command. Refer to Section 7.3
Signals
.
gdb assigns a number to each breakpoint, watchpoint, or catchpoint when you create it; these numbers
are successive integers starting with one. In many of the commands for controlling various features
of breakpoints you use the breakpoint number to say which breakpoint you want to change. Each
breakpoint may be
enabled
or
disabled
; if disabled, it has no effect on your program until you enable
it again.
Some gdb commands accept a range of breakpoints on which to operate. A breakpoint range is either
a single breakpoint number, like
5
, or two such numbers, in increasing order, separated by a hyphen,
like
5-7
. When a breakpoint range is given to a command, all breakpoint in that range are operated
on.
Summary of Contents for ENTERPRISE LINUX 3 - SECURITY GUIDE
Page 1: ...Red Hat Enterprise Linux 3 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: ......