[GDB 6.8] Problem using watchpoints with compound objects
Antony KING
antony.king@st.com
Tue Mar 3 17:39:00 GMT 2009
I am investigating a problem with H/W watchpoints on compound objects in
GDB 6.8 whereby they are not being set in the target nor are they being
detected as being changed (once the first problem is fixed). Take for
example the following simple application:
int a[4];
int main (void)
{
a[0] = 1;
return 0;
}
Problem 1 - watchpoint is not set
---------------------------------
If I issue "watch a" to GDB then GDB reports that it has set a H/W
watchpoint but when I continue the watchpoint is not being set. This I
believe is due to a problem in update_watchpoints() in the following test:
if (v == b->val
|| (TYPE_CODE (vtype) != TYPE_CODE_STRUCT
&& TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
The if is unnecessary failing since the test "v == b->val" is not taking
into account that b->val may *not* have been set to v earlier on in the
same function. Looking the CVS head this code has been modified so that
this problem is no longer present. Making a similar change to GDB 6.8
seems to fix the problem (see patch1.txt). Is this solution correct ?
Problem 2 - watchpoint is not detected
--------------------------------------
After applying the patch for problem 1 I then encountered a second
problem where a watchpoint is being erroneously dismissed as being
unchanged. I believe this problem is due to the following test in
watchpoint_check():
if (!value_equal (b->val, new_val))
This test is only comparing the address of the object and not its
contents. I think the test should be revised to the following:
if (!value_equal (b->val, new_val)
|| !value_contents_equal (b->val, new_val))
assuming that the value_equal() test is still required (otherwise the
value_equal test could be dropped). Looking at the code in the CVS head
the same issue still seems present. Do you think the above is sufficient
to fix the problem ?
Cheers,
Antony.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gdb.patch
URL: <http://sourceware.org/pipermail/gdb/attachments/20090303/89753d43/attachment.ksh>
More information about the Gdb
mailing list