gnat: symbolic traceback on exceptions



Using gnat 3.15p on WindowsXP. Wanted symbolic traceback automatically generated on unhandled exceptions. Mainly for student programs.

The following recipe can produce the wanted info, as suggested by the gnat user's guide:

....> gnatmake -g main_program -bargs -E

....> main_program
Execution terminated by unhandled exception
Exception name: CONSTRAINT_ERROR
Message: main_program.adb:5 explicit raise
Call stack traceback locations:
0x404a69 0x401bdf 0x4012f3 0x40130b 0x40131c 0x4012bb 0x401103

....>addr2line --exe=main_progam.exe 0x404a69 0x401bdf 0x4012f3 0x40130b 0x40131c 0x4012bb 0x401103
00404A69 at c:/manual/build-kiev/src/ada/rts/a-except.adb:1320
00401BDF at c:/manual/build-kiev/src/ada/rts/a-except.adb:592
004012F3 at E:/.../main_program.adb:5
0040130B at E:/.../main_program.adb:10
0040131C at E:/.../main_program.adb:14
004012BB at E:/...//b~main_program.adb:109
00401103 at fake:0


This is an unfriendly way of doing things. The list of binary addresses must be manually grabbed from the exception message and pasted in the addr2line command.

Is there a different set of gnat switches that could be used to have the symbolic traceback directly listed in the exception message?

Or can it be programmatically generated, by explicitly invoking the message generation from the main program? Something like:

  procedure main_program is
  begin
    ...
  exception
    when others => Trace_Exception;
 end main_program;

Where Trace_Exception is a general trace routine that uses gnat specific features and library routines. (which ones?)

Thanks in advance.
--
To reply by e-mail, please remove the extra dot
in the given address:  m.collado -> mcollado
.



Relevant Pages

  • Re: How to debug?
    ... Store tracebacks in exception occurrences when the target supports it. ... I'm on Windows XP, with GNAT 3.15p. ... Ada, GNAT, the 'p' versions, does not facilitate debugging like e.g. the ...
    (comp.lang.ada)
  • Re: GNAT and -fstack-check, does it work?
    ... We are hit by that bug, feature or whatever it is since GNAT 3.15p ... Execution terminated by unhandled exception ... stack overflow ...
    (comp.lang.ada)
  • Re: Enumeration type - GNAT 3.15p bug?
    ... GNAT 3.15p: ... raised CONSTRAINT_ERROR: jenumxa.adb:8 overflow check failed ... exception, but the compare seem to access a wrong address. ...
    (comp.lang.ada)
  • Re: Filenames in Ada
    ... Martin Krischik wrote: ... Should the exception not be in Ada.Directories.Simple_Name? ... Assuming you are using GNAT, there is also note there is a bug in the ... I've reported this in Bugzilla yonks ago but no changes in GCC yet, ...
    (comp.lang.ada)