Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Re: [rfc] Allow watchpoints on inaccessible memory
Date: Tue, 21 Aug 2007 22:49:00 -0000	[thread overview]
Message-ID: <m3wsvo4i71.fsf@codesourcery.com> (raw)
In-Reply-To: <20070821180630.GA8332@caradoc.them.org> (Daniel Jacobowitz's message of "Tue, 21 Aug 2007 14:06:30 -0400")


Daniel Jacobowitz <drow@false.org> writes:
> On Tue, Aug 21, 2007 at 09:33:28AM -0700, Jim Blandy wrote:
>> One thing I don't understand: why are the "always watch the outermost
>> value even if it is lazy" changes needed?  The code that evaluates the
>> watchpoint condition should always simply unlazy the expression's
>> final value to begin with, so it'll never be lazy by the time the
>> other code sees it.
>
> But that might fail.  That's why I switched from value_fetch_lazy to
> gdb_value_fetch_lazy, which catches exceptiosn.  Consider "watch *0";
> evaluating the expression works fine, but fetching the result of
> evaluate_expression will call memory_error.  We still want to set
> the watchpoint.

Okay, I see.

So there are actually two independent changes here:

- Even when we can't unlazy the final value of an expression, we may
  be able to set a hardware watchpoint on it, because hardware
  watchpoints don't require the address being watched to actually be
  accessible.

- When evaluating an expression to yield even a lazy a result fails,
  we can treat the fact of failure as a distinct value, and watch for
  that to change.

This change could be generalized, although I'm not sure it's worth it.
In evaluating an expression like p->q->r->s, if p->q is an invalid
address, we could set a hardware watchpoint on p->q.  In other words,
watching the values produced by a failing expression up to the point
of failure would allow us to use hardware watchpoints whenever
possible.  As it stands, your patch will record NULL as that
watchpoint's value, and single-step to watch for changes.

A lot of this rationale was not obvious to me by a long shot; I spent
about an hour working it all out.  I think the patch needs more
comments.  If you'd like me to write them, just say the word; I like
writing docs.


  reply	other threads:[~2007-08-21 22:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-21 14:25 Daniel Jacobowitz
2007-08-21 16:33 ` Jim Blandy
2007-08-21 18:06   ` Daniel Jacobowitz
2007-08-21 22:49     ` Jim Blandy [this message]
2007-08-21 23:17       ` Daniel Jacobowitz
2007-08-21 19:04 ` Eli Zaretskii
2007-11-20  7:56 ` Vladimir Prus
2008-02-28 16:27 ` Daniel Jacobowitz
2008-02-29 10:11   ` Eli Zaretskii
2008-03-02  4:24     ` Daniel Jacobowitz
2008-03-02 21:09       ` Eli Zaretskii
2008-03-02 23:23         ` Daniel Jacobowitz
2008-03-03  4:27           ` Eli Zaretskii
2008-03-03 14:07             ` Daniel Jacobowitz
2008-02-29 17:54   ` Jim Blandy

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=m3wsvo4i71.fsf@codesourcery.com \
    --to=jimb@codesourcery.com \
    --cc=gdb-patches@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