This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Solution sought to GCC 4.1.1 backtrace problem
- From: Andrew Haley <aph-gcc at littlepinkcloud dot COM>
- To: Blair Barnett <blairbarnett at sbcglobal dot net>
- Cc: gcc-help mailing list <gcc-help at gcc dot gnu dot org>
- Date: Sun, 2 Sep 2007 11:31:00 +0100
- Subject: Re: Solution sought to GCC 4.1.1 backtrace problem
- References: <256867.1492.qm@web82611.mail.mud.yahoo.com>
Blair Barnett writes:
> Hi Andrew,
>
> So our experiment with the 4.1.1 EABI compiler along with your patch provided no new results.
>
> I applied your patch and recompiled arm-linux-gcc and recompiled our little test program. I copied the program to our arm device and ran it, obtaining the following output:
>
> arm-linux-gcc -o fault-unwind fault.c
>
> ./fault-unwind
> in routine1 at 0x00008874
> in routine2 at 0x0000882c
> in routine3 at 0x000087e4
> in routine4 at 0x00008794
> in catch_segfault
> Obtained 1 stack frames.
> /lib/ld-linux.so.2 [0x40012f84]
> Segmentation fault
That's what I predicted, right?
>
>
> If we run the 4.1.2 compiler included with ubuntu on our little test program, we get the following results:
>
> bbarnett@kitt:~$ gcc -v
> Using built-in specs.
> Target: i486-linux-gnu
> Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
> Thread model: posix
> gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
> bbarnett@kitt:~$ gcc -o fault fault.c
> bbarnett@kitt:~$ ./fault
> in routine1 at 0x080486de
> in routine2 at 0x080486ae
> in routine3 at 0x0804867e
> in routine4 at 0x0804864a
> in catch_segfault
> Obtained 8 stack frames.
> ./fault [0x8048547]
> [0xffffe420]
> ./fault [0x80486ac]
> ./fault [0x80486dc]
> ./fault [0x804870c]
> ./fault [0x8048730]
> /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc) [0xb7e5febc]
> ./fault [0x8048491]
> Segmentation fault (core dumped)
>
> So glibc backtrace() appears to work in an EABI environment, just not an ARM EABI environment.
Sure, because ARM doesn't have fallback_frame_state_for, like I said.
x86 does.
Remember what I advised you to do:
--------------------------------------------------------------------
The SIGCONTEXT ctx that's passed to your segfault handler contains the
registers at the point the segfault occurred, and you can unwind
starting from there.
Don't do this:
void *fp = __builtin_frame_address (0);
Instead, pull fp and sp out of the SIGCONTEXT ctx.
--------------------------------------------------------------------
Andrew.