This is the mail archive of the
mailing list for the GCC project.
Re: GCC stack backtraces
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 29 Aug 2012 10:43:28 +0300
- Subject: Re: GCC stack backtraces
- References: <firstname.lastname@example.org>
On Wed, Aug 29, 2012 at 10:22 AM, Ian Lance Taylor <email@example.com> wrote:
> I've spent the last couple of days working on a stack backtrace library.
> It uses the GCC unwind interface to collect a stack trace, and parses
> DWARF debug info to get file/line/function information.
> I expect to use this code not just for GCC proper, but also for libgo
> (currently libgo uses Go code to parse DWARF, but that is not very
> satisfactory as that code is only available if it has been imported into
> the program). So I put it under a BSD license, although that is open
> for discussion. Also in case it finds more uses elsewhere I wrote it in
> reasonably portable C rather than C++.
> Does this seem like something we could usefully add to GCC? Does
> anybody see any big problems with it?
I haven't looked at the code, but if it is async-signal-safe it could
be interesting for gfortran. Currently in libgfortran we have a
backtracing routine, originally written by FX Coudert IIRC, since
rewritten by yours truly a few times, that uses _Unwind_Backtrace()
from libgcc and then pipes the output via addr2line, if found. Since
it's invoked from a signal handler when the program (user program, not
the compiler!) crashes, it needs to be async-signal-safe. AFAIK the
current implementation *should* fulfill that requirement. But
something that would be async-signal-safe and won't need addr2line to
get symbolic info would be a nice improvement, in particular since
addr2line doesn't work on OSX, and all that piping stuff doesn't work