* config/xtensa/xtensa.h (GO_IF_MODE_DEPENDENT_ADDRESS): Treat
[official-gcc.git] / gcc / ada / s-except.ads
blob66d7ce1849b1ed4dea00b6c78272fcd46f3d4bb2
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- S Y S T E M . E X C E P T I O N S --
6 -- --
7 -- S p e c --
8 -- --
9 -- --
10 -- Copyright (C) 1992-2000 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
32 -- --
33 ------------------------------------------------------------------------------
35 -- This package contains definitions used for zero cost exception handling.
36 -- See unit Ada.Exceptions for further details. Note that the reason that
37 -- we separate out these definitions is to avoid problems with recursion
38 -- in rtsfind. They must be in a unit which does not require any exception
39 -- table generation of any kind.
41 with Ada.Exceptions;
43 with System;
44 with System.Standard_Library;
46 with Unchecked_Conversion;
48 package System.Exceptions is
50 package SSL renames System.Standard_Library;
51 package AEX renames Ada.Exceptions;
53 -- The following section defines data structures used for zero cost
54 -- exception handling if System.Parameters.Zero_Cost_Exceptions is
55 -- set true (i.e. zero cost exceptions are implemented on this target).
57 -- The approach is to build tables that describe the PC ranges that
58 -- are covered by various exception frames. When an exception occurs,
59 -- these tables are searched to determine the address of the applicable
60 -- handler for the current exception.
62 subtype Handler_Loc is System.Address;
63 -- Code location representing entry address of a handler. Values of
64 -- this type are created using the N_Handler_Loc node, and then
65 -- passed to the Enter_Handler procedure to enter a handler.
67 subtype Code_Loc is System.Address;
68 -- Code location used in building exception tables and for call
69 -- addresses when propagating an exception (also traceback table)
70 -- Values of this type are created by using Label'Address or
71 -- extracted from machine states using Get_Code_Loc.
73 --------------------
74 -- Handler_Record --
75 --------------------
77 -- A Handler record is built for each choice for each exception handler
78 -- in a frame.
80 function To_Exception_Id is
81 new Unchecked_Conversion (SSL.Exception_Data_Ptr, AEX.Exception_Id);
83 Others_Dummy_Exception : aliased SSL.Exception_Data;
84 Others_Id : constant AEX.Exception_Id :=
85 To_Exception_Id (Others_Dummy_Exception'Access);
86 -- Dummy exception used to signal others exception
88 All_Others_Dummy_Exception : aliased SSL.Exception_Data;
89 All_Others_Id : constant AEX.Exception_Id :=
90 To_Exception_Id (All_Others_Dummy_Exception'Access);
91 -- Dummy exception used to signal all others exception (including
92 -- exceptions not normally handled by others, e.g. Abort_Signal)
94 type Handler_Record is record
95 Lo : Code_Loc;
96 Hi : Code_Loc;
97 -- Range of PC values of code covered by this handler record. The
98 -- handler covers all code addresses that are greater than the Lo
99 -- value, and less than or equal to the Hi value.
101 Id : AEX.Exception_Id;
102 -- Id of exception being handled, or one of the above special values
104 Handler : Handler_Loc;
105 -- Address of label at start of handler
106 end record;
108 type Handler_Record_Ptr is access all Handler_Record;
109 type Handler_Record_List is array (Natural range <>) of Handler_Record_Ptr;
111 ---------------------------
112 -- Subprogram_Descriptor --
113 ---------------------------
115 -- A Subprogram_Descriptor is built for each subprogram through which
116 -- exceptions may propagate, this includes all Ada subprograms,
117 -- and also all foreign language imported subprograms.
119 subtype Subprogram_Info_Type is System.Address;
120 -- This type is used to represent a value that is used to unwind stack
121 -- frames. It references target dependent data that provides sufficient
122 -- information (e.g. about the location of the return point, use of a
123 -- frame pointer, save-over-call registers etc) to unwind the machine
124 -- state to the caller. For some targets, this is simply a pointer to
125 -- the entry point of the procedure (and the routine to pop the machine
126 -- state disassembles the code at the entry point to obtain the required
127 -- information). On other targets, it is a pointer to data created by the
128 -- backend or assembler to represent the required information.
130 No_Info : constant Subprogram_Info_Type := System.Null_Address;
131 -- This is a special value used to indicate that it is not possible
132 -- to pop past this frame. This is used at the outer level (e.g. for
133 -- package elaboration procedures or the main procedure), and for any
134 -- other foreign language procedure for which propagation is known
135 -- to be impossible. An exception is considered unhandled if an
136 -- attempt is made to pop a frame whose Subprogram_Info_Type value
137 -- is set to No_Info.
139 type Subprogram_Descriptor (Num_Handlers : Natural) is record
140 Code : Code_Loc;
141 -- This is a code location used to determine which procedure we are
142 -- in. Most usually it is simply the entry address for the procedure.
143 -- hA given address is considered to be within the procedure referenced
144 -- by a Subprogram_Descriptor record if this is the descriptor for
145 -- which the Code value is as large as possible without exceeding
146 -- the given value.
148 Subprogram_Info : Subprogram_Info_Type;
149 -- This is a pointer to a target dependent data item that provides
150 -- sufficient information for unwinding the stack frame of this
151 -- procedure. A value of No_Info (zero) means that we are the
152 -- outer level procedure.
154 Handler_Records : Handler_Record_List (1 .. Num_Handlers);
155 -- List of pointers to Handler_Records for this procedure. The array
156 -- is sorted inside out, i.e. entries for inner frames appear before
157 -- entries for outer handlers. This ensures that a serial search
158 -- finds the innermost applicable handler
159 end record;
161 subtype Subprogram_Descriptor_0 is Subprogram_Descriptor (0);
162 subtype Subprogram_Descriptor_1 is Subprogram_Descriptor (1);
163 subtype Subprogram_Descriptor_2 is Subprogram_Descriptor (2);
164 subtype Subprogram_Descriptor_3 is Subprogram_Descriptor (3);
165 -- Predeclare commonly used subtypes for buildingt he tables
167 type Subprogram_Descriptor_Ptr is access all Subprogram_Descriptor;
169 type Subprogram_Descriptor_List
170 is array (Natural range <>) of Subprogram_Descriptor_Ptr;
172 type Subprogram_Descriptors_Record (Count : Natural) is record
173 SDesc : Subprogram_Descriptor_List (1 .. Count);
174 end record;
176 type Subprogram_Descriptors_Ptr is
177 access all Subprogram_Descriptors_Record;
179 --------------------------
180 -- Unit Exception_Table --
181 --------------------------
183 -- If a unit contains at least one subprogram, then a library level
184 -- declaration of the form:
186 -- Tnn : aliased constant Subprogram_Descriptors :=
187 -- (Count => n,
188 -- SDesc =>
189 -- (SD1'Unrestricted_Access,
190 -- SD2'Unrestricted_Access,
191 -- ...
192 -- SDn'Unrestricted_Access));
193 -- pragma Export (Ada, Tnn, "__gnat_unit_name__SDP");
195 -- is generated where the initializing expression is an array aggregate
196 -- whose elements are pointers to the generated subprogram descriptors
197 -- for the units.
199 -- Note: the ALI file contains the designation UX in each unit entry
200 -- if a unit exception table is generated.
202 -- The binder generates a list of addresses of pointers to these tables.
204 end System.Exceptions;