From mboxrd@z Thu Jan 1 00:00:00 1970 From: Edward Peschko To: gdb@sources.redhat.com Subject: watchpoints inside 'commands' Date: Thu, 05 Apr 2001 20:05:00 -0000 Message-id: <20010405200525.A18623@excitehome.net> References: <20010405200028.A18474@excitehome.net> X-SW-Source: 2001-04/msg00045.html 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?)