aaa_0.2.6_dfd6339b/src/aaa-debug.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
with GNAT.IO;

package body AAA.Debug is

   -----------
   -- Image --
   -----------

   function Image (E : Ada.Exceptions.Exception_Occurrence) return String
   is
      use Ada.Exceptions;
      use ASCII;
   begin
      return
        "EXCEPTION NAME" & LF & Exception_Name (E) & LF
        & "EXCEPTION MESSAGE" & LF & Exception_Message (E) & LF
        & "EXCEPTION INFORMATION" & LF & Exception_Information (E);
   end Image;

   -------------------
   -- Put_Exception --
   -------------------

   procedure Put_Exception (E           : Ada.Exceptions.Exception_Occurrence;
                            Title       : String := "AAA EXCEPTION DUMP:";
                            Stack_Trace : Boolean := True)
   is
      use GNAT.IO;
   begin
      Put_Line (Title & ASCII.LF
                & Image (E));
      if Stack_Trace then
         Put_Line (Debug.Stack_Trace);
      end if;
   end Put_Exception;

   -----------------
   -- Stack_Trace --
   -----------------

   function Stack_Trace return String is
      Debug_Exception : exception;
   begin
      raise Debug_Exception;
   exception
      when E : Debug_Exception =>
         return Ada.Exceptions.Exception_Information (E);
   end Stack_Trace;

end AAA.Debug;