Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Watching memory adress given by an expression
@ 2009-01-12 12:57 Yves Jaradin
  2009-01-12 15:15 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: Yves Jaradin @ 2009-01-12 12:57 UTC (permalink / raw)
  To: gdb

Hi,

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:

break emulate.cc:316
ignore $bpnum 9
commands
print entry
x &(entry.pc)
set $targetpc=$_
watch *($targetpc)
continue
end
continue


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 
isn't cleaner.

Is there a cleaner way to do this kind of debugging?

I would have liked to have a command like:
watchmem &(entry.pc)
which would immediately evaluate it's expression to a pointer and set a 
watcher to the pointed space.

Regards,
Yves


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-12 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-12 12:57 Watching memory adress given by an expression Yves Jaradin
2009-01-12 15:15 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox