Chapter 7. Stopping and Continuing
39
awatch
expr
Set a watchpoint that will break when
expr
is either read or written into by the program.
info watchpoints
This command prints a list of watchpoints, breakpoints, and catchpoints; it is the same as
info
break
.
gdb sets a
hardware watchpoint
if possible. Hardware watchpoints execute very quickly, and the
debugger reports a change in value at the exact instruction where the change occurs. If gdb cannot
set a hardware watchpoint, it sets a software watchpoint, which executes more slowly and reports the
change in value at the next statement, not the instruction, after the change occurs.
When you issue the
watch
command, gdb reports
Hardware watchpoint
num
:
expr
if it was able to set a hardware watchpoint.
Currently, the
awatch
and
rwatch
commands can only set hardware watchpoints, because accesses
to data that don’t change the value of the watched expression cannot be detected without examining
every instruction as it is being executed, and gdb does not do that currently. If gdb finds that it is
unable to set a hardware breakpoint with the
awatch
or
rwatch
command, it will print a message
like this:
Expression cannot be implemented with read/access watchpoint.
Sometimes, gdb cannot set a hardware watchpoint because the data type of the watched expression
is wider than what a hardware watchpoint on the target machine can handle. For example, some
systems can only watch regions that are up to 4 bytes wide; on such systems you cannot set hardware
watchpoints for an expression that yields a double-precision floating-point number (which is typically
8 bytes wide). As a work-around, it might be possible to break the large region into a series of smaller
ones and watch them with separate watchpoints.
If you set too many hardware watchpoints, gdb might be unable to insert all of them when you resume
the execution of your program. Since the precise number of active watchpoints is unknown until such
time as the program is about to be resumed, gdb might not be able to warn you about this when you
set the watchpoints, and the warning will be printed only when the program is resumed:
Hardware watchpoint
num
: Could not insert watchpoint
If this happens, delete or disable some of the watchpoints.
The SPARClite DSU will generate traps when a program accesses some data or instruction address
that is assigned to the debug registers. For the data addresses, DSU facilitates the
watch
command.
However the hardware breakpoint registers can only take two data watchpoints, and both watchpoints
must be the same kind. For example, you can set two watchpoints with
watch
commands, two with
rwatch
commands,
or
two with
awatch
commands, but you cannot set one watchpoint with one
command and the other with a different command. gdb will reject the command if you try to mix
watchpoints. Delete or disable unused watchpoint commands before setting new ones.
If you call a function interactively using
or
call
, any watchpoints you have set will be inactive
until gdb reaches another kind of breakpoint or the call completes.
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: ......