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: Tue, 27 Nov 2007 23:00:00 -0000 [thread overview]
Message-ID: <m3abozfg5c.fsf@codesourcery.com> (raw)
In-Reply-To: <200711202013.47537.vladimir@codesourcery.com> (Vladimir Prus's message of "Tue, 20 Nov 2007 20:13:46 +0300")
Vladimir Prus <vladimir at codesourcery.com> writes:
> There's code inside breakpoint_re_set_one to refresh watchpoints,
> which seems suspicious to me.
>
> First problem with that code is that it always resets watchpoint's
> block to NULL. So, if we have a local watchpoint, and you do
> dlopen (without exiting the scope where watchpoint is valid),
> then the watchpoint's block will be reset to NULL, and
> watchpoint's expression will be reparsed in global block --
> which will surely break the watchpoint.
Is that right? We set innermost_block to NULL, but then we call
parse_expression, which should set innermost_block to the innermost
block containing a symbol actually used by the expression.
We also call breakpoint_re_set_one when we've unloaded a shared
library. At that point, b->exp_valid_block could be a dangling
pointer; we can't use it to re-parse the expression.
I think the bug is that we re-parse the expression with
parse_expression, which leaves the scope unspecified, defaulting to
the currently selected frame. We should:
1) Verify that the frame given by b->watchpoint_frame is still valid,
and delete the watchpoint if it isn't.
2) Call get_frame_block (b->watchpoint_frame) to see if we have a
block for the frame's location, and deleting the watchpoint if we
don't (saying we don't have the symbolic info available to update
it), and
3) Call parse_exp_1 (..., watchpoint frame's block, ...) to reparse
the watchpoint's expression in the proper block.
> Second problem is that this code reevalautes the expression,
> and given that insert_breakpoints does that too, we can just
> reset breakpoints value to NULL, and have insert_breakpoints to the
> work.
I think it's an invariant that b->val may be NULL only when we have
just started the inferior, and know that insert_breakpoints will be
called. In other contexts, we don't always call insert_breakpoints
before letting the program run. Wouldn't leaving the value NULL cause
a problem in that case?
> Finally, this code reevaluates condition.
Re-parses, you mean?
> While this is probably
> correct way to handle case where meaning of condition changes due to
> loading of shared library, there's no code to match for the
> case when a shared library is unloaded. I think a more robust
> approach if to reevaluate condition inside insert_bp_location.
I agree.
> This patch is prompted by the following problem:
>
> void some_function() {
>
> g = 10;
> ....
> dlopen("whatever", ...);
> ....
> g = 15;
> }
>
> If you set watchpoint on 'g', and continue over dlopen, the watchpoint is never hit.
> The exact mode of failure differs. I actually have a testcase for this, and it
> passes for me locally, and I would have liked to provide it, but there are two
> issues for which I don't have yet a complete solution:
>
> - if we have no debug information for ld.so, then when we stop in
> ld.so, we cannot find the frame associated with watchpoint, and delete
> watchpoint.
Does this case arise in normal usage? I'm not saying it doesn't; I'm
just not sure how to work around it either, so I'm wondering how
serious a problem it is.
> - if we have debug information for ld.so, then when we stop in
> ld.so, gdb tries to reevaluate 'g'. Unfortunately, it does that in
> wrong block, does not find 'g', and dies with internal error.
My suggestion above should avoid this.
next prev parent reply other threads:[~2007-11-27 23:00 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 [this message]
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
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=m3abozfg5c.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