From: Daniel Jacobowitz <drow@false.org>
To: Andrew STUBBS <andrew.stubbs@st.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Allow writing to registers before the program starts
Date: Wed, 03 May 2006 14:40:00 -0000 [thread overview]
Message-ID: <20060503143952.GA5965@nevyn.them.org> (raw)
In-Reply-To: <4458B803.5050506@st.com>
On Wed, May 03, 2006 at 03:02:43PM +0100, Andrew STUBBS wrote:
> Reverting the valops.c portion of this patch solves the problem for me.
> I have tested it and it produced no regressions.
>
> Ok to apply the attached reversion?
No, this patch is incorrect. I don't recall exactly why, but I think
it will mess up writing to the saved registers after using "up".
I happen to know the actual cause of the problem you're trying to
fix; there's a nasty hack in CodeSourcery's branch to fix it, but
the real fix is more work than I've had time for yet. It's a
representation problem.
As a starting point, here's my fix for the same problem:
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.211
diff -u -p -r1.211 frame.c
--- frame.c 17 Dec 2005 22:33:59 -0000 1.211
+++ frame.c 2 Apr 2006 02:31:24 -0000
@@ -395,16 +395,26 @@ frame_find_by_id (struct frame_id id)
{
struct frame_info *frame;
+#if 0
/* ZERO denotes the null frame, let the caller decide what to do
about it. Should it instead return get_current_frame()? */
if (!frame_id_p (id))
return NULL;
+#endif
for (frame = get_current_frame ();
frame != NULL;
frame = get_prev_frame (frame))
{
struct frame_id this = get_frame_id (frame);
+#if 1
+ /* We use an invalid frame id to mean "could not unwind from
+ here"! This hack fixes the "value being assigned to is
+ no longer active" problem. This strongly suggests that
+ we need to change the representation. */
+ if (!frame_id_p (id) && !frame_id_p (this))
+ return frame;
+#endif
if (frame_id_eq (id, this))
/* An exact match. */
return frame;
Basically, the problem comes about because we signal the end of the
stack by returning an invalid frame ID from ->this_id in the unwinder.
But we also use invalid IDs in various places to mean "no frame at all"
or "no frame in particular". I think this causes trouble in other
places as well. For instance you can't use outer/inner on the ID of
the last frame.
Sometimes, we don't have any idea what ID to use for the last frame. We
use the null ID in that case. This is somewhat reasonable, but could
be problematic - we can't tell it apart from a completely different
frame that we can't unwind either. The opposite could also be
problematic; using $sp might mean the frame ID changes unexpectedly
when we're within the same logical frame. Maybe use a different
sentinal ID than the current one.
But it's the other case that I find more interesting. A lot of the
times we know exactly what this frame's ID is, but have made a
conscious decision to stop unwinding (e.g. because the next frame's
stack pointer would be a sentinel value). If we had a different
way to signal "stop unwinding here" but return a valid ID... I think
much of this awkwardness would go away.
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2006-05-03 14:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-03 14:06 Andrew STUBBS
2006-05-03 14:40 ` Daniel Jacobowitz [this message]
2006-05-04 9:43 ` Andrew STUBBS
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=20060503143952.GA5965@nevyn.them.org \
--to=drow@false.org \
--cc=andrew.stubbs@st.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