From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,f5ce49ceb519648b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!k26g2000vbp.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: addr2line i mingw gcc 4.4.0 Date: Sat, 27 Jun 2009 06:05:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2c43aaf0-e995-47a6-81c6-967dc39803eb@k26g2000vbp.googlegroups.com> References: <86f46e08-56e0-4cc1-89be-93af2e7cad31@q37g2000vbi.googlegroups.com> <550a535e-eef9-4317-ac38-6ae915df6eed@r16g2000vbn.googlegroups.com> <1lj06mpzo0kub$.1smjw0922rv52$.dlg@40tude.net> NNTP-Posting-Host: 94.108.198.108 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1246107948 28969 127.0.0.1 (27 Jun 2009 13:05:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 27 Jun 2009 13:05:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k26g2000vbp.googlegroups.com; posting-host=94.108.198.108; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.7) Gecko/2009030810 Iceweasel/3.0.9 (Debian-3.0.9-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6667 Date: 2009-06-27T06:05:46-07:00 List-Id: On Jun 27, 2:29=A0pm, "Dmitry A. Kazakov" wrote: > On Sat, 27 Jun 2009 07:28:32 -0400, Stephen Leake wrote: > > Ludovic Brenta 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. =A0I am not aware of any binary distribution of it apart from > >> AdaCore's own. =A0In Debian, I've patched GCC so that it supports > >> symbolic tracebacks by calling addr2line in an external process rather > >> than using libaddr2line in-process. =A0An early version of this patch > >> was in the Ada for Linux Team distribution by J=FCrgen Pfeiffer for Re= d > >> 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; =A0 =A0 =A0 =A0 =A0 =A0 =A0use Ada.Text_IO; > with GNAT.Traceback; =A0 =A0 =A0 =A0 =A0 use GNAT.Traceback; > with GNAT.Traceback.Symbolic; =A0use GNAT.Traceback.Symbolic; > > procedure Call_Stack is > =A0 =A0TB =A0: Tracebacks_Array (1..100); > =A0 =A0Len : Natural; > begin > =A0 =A0Call_Chain (TB, Len); > =A0 =A0Put_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) a= nd > 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.