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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: ADA.STRINGS.INDEX_ERROR : a-strunb.adb:782 Date: Tue, 16 Jan 2018 16:06:31 -0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <4ff1db1f-cf2e-4683-9882-da9a907d07b0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 16 Jan 2018 16:06:31 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="5228da29b834e770ca1d263278c261b6"; logging-data="13993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+htQaGOFAWetmPOxxSIFzuWyQRPkyuHYc=" User-Agent: Pan/0.141 (Tarzan's Death; 168b179 git.gnome.org/pan2) Cancel-Lock: sha1:oQJKFr3HfHtTRTKMjxROvIEBcFg= Xref: reader02.eternal-september.org comp.lang.ada:49933 Date: 2018-01-16T16:06:31+00:00 List-Id: On Mon, 15 Jan 2018 09:22:34 -0800, Anh Vo wrote: > On Monday, January 15, 2018 at 12:29:41 AM UTC-8, Dmitry A. Kazakov >> >> addr2line --exe= >> >> That will give you the stack trace. > > It is even better to use GNAT addition to print out full stack trace as > shown in the snippet. > > -- ... > > exception > > when Err : others => > > Text_Io.Put_Line ("Houston we have a problem: " & > Exceptions.Exception_Information > (Err)); > Text_Io.Put_Line ("Traceback => " & > GNAT.Traceback.Symbolic.Symbolic_Traceback(Err)); > end [Ada Unit Name]; This has some issues with (FSF) Gnat 6.3 (at least on Debian Stretch). I asked about this on the Gnoga list, still working through the issues. (1) It just prints out the same funny numbers, with capital letters in the hex part. (2) Feeding the funny numbers to addr2line just gives a bunch of question marks. The culprit appears to be something to do with Position Independent Executables, and Address Space Randomization, which appear to have broken a few things. Adding "-no-pie" (NOT "-Wl,-no_pie") to the Linker switches changes the funny numbers, such that addr2line can now parse them, fixing (2). However neither this nor explicitly linking libreadline (adding "-lreadline" to teh linker options fixes (1). I have a feeling that when (2) broke, a quick fix was added to GNAT.Traceback.Symbolic to "fix" (1). (checking the RTS source I see a comment... -- This is the default implementation for platforms where the full capability -- is not supported. It returns tracebacks as lists of hexadecimal addresses -- of the form "0x...". So, apparently not provided in recent-ish FSF Gnat compilers ... if it ever was. -- Brian