This is the mail archive of the
mailing list for the GCC project.
Re: Using libbacktrace in libgfortran: some questions
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Ian Lance Taylor <ian at airs dot com>
- Cc: FX <fxcoudert at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Thu, 13 Aug 2015 17:06:21 +0300
- Subject: Re: Using libbacktrace in libgfortran: some questions
- Authentication-results: sourceware.org; auth=none
- References: <8880A586-94DE-4745-B2BD-E07582E0F1DD at gmail dot com> <m3r3n7l2vb dot fsf at pepe dot airs dot com>
Resending in text/plain, sorry for any extra spam...
On Thu, Aug 13, 2015 at 4:44 PM, Ian Lance Taylor <firstname.lastname@example.org> wrote:
> FX <email@example.com> writes:
> > 1. It appears that even on platforms with BACKTRACE_SUPPORTED == 0
> > (such as x86_64-apple-darwin), libbacktrace is built and able to
> > perform a nonsymbolic backtrace (which appears accurate). Is that a
> > feature? Can I rely on it?
> Yes, that is a feature. You should always get accurate PC values even
> on systems where libbacktrace does not yet generate file/line
> > 2. The backtraces I get on x86_64-linux-gnu are missing symbols. The
> > attached source file, compiled with âgfortran -gâ with the attached
> > patch, gives the following backtrace with libgfortranâs existing code,
> > which uses unwind and calls to addr2line:
> >> #0 0x7F4F6E333467
> >> #1 0x7F4F6E334C42
> >> #2 0x7F4F6E409308
> >> #3 0x4008A3 in bar at a.f90:9
> >> #4 0x4008C8 in foo at a.f90:5
> >> #5 0x4008AF in test at a.f90:2
Yes, the current implementation cannot resolve addresses from dynamic
libraries, since those are loaded at a random offset and addr2line
looks at the binary on disk and not the process image in memory. A
workaround is to compile with "-g -static".
> > with my patch using libbacktrace, I get:
> >> 0x7f04f00f8c7d _gfortrani_show_backtrace
> >> ../../../trunk/libgfortran/runtime/backtrace.c:112
> >> 0x7f04f00f9ac4 _gfortrani_sys_abort
> >> ../../../trunk/libgfortran/runtime/error.c:176
> >> 0x7f04f01c8c78 _gfortran_abort
> >> ../../../trunk/libgfortran/intrinsics/abort.c:33
> >> 0x4008a3 ???
> >> /home/fx/gcc/irun/a.f90:9
> >> 0x4008c8 ???
> >> /home/fx/gcc/irun/a.f90:5
> >> 0x4008af test
> >> /home/fx/gcc/irun/a.f90:2
> >> 0x4008ff main
> >> /home/fx/gcc/irun/a.f90:2
> > where the symbols for foo() and bar() are apparently not found, though
> > the source location is. Am I missing something here? Iâm attaching the
> > output of âdwarfdump a.outâ and the a.out executable file itself
> > (gzipped).
> I don't know why this is not working. Everything looks fine in the
> a.out that you sent. Unfortunately, I think you sent the one built
> without libbacktrace. Can you send me the one built with libbacktrace?
You might also take a look at the patch posted to PR 54572 which was
my attempt to use libbacktrace a few years ago. While I got symbolic
backtraces working somewhat, unfortunately I never got it to work
completely since it crashed somewhere in libbacktrace in some cases,
but maybe whatever bugs caused that have been fixed in the meantime...