This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [GDB 6.8] Problem using watchpoints with compound objects

The following is the example I am using:

int a[4];
int main (void)
  a[0] = 1;
  return 0;

and the GDB command is "watch a", so GDB should be watching the contents
of the array object and not its address. I have also tried the following
test with the same effect:

struct {int m1, m2, m3, m4;} a;
int main (void)
  a.m1 = 1;
  return 0;

In both cases value_equal is comparing the address of the object and not
the contents. This is caused, I believe, by the following code at the
start of value_equal:

  arg1 = coerce_array (arg1);
  arg2 = coerce_array (arg2);

which is converting the compound objects into pointers. These are then
used in the latter tests of value_equal.



Daniel Jacobowitz wrote:
> On Tue, Mar 03, 2009 at 05:38:56PM +0000, Antony KING wrote:
>> 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:
> What are you setting a watchpoint on?  value_equal is an
> implementation of the equality operator in the CLI.  If you have a
> pointer, it will only compare the addresses, but for a struct object
> it should compare contents.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]