This is the mail archive of the
mailing list for the GDB project.
Watching memory adress given by an expression
- From: Yves Jaradin <yves dot jaradin at uclouvain dot be>
- To: gdb at sourceware dot org
- Date: Mon, 12 Jan 2009 13:56:17 +0100
- Subject: Watching memory adress given by an expression
Recently, I stumbled upon a dangling pointer in some code I'm maintaining.
The best reproducible crash was still very time sensitive (order of a
few seconds at most),
so I couldn't really debug interactively.
Some structure on the heap was corrupted, so I set up a breakpoint when
the structure was correctly initialized with commands to set up a
watchpoint on the memory that would be corrupted.
Unfortunately, the expression I had for the to-be-corrupted memory was
going out of scope before the corruption.
I resorted to this:
ignore $bpnum 9
Which is ugly because:
I works only for a single triggering of the breakpoint.
It prints an extra value.
The $_ business I'm doing is really a hack.
I could remove the first problem using shell, source, etc. but this
Is there a cleaner way to do this kind of debugging?
I would have liked to have a command like:
which would immediately evaluate it's expression to a pointer and set a
watcher to the pointed space.