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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [s-mastop-tru64.adb] - Blame information for rev 311

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

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                     SYSTEM.MACHINE_STATE_OPERATIONS                      --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                         (Version for Alpha/Dec Unix)                     --
9
--                                                                          --
10
--                     Copyright (C) 1999-2005, AdaCore                     --
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,  51  Franklin  Street,  Fifth  Floor, --
21
-- Boston, MA 02110-1301, 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
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
32
--                                                                          --
33
------------------------------------------------------------------------------
34
 
35
--  This version of System.Machine_State_Operations is for use on
36
--  Alpha systems running DEC Unix.
37
 
38
with System.Memory;
39
 
40
package body System.Machine_State_Operations is
41
 
42
   pragma Linker_Options ("-lexc");
43
   --  Needed for definitions of exc_capture_context and exc_virtual_unwind
44
 
45
   ----------------------------
46
   -- Allocate_Machine_State --
47
   ----------------------------
48
 
49
   function Allocate_Machine_State return Machine_State is
50
      use System.Storage_Elements;
51
 
52
      function c_machine_state_length return Storage_Offset;
53
      pragma Import (C, c_machine_state_length, "__gnat_machine_state_length");
54
 
55
   begin
56
      return Machine_State
57
        (Memory.Alloc (Memory.size_t (c_machine_state_length)));
58
   end Allocate_Machine_State;
59
 
60
   ----------------
61
   -- Fetch_Code --
62
   ----------------
63
 
64
   function Fetch_Code (Loc : Code_Loc) return Code_Loc is
65
   begin
66
      return Loc;
67
   end Fetch_Code;
68
 
69
   ------------------------
70
   -- Free_Machine_State --
71
   ------------------------
72
 
73
   procedure Free_Machine_State (M : in out Machine_State) is
74
   begin
75
      Memory.Free (Address (M));
76
      M := Machine_State (Null_Address);
77
   end Free_Machine_State;
78
 
79
   ------------------
80
   -- Get_Code_Loc --
81
   ------------------
82
 
83
   function Get_Code_Loc (M : Machine_State) return Code_Loc is
84
      Asm_Call_Size : constant := 4;
85
 
86
      function c_get_code_loc (M : Machine_State) return Code_Loc;
87
      pragma Import (C, c_get_code_loc, "__gnat_get_code_loc");
88
 
89
      --  Code_Loc returned by c_get_code_loc is the return point but here we
90
      --  want Get_Code_Loc to return the call point. Under DEC Unix a call
91
      --  asm instruction takes 4 bytes. So we must remove this value from
92
      --  c_get_code_loc to have the call point.
93
 
94
      Loc : constant Code_Loc := c_get_code_loc (M);
95
 
96
   begin
97
      if Loc = 0 then
98
         return 0;
99
      else
100
         return Loc - Asm_Call_Size;
101
      end if;
102
   end Get_Code_Loc;
103
 
104
   --------------------------
105
   -- Machine_State_Length --
106
   --------------------------
107
 
108
   function Machine_State_Length
109
     return System.Storage_Elements.Storage_Offset
110
   is
111
      use System.Storage_Elements;
112
 
113
      function c_machine_state_length return Storage_Offset;
114
      pragma Import (C, c_machine_state_length, "__gnat_machine_state_length");
115
 
116
   begin
117
      return c_machine_state_length;
118
   end Machine_State_Length;
119
 
120
   ---------------
121
   -- Pop_Frame --
122
   ---------------
123
 
124
   procedure Pop_Frame (M : Machine_State) is
125
      procedure exc_virtual_unwind (Fcn : System.Address; M : Machine_State);
126
      pragma Import (C, exc_virtual_unwind, "exc_virtual_unwind");
127
 
128
      function exc_lookup_function (Loc : Code_Loc) return System.Address;
129
      pragma Import (C, exc_lookup_function, "exc_lookup_function_entry");
130
 
131
      procedure c_set_code_loc (M : Machine_State; Loc : Code_Loc);
132
      pragma Import (C, c_set_code_loc, "__gnat_set_code_loc");
133
 
134
      --  Look for a code-range descriptor table containing the PC of the
135
      --  specified machine state. If we don't find any, attempting to unwind
136
      --  further would fail so we set the machine state's code location to a
137
      --  value indicating that the top of the call chain is reached. This
138
      --  happens when the function at the address pointed to by PC has not
139
      --  been registered with the unwinding machinery, as with the __istart
140
      --  functions generated by the linker in presence of initialization
141
      --  routines for example.
142
 
143
      Prf : constant System.Address := exc_lookup_function (Get_Code_Loc (M));
144
 
145
   begin
146
      if Prf = System.Null_Address then
147
         c_set_code_loc (M, 0);
148
      else
149
         exc_virtual_unwind (Prf, M);
150
      end if;
151
   end Pop_Frame;
152
 
153
   -----------------------
154
   -- Set_Machine_State --
155
   -----------------------
156
 
157
   procedure Set_Machine_State (M : Machine_State) is
158
      procedure c_capture_context (M : Machine_State);
159
      pragma Import (C, c_capture_context, "exc_capture_context");
160
   begin
161
      c_capture_context (M);
162
      Pop_Frame (M);
163
   end Set_Machine_State;
164
 
165
end System.Machine_State_Operations;

powered by: WebSVN 2.1.0

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