f78
Setting watchpoints
Watchpoints currently execute two orders of magnitude more slowly than other
breakpoints, but this can be well worth it to catch errors where you have no
clue what part of your program is the culprit.
Warning:
Set a watchpoint for an expression. GDB will break when expr is written into
by the program and its value changes. This can be used with the new
trap-generation provided by SPARClite DSU. DSU will generate traps when a program accesses
some date 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. {No value for “GBDN”} will reject the command if you
try to mix watchpoints. Delete or disable unused watchpoint commands before
setting new ones.
Set a watchpoint that will break when watch args is read by the program. If you use both watchpoints, both must be set with
the rwatch command.
Set a watchpoint that will break when args is read and written into by the program. If you use both watchpoints, both
must be set with the awatch command.
This command prints a list of watchpoints and breakpoints; it is the same as info break.
In multi-thread programs, watchpoints have only limited usefulness. With the
current watchpoint implementation, GDB can only watch the value of an expression
in a single thread. If you are confident that the expression can only change due to the current
thread’s activity (and if you are also confident that no other thread can
become current), then you can use watchpoints as usual.
77
However, GDB may not notice
when a non-current thread’s activity changes the expression.