Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: read watchpoints don't work on targets that support read watchpoints
Date: Thu, 18 Feb 2010 18:41:00 -0000	[thread overview]
Message-ID: <83aav6xuag.fsf@gnu.org> (raw)
In-Reply-To: <201002180111.31520.pedro@codesourcery.com>

> From: Pedro Alves <pedro@codesourcery.com>
> Date: Thu, 18 Feb 2010 01:11:31 +0000
> 
> The problem is that bpstat_check_watchpoint logic for read watchpoints
> is bogus for targets that do support read watchpoints properly:

I'd say "bogus" is a little exaggerated here, to say the least.  For
x86, it's the best we can do, and works reasonably well even under
contrived conditions (see below for one such example).  And at the
time this was written, the number of targets that did support
read-only watchpoints was very small.

>  	    case WP_VALUE_CHANGED:
> 	      if (b->type == bp_read_watchpoint)
> 		{
> 		  /* Don't stop: read watchpoints shouldn't fire if
> 		     the value has changed.  This is for targets
> 		     which cannot set read-only watchpoints.  */
> 		  bs->print_it = print_it_noop;
> 		  bs->stop = 0;
> 		}
> 
> If we don't get a memory write trap, then when the next read traps,
> we'll see that the watched value changes, and consequently we just
> ignore the watchpoint!

Right, but I could argue that this situation is rarely of practical
importance: why didn't the user use a data-write watchpoint for the
program you've shown?

> As Jeremy says on the PR: "over-enthusiastic reporting is less
> of an issue than under-enthusiastic reporting".

I don't agree with this philosophy, but I don't want to start an
academic argument, either.  What worries me is this: what will happen
on x86 under your suggested change if the same address is watched with
2 different watchpoints: a read one and a write one?  (If you wonder
why would that be useful, then the answer is that each one could use a
different condition.)  Before the changes which added this logic, the
results were a total mess.

> The logic of not reporting read watchpoints if the memory
> changes could be reinstated, if conditionalized on the target
> telling the core that it can't do read watchpoints, but it
> can do access watchpoints instead.  Or the target itself could
> do that (filtering read-write traps from gdb if the memory
> watched doesn't change), which is more efficient, transparent
> and flexible.  Or such targets should just refuse
> to install read watchpoints, and GDB should try to fallback
> to trying access watchpoints, and knowing it should apply
> the "only-if-not-changed" logic then.  This is never perfect,
> because we'll report reads when the program writes the same value
> as the memory already had, but then again, this is what already
> happens today.  The latter option is a bit problematic with
> the current interfaces, as we don't know _why_ is the target
> refusing a read watchpoint.  In any case, I think that
> targets allowing read watchpoints to be inserted, and
> then trapping on writes should get what they deserve.
> 
> I think we should apply this, and work from here on if needed.
> Any objection or better ideas?

I would suggest to fix the problem in a more fundamental manner,
instead of degrading the watchpoint support on one target for the sake
of another.

I like this suggestion the best:

  The logic of not reporting read watchpoints if the memory
  changes could be reinstated, if conditionalized on the target
  telling the core that it can't do read watchpoints, but it
  can do access watchpoints instead.

With this setup, we can properly support both x86 and targets that
support real read-only watchpoints.


  reply	other threads:[~2010-02-18 18:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18  1:11 Pedro Alves
2010-02-18 18:41 ` Eli Zaretskii [this message]
2010-02-19 10:19   ` Eli Zaretskii
2010-02-21 21:47     ` Pedro Alves
2010-02-22 19:24       ` Eli Zaretskii
2010-02-22 20:09         ` Pedro Alves
2010-02-22 20:12           ` Pedro Alves
2010-02-22 21:12           ` Eli Zaretskii
2010-02-22 23:39             ` Pedro Alves

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=83aav6xuag.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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