watchpoints inside 'commands'
Edward Peschko
edwardp@excitehome.net
Thu Apr 5 20:05:00 GMT 2001
On Thu, Apr 05, 2001 at 08:00:28PM -0700, Edward Peschko wrote:
hey,
I was wondering how people might tackle the following problem:
I'm trying to track down a memory corruption bug in my C++ code, and am finding
it very difficult. it comes in a function that creates several items...
Anyways, I was thinking of putting in a watchpoint, but I would have to put
in several watchpoints because the bug is intermittant:
Key *Object::getItem(Key key)
{
return (Object::getItem(&key)); bug here.
}
So. I tried the following:
b Object.cpp:12
commands 1
> silent
> watch key._data[0]
> continue
Unfortunately, this doesn't seem to work because, when the watchpoint is
eliminated, the program auto halts. Why?
And can you set an 'intelligent' watchpoint, one that watches the value of a
variable *name* (not a variable instance) between point 'a' and point 'b' in
your code? This would be far more useful than the current behaviour -
currently, tracing one instance of a variable is useless if you've got a
function which creates and destroys tons of them...
ed
(ps -- this brings up another thing.. if you've got a heisenbug, how do you go
about tracking it down? Say that another piece of your code (in another thread)
is trashing your thread via an array bounds write (or some such thing) How can
you track this down as being the cause? And how do you fix it?)
More information about the Gdb
mailing list