Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Antony KING <antony.king@st.com>
To: gdb@sourceware.org
Subject: Re: [GDB 6.8] Problem using watchpoints with compound objects
Date: Tue, 03 Mar 2009 21:18:00 -0000	[thread overview]
Message-ID: <49AD9E8A.3020608@st.com> (raw)
In-Reply-To: <20090303203309.GA2672@caradoc.them.org>

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.

Cheers,

Antony.

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.


  reply	other threads:[~2009-03-03 21:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-03 17:39 Antony KING
2009-03-03 20:33 ` Daniel Jacobowitz
2009-03-03 21:18   ` Antony KING [this message]
2009-03-03 21:46     ` Daniel Jacobowitz
2009-03-04 19:20       ` Antony KING
2009-03-04 19:28         ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49AD9E8A.3020608@st.com \
    --to=antony.king@st.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox