comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: addr2line i mingw gcc 4.4.0
Date: Sat, 27 Jun 2009 06:05:46 -0700 (PDT)
Date: 2009-06-27T06:05:46-07:00	[thread overview]
Message-ID: <2c43aaf0-e995-47a6-81c6-967dc39803eb@k26g2000vbp.googlegroups.com> (raw)
In-Reply-To: 1lj06mpzo0kub$.1smjw0922rv52$.dlg@40tude.net

On Jun 27, 2:29 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Sat, 27 Jun 2009 07:28:32 -0400, Stephen Leake wrote:
> > Ludovic Brenta <ludo...@ludovic-brenta.org> writes:
>
> >> libaddr2line.a is an invention from AdaCore several years ago; it is a
> >> patch against the program "addr2line" in certain versions of binutils,
> >> not GCC.  I am not aware of any binary distribution of it apart from
> >> AdaCore's own.  In Debian, I've patched GCC so that it supports
> >> symbolic tracebacks by calling addr2line in an external process rather
> >> than using libaddr2line in-process.  An early version of this patch
> >> was in the Ada for Linux Team distribution by Jürgen Pfeiffer for Red
> >> Hat Linux 6 (in 1999).
>
> >> So, I think you can have symbolic tracebacks in mingw in one of two
> >> ways: patch binutils to build libaddr2line.a then link libgnat against
> >> it; or patch libgnat to use the same method as on Debian.
>
> > A third alternative is to output numeric traceback from the failing
> > program, and then use addr2line (the program) to get the symbolic
> > traceback in a separate manual step.
>
> It is quite simple to print the symbolic traceback from the program:
>
> with Ada.Text_IO;              use Ada.Text_IO;
> with GNAT.Traceback;           use GNAT.Traceback;
> with GNAT.Traceback.Symbolic;  use GNAT.Traceback.Symbolic;
>
> procedure Call_Stack is
>    TB  : Tracebacks_Array (1..100);
>    Len : Natural;
> begin
>    Call_Chain (TB, Len);
>    Put_Line (Symbolic_Traceback (TB (1..Len)));
> end Call_Stack;
>
> This prints the call stack. I am using this for tracing Gtk errors before
> they corrupt the stack due to exception propagation.
>
> Note that Tracebacks_Array is merely an array of addresses, so if you get
> it in other way, for example, from Exception_Information, you can convert
> each number there to Address (using System.Storage_Elements.To_Address) and
> then pass the result to (Symbolic_Traceback.

Like I explained, this works in GNAT GPL Edition only because this
distribution includes libaddr2line.a, which GNAT.Tracebacks.Symbolic
uses.  For GCC, a patch is required either to binutils or to GCC
(libgnat, actually) itself.

--
Ludovic Brenta.



  reply	other threads:[~2009-06-27 13:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-26 14:41 addr2line i mingw gcc 4.4.0 björn lundin
2009-06-26 20:56 ` sjw
2009-06-26 21:28   ` björn lundin
2009-06-27  0:00     ` Ludovic Brenta
2009-06-27 11:28       ` Stephen Leake
2009-06-27 12:29         ` Dmitry A. Kazakov
2009-06-27 13:05           ` Ludovic Brenta [this message]
2009-06-27 16:24         ` sjw
2009-06-27 18:50           ` björn lundin
2009-06-27 20:49           ` Georg Bauhaus
2009-06-29 21:49             ` Randy Brukardt
2009-06-28 16:20           ` sjw
2009-06-27 17:09         ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox