This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, libfortran] PR 46686 Implement backtrace using libgcc functionality
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Fortran List <fortran at gcc dot gnu dot org>
- Date: Tue, 8 Nov 2011 20:44:55 -0800
- Subject: Re: [Patch, libfortran] PR 46686 Implement backtrace using libgcc functionality
- References: <CAO9iq9F3L4rj13km3-v1LGpiS+mZKrTWo+aHxTrDJK6Hud64yw@mail.gmail.com>
On Tue, Nov 01, 2011 at 08:23:56PM +0200, Janne Blomqvist wrote:
> Hi,
>
> the attached patch changes the backtracing functionality, which is
> used to print a stack trace before aborting when something goes
> belly-up, to use the stack unwinding functionality provided by libgcc
> instead of using the glibc backtrace_symbols and backtrace_symbols_fd
> functions, or the "pstack" utility which is available on some systems
> (Solaris?). There are some nice benefits of this:
>
> - It should work on all targets, not only those which use glibc or pstack.
>
> - It gets the correct line numbers, whereas the backtrace_symbols_fd
> output was usually (but not always) offset by one. This is probably
> related to the use of _Unwind_GetIPInfo and in some cases decrementing
> the IP.
>
> - Based on some googling, it's a bit unclear whether backtrace()
> and/or backtrace_symbols_fd() actually are async-signal-safe due to
> usage of dlsym/dladdr and such.
>
> It still uses addr2line if available to print out function and file
> names and line numbers. If addr2line is not found on the path during
> program startup, it resorts to printing out the addresses only.
>
> Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
>
> 2011-11-01 Janne Blomqvist <jb@gcc.gnu.org>
>
> PR fortran/46686
> * configure.ac: Don't check execinfo.h, backtrace,
> backtrace_symbols_fd. Check execve instead of execvp. Call
> GCC_CHECK_UNWIND_GETIPINFO.
> * runtime/backtrace.c: Don't include unused headers, include
> limits.h and unwind.h.
> (CAN_FORK): Check execve instead of execvp.
> (GLIBC_BACKTRACE): Remove.
> (bt_header): Conform to gdb backtrace format.
> (struct bt_state): New struct.
> (trace_function): New function.
> (show_backtrace): Use _Unwind_Backtrace from libgcc instead of
> glibc backtrace functions.
OK.
--
Steve