1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- SYSTEM.MACHINE_STATE_OPERATIONS --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 1999-2009, Free Software Foundation, Inc. --
|
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 3, 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. --
|
17 |
|
|
-- --
|
18 |
|
|
-- As a special exception under Section 7 of GPL version 3, you are granted --
|
19 |
|
|
-- additional permissions described in the GCC Runtime Library Exception, --
|
20 |
|
|
-- version 3.1, as published by the Free Software Foundation. --
|
21 |
|
|
-- --
|
22 |
|
|
-- You should have received a copy of the GNU General Public License and --
|
23 |
|
|
-- a copy of the GCC Runtime Library Exception along with this program; --
|
24 |
|
|
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
|
25 |
|
|
-- <http://www.gnu.org/licenses/>. --
|
26 |
|
|
-- --
|
27 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
28 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
29 |
|
|
-- --
|
30 |
|
|
------------------------------------------------------------------------------
|
31 |
|
|
|
32 |
|
|
pragma Compiler_Unit;
|
33 |
|
|
|
34 |
|
|
pragma Polling (Off);
|
35 |
|
|
-- We must turn polling off for this unit, because otherwise we get
|
36 |
|
|
-- elaboration circularities with System.Exception_Tables.
|
37 |
|
|
|
38 |
|
|
with System.Storage_Elements;
|
39 |
|
|
|
40 |
|
|
package System.Machine_State_Operations is
|
41 |
|
|
|
42 |
|
|
subtype Code_Loc is System.Address;
|
43 |
|
|
-- Code location used in building exception tables and for call
|
44 |
|
|
-- addresses when propagating an exception (also traceback table)
|
45 |
|
|
-- Values of this type are created by using Label'Address or
|
46 |
|
|
-- extracted from machine states using Get_Code_Loc.
|
47 |
|
|
|
48 |
|
|
type Machine_State is new System.Address;
|
49 |
|
|
-- The table based exception handling approach (see a-except.adb) isolates
|
50 |
|
|
-- the target dependent aspects using an abstract data type interface
|
51 |
|
|
-- to the type Machine_State, which is represented as a System.Address
|
52 |
|
|
-- value (presumably implemented as a pointer to an appropriate record
|
53 |
|
|
-- structure).
|
54 |
|
|
|
55 |
|
|
function Machine_State_Length return System.Storage_Elements.Storage_Offset;
|
56 |
|
|
-- Function to determine the length of the Storage_Array needed to hold
|
57 |
|
|
-- a machine state. The machine state will always be maximally aligned.
|
58 |
|
|
-- The value returned is a constant that will be used to allocate space
|
59 |
|
|
-- for a machine state value.
|
60 |
|
|
|
61 |
|
|
function Allocate_Machine_State return Machine_State;
|
62 |
|
|
-- Allocate the required space for a Machine_State
|
63 |
|
|
|
64 |
|
|
procedure Free_Machine_State (M : in out Machine_State);
|
65 |
|
|
-- Free the dynamic memory taken by Machine_State
|
66 |
|
|
|
67 |
|
|
-- The initial value of type Machine_State is created by the low level
|
68 |
|
|
-- routine that actually raises an exception using the special builtin
|
69 |
|
|
-- _builtin_machine_state. This value will typically encode the value
|
70 |
|
|
-- of the program counter, and relevant registers. The following
|
71 |
|
|
-- operations are defined on Machine_State values:
|
72 |
|
|
|
73 |
|
|
function Get_Code_Loc (M : Machine_State) return Code_Loc;
|
74 |
|
|
-- This function extracts the program counter value from a machine
|
75 |
|
|
-- state, which the caller uses for searching the exception tables,
|
76 |
|
|
-- and also for recording entries in the traceback table. The call
|
77 |
|
|
-- returns a value of Null_Loc if the machine state represents the
|
78 |
|
|
-- outer level, or some other frame for which no information can be
|
79 |
|
|
-- provided.
|
80 |
|
|
|
81 |
|
|
procedure Pop_Frame (M : Machine_State);
|
82 |
|
|
-- This procedure pops the machine state M so that it represents the
|
83 |
|
|
-- call point, as though the current subprogram had returned. It
|
84 |
|
|
-- changes only the value referenced by M, and does not affect
|
85 |
|
|
-- the current stack environment.
|
86 |
|
|
|
87 |
|
|
function Fetch_Code (Loc : Code_Loc) return Code_Loc;
|
88 |
|
|
-- Some architectures (notably VMS) use a descriptor to describe
|
89 |
|
|
-- a subprogram address. This function computes the actual starting
|
90 |
|
|
-- address of the code from Loc.
|
91 |
|
|
--
|
92 |
|
|
-- ??? This function will go away when 'Code_Address is fixed on VMS.
|
93 |
|
|
--
|
94 |
|
|
-- Do not add pragma Inline to this function: there is a curious
|
95 |
|
|
-- interaction between rtsfind and front-end inlining. The exception
|
96 |
|
|
-- declaration in s-auxdec calls rtsfind, which forces several other system
|
97 |
|
|
-- packages to be compiled. Some of those have a pragma Inline, and we
|
98 |
|
|
-- compile the corresponding bodies so that inlining can take place. One
|
99 |
|
|
-- of these packages is s-mastop, which depends on s-auxdec, which is still
|
100 |
|
|
-- being compiled: we have not seen all the declarations in it yet, so we
|
101 |
|
|
-- get confused semantic errors.
|
102 |
|
|
|
103 |
|
|
procedure Set_Machine_State (M : Machine_State);
|
104 |
|
|
-- This routine sets M from the current machine state. It is called
|
105 |
|
|
-- when an exception is initially signalled to initialize the state.
|
106 |
|
|
|
107 |
|
|
end System.Machine_State_Operations;
|