public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: GCC stack backtraces
       [not found] ` <CAO9iq9GY6Q94ssKu1f9HdhT=N6dPRqAT7f7boVbZi0rRvUpbeA@mail.gmail.com>
@ 2012-08-29 17:09   ` David Daney
  0 siblings, 0 replies; only message in thread
From: David Daney @ 2012-08-29 17:09 UTC (permalink / raw)
  To: Janne Blomqvist; +Cc: Ian Lance Taylor, gcc, Java List

On 08/29/2012 12:43 AM, Janne Blomqvist wrote:
> On Wed, Aug 29, 2012 at 10:22 AM, Ian Lance Taylor <iant@google.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.
> [snip]
>> 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,

libgcj also uses this technique.  If this were merged, it would be 
really nice to retrofit libgcj to use it as well.

Having this capability available from C and C++ code would also be 
really nice.  Several times in the past I have hacked together an 
unwinder by calling _Unwind_Backtrace(), and then decoded the traces 
off-line using addr2line.  An easy, low-overhead way to add 
function/line number information to a trace would be quite welcome.

I would almost say to put it in libgcc along side of 
_Unwind_Backtrace(), but that doesn't seem the proper place for it.  It 
would be very convenient though.


Thanks,
David Daney

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-08-29 17:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mcroblumab4.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
     [not found] ` <CAO9iq9GY6Q94ssKu1f9HdhT=N6dPRqAT7f7boVbZi0rRvUpbeA@mail.gmail.com>
2012-08-29 17:09   ` GCC stack backtraces David Daney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).