Re: gnat: symbolic traceback on exceptions



Björn Lundin escribió:
...
Not compiled, not tested, but should work
You could put it in a separate package if you like.

-----------
with Ada.Exceptions;
with Text_Io; use Text_Io;
with Gnat.Traceback;
...[snipped]...
begin
 A := "Hello, this raises Constraint_Error";
exception
  when E: others =>
    Tracebackinfo(E);
end A_Test;

Thank you very much. Your code worked almost immediatly (after correcting a minor omission in a with clause). After putting the reporting routine in a separate compilation unit, the user's code is really simple:


------------------------------
with Trace_Exception;

procedure New_Test is
   A : String (1..1);

begin
   A := "Hello, this raises Constraint_Error";
exception
   when E: others =>
      Trace_Exception( E );
end New_Test;
------------------------------

...>new_test
Exception raised : CONSTRAINT_ERROR
Message : new_test.adb:8 length check failed
Call chain traceback :
 Address Subprogram name and source code location
-------- ----------------------------------------
0040536D in ada.exceptions.process_raise_exception at a-except.adb:1320
00402537 in <__gnat_rcheck_07> at a-except.adb:607
00401BEA in new_test at new_test.adb:8
004013D3 in main at b~new_test.adb:168
00401103 in ?? at fake:0
------------------------------

I've adapted your code to my own taste. The user's code is simple enough to be used by our students. I wonder why the gnat compiler doesn't provide a -gnat.. switch to turn on the symbolic call stack reporting at the user's request.

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



Relevant Pages

  • Re: Problem overriding sys.excepthook
    ... > importing the traceback module at the beginning of the script, ... uncaught exception. ... is -- Python will compile the entire module before executing it. ... "import" statement (although AFTER compilation of the main module), ...
    (comp.lang.python)
  • Re: Try-catch not working - why does this throw an Exception?
    ... This isn't a runtime error but an actual ... compilation error... ... > The following code throws a "CS0020: Division by constant zero Exception". ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Try-catch not working - why does this throw an Exception?
    ... This isn't a runtime error but an actual ... compilation error... ... > The following code throws a "CS0020: Division by constant zero Exception". ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Linux 64 bit arch: running compiled magicsquare example on similar architecture
    ... architectures or a problem with the 7.6 version of the MCR. ... seemed to help resolve the floating point exception on the ... I will try the latest 2007b release compilation and porting ... development machine (a 64-b Linux) the magicsquare example. ...
    (comp.soft-sys.matlab)
  • Re: Oh boy, how did we miss this...
    ... >Exception objects), you would need to add some unit to make it work. ... cases if you don't use a unit you need, you get a compilation error. ... Catherine Rees Lay ...
    (comp.lang.pascal.delphi.misc)