From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30102 invoked by alias); 29 Aug 2012 17:09:10 -0000 Received: (qmail 30081 invoked by uid 22791); 29 Aug 2012 17:09:08 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_BG,TW_GC X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Aug 2012 17:08:54 +0000 Received: by pbcwy7 with SMTP id wy7so1534945pbc.20 for ; Wed, 29 Aug 2012 10:08:54 -0700 (PDT) Received: by 10.68.193.194 with SMTP id hq2mr5977844pbc.93.1346260133822; Wed, 29 Aug 2012 10:08:53 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPS id sr3sm19647347pbc.44.2012.08.29.10.08.52 (version=SSLv3 cipher=OTHER); Wed, 29 Aug 2012 10:08:52 -0700 (PDT) Message-ID: <503E4CA2.8060400@gmail.com> Date: Wed, 29 Aug 2012 17:09:00 -0000 From: David Daney User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Janne Blomqvist CC: Ian Lance Taylor , gcc@gcc.gnu.org, Java List Subject: Re: GCC stack backtraces References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2012-08/txt/msg00003.txt.bz2 On 08/29/2012 12:43 AM, Janne Blomqvist wrote: > On Wed, Aug 29, 2012 at 10:22 AM, Ian Lance Taylor 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