This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran,patch] Allow backtracing non-library errors
- From: FX Coudert <fxcoudert at gmail dot com>
- To: Thomas Koenig <tkoenig at alice-dsl dot net>
- Cc: GNU Fortran <fortran at gcc dot gnu dot org>
- Date: Fri, 10 Aug 2007 23:58:22 +0100
- Subject: Re: [gfortran,patch] Allow backtracing non-library errors
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=GByCLmqTCUayOAra58RUsmEFTK7PwRhSOCPCrmBwtDqTL0cV6JGd/ukPT4cUsoZAbl2WZbNiJhnFn1xbPaWifo8YFUpV6tjFBpXqW6+LHbJqR/TXdoG/Mg1GuZ0sLto6WaSn5ubrMkTRSJVaMMy2XoclFpQrfUsrWLCjmxaXCRg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=ZmYN1CbGOULJtuAtzV3uTwi8BdVkVtJrIMNk/eRRNCIMcDKkOACjLLzdUl9NjombyuzIFVO38KggZuLWomejGTgNRo9uDIWYBZ2rf17H2P+svc8z0UiqZzZ9KWs1VpNCFRZYfR6i7tfuG5YloyA2TL++LNharVr3mBtG/+bQSOM=
- References: <23DD0646-EB5E-4621-9F64-71222F45CA01@gmail.com> <1186305632.3449.5.camel@meiner.onlinehome.de> <BE76F626-4B07-4B12-B15F-C30A1114ECA2@gmail.com> <1186314392.3449.7.camel@meiner.onlinehome.de> <F8492121-AC99-455F-B180-57A36D753517@gmail.com> <1186341482.3462.2.camel@meiner.onlinehome.de>
OK, I've found why I couldn't see it before: it happens on x86_64-
linux only with -m32.
So gdb appears to be fine, but it does recognize something that the
normal backtrace code apparently doesn't.
Yup, somehow the glibc backtrace() function thinks the error happened
at 0xffffe500, but addr2line can make anything out of that address.
Somehow, gdb is smarter than that. The following small C testcase
show this:
$ cat a.c
#include <stddef.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <execinfo.h>
void
handler (int signum)
{
void *trace[50];
int depth = backtrace (trace, 50), i;
char **str;
str = backtrace_symbols (trace, depth);
for (i = 0; i < depth; i++)
printf ("%s\n", str[i]);
_exit (1);
}
int main (void)
{
int * foo = NULL;
signal (SIGSEGV, handler);
*foo = 42;
return 0;
}
$ gcc a.c -m64 -g && ./a.out
./a.out [0x40060e]
/lib/libc.so.6 [0x2aeb0d8c2110]
./a.out [0x40067b]
/lib/libc.so.6(__libc_start_main+0xda) [0x2aeb0d8af4ca]
./a.out [0x40052a]
$ gcc a.c -m32 -g && ./a.out
./a.out [0x80484a3]
[0xffffe500]
/lib32/libc.so.6(__libc_start_main+0xd3) [0xf7e0cea3]
./a.out [0x80483d1]
From my experiments, it's always the top-most frame that is missing
from the backtrace. I'll post this to the glibc mailing-list, and see
if there is a workaround.
FX