Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Randolph Chung <randolph@tausq.org>
To: gdb@sources.redhat.com
Subject: interesting unwind problem with noreturn functions
Date: Thu, 02 Mar 2006 15:13:00 -0000	[thread overview]
Message-ID: <44070B97.2050707@tausq.org> (raw)

i ran across this when debugging gdb on hppa-linux.....

value_from_double calls error() in the case that I was debugging, but if 
i break in error(), i get a corrupted backtrace.

(top-gdb) bt
#0  error (
     string=0x23d89c "Unexpected type encountered for floating constant.")
     at ../../gdb-cvs/gdb/utils.c:645
#1  0x000b848c in value_from_double (type=0x31d9d0,
     num=4.9406564584124654e-324) at ../../gdb-cvs/gdb/value.c:1570
#2  0x000b848c in value_from_double (type=0x31d9d0,
     num=4.9406564584124654e-324) at ../../gdb-cvs/gdb/value.c:1570
Previous frame identical to this frame (corrupt stack?)

looking into this, it looks like gcc is being a bit too clever for gdb....

000b83dc <value_from_double>:
    b83dc:       6b c2 3f d9     stw rp,-14(sp)
    b83e0:       6f c3 01 00     stw,ma r3,80(sp)
[...]
    b8484:       e8 40 08 bc     b,l b98e8 <_initialize_values+0xf3c>,rp
    b8488:       08 1c 02 5a     copy ret0,r26

000b848c <coerce_ref>:
    b848c:       6b c2 3f d9     stw rp,-14(sp)
    b8490:       6f c4 01 00     stw,ma r4,80(sp)

b8484 is the call to error (through a long branch stub, so the name 
looks funny). The return pointer of the call points past 
value_from_double into the next function (hppa has a delay slot for 
branches, and rp points to .+8 for a branch insn). Since error() is 
defined as a noreturn function, I suppose this is a valid thing for gcc 
to do, even if it looks a bit weird.

So when you unwind from error(), the hppa frame unwinder tries to unwind 
from rp=b848c, which is in a different function from the actual caller, 
and the unwinder gets all confused....

I suppose this is not a hppa specific thing, other architectures might 
also encounter the same problem. How is it fixed there? Should the 
unwinder be storing the PC as RP-offset? (This seems rather ugly, if not 
wrong.)

randolph


             reply	other threads:[~2006-03-02 15:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-02 15:13 Randolph Chung [this message]
2006-03-02 15:15 ` Daniel Jacobowitz

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=44070B97.2050707@tausq.org \
    --to=randolph@tausq.org \
    --cc=gdb@sources.redhat.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