Possible Duplicate:
Can 开发者_开发问答I set a breakpoint on 'memory access' in GDB?
I want to trace how a specific variable is initialized,
can gdb do this kind of job?
The gdb command watch <expr>
sets a breakpoint on write, rwatch
on read, and awatch
on read or write. You can use them as you would with breakpoints, with two considerations:
- You can't use gdb expressions in them (like
$esp+...
) - You need support for them. Software support is much, much slower than hardware. To find out if your gdb can use hardware watchpoints, see the output of
show can-use-hw-watchpoints
.
精彩评论