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: Wed, 04 Mar 2009 19:20:00 -0000	[thread overview]
Message-ID: <49AED46D.7010701@st.com> (raw)
In-Reply-To: <20090303214606.GA9404@caradoc.them.org>

OK. I now understand why the "struct" example below was not working and
my false assumption that coerce_array() was the culprit in both cases (I
checked the array case but assumed it was the same for the struct :-( ).
The reason why it was not working was because I was initially running
the program with the following GDB script:

file a.out
break main
run
watch a
continue

Using the above script I see the following output from GDB (using the
snapshot version 6.8.50.20090303):

> Breakpoint 1 at 0x8048320: file a.c, line 4.
> 
> Breakpoint 1, main () at a.c:4
> 4         a.m1 = 1;
> Hardware watchpoint 2: a
> 
> Program exited normally.

which shows that the watchpoint is not being reported. However if I
replace "break main" with "tbreak main" in the above script I see the
watchpoint being reported, as follows:

> Temporary breakpoint 1 at 0x8048320: file a.c, line 4.
> 
> Temporary breakpoint 1, main () at a.c:4
> 4         a.m1 = 1;
> Hardware watchpoint 2: a
> Hardware watchpoint 2: a
> 
> Old value = {m1 = 0, m2 = 0, m3 = 0, m4 = 0}
> New value = {m1 = 1, m2 = 0, m3 = 0, m4 = 0}
> main () at a.c:5
> 5         return 0;

So in this instance it seems the problem has nothing to do with "a"
being a struct object (as you correctly point out) but as a result of
continuing from a breakpoint; a different GDB issue :-).

However my original query relating to arrays is still valid. If I
perform the same test with "a" defined as an array (as in my original
email) then the effect of coerce_array() in value_equal() remains; the
watchpoint is reported by the H/W but value_equal() will always report
TRUE (since it compares the address of the array and not its contents)
and hence GDB erroneously ignores the watchpoint as unchanged. Therefore
I still think the change to watchpoint_check() is still valid. If you
concur I will submit a patch for this.

[Note that this was tested on RedHat EL3 and EL4 hosts with the same
results.]

Cheers,

Antony.

Daniel Jacobowitz wrote:
> On Tue, Mar 03, 2009 at 09:18:02PM +0000, Antony KING wrote:
>> 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.
> 
> Arrays are supposed to be handled specially, but I was talking about
> structs since that was in your original example.  coerce_array has no
> effect on structs.


  reply	other threads:[~2009-03-04 19:20 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
2009-03-03 21:46     ` Daniel Jacobowitz
2009-03-04 19:20       ` Antony KING [this message]
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=49AED46D.7010701@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