From: Randolph Chung <randolph@tausq.org>
To: gdb@sources.redhat.com
Subject: Unwinding past main
Date: Tue, 02 Nov 2004 23:29:00 -0000 [thread overview]
Message-ID: <20041102232929.GW4249@tausq.org> (raw)
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/
next reply other threads:[~2004-11-02 23:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-02 23:29 Randolph Chung [this message]
2004-11-02 23:33 ` Randolph Chung
2004-11-03 0:14 ` Joel Brobecker
2004-11-03 0:48 ` Randolph Chung
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=20041102232929.GW4249@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