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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?B?QmrDtnJuIEx1bmRpbg==?= Newsgroups: comp.lang.ada Subject: Re: How to get nice with GNAT? Date: Fri, 21 Nov 2014 13:42:02 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 21 Nov 2014 12:40:25 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="23e59b4906029a0ce22afc4c4b1f25ee"; logging-data="9435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BksTu165uHIdpVhmYpLWT" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 In-Reply-To: Cancel-Lock: sha1:+LtG7mkxyAC7qnDpzl4caK4jnvY= Xref: news.eternal-september.org comp.lang.ada:23602 Date: 2014-11-21T13:42:02+01:00 List-Id: On 2014-11-21 12:41, Natasha Kerensikova wrote: > As a user, is there something I can do to improve the traceback > representation on those platforms? > Or is it completely in the hands of the GNAT packager/maintainer? > I run gnat on Aix/win32/linux32/64 and until recently, I tucked everything related to stacktrace into a package Stacktrace. package Stacktrace is procedure Tracebackinfo(E : Ada.Exceptions.Exception_Occurrence) ; end Stacktrace; used as procedure bla is ... ... exception when E: others => Stacktrace.Tracebackinfo(E); end ; where i called Ada.Exceptions.Exception_Name(E); Ada.Exceptions.Exception_Message(E); Ada.Exceptions.Exception_Information(E); and output them however, from Gnat GPL 2014 (64) and gnat fsf on debian Jessie (gnat 4.9 i think) the Tracebackinfo is not called anymore. So my current workaround is to print those function directly like procedure bla is ... exception when E: others => declare Last_Exception_Name : constant String := Ada.Exceptions.Exception_Name(E); Last_Exception_Messsage : constant String := Ada.Exceptions.Exception_Message(E); Last_Exception_Info : constant String := Ada.Exceptions.Exception_Information(E); begin Log(Last_Exception_Name); Log("Message : " & Last_Exception_Messsage); Log(Last_Exception_Info); Log("addr2line" & " --functions --basenames --exe=" & Ada.Command_Line.Command_Name & " " & Stacktrace.Pure_Hexdump(Last_Exception_Info)); end ; end bla; the function Pure_Hexdump strips away everything before the first 0x in the string. final output is like 2014-11-21 13:33:26.278 SQL.NOT_CONNECTED 2014-11-21 13:33:26.278 Message : Sql.Connect: Not_Connected 2014-11-21 13:33:26.278 Exception name: SQL.NOT_CONNECTED Message: Sql.Connect: Not_Connected Call stack traceback locations: 0x5be389 0x5cd93c 0x40c988 0x7fca95a8beab 0x40bab7 2014-11-21 13:33:26.278 addr2line --functions --basenames --exe=/home/bnl/bnlbot/botstart/bot-1-0/target/bin/back_hitrate 0x5be389 0x5cd93c 0x40c988 0x7fca95a8beab 0x40bab7 and running addr2line gives addr2line --functions --basenames --exe=/home/bnl/bnlbot/botstart/bot-1-0/target/bin/back_hitrate 0x5be389 0x5cd93c 0x40c988 0x7fca95a8beab 0x40bab7 sql__connect sql.adb:432 _ada_back_hitrate back_hitrate.adb:165 main b~back_hitrate.adb:761 ?? ??:0 _start ??:? A bit clumpsy but good enough for my _hobby_ projects. -- Björn