Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Gareth McMullin <gareth@blacksphere.co.nz>, gdb@sourceware.org
Subject: Re: question about ARM watchpoints
Date: Fri, 05 Sep 2014 08:17:00 -0000	[thread overview]
Message-ID: <540971A1.2040506@redhat.com> (raw)
In-Reply-To: <20140905035127.GA27655@adacore.com>

On 09/05/2014 04:51 AM, Joel Brobecker wrote:
>> So sounds like this line should be skipped on ARMv7-M:
>>
>>   arm-tdep.c:  set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
>>
>> Could you try removing it?
>>
>> But then I wonder why we never heard of this before.  Are there
>> ARMv7-M's that behave differently?  And what about ARMv6-M ?
> 
> That's what I wanted to try too, and will do soon. As to why we never
> heard of this before - the only affirmative answer would be from someone
> better able to undertand the docs than me.  But here's a wild guess: the
> fact that GDB stopped one instruction too late is invisible to the user
> 99% of the time. What triggered me seeing it was a change in code
> generation which caused the update to be at the penultimate instruction
> of a function. I wouldn't have seen it if the update was anywhere before
> that.

Ah, indeed.

Hmm.  Sounds like we need a test to catch this.  :-)

Most preferably, a portable one, which may be tricky.

I've written something like this before:

volatile int i1;
volatile int i2;
volatile int i3;

int main ()
{
	i1 = 1;
	i2 = 2;
	i3 = 3;
}

assuming each write would be one insn, but, then that turned
out to be a wrong assumption, for ARM even, I think.

Hmm...  I had an idea.  How about:

volatile int global;

set_global (int val)
{
	global = val;
}

main ()
{
   set_global (1);
   set_global (2);
}

#01 - run to main
#02 - set a _software_ watchpoint on i1 (w/ hw watchpoints force-disabled)
#03 - continue
#04 - (GDB single-steps the inferior, and checks the watchpoint's
     value at each step.)
#05 - watchpoint triggers
#06 - the PC now points to the instruction right after the instruction that
     actually caused the memory write.  So this is the address a hardware
     watchpoint should present the stop to the user too.  Store the PC address.
#07 - delete the software watchpoint
#08 - set a _hardware_ watchpoint on i1.
#09 - continue
#10 - hardware watchpoint triggers.  PC should point to the address
      stored in #6.

Thanks,
Pedro Alves


  reply	other threads:[~2014-09-05  8:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-01  8:57 Joel Brobecker
2014-09-04 22:37 ` Gareth McMullin
2014-09-05  0:28   ` Pedro Alves
2014-09-05  3:51     ` Joel Brobecker
2014-09-05  8:17       ` Pedro Alves [this message]
2014-09-05  9:46         ` Pedro Alves
2014-09-16 11:18           ` Pedro Alves
2014-09-16 12:13             ` Joel Brobecker
2014-09-16 13:21               ` Pedro Alves
     [not found]       ` <87ioktav6i.fsf@codesourcery.com>
2014-09-15 13:02         ` Joel Brobecker

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=540971A1.2040506@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gareth@blacksphere.co.nz \
    --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