1

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?

Community
  • 1
  • 1
cpuer
  • 7,413
  • 14
  • 35
  • 39

1 Answers1

1

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.
Michael Foukarakis
  • 39,737
  • 6
  • 87
  • 123