From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17068 invoked by alias); 2 Nov 2004 23:29:26 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 17055 invoked from network); 2 Nov 2004 23:29:25 -0000 Received: from unknown (HELO pippin.tausq.org) (64.81.244.94) by sourceware.org with SMTP; 2 Nov 2004 23:29:25 -0000 Received: by pippin.tausq.org (Postfix, from userid 1000) id BA656CE596; Tue, 2 Nov 2004 15:29:29 -0800 (PST) Date: Tue, 02 Nov 2004 23:29:00 -0000 From: Randolph Chung To: gdb@sources.redhat.com Subject: Unwinding past main Message-ID: <20041102232929.GW4249@tausq.org> Reply-To: Randolph Chung Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-GPG: for GPG key, see http://www.tausq.org/gpg.txt User-Agent: Mutt/1.5.5.1+cvs20040105i X-SW-Source: 2004-11/txt/msg00020.txt.bz2 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 : 10518: e8 40 c0 00 bv r0(rp) 1051c: 34 1c 00 02 ldi 1,ret0 00010520
: 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 ,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/