public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Daney <ddaney.cavm@gmail.com>
To: Janne Blomqvist <blomqvist.janne@gmail.com>
Cc: Ian Lance Taylor <iant@google.com>,
	gcc@gcc.gnu.org,  Java List <java@gcc.gnu.org>
Subject: Re: GCC stack backtraces
Date: Wed, 29 Aug 2012 17:09:00 -0000	[thread overview]
Message-ID: <503E4CA2.8060400@gmail.com> (raw)
In-Reply-To: <CAO9iq9GY6Q94ssKu1f9HdhT=N6dPRqAT7f7boVbZi0rRvUpbeA@mail.gmail.com>

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

           reply	other threads:[~2012-08-29 17:09 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CAO9iq9GY6Q94ssKu1f9HdhT=N6dPRqAT7f7boVbZi0rRvUpbeA@mail.gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=503E4CA2.8060400@gmail.com \
    --to=ddaney.cavm@gmail.com \
    --cc=blomqvist.janne@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=java@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).