Re: gnat: symbolic traceback on exceptions




2005-05-23 kl. 12.48 skrev Manuel Collado:

..> gnatmake -g main_program -bargs -E

This is a requirement below as well


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?)

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

-----------
with Ada.Exceptions;
with Text_Io; use Text_Io;
with Gnat.Traceback;


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

procedure Tracebackinfo(E : Ada.Exceptions.Exception_Occurrence) is
Last_Exception_Name : constant String := Ada.Exceptions.Exception_Name(E);
Last_Exception_Messsage : constant String:= Ada.Exceptions.Exception_Message(E);
Last_Exception_Info : constant String:= Ada.Exceptions.Exception_Information(E);
begin
Put("Exception raised : "); Put_Line(Last_Exception_Name);
New_Line;
Put_Line("Message : " & Last_Exception_Messsage);
Put_Line(Last_Exception_Info);
Put_Line("...................................................");
New_Line;
Put_Line("Hex Subprogram name and file");
Put_Line("----- ------------------------");
Put_Line(Gnat.Traceback.Symbolic.Symbolic_Traceback(E));
Put_Line("-------------------------------------------------");
end Tracebackinfo;


begin
 A := "Hello, this raises Constraint_Error";
exception
  when E: others =>
    Tracebackinfo(E);
end A_Test;



Björn Lundin
bnl at spray dot se

.