public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Unwinding past main
@ 2004-11-02 23:29 Randolph Chung
  2004-11-02 23:33 ` Randolph Chung
  2004-11-03  0:14 ` Joel Brobecker
  0 siblings, 2 replies; 4+ messages in thread
From: Randolph Chung @ 2004-11-02 23:29 UTC (permalink / raw)
  To: gdb

I'm seeing a stack unwinding problem on hppa. Seems like this should be
applicable to other targets too -- how do you solve this problem?

Take a simple test program:
====
int foo(void) { return 1; }
int main(void) { return foo(); }
====

gcc does some tail call optimizations on this (when compiled with -O2),
so that the generated code looks like:

00010518 <foo>:
   10518:       e8 40 c0 00     bv r0(rp)
   1051c:       34 1c 00 02     ldi 1,ret0

00010520 <main>:
   10520:       6b c2 3f d9     stw rp,-14(,sp)
   10524:       37 de 00 80     ldo 40(sp),sp
   10528:       4b c2 3f 59     ldw -54(,sp),rp
   1052c:       e8 1f 1f cd     b,l 10518 <foo>,r0
   10530:       37 de 3f 81     ldo -40(sp),sp
   10534:       08 00 02 40     nop

doing a backtrace from foo results in an infinite loop :) I see some
code in gcc that tries to determine when we are in the main() function,
and stops the backtrace. But here, foo() returns directly to the caller
of main() (__libc_start_main on a glibc system), so we try to continue
to unwind through glibc and hit some asm bits that cannot be unwound
properly.

what is the "proper" way to handle this?

thanks,
randolph
-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-03  0:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-02 23:29 Unwinding past main Randolph Chung
2004-11-02 23:33 ` Randolph Chung
2004-11-03  0:14 ` Joel Brobecker
2004-11-03  0:48   ` Randolph Chung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).