This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
Re: backtrace/1767: Backtrace in naked functions
- From: Daniel Jacobowitz <drow at false dot org>
- To: nobody at sources dot redhat dot com
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 27 Sep 2005 14:38:02 -0000
- Subject: Re: backtrace/1767: Backtrace in naked functions
- Reply-to: Daniel Jacobowitz <drow at false dot org>
The following reply was made to PR backtrace/1767; it has been noted by GNATS.
From: Daniel Jacobowitz <drow@false.org>
To: gdb-gnats@sourceware.org
Cc:
Subject: Re: backtrace/1767: Backtrace in naked functions
Date: Tue, 27 Sep 2005 10:29:56 -0400
On Sat, Sep 24, 2005 at 10:55:46AM +0200, Marius Groeger wrote:
> Thanks for responding. I'm using GDB 6.3.50.20050810 which I think is
> fairly recent. Acutally I only noticed a /comparable/ symptom on i386
> and ppc hosts, and was hoping the solutition to PR#1767 could help me
> too. We've also discussed this on the crossgcc list. On embedded
> systems, you often run into having to debug code which does not hava
> main(), like an exception handler or a self-made threading
> environment.
No, sorry, this is a problem that has nothing to do with the naked
functions bug. Without main in the backtrace GDB should work just
fine; it will go a few functions past the end, wander into garbage,
catch itself, and stop.
> I received the following promising hint regarding this, maybe you can
> add some thoughts: by using the N_MAIN stab flag, you can make any
> function appear to GDB as if was main(). Unfortunatly, while the GDB
> source (as far as I understood it :-) somehow seems to indicate this
> might work, it doesn't. I also tried -g options of CC up to -ggdb but
> had no look. OBJDUMP correctly lists my toplevel wrapper function as
> MAIN stab.
>
> Reading the frame.c:get_prev_frame(), there are a lot of tests which
> could lead to terminating stack frame. It is my impression, though,
> that most systems use the main() thing. How else can I reliably
> terminate a stack backtrace, ideally platform neutrally?
Rather than messing around with the name of main, you need to do a
generally architecture-specific trick to indicate the end of the call
stack, e.g. setting the frame pointer to zero. Current versions of GDB
allow you to express this using DWARF-2 unwind information, by defining
the return address column as undefined (see the gdb@ list archives for
more details, a couple of months ago).
--
Daniel Jacobowitz
CodeSourcery, LLC