This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

interesting unwind problem with noreturn functions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]