Re: gnat: symbolic traceback on exceptions



Manuel Collado:

> > Did you try it with AdaGide with switch "Trace exception" set? Compile F3,
> > run F4.
>
> No, I din't. But I've done it now without success. It seems that the
> "Trace exceptions" option lets AdaGide to run the program through an
> "AD" utility that interfaces with GDB. In my machine AD itself seems to
> crash. Example:
(...)

This AD should disappear one day - I don't know if it even sometimes
works...

The solution to your problem ("the GNAT 3.13+ way") is, generically
written:

------------------------------------------------------------------------------
-- File: TB_Wrap.ads
-- Description: Trace-back wrapper for GNAT 3.13p+ (spec.)
------------------------------------------------------------------------------

generic

with procedure My_main_procedure;

procedure TB_Wrap;


------------------------------------------------------------------------------
-- File: TB_Wrap.adb
-- Description: Trace-back wrapper for GNAT 3.13p+ (body)
------------------------------------------------------------------------------

with GNAT.Traceback.Symbolic, Ada.Exceptions, Ada.Text_IO;
use Ada.Exceptions, Ada.Text_IO;

procedure TB_Wrap is
pragma Compiler_options("-g");
pragma Binder_options("-E");
begin
My_main_procedure;
exception
when E: others =>
New_Line;
Put_Line("---------------[ Unhandled exception ]------------");
Put_Line(" > Name of exception . . . . .: " &
Ada.Exceptions.Exception_Name(E) );
Put_Line(" > Message for exception . . .: " &
Ada.Exceptions.Exception_Message(E) );
Put_Line(" > Trace-back of call stack: " );
Put_Line( GNAT.Traceback.Symbolic.Symbolic_Traceback(E) );
end TB_Wrap;

-----------

with TB_Wrap, Test;

procedure Test_TB_Wrap is new TB_Wrap(Test);

-----------

Of course you can do it without the generic wrapper, just paste
the exception part at the end of your main procedure.

The switches mentioned in the above code correspond to the compiler
switches "debug info" and "trace-back" in the "Debugging" group
of AdaGIDE's "Project settings" -> "Debug/Release settings".

HTH
______________________________________________________________
Gautier -- http://www.mysunrise.ch/users/gdm/index.htm
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!

.



Relevant Pages

  • exception using wmic
    ... I get an exception when I try to execute any command using wmic. ... SUCCESS: CoCreateInstance(CLSID_XSLTemplate, NULL, CLSCTX_SERVER, ...
    (microsoft.public.win32.programmer.wmi)
  • Cross Thread Calls
    ... prevent the cross thread calls exception from being thrown with no ... bool success = false; ... fThreadLoadAsset = new Thread); ... fStatus = STATUS.LOADING; ...
    (microsoft.public.dotnet.csharp.general)
  • Re: Removing else blocks
    ... > return success; ... throw an exception. ... In most of these cases I actually use an ASSERT macro to do the "throw ... I know Bjarne recommends using a template for ...
    (comp.lang.cpp)
  • Re: Oklahomas innovations
    ... anticipated its "innovations" but argues that they didn't "Change ... different kind - and that OK!'s *success* was the factor that changed that. ... furthering of those innovations made it impossible to go back to essentially ... "revolution" (the one main exception, of course, was ONE TOUCH OF VENUS ...
    (rec.arts.theatre.musicals)
  • Re: Handling exceptions
    ... I understand that failure will always be returned because of the ... What is the best practice to return a value if success or failure. ... Or should the exception be propagated to the calling method? ... void foo() throws FooException { ...
    (comp.lang.java.programmer)