From: Jim Blandy <jimb@codesourcery.com>
To: Vladimir Prus <vladimir@codesourcery.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] Don't reset watchpoint block on solib load.
Date: Wed, 28 Nov 2007 22:18:00 -0000 [thread overview]
Message-ID: <m3prxuauap.fsf@codesourcery.com> (raw)
In-Reply-To: <200711281858.51145.vladimir@codesourcery.com> (Vladimir Prus's message of "Wed, 28 Nov 2007 18:58:50 +0300")
Actually, let me withdraw the three steps I suggested above. I
understand that I'm straying from commenting on your patch ---
apologies --- but that's because as I tried to think about it, I
became confused about what behavior we actually want to get out of
GDB.
Here's the behavior I think we actually want:
A watchpoint should 'stick' to the scope it was originally set in.
For example, suppose I have a shared library libx.so with a source
file x.c, and that x.c has a static variable S. And suppose there's
also a global variable named S defined in the main program. While
control is stopped somewhere in x.c, I set a watchpoint on S.
Clearly, that watchpoint refers to x.c's static S, not the global S.
Now, if I later unload libx.so, the watchpoint should delete itself
with an appropriate message, just as a watchpoint on a stack variable
does when its frame is popped --- when a shared library is unloaded,
that ends the lifetimes of the variables it defines, just as exiting a
block ends the lifetimes of the variables defined in the block.
But specifically, the watchpoint should *not* transform into a
watchpoint on the global S. That's an entirely different variable; it
could even have a different type. This is what I mean by a watchpoint
'sticking' to the scope it was set in.
So, opening and closing shared libraries should never cause us to
re-parse a watchpoint's expression. Loading a shared library should
never re-parse a watchpoint expression, because the watchpoint should
stick to its original scope, which is still there. Unloading a shared
library should never re-parse the watchpoint expression, but it should
delete the watchpoint if it refers to variables from shared library,
since they're gone now.
This isn't what GDB does now, but I think this behavior is not hard to
obtain. When we set a watchpoint, instead of b->exp_valid_block, we
should record the PC in whose scope we parsed the expression. When we
check a watchpoint's condition, we should look up the PC's block: if
we can't find one, then we've unloaded symbolic information for that
watchpoint, and we should delete it.
The tricky part is deciding what to do when the main executable file
is modified. It's hard to see what exactly the watchpoint should
stick to in this case, since the PC isn't a reliable identifier across
such changes. Perhaps it would be enough to also record the name of
the function and source file the PC falls in, re-parse if they have
remained stable, and delete the watchpoint if they have changed.
next prev parent reply other threads:[~2007-11-28 22:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-20 17:14 Vladimir Prus
2007-11-27 23:00 ` Jim Blandy
2007-11-28 15:59 ` Vladimir Prus
2007-11-28 16:23 ` Vladimir Prus
2007-11-28 19:46 ` Jim Blandy
2007-11-28 20:04 ` Vladimir Prus
2007-11-28 22:37 ` Jim Blandy
2007-11-29 6:09 ` Vladimir Prus
2007-11-28 22:50 ` Jim Blandy
2007-11-28 22:18 ` Jim Blandy [this message]
2007-11-29 4:24 ` Eli Zaretskii
2007-11-29 7:04 ` Vladimir Prus
2007-11-29 18:54 ` Jim Blandy
2007-11-29 19:03 ` Variable identification (Was: [RFA] Don't reset watchpoint block on solib load.) Vladimir Prus
2007-11-30 1:22 ` Michael Snyder
2007-11-30 5:52 ` Vladimir Prus
2007-11-30 20:53 ` Eli Zaretskii
2007-12-01 1:39 ` Variable identification Jim Blandy
2007-12-01 1:47 ` Michael Snyder
2008-01-16 1:29 ` [RFA] Don't reset watchpoint block on solib load Jim Blandy
2008-01-23 9:58 ` Vladimir Prus
2008-01-29 15:23 ` Daniel Jacobowitz
2007-11-29 6:55 ` Vladimir Prus
2007-11-29 18:40 ` Jim Blandy
2007-11-29 18:45 ` Vladimir Prus
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=m3prxuauap.fsf@codesourcery.com \
--to=jimb@codesourcery.com \
--cc=gdb-patches@sources.redhat.com \
--cc=vladimir@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