From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!aioe.org!siG8trSPtxwtkBCOZpBn8A.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Extra information in the message string of exceptions. Date: Wed, 8 Jun 2022 10:04:26 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <3bc7a99c-d541-497b-b3fd-7a6db0ee0de9n@googlegroups.com> <574017e3-d354-41b9-87a1-1f3aa6edf4a2n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="15527"; posting-host="siG8trSPtxwtkBCOZpBn8A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63953 List-Id: On 2022-06-08 09:31, Jerry wrote: > On Tuesday, June 7, 2022 at 8:56:00 AM UTC-7, Fabien Chouteau wrote: >> On Monday, June 6, 2022 at 3:40:38 PM UTC+2, Fabien Chouteau wrote: >>> But this feature could be activated with a switch only when needed. >> Well, it turns our this is already implemented in GNAT ^^ >> >> Example here: https://godbolt.org/z/fcTEaq3xP > Indeed. The switch is -GNATeE. It provides additional information for the program at that page, > > procedure Main is > procedure Test (A : Integer) is > type T is range 0 .. 42; > begin > Ada.Text_IO.Put_Line (T (A)'Img); > end; > begin > Test (-1); > end Main; > > But has no effect on this program; > > procedure CE_2 is > i : Positive; > j : Integer := 1; > begin > i := -j; > end CE_2; The switches are -E for binder and -g for everything else. Try this: --- test_ce.gpr ---------------------------------------- project Test_CE is for Source_Files use ("test_ce.adb"); for Main use ("test_ce.adb"); package Binder is for Default_Switches ("ada") use ("-E"); end Binder; package Builder is for Default_Switches ("ada") use ("-g"); end Builder; package Compiler is for Default_Switches ("ada") use ("-g"); end Compiler; package Linker is for Default_Switches ("ada") use ("-g"); end Linker; end Test_CE; --- test_ce.adb ---------------------------------------- with System.Exception_Traces; use System.Exception_Traces; with System.Traceback.Symbolic; procedure Test_CE is i : Positive; j : Integer := 1; begin Trace_On (System.Exception_Traces.Unhandled_Raise); Set_Trace_Decorator ( System.Traceback.Symbolic.Symbolic_Traceback'Access ); i := -j; end Test_CE; Notes: 1. You can just use Symbolic_Traceback whenever you want. E.g. you can set an exception handler and dump traceback at the raising point. It is slow as hell, of course. 2. There are problems getting symbolic traceback working on ARM. 3. This becomes pretty much useless with relocated libraries. I do not know how to make it work with them. 4. Under Windows you will not get traceback from non-GCC compiled stuff because it does not understand *.pdb files. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de