OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [ada/] [g-exctra.adb] - Blame information for rev 816

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT RUN-TIME COMPONENTS                         --
4
--                                                                          --
5
--                  G N A T . E X C E P T I O N _ T R A C E S               --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--                     Copyright (C) 2000-2009, AdaCore                     --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17
-- for  more details.  You should have  received  a copy of the GNU General --
18
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20
-- Boston, MA 02110-1301, USA.                                              --
21
--                                                                          --
22
-- As a special exception,  if other files  instantiate  generics from this --
23
-- unit, or you link  this unit with other files  to produce an executable, --
24
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
25
-- covered  by the  GNU  General  Public  License.  This exception does not --
26
-- however invalidate  any other reasons why  the executable file  might be --
27
-- covered by the  GNU Public License.                                      --
28
--                                                                          --
29
-- GNAT was originally developed  by the GNAT team at  New York University. --
30
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
31
--                                                                          --
32
------------------------------------------------------------------------------
33
 
34
with System.Standard_Library; use System.Standard_Library;
35
with System.Soft_Links;       use System.Soft_Links;
36
 
37
package body GNAT.Exception_Traces is
38
 
39
   --  Calling the decorator directly from where it is needed would require
40
   --  introducing nasty dependencies upon the spec of this package (typically
41
   --  in a-except.adb). We also have to deal with the fact that the traceback
42
   --  array within an exception occurrence and the one the decorator shall
43
   --  accept are of different types. These are two reasons for which a wrapper
44
   --  with a System.Address argument is indeed used to call the decorator
45
   --  provided by the user of this package. This wrapper is called via a
46
   --  soft-link, which either is null when no decorator is in place or "points
47
   --  to" the following function otherwise.
48
 
49
   function Decorator_Wrapper
50
     (Traceback : System.Address;
51
      Len       : Natural) return String;
52
   --  The wrapper to be called when a decorator is in place for exception
53
   --  backtraces.
54
   --
55
   --  Traceback is the address of the call chain array as stored in the
56
   --  exception occurrence and Len is the number of significant addresses
57
   --  contained in this array.
58
 
59
   Current_Decorator : Traceback_Decorator := null;
60
   --  The decorator to be called by the wrapper when it is not null, as set
61
   --  by Set_Trace_Decorator. When this access is null, the wrapper is null
62
   --  also and shall then not be called.
63
 
64
   -----------------------
65
   -- Decorator_Wrapper --
66
   -----------------------
67
 
68
   function Decorator_Wrapper
69
     (Traceback : System.Address;
70
      Len       : Natural) return String
71
   is
72
      Decorator_Traceback : Tracebacks_Array (1 .. Len);
73
      for Decorator_Traceback'Address use Traceback;
74
 
75
      --  Handle the "transition" from the array stored in the exception
76
      --  occurrence to the array expected by the decorator.
77
 
78
      pragma Import (Ada, Decorator_Traceback);
79
 
80
   begin
81
      return Current_Decorator.all (Decorator_Traceback);
82
   end Decorator_Wrapper;
83
 
84
   -------------------------
85
   -- Set_Trace_Decorator --
86
   -------------------------
87
 
88
   procedure Set_Trace_Decorator (Decorator : Traceback_Decorator) is
89
   begin
90
      Current_Decorator := Decorator;
91
      Traceback_Decorator_Wrapper :=
92
        (if Current_Decorator /= null
93
         then Decorator_Wrapper'Access else null);
94
   end Set_Trace_Decorator;
95
 
96
   ---------------
97
   -- Trace_Off --
98
   ---------------
99
 
100
   procedure Trace_Off is
101
   begin
102
      Exception_Trace := RM_Convention;
103
   end Trace_Off;
104
 
105
   --------------
106
   -- Trace_On --
107
   --------------
108
 
109
   procedure Trace_On (Kind : Trace_Kind) is
110
   begin
111
      case Kind is
112
         when Every_Raise =>
113
            Exception_Trace := Every_Raise;
114
         when Unhandled_Raise =>
115
            Exception_Trace := Unhandled_Raise;
116
      end case;
117
   end Trace_On;
118
 
119
end GNAT.Exception_Traces;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.