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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news4.google.com!feeder.news-service.com!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: addr2line i mingw gcc 4.4.0 Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <86f46e08-56e0-4cc1-89be-93af2e7cad31@q37g2000vbi.googlegroups.com> <550a535e-eef9-4317-ac38-6ae915df6eed@r16g2000vbn.googlegroups.com> Date: Sat, 27 Jun 2009 14:29:34 +0200 Message-ID: <1lj06mpzo0kub$.1smjw0922rv52$.dlg@40tude.net> NNTP-Posting-Date: 27 Jun 2009 14:29:34 CEST NNTP-Posting-Host: dc16bd4b.newsspool1.arcor-online.net X-Trace: DXC=7C?dJdKiAR^YI9]OHn9o5^ic==]BZ:af^4Fo<]lROoRQ^YC2XCjHcbY\b@h]d3K4HUDNcfSJ;bb[UIRnRBaCd 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. 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. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de