From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [RFA/commit] Fix SP register unwinding on alpha-tru64
Date: Fri, 30 May 2008 15:13:00 -0000 [thread overview]
Message-ID: <20080529205215.GG13826@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2320 bytes --]
Hello,
While working on the alpha-tru64 port, I noticed that some backtraces
would break:
(gdb) bt
#0 0x000003000003d3dc in __hstTransferRegistersPC ()
from /usr/shlib/libpthread.so
#1 0x000003000002e694 in __osTransferContext ()
from /usr/shlib/libpthread.so
#2 0x0000030000020e80 in __dspDispatch () from /usr/shlib/libpthread.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
I traced the issue down to computing the wrong value for the SP register
for frame #2. As the RA register was saved on the stack at of offset
of the SP, we end up computing the wrong return address, leading to
the breakage.
The 'heuristic' frame unwinder relies on trad frames to compute
register values. But we have to handle the case of the SP a little
differently because it is not necessarily saved on the stack. In fact,
in our case, the code in frame #1 looks like this:
0x000003000002e4b0 <__osTransferContext+0>: ldah gp,16322(t12)
0x000003000002e4b4 <__osTransferContext+4>: unop
0x000003000002e4b8 <__osTransferContext+8>: lda gp,-1168(gp)
0x000003000002e4bc <__osTransferContext+12>: unop
0x000003000002e4c0 <__osTransferContext+16>: lda sp,-64(sp)
0x000003000002e4c4 <__osTransferContext+20>: stq ra,0(sp)
0x000003000002e4c8 <__osTransferContext+24>: stq s0,8(sp)
0x000003000002e4cc <__osTransferContext+28>: stq s1,16(sp)
0x000003000002e4d0 <__osTransferContext+32>: stq s2,24(sp)
0x000003000002e4d4 <__osTransferContext+36>: stq s3,32(sp)
0x000003000002e4d8 <__osTransferContext+40>: stq s4,40(sp)
0x000003000002e4dc <__osTransferContext+44>: stq fp,48(sp)
0x000003000002e4e0 <__osTransferContext+48>: mov sp,fp
So the SP has been saved inside the FP register.
Fortunately, the prologue parser already determines the frame base
(aka the "vfp"), and this frame base is in practice the sp in the
caller's frame...
2008-05-29 Joel Brobecker <brobecker@adacore.com>
* alpha-tdep.c (alpha_heuristic_frame_prev_register): Fix handling
of the SP register.
This testcase fixes the problem and was successfully tested with
the AdaCore testsuite. I'll commit in a week unless we get some
comments...
--
Joel
[-- Attachment #2: alpha-tdep.c.diff --]
[-- Type: text/plain, Size: 691 bytes --]
Index: alpha-tdep.c
===================================================================
--- alpha-tdep.c (revision 131678)
+++ alpha-tdep.c (working copy)
@@ -1175,6 +1175,10 @@ alpha_heuristic_frame_prev_register (str
struct alpha_heuristic_unwind_cache *info
= alpha_heuristic_frame_unwind_cache (this_frame, this_prologue_cache, 0);
+ /* The stack pointer of the previous frame is this frame's vfp. */
+ if (regnum == ALPHA_SP_REGNUM)
+ return frame_unwind_got_constant (this_frame, regnum, info->vfp);
+
/* The PC of the previous frame is stored in the link register of
the current frame. Frob regnum so that we pull the value from
the correct place. */
next reply other threads:[~2008-05-29 20:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-30 15:13 Joel Brobecker [this message]
2008-05-30 15:20 ` Ulrich Weigand
2008-05-31 6:46 ` Joel Brobecker
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=20080529205215.GG13826@adacore.com \
--to=brobecker@adacore.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