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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [ada/] [a-except-2005.adb] - Blame information for rev 847

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
--                       A D A . E X C E P T I O N S                        --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-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
--  This version of Ada.Exceptions fully supports both Ada 95 and Ada 2005.
33
--  It is used in all situations except for the build of the compiler and
34
--  other basic tools. For these latter builds, we use an Ada 95-only version.
35
 
36
--  The reason for this splitting off of a separate version is that bootstrap
37
--  compilers often will be used that do not support Ada 2005 features, and
38
--  Ada.Exceptions is part of the compiler sources.
39
 
40
pragma Style_Checks (All_Checks);
41
--  No subprogram ordering check, due to logical grouping
42
 
43
pragma Polling (Off);
44
--  We must turn polling off for this unit, because otherwise we get
45
--  elaboration circularities with System.Exception_Tables.
46
 
47
with System;                  use System;
48
with System.Exceptions;       use System.Exceptions;
49
with System.Standard_Library; use System.Standard_Library;
50
with System.Soft_Links;       use System.Soft_Links;
51
with System.WCh_Con;          use System.WCh_Con;
52
with System.WCh_StW;          use System.WCh_StW;
53
 
54
package body Ada.Exceptions is
55
 
56
   pragma Suppress (All_Checks);
57
   --  We definitely do not want exceptions occurring within this unit, or
58
   --  we are in big trouble. If an exceptional situation does occur, better
59
   --  that it not be raised, since raising it can cause confusing chaos.
60
 
61
   -----------------------
62
   -- Local Subprograms --
63
   -----------------------
64
 
65
   --  Note: the exported subprograms in this package body are called directly
66
   --  from C clients using the given external name, even though they are not
67
   --  technically visible in the Ada sense.
68
 
69
   function Code_Address_For_AAA return System.Address;
70
   function Code_Address_For_ZZZ return System.Address;
71
   --  Return start and end of procedures in this package
72
   --
73
   --  These procedures are used to provide exclusion bounds in
74
   --  calls to Call_Chain at exception raise points from this unit. The
75
   --  purpose is to arrange for the exception tracebacks not to include
76
   --  frames from routines involved in the raise process, as these are
77
   --  meaningless from the user's standpoint.
78
   --
79
   --  For these bounds to be meaningful, we need to ensure that the object
80
   --  code for the routines involved in processing a raise is located after
81
   --  the object code Code_Address_For_AAA and before the object code
82
   --  Code_Address_For_ZZZ. This will indeed be the case as long as the
83
   --  following rules are respected:
84
   --
85
   --  1) The bodies of the subprograms involved in processing a raise
86
   --     are located after the body of Code_Address_For_AAA and before the
87
   --     body of Code_Address_For_ZZZ.
88
   --
89
   --  2) No pragma Inline applies to any of these subprograms, as this
90
   --     could delay the corresponding assembly output until the end of
91
   --     the unit.
92
 
93
   procedure Call_Chain (Excep : EOA);
94
   --  Store up to Max_Tracebacks in Excep, corresponding to the current
95
   --  call chain.
96
 
97
   procedure To_Stderr (S : String);
98
   pragma Export (Ada, To_Stderr, "__gnat_to_stderr");
99
   --  Little routine to output string to stderr that is also used
100
   --  in the tasking run time.
101
 
102
   procedure To_Stderr (C : Character);
103
   pragma Inline (To_Stderr);
104
   pragma Export (Ada, To_Stderr, "__gnat_to_stderr_char");
105
   --  Little routine to output a character to stderr, used by some of
106
   --  the separate units below.
107
 
108
   package Exception_Data is
109
 
110
      ---------------------------------
111
      -- Exception messages routines --
112
      ---------------------------------
113
 
114
      procedure Set_Exception_C_Msg
115
        (Id   : Exception_Id;
116
         Msg1 : System.Address;
117
         Line : Integer        := 0;
118
         Msg2 : System.Address := System.Null_Address);
119
      --  This routine is called to setup the exception referenced by the
120
      --  Current_Excep field in the TSD to contain the indicated Id value
121
      --  and message. Msg1 is a null terminated string which is generated
122
      --  as the exception message. If line is non-zero, then a colon and
123
      --  the decimal representation of this integer is appended to the
124
      --  message. When Msg2 is non-null, a space and this additional null
125
      --  terminated string is added to the message.
126
 
127
      procedure Set_Exception_Msg
128
        (Id      : Exception_Id;
129
         Message : String);
130
      --  This routine is called to setup the exception referenced by the
131
      --  Current_Excep field in the TSD to contain the indicated Id value
132
      --  and message. Message is a string which is generated as the
133
      --  exception message.
134
 
135
      --------------------------------------
136
      -- Exception information subprogram --
137
      --------------------------------------
138
 
139
      function Exception_Information (X : Exception_Occurrence) return String;
140
      --  The format of the exception information is as follows:
141
      --
142
      --    Exception_Name: <exception name> (as in Exception_Name)
143
      --    Message: <message> (only if Exception_Message is empty)
144
      --    PID=nnnn (only if != 0)
145
      --    Call stack traceback locations:  (only if at least one location)
146
      --    <0xyyyyyyyy 0xyyyyyyyy ...>      (is recorded)
147
      --
148
      --  The lines are separated by a ASCII.LF character.
149
      --  The nnnn is the partition Id given as decimal digits.
150
      --  The 0x... line represents traceback program counter locations, in
151
      --  execution order with the first one being the exception location. It
152
      --  is present only
153
      --
154
      --  The Exception_Name and Message lines are omitted in the abort
155
      --  signal case, since this is not really an exception.
156
 
157
      --  !! If the format of the generated string is changed, please note
158
      --  !! that an equivalent modification to the routine String_To_EO must
159
      --  !! be made to preserve proper functioning of the stream attributes.
160
 
161
      ---------------------------------------
162
      -- Exception backtracing subprograms --
163
      ---------------------------------------
164
 
165
      --  What is automatically output when exception tracing is on is the
166
      --  usual exception information with the call chain backtrace possibly
167
      --  tailored by a backtrace decorator. Modifying Exception_Information
168
      --  itself is not a good idea because the decorated output is completely
169
      --  out of control and would break all our code related to the streaming
170
      --  of exceptions.  We then provide an alternative function to compute
171
      --  the possibly tailored output, which is equivalent if no decorator is
172
      --  currently set:
173
 
174
      function Tailored_Exception_Information
175
        (X : Exception_Occurrence) return String;
176
      --  Exception information to be output in the case of automatic tracing
177
      --  requested through GNAT.Exception_Traces.
178
      --
179
      --  This is the same as Exception_Information if no backtrace decorator
180
      --  is currently in place. Otherwise, this is Exception_Information with
181
      --  the call chain raw addresses replaced by the result of a call to the
182
      --  current decorator provided with the call chain addresses.
183
 
184
      pragma Export
185
        (Ada, Tailored_Exception_Information,
186
           "__gnat_tailored_exception_information");
187
      --  This is currently used by System.Tasking.Stages
188
 
189
   end Exception_Data;
190
 
191
   package Exception_Traces is
192
 
193
      use Exception_Data;
194
      --  Imports Tailored_Exception_Information
195
 
196
      ----------------------------------------------
197
      -- Run-Time Exception Notification Routines --
198
      ----------------------------------------------
199
 
200
      --  These subprograms provide a common run-time interface to trigger the
201
      --  actions required when an exception is about to be propagated (e.g.
202
      --  user specified actions or output of exception information). They are
203
      --  exported to be usable by the Ada exception handling personality
204
      --  routine when the GCC 3 mechanism is used.
205
 
206
      procedure Notify_Handled_Exception;
207
      pragma Export
208
        (C, Notify_Handled_Exception, "__gnat_notify_handled_exception");
209
      --  This routine is called for a handled occurrence is about to be
210
      --  propagated.
211
 
212
      procedure Notify_Unhandled_Exception;
213
      pragma Export
214
        (C, Notify_Unhandled_Exception, "__gnat_notify_unhandled_exception");
215
      --  This routine is called when an unhandled occurrence is about to be
216
      --  propagated.
217
 
218
      procedure Unhandled_Exception_Terminate;
219
      pragma No_Return (Unhandled_Exception_Terminate);
220
      --  This procedure is called to terminate execution following an
221
      --  unhandled exception. The exception information, including
222
      --  traceback if available is output, and execution is then
223
      --  terminated. Note that at the point where this routine is
224
      --  called, the stack has typically been destroyed.
225
 
226
   end Exception_Traces;
227
 
228
   package Exception_Propagation is
229
 
230
      use Exception_Traces;
231
      --  Imports Notify_Unhandled_Exception and
232
      --  Unhandled_Exception_Terminate
233
 
234
      ------------------------------------
235
      -- Exception propagation routines --
236
      ------------------------------------
237
 
238
      procedure Setup_Exception
239
        (Excep    : EOA;
240
         Current  : EOA;
241
         Reraised : Boolean := False);
242
      --  Perform the necessary operations to prepare the propagation of Excep
243
      --  in a task where Current is the current occurrence. Excep is assumed
244
      --  to be a valid (non null) pointer.
245
      --
246
      --  This should be called before any (re-)setting of the current
247
      --  occurrence. Any such (re-)setting shall take care *not* to clobber
248
      --  the Private_Data component.
249
      --
250
      --  Having Current provided as an argument (instead of retrieving it via
251
      --  Get_Current_Excep internally) is required to allow one task to setup
252
      --  an exception for another task, which is used by Transfer_Occurrence.
253
 
254
      procedure Propagate_Exception
255
        (E                   : Exception_Id;
256
         From_Signal_Handler : Boolean);
257
      pragma No_Return (Propagate_Exception);
258
      --  This procedure propagates the exception represented by the occurrence
259
      --  referenced by Current_Excep in the TSD for the current task.
260
 
261
   end Exception_Propagation;
262
 
263
   package Stream_Attributes is
264
 
265
      --------------------------------
266
      -- Stream attributes routines --
267
      --------------------------------
268
 
269
      function EId_To_String (X : Exception_Id) return String;
270
      function String_To_EId (S : String) return Exception_Id;
271
      --  Functions for implementing Exception_Id stream attributes
272
 
273
      function EO_To_String (X : Exception_Occurrence) return String;
274
      function String_To_EO (S : String) return Exception_Occurrence;
275
      --  Functions for implementing Exception_Occurrence stream
276
      --  attributes
277
 
278
   end Stream_Attributes;
279
 
280
   procedure Raise_Current_Excep (E : Exception_Id);
281
   pragma No_Return (Raise_Current_Excep);
282
   pragma Export (C, Raise_Current_Excep, "__gnat_raise_nodefer_with_msg");
283
   --  This is a simple wrapper to Exception_Propagation.Propagate_Exception
284
   --  setting the From_Signal_Handler argument to False.
285
   --
286
   --  This external name for Raise_Current_Excep is historical, and probably
287
   --  should be changed but for now we keep it, because gdb and gigi know
288
   --  about it.
289
 
290
   procedure Raise_Exception_No_Defer
291
      (E : Exception_Id; Message : String := "");
292
   pragma Export
293
    (Ada, Raise_Exception_No_Defer,
294
     "ada__exceptions__raise_exception_no_defer");
295
   pragma No_Return (Raise_Exception_No_Defer);
296
   --  Similar to Raise_Exception, but with no abort deferral
297
 
298
   procedure Raise_With_Msg (E : Exception_Id);
299
   pragma No_Return (Raise_With_Msg);
300
   pragma Export (C, Raise_With_Msg, "__gnat_raise_with_msg");
301
   --  Raises an exception with given exception id value. A message
302
   --  is associated with the raise, and has already been stored in the
303
   --  exception occurrence referenced by the Current_Excep in the TSD.
304
   --  Abort is deferred before the raise call.
305
 
306
   procedure Raise_With_Location_And_Msg
307
     (E : Exception_Id;
308
      F : System.Address;
309
      L : Integer;
310
      M : System.Address := System.Null_Address);
311
   pragma No_Return (Raise_With_Location_And_Msg);
312
   --  Raise an exception with given exception id value. A filename and line
313
   --  number is associated with the raise and is stored in the exception
314
   --  occurrence and in addition a string message M is appended to
315
   --  this (if M is not null).
316
 
317
   procedure Raise_Constraint_Error
318
     (File : System.Address;
319
      Line : Integer);
320
   pragma No_Return (Raise_Constraint_Error);
321
   pragma Export
322
     (C, Raise_Constraint_Error, "__gnat_raise_constraint_error");
323
   --  Raise constraint error with file:line information
324
 
325
   procedure Raise_Constraint_Error_Msg
326
     (File : System.Address;
327
      Line : Integer;
328
      Msg  : System.Address);
329
   pragma No_Return (Raise_Constraint_Error_Msg);
330
   pragma Export
331
     (C, Raise_Constraint_Error_Msg, "__gnat_raise_constraint_error_msg");
332
   --  Raise constraint error with file:line + msg information
333
 
334
   procedure Raise_Program_Error
335
     (File : System.Address;
336
      Line : Integer);
337
   pragma No_Return (Raise_Program_Error);
338
   pragma Export
339
     (C, Raise_Program_Error, "__gnat_raise_program_error");
340
   --  Raise program error with file:line information
341
 
342
   procedure Raise_Program_Error_Msg
343
     (File : System.Address;
344
      Line : Integer;
345
      Msg  : System.Address);
346
   pragma No_Return (Raise_Program_Error_Msg);
347
   pragma Export
348
     (C, Raise_Program_Error_Msg, "__gnat_raise_program_error_msg");
349
   --  Raise program error with file:line + msg information
350
 
351
   procedure Raise_Storage_Error
352
     (File : System.Address;
353
      Line : Integer);
354
   pragma No_Return (Raise_Storage_Error);
355
   pragma Export
356
     (C, Raise_Storage_Error, "__gnat_raise_storage_error");
357
   --  Raise storage error with file:line information
358
 
359
   procedure Raise_Storage_Error_Msg
360
     (File : System.Address;
361
      Line : Integer;
362
      Msg  : System.Address);
363
   pragma No_Return (Raise_Storage_Error_Msg);
364
   pragma Export
365
     (C, Raise_Storage_Error_Msg, "__gnat_raise_storage_error_msg");
366
   --  Raise storage error with file:line + reason msg information
367
 
368
   --  The exception raising process and the automatic tracing mechanism rely
369
   --  on some careful use of flags attached to the exception occurrence. The
370
   --  graph below illustrates the relations between the Raise_ subprograms
371
   --  and identifies the points where basic flags such as Exception_Raised
372
   --  are initialized.
373
   --
374
   --  (i) signs indicate the flags initialization points. R stands for Raise,
375
   --  W for With, and E for Exception.
376
   --
377
   --                   R_No_Msg    R_E   R_Pe  R_Ce  R_Se
378
   --                       |        |     |     |     |
379
   --                       +--+  +--+     +---+ | +---+
380
   --                          |  |            | | |
381
   --     R_E_No_Defer(i)    R_W_Msg(i)       R_W_Loc
382
   --           |               |              |   |
383
   --           +------------+  |  +-----------+   +--+
384
   --                        |  |  |                  |
385
   --                        |  |  |             Set_E_C_Msg(i)
386
   --                        |  |  |
387
   --                   Raise_Current_Excep
388
 
389
   procedure Reraise;
390
   pragma No_Return (Reraise);
391
   pragma Export (C, Reraise, "__gnat_reraise");
392
   --  Reraises the exception referenced by the Current_Excep field of
393
   --  the TSD (all fields of this exception occurrence are set). Abort
394
   --  is deferred before the reraise operation.
395
 
396
   --  Save_Occurrence variations: As the management of the private data
397
   --  attached to occurrences is delicate, whether or not pointers to such
398
   --  data has to be copied in various situations is better made explicit.
399
   --  The following procedures provide an internal interface to help making
400
   --  this explicit.
401
 
402
   procedure Save_Occurrence_No_Private
403
     (Target : out Exception_Occurrence;
404
      Source : Exception_Occurrence);
405
   --  Copy all the components of Source to Target, except the
406
   --  Private_Data pointer.
407
 
408
   procedure Transfer_Occurrence
409
     (Target : Exception_Occurrence_Access;
410
      Source : Exception_Occurrence);
411
   pragma Export (C, Transfer_Occurrence, "__gnat_transfer_occurrence");
412
   --  Called from System.Tasking.RendezVous.Exceptional_Complete_RendezVous
413
   --  to setup Target from Source as an exception to be propagated in the
414
   --  caller task. Target is expected to be a pointer to the fixed TSD
415
   --  occurrence for this task.
416
 
417
   -----------------------------
418
   -- Run-Time Check Routines --
419
   -----------------------------
420
 
421
   --  These routines raise a specific exception with a reason message
422
   --  attached. The parameters are the file name and line number in each
423
   --  case. The names are keyed to the codes defined in types.ads and
424
   --  a-types.h (for example, the name Rcheck_05 refers to the Reason
425
   --  RT_Exception_Code'Val (5)).
426
 
427
   procedure Rcheck_00 (File : System.Address; Line : Integer);
428
   procedure Rcheck_01 (File : System.Address; Line : Integer);
429
   procedure Rcheck_02 (File : System.Address; Line : Integer);
430
   procedure Rcheck_03 (File : System.Address; Line : Integer);
431
   procedure Rcheck_04 (File : System.Address; Line : Integer);
432
   procedure Rcheck_05 (File : System.Address; Line : Integer);
433
   procedure Rcheck_06 (File : System.Address; Line : Integer);
434
   procedure Rcheck_07 (File : System.Address; Line : Integer);
435
   procedure Rcheck_08 (File : System.Address; Line : Integer);
436
   procedure Rcheck_09 (File : System.Address; Line : Integer);
437
   procedure Rcheck_10 (File : System.Address; Line : Integer);
438
   procedure Rcheck_11 (File : System.Address; Line : Integer);
439
   procedure Rcheck_12 (File : System.Address; Line : Integer);
440
   procedure Rcheck_13 (File : System.Address; Line : Integer);
441
   procedure Rcheck_14 (File : System.Address; Line : Integer);
442
   procedure Rcheck_15 (File : System.Address; Line : Integer);
443
   procedure Rcheck_16 (File : System.Address; Line : Integer);
444
   procedure Rcheck_17 (File : System.Address; Line : Integer);
445
   procedure Rcheck_18 (File : System.Address; Line : Integer);
446
   procedure Rcheck_19 (File : System.Address; Line : Integer);
447
   procedure Rcheck_20 (File : System.Address; Line : Integer);
448
   procedure Rcheck_21 (File : System.Address; Line : Integer);
449
   procedure Rcheck_22 (File : System.Address; Line : Integer);
450
   procedure Rcheck_23 (File : System.Address; Line : Integer);
451
   procedure Rcheck_24 (File : System.Address; Line : Integer);
452
   procedure Rcheck_25 (File : System.Address; Line : Integer);
453
   procedure Rcheck_26 (File : System.Address; Line : Integer);
454
   procedure Rcheck_27 (File : System.Address; Line : Integer);
455
   procedure Rcheck_28 (File : System.Address; Line : Integer);
456
   procedure Rcheck_29 (File : System.Address; Line : Integer);
457
   procedure Rcheck_30 (File : System.Address; Line : Integer);
458
   procedure Rcheck_31 (File : System.Address; Line : Integer);
459
   procedure Rcheck_32 (File : System.Address; Line : Integer);
460
   procedure Rcheck_33 (File : System.Address; Line : Integer);
461
 
462
   pragma Export (C, Rcheck_00, "__gnat_rcheck_00");
463
   pragma Export (C, Rcheck_01, "__gnat_rcheck_01");
464
   pragma Export (C, Rcheck_02, "__gnat_rcheck_02");
465
   pragma Export (C, Rcheck_03, "__gnat_rcheck_03");
466
   pragma Export (C, Rcheck_04, "__gnat_rcheck_04");
467
   pragma Export (C, Rcheck_05, "__gnat_rcheck_05");
468
   pragma Export (C, Rcheck_06, "__gnat_rcheck_06");
469
   pragma Export (C, Rcheck_07, "__gnat_rcheck_07");
470
   pragma Export (C, Rcheck_08, "__gnat_rcheck_08");
471
   pragma Export (C, Rcheck_09, "__gnat_rcheck_09");
472
   pragma Export (C, Rcheck_10, "__gnat_rcheck_10");
473
   pragma Export (C, Rcheck_11, "__gnat_rcheck_11");
474
   pragma Export (C, Rcheck_12, "__gnat_rcheck_12");
475
   pragma Export (C, Rcheck_13, "__gnat_rcheck_13");
476
   pragma Export (C, Rcheck_14, "__gnat_rcheck_14");
477
   pragma Export (C, Rcheck_15, "__gnat_rcheck_15");
478
   pragma Export (C, Rcheck_16, "__gnat_rcheck_16");
479
   pragma Export (C, Rcheck_17, "__gnat_rcheck_17");
480
   pragma Export (C, Rcheck_18, "__gnat_rcheck_18");
481
   pragma Export (C, Rcheck_19, "__gnat_rcheck_19");
482
   pragma Export (C, Rcheck_20, "__gnat_rcheck_20");
483
   pragma Export (C, Rcheck_21, "__gnat_rcheck_21");
484
   pragma Export (C, Rcheck_22, "__gnat_rcheck_22");
485
   pragma Export (C, Rcheck_23, "__gnat_rcheck_23");
486
   pragma Export (C, Rcheck_24, "__gnat_rcheck_24");
487
   pragma Export (C, Rcheck_25, "__gnat_rcheck_25");
488
   pragma Export (C, Rcheck_26, "__gnat_rcheck_26");
489
   pragma Export (C, Rcheck_27, "__gnat_rcheck_27");
490
   pragma Export (C, Rcheck_28, "__gnat_rcheck_28");
491
   pragma Export (C, Rcheck_29, "__gnat_rcheck_29");
492
   pragma Export (C, Rcheck_30, "__gnat_rcheck_30");
493
   pragma Export (C, Rcheck_31, "__gnat_rcheck_31");
494
   pragma Export (C, Rcheck_32, "__gnat_rcheck_32");
495
   pragma Export (C, Rcheck_33, "__gnat_rcheck_33");
496
 
497
   --  None of these procedures ever returns (they raise an exception!). By
498
   --  using pragma No_Return, we ensure that any junk code after the call,
499
   --  such as normal return epilog stuff, can be eliminated).
500
 
501
   pragma No_Return (Rcheck_00);
502
   pragma No_Return (Rcheck_01);
503
   pragma No_Return (Rcheck_02);
504
   pragma No_Return (Rcheck_03);
505
   pragma No_Return (Rcheck_04);
506
   pragma No_Return (Rcheck_05);
507
   pragma No_Return (Rcheck_06);
508
   pragma No_Return (Rcheck_07);
509
   pragma No_Return (Rcheck_08);
510
   pragma No_Return (Rcheck_09);
511
   pragma No_Return (Rcheck_10);
512
   pragma No_Return (Rcheck_11);
513
   pragma No_Return (Rcheck_12);
514
   pragma No_Return (Rcheck_13);
515
   pragma No_Return (Rcheck_14);
516
   pragma No_Return (Rcheck_15);
517
   pragma No_Return (Rcheck_16);
518
   pragma No_Return (Rcheck_17);
519
   pragma No_Return (Rcheck_18);
520
   pragma No_Return (Rcheck_19);
521
   pragma No_Return (Rcheck_20);
522
   pragma No_Return (Rcheck_21);
523
   pragma No_Return (Rcheck_22);
524
   pragma No_Return (Rcheck_23);
525
   pragma No_Return (Rcheck_24);
526
   pragma No_Return (Rcheck_25);
527
   pragma No_Return (Rcheck_26);
528
   pragma No_Return (Rcheck_27);
529
   pragma No_Return (Rcheck_28);
530
   pragma No_Return (Rcheck_29);
531
   pragma No_Return (Rcheck_30);
532
   pragma No_Return (Rcheck_32);
533
   pragma No_Return (Rcheck_33);
534
 
535
   ---------------------------------------------
536
   -- Reason Strings for Run-Time Check Calls --
537
   ---------------------------------------------
538
 
539
   --  These strings are null-terminated and are used by Rcheck_nn. The
540
   --  strings correspond to the definitions for Types.RT_Exception_Code.
541
 
542
   use ASCII;
543
 
544
   Rmsg_00 : constant String := "access check failed"              & NUL;
545
   Rmsg_01 : constant String := "access parameter is null"         & NUL;
546
   Rmsg_02 : constant String := "discriminant check failed"        & NUL;
547
   Rmsg_03 : constant String := "divide by zero"                   & NUL;
548
   Rmsg_04 : constant String := "explicit raise"                   & NUL;
549
   Rmsg_05 : constant String := "index check failed"               & NUL;
550
   Rmsg_06 : constant String := "invalid data"                     & NUL;
551
   Rmsg_07 : constant String := "length check failed"              & NUL;
552
   Rmsg_08 : constant String := "null Exception_Id"                & NUL;
553
   Rmsg_09 : constant String := "null-exclusion check failed"      & NUL;
554
   Rmsg_10 : constant String := "overflow check failed"            & NUL;
555
   Rmsg_11 : constant String := "partition check failed"           & NUL;
556
   Rmsg_12 : constant String := "range check failed"               & NUL;
557
   Rmsg_13 : constant String := "tag check failed"                 & NUL;
558
   Rmsg_14 : constant String := "access before elaboration"        & NUL;
559
   Rmsg_15 : constant String := "accessibility check failed"       & NUL;
560
   Rmsg_16 : constant String := "attempt to take address of"       &
561
                                " intrinsic subprogram"            & NUL;
562
   Rmsg_17 : constant String := "all guards closed"                & NUL;
563
   Rmsg_18 : constant String := "Current_Task referenced in entry" &
564
                                " body"                            & NUL;
565
   Rmsg_19 : constant String := "duplicated entry address"         & NUL;
566
   Rmsg_20 : constant String := "explicit raise"                   & NUL;
567
   Rmsg_21 : constant String := "finalize/adjust raised exception" & NUL;
568
   Rmsg_22 : constant String := "implicit return with No_Return"   & NUL;
569
   Rmsg_23 : constant String := "misaligned address value"         & NUL;
570
   Rmsg_24 : constant String := "missing return"                   & NUL;
571
   Rmsg_25 : constant String := "overlaid controlled object"       & NUL;
572
   Rmsg_26 : constant String := "potentially blocking operation"   & NUL;
573
   Rmsg_27 : constant String := "stubbed subprogram called"        & NUL;
574
   Rmsg_28 : constant String := "unchecked union restriction"      & NUL;
575
   Rmsg_29 : constant String := "actual/returned class-wide"       &
576
                                " value not transportable"         & NUL;
577
   Rmsg_30 : constant String := "empty storage pool"               & NUL;
578
   Rmsg_31 : constant String := "explicit raise"                   & NUL;
579
   Rmsg_32 : constant String := "infinite recursion"               & NUL;
580
   Rmsg_33 : constant String := "object too large"                 & NUL;
581
 
582
   -----------------------
583
   -- Polling Interface --
584
   -----------------------
585
 
586
   type Unsigned is mod 2 ** 32;
587
 
588
   Counter : Unsigned := 0;
589
   pragma Warnings (Off, Counter);
590
   --  This counter is provided for convenience. It can be used in Poll to
591
   --  perform periodic but not systematic operations.
592
 
593
   procedure Poll is separate;
594
   --  The actual polling routine is separate, so that it can easily
595
   --  be replaced with a target dependent version.
596
 
597
   --------------------------
598
   -- Code_Address_For_AAA --
599
   --------------------------
600
 
601
   --  This function gives us the start of the PC range for addresses
602
   --  within the exception unit itself. We hope that gigi/gcc keep all the
603
   --  procedures in their original order!
604
 
605
   function Code_Address_For_AAA return System.Address is
606
   begin
607
      --  We are using a label instead of merely using
608
      --  Code_Address_For_AAA'Address because on some platforms the latter
609
      --  does not yield the address we want, but the address of a stub or of
610
      --  a descriptor instead. This is the case at least on Alpha-VMS and
611
      --  PA-HPUX.
612
 
613
      <<Start_Of_AAA>>
614
      return Start_Of_AAA'Address;
615
   end Code_Address_For_AAA;
616
 
617
   ----------------
618
   -- Call_Chain --
619
   ----------------
620
 
621
   procedure Call_Chain (Excep : EOA) is separate;
622
   --  The actual Call_Chain routine is separate, so that it can easily
623
   --  be dummied out when no exception traceback information is needed.
624
 
625
   ------------------------------
626
   -- Current_Target_Exception --
627
   ------------------------------
628
 
629
   function Current_Target_Exception return Exception_Occurrence is
630
   begin
631
      return Null_Occurrence;
632
   end Current_Target_Exception;
633
 
634
   -------------------
635
   -- EId_To_String --
636
   -------------------
637
 
638
   function EId_To_String (X : Exception_Id) return String
639
     renames Stream_Attributes.EId_To_String;
640
 
641
   ------------------
642
   -- EO_To_String --
643
   ------------------
644
 
645
   --  We use the null string to represent the null occurrence, otherwise
646
   --  we output the Exception_Information string for the occurrence.
647
 
648
   function EO_To_String (X : Exception_Occurrence) return String
649
     renames Stream_Attributes.EO_To_String;
650
 
651
   ------------------------
652
   -- Exception_Identity --
653
   ------------------------
654
 
655
   function Exception_Identity
656
     (X : Exception_Occurrence) return Exception_Id
657
   is
658
   begin
659
      --  Note that the following test used to be here for the original
660
      --  Ada 95 semantics, but these were modified by AI-241 to require
661
      --  returning Null_Id instead of raising Constraint_Error.
662
 
663
      --  if X.Id = Null_Id then
664
      --     raise Constraint_Error;
665
      --  end if;
666
 
667
      return X.Id;
668
   end Exception_Identity;
669
 
670
   ---------------------------
671
   -- Exception_Information --
672
   ---------------------------
673
 
674
   function Exception_Information (X : Exception_Occurrence) return String is
675
   begin
676
      if X.Id = Null_Id then
677
         raise Constraint_Error;
678
      end if;
679
 
680
      return Exception_Data.Exception_Information (X);
681
   end Exception_Information;
682
 
683
   -----------------------
684
   -- Exception_Message --
685
   -----------------------
686
 
687
   function Exception_Message (X : Exception_Occurrence) return String is
688
   begin
689
      if X.Id = Null_Id then
690
         raise Constraint_Error;
691
      end if;
692
 
693
      return X.Msg (1 .. X.Msg_Length);
694
   end Exception_Message;
695
 
696
   --------------------
697
   -- Exception_Name --
698
   --------------------
699
 
700
   function Exception_Name (Id : Exception_Id) return String is
701
   begin
702
      if Id = null then
703
         raise Constraint_Error;
704
      end if;
705
 
706
      return To_Ptr (Id.Full_Name) (1 .. Id.Name_Length - 1);
707
   end Exception_Name;
708
 
709
   function Exception_Name (X : Exception_Occurrence) return String is
710
   begin
711
      return Exception_Name (X.Id);
712
   end Exception_Name;
713
 
714
   ---------------------------
715
   -- Exception_Name_Simple --
716
   ---------------------------
717
 
718
   function Exception_Name_Simple (X : Exception_Occurrence) return String is
719
      Name : constant String := Exception_Name (X);
720
      P    : Natural;
721
 
722
   begin
723
      P := Name'Length;
724
      while P > 1 loop
725
         exit when Name (P - 1) = '.';
726
         P := P - 1;
727
      end loop;
728
 
729
      --  Return result making sure lower bound is 1
730
 
731
      declare
732
         subtype Rname is String (1 .. Name'Length - P + 1);
733
      begin
734
         return Rname (Name (P .. Name'Length));
735
      end;
736
   end Exception_Name_Simple;
737
 
738
   --------------------
739
   -- Exception_Data --
740
   --------------------
741
 
742
   package body Exception_Data is separate;
743
   --  This package can be easily dummied out if we do not want the
744
   --  basic support for exception messages (such as in Ada 83).
745
 
746
   ---------------------------
747
   -- Exception_Propagation --
748
   ---------------------------
749
 
750
   package body Exception_Propagation is separate;
751
   --  Depending on the actual exception mechanism used (front-end or
752
   --  back-end based), the implementation will differ, which is why this
753
   --  package is separated.
754
 
755
   ----------------------
756
   -- Exception_Traces --
757
   ----------------------
758
 
759
   package body Exception_Traces is separate;
760
   --  Depending on the underlying support for IO the implementation
761
   --  will differ. Moreover we would like to dummy out this package
762
   --  in case we do not want any exception tracing support. This is
763
   --  why this package is separated.
764
 
765
   -----------------------
766
   -- Stream Attributes --
767
   -----------------------
768
 
769
   package body Stream_Attributes is separate;
770
   --  This package can be easily dummied out if we do not want the
771
   --  support for streaming Exception_Ids and Exception_Occurrences.
772
 
773
   ----------------------------
774
   -- Raise_Constraint_Error --
775
   ----------------------------
776
 
777
   procedure Raise_Constraint_Error
778
     (File : System.Address;
779
      Line : Integer)
780
   is
781
   begin
782
      Raise_With_Location_And_Msg
783
        (Constraint_Error_Def'Access, File, Line);
784
   end Raise_Constraint_Error;
785
 
786
   --------------------------------
787
   -- Raise_Constraint_Error_Msg --
788
   --------------------------------
789
 
790
   procedure Raise_Constraint_Error_Msg
791
     (File : System.Address;
792
      Line : Integer;
793
      Msg  : System.Address)
794
   is
795
   begin
796
      Raise_With_Location_And_Msg
797
        (Constraint_Error_Def'Access, File, Line, Msg);
798
   end Raise_Constraint_Error_Msg;
799
 
800
   -------------------------
801
   -- Raise_Current_Excep --
802
   -------------------------
803
 
804
   procedure Raise_Current_Excep (E : Exception_Id) is
805
 
806
      pragma Inspection_Point (E);
807
      --  This is so the debugger can reliably inspect the parameter when
808
      --  inserting a breakpoint at the start of this procedure.
809
 
810
      --  To provide support for breakpoints on unhandled exceptions, the
811
      --  debugger will also need to be able to inspect the value of E from
812
      --  inner frames so we need to make sure that its value is also spilled
813
      --  on stack.  We take the address and dereference using volatile local
814
      --  objects for this purpose.
815
 
816
      --  The pragma Warnings (Off) are needed because the compiler knows that
817
      --  these locals are not referenced and that this use of pragma Volatile
818
      --  is peculiar!
819
 
820
      type EID_Access is access Exception_Id;
821
 
822
      Access_To_E : EID_Access := E'Unrestricted_Access;
823
      pragma Volatile (Access_To_E);
824
      pragma Warnings (Off, Access_To_E);
825
 
826
      Id : Exception_Id := Access_To_E.all;
827
      pragma Volatile (Id);
828
      pragma Warnings (Off, Id);
829
 
830
   begin
831
      Debug_Raise_Exception (E => SSL.Exception_Data_Ptr (E));
832
      Exception_Propagation.Propagate_Exception
833
        (E => E, From_Signal_Handler => False);
834
   end Raise_Current_Excep;
835
 
836
   ---------------------
837
   -- Raise_Exception --
838
   ---------------------
839
 
840
   procedure Raise_Exception
841
     (E       : Exception_Id;
842
      Message : String := "")
843
   is
844
      EF : Exception_Id := E;
845
 
846
   begin
847
      --  Raise CE if E = Null_ID (AI-446)
848
 
849
      if E = null then
850
         EF := Constraint_Error'Identity;
851
      end if;
852
 
853
      --  Go ahead and raise appropriate exception
854
 
855
      Exception_Data.Set_Exception_Msg (EF, Message);
856
      Abort_Defer.all;
857
      Raise_Current_Excep (EF);
858
   end Raise_Exception;
859
 
860
   ----------------------------
861
   -- Raise_Exception_Always --
862
   ----------------------------
863
 
864
   procedure Raise_Exception_Always
865
     (E       : Exception_Id;
866
      Message : String := "")
867
   is
868
   begin
869
      Exception_Data.Set_Exception_Msg (E, Message);
870
      Abort_Defer.all;
871
      Raise_Current_Excep (E);
872
   end Raise_Exception_Always;
873
 
874
   -------------------------------------
875
   -- Raise_From_Controlled_Operation --
876
   -------------------------------------
877
 
878
   procedure Raise_From_Controlled_Operation
879
     (X : Ada.Exceptions.Exception_Occurrence)
880
   is
881
      Prefix   : constant String := "adjust/finalize raised ";
882
      Orig_Msg : constant String := Exception_Message (X);
883
      New_Msg  : constant String := Prefix & Exception_Name (X);
884
 
885
   begin
886
      if Orig_Msg'Length >= Prefix'Length
887
        and then
888
          Orig_Msg (Orig_Msg'First .. Orig_Msg'First + Prefix'Length - 1) =
889
                                                                     Prefix
890
      then
891
         --  Message already has proper prefix, just re-reraise PROGRAM_ERROR
892
 
893
         Raise_Exception_No_Defer
894
           (E       => Program_Error'Identity,
895
            Message => Orig_Msg);
896
 
897
      elsif Orig_Msg = "" then
898
 
899
         --  No message present: just provide our own
900
 
901
         Raise_Exception_No_Defer
902
           (E       => Program_Error'Identity,
903
            Message => New_Msg);
904
 
905
      else
906
         --  Message present, add informational prefix
907
 
908
         Raise_Exception_No_Defer
909
           (E       => Program_Error'Identity,
910
            Message => New_Msg & ": " & Orig_Msg);
911
      end if;
912
   end Raise_From_Controlled_Operation;
913
 
914
   -------------------------------
915
   -- Raise_From_Signal_Handler --
916
   -------------------------------
917
 
918
   procedure Raise_From_Signal_Handler
919
     (E : Exception_Id;
920
      M : System.Address)
921
   is
922
   begin
923
      Exception_Data.Set_Exception_C_Msg (E, M);
924
      Abort_Defer.all;
925
      Exception_Propagation.Propagate_Exception
926
        (E => E, From_Signal_Handler => True);
927
   end Raise_From_Signal_Handler;
928
 
929
   -------------------------
930
   -- Raise_Program_Error --
931
   -------------------------
932
 
933
   procedure Raise_Program_Error
934
     (File : System.Address;
935
      Line : Integer)
936
   is
937
   begin
938
      Raise_With_Location_And_Msg
939
        (Program_Error_Def'Access, File, Line);
940
   end Raise_Program_Error;
941
 
942
   -----------------------------
943
   -- Raise_Program_Error_Msg --
944
   -----------------------------
945
 
946
   procedure Raise_Program_Error_Msg
947
     (File : System.Address;
948
      Line : Integer;
949
      Msg  : System.Address)
950
   is
951
   begin
952
      Raise_With_Location_And_Msg
953
        (Program_Error_Def'Access, File, Line, Msg);
954
   end Raise_Program_Error_Msg;
955
 
956
   -------------------------
957
   -- Raise_Storage_Error --
958
   -------------------------
959
 
960
   procedure Raise_Storage_Error
961
     (File : System.Address;
962
      Line : Integer)
963
   is
964
   begin
965
      Raise_With_Location_And_Msg
966
        (Storage_Error_Def'Access, File, Line);
967
   end Raise_Storage_Error;
968
 
969
   -----------------------------
970
   -- Raise_Storage_Error_Msg --
971
   -----------------------------
972
 
973
   procedure Raise_Storage_Error_Msg
974
     (File : System.Address;
975
      Line : Integer;
976
      Msg  : System.Address)
977
   is
978
   begin
979
      Raise_With_Location_And_Msg
980
        (Storage_Error_Def'Access, File, Line, Msg);
981
   end Raise_Storage_Error_Msg;
982
 
983
   ---------------------------------
984
   -- Raise_With_Location_And_Msg --
985
   ---------------------------------
986
 
987
   procedure Raise_With_Location_And_Msg
988
     (E : Exception_Id;
989
      F : System.Address;
990
      L : Integer;
991
      M : System.Address := System.Null_Address)
992
   is
993
   begin
994
      Exception_Data.Set_Exception_C_Msg (E, F, L, M);
995
      Abort_Defer.all;
996
      Raise_Current_Excep (E);
997
   end Raise_With_Location_And_Msg;
998
 
999
   --------------------
1000
   -- Raise_With_Msg --
1001
   --------------------
1002
 
1003
   procedure Raise_With_Msg (E : Exception_Id) is
1004
      Excep : constant EOA := Get_Current_Excep.all;
1005
 
1006
   begin
1007
      Exception_Propagation.Setup_Exception (Excep, Excep);
1008
 
1009
      Excep.Exception_Raised := False;
1010
      Excep.Id               := E;
1011
      Excep.Num_Tracebacks   := 0;
1012
      Excep.Cleanup_Flag     := False;
1013
      Excep.Pid              := Local_Partition_ID;
1014
      Abort_Defer.all;
1015
      Raise_Current_Excep (E);
1016
   end Raise_With_Msg;
1017
 
1018
   --------------------------------------
1019
   -- Calls to Run-Time Check Routines --
1020
   --------------------------------------
1021
 
1022
   procedure Rcheck_00 (File : System.Address; Line : Integer) is
1023
   begin
1024
      Raise_Constraint_Error_Msg (File, Line, Rmsg_00'Address);
1025
   end Rcheck_00;
1026
 
1027
   procedure Rcheck_01 (File : System.Address; Line : Integer) is
1028
   begin
1029
      Raise_Constraint_Error_Msg (File, Line, Rmsg_01'Address);
1030
   end Rcheck_01;
1031
 
1032
   procedure Rcheck_02 (File : System.Address; Line : Integer) is
1033
   begin
1034
      Raise_Constraint_Error_Msg (File, Line, Rmsg_02'Address);
1035
   end Rcheck_02;
1036
 
1037
   procedure Rcheck_03 (File : System.Address; Line : Integer) is
1038
   begin
1039
      Raise_Constraint_Error_Msg (File, Line, Rmsg_03'Address);
1040
   end Rcheck_03;
1041
 
1042
   procedure Rcheck_04 (File : System.Address; Line : Integer) is
1043
   begin
1044
      Raise_Constraint_Error_Msg (File, Line, Rmsg_04'Address);
1045
   end Rcheck_04;
1046
 
1047
   procedure Rcheck_05 (File : System.Address; Line : Integer) is
1048
   begin
1049
      Raise_Constraint_Error_Msg (File, Line, Rmsg_05'Address);
1050
   end Rcheck_05;
1051
 
1052
   procedure Rcheck_06 (File : System.Address; Line : Integer) is
1053
   begin
1054
      Raise_Constraint_Error_Msg (File, Line, Rmsg_06'Address);
1055
   end Rcheck_06;
1056
 
1057
   procedure Rcheck_07 (File : System.Address; Line : Integer) is
1058
   begin
1059
      Raise_Constraint_Error_Msg (File, Line, Rmsg_07'Address);
1060
   end Rcheck_07;
1061
 
1062
   procedure Rcheck_08 (File : System.Address; Line : Integer) is
1063
   begin
1064
      Raise_Constraint_Error_Msg (File, Line, Rmsg_08'Address);
1065
   end Rcheck_08;
1066
 
1067
   procedure Rcheck_09 (File : System.Address; Line : Integer) is
1068
   begin
1069
      Raise_Constraint_Error_Msg (File, Line, Rmsg_09'Address);
1070
   end Rcheck_09;
1071
 
1072
   procedure Rcheck_10 (File : System.Address; Line : Integer) is
1073
   begin
1074
      Raise_Constraint_Error_Msg (File, Line, Rmsg_10'Address);
1075
   end Rcheck_10;
1076
 
1077
   procedure Rcheck_11 (File : System.Address; Line : Integer) is
1078
   begin
1079
      Raise_Constraint_Error_Msg (File, Line, Rmsg_11'Address);
1080
   end Rcheck_11;
1081
 
1082
   procedure Rcheck_12 (File : System.Address; Line : Integer) is
1083
   begin
1084
      Raise_Constraint_Error_Msg (File, Line, Rmsg_12'Address);
1085
   end Rcheck_12;
1086
 
1087
   procedure Rcheck_13 (File : System.Address; Line : Integer) is
1088
   begin
1089
      Raise_Constraint_Error_Msg (File, Line, Rmsg_13'Address);
1090
   end Rcheck_13;
1091
 
1092
   procedure Rcheck_14 (File : System.Address; Line : Integer) is
1093
   begin
1094
      Raise_Program_Error_Msg (File, Line, Rmsg_14'Address);
1095
   end Rcheck_14;
1096
 
1097
   procedure Rcheck_15 (File : System.Address; Line : Integer) is
1098
   begin
1099
      Raise_Program_Error_Msg (File, Line, Rmsg_15'Address);
1100
   end Rcheck_15;
1101
 
1102
   procedure Rcheck_16 (File : System.Address; Line : Integer) is
1103
   begin
1104
      Raise_Program_Error_Msg (File, Line, Rmsg_16'Address);
1105
   end Rcheck_16;
1106
 
1107
   procedure Rcheck_17 (File : System.Address; Line : Integer) is
1108
   begin
1109
      Raise_Program_Error_Msg (File, Line, Rmsg_17'Address);
1110
   end Rcheck_17;
1111
 
1112
   procedure Rcheck_18 (File : System.Address; Line : Integer) is
1113
   begin
1114
      Raise_Program_Error_Msg (File, Line, Rmsg_18'Address);
1115
   end Rcheck_18;
1116
 
1117
   procedure Rcheck_19 (File : System.Address; Line : Integer) is
1118
   begin
1119
      Raise_Program_Error_Msg (File, Line, Rmsg_19'Address);
1120
   end Rcheck_19;
1121
 
1122
   procedure Rcheck_20 (File : System.Address; Line : Integer) is
1123
   begin
1124
      Raise_Program_Error_Msg (File, Line, Rmsg_20'Address);
1125
   end Rcheck_20;
1126
 
1127
   procedure Rcheck_21 (File : System.Address; Line : Integer) is
1128
   begin
1129
      Raise_Program_Error_Msg (File, Line, Rmsg_21'Address);
1130
   end Rcheck_21;
1131
 
1132
   procedure Rcheck_22 (File : System.Address; Line : Integer) is
1133
   begin
1134
      Raise_Program_Error_Msg (File, Line, Rmsg_22'Address);
1135
   end Rcheck_22;
1136
 
1137
   procedure Rcheck_23 (File : System.Address; Line : Integer) is
1138
   begin
1139
      Raise_Program_Error_Msg (File, Line, Rmsg_23'Address);
1140
   end Rcheck_23;
1141
 
1142
   procedure Rcheck_24 (File : System.Address; Line : Integer) is
1143
   begin
1144
      Raise_Program_Error_Msg (File, Line, Rmsg_24'Address);
1145
   end Rcheck_24;
1146
 
1147
   procedure Rcheck_25 (File : System.Address; Line : Integer) is
1148
   begin
1149
      Raise_Program_Error_Msg (File, Line, Rmsg_25'Address);
1150
   end Rcheck_25;
1151
 
1152
   procedure Rcheck_26 (File : System.Address; Line : Integer) is
1153
   begin
1154
      Raise_Program_Error_Msg (File, Line, Rmsg_26'Address);
1155
   end Rcheck_26;
1156
 
1157
   procedure Rcheck_27 (File : System.Address; Line : Integer) is
1158
   begin
1159
      Raise_Program_Error_Msg (File, Line, Rmsg_27'Address);
1160
   end Rcheck_27;
1161
 
1162
   procedure Rcheck_28 (File : System.Address; Line : Integer) is
1163
   begin
1164
      Raise_Program_Error_Msg (File, Line, Rmsg_28'Address);
1165
   end Rcheck_28;
1166
 
1167
   procedure Rcheck_29 (File : System.Address; Line : Integer) is
1168
   begin
1169
      Raise_Program_Error_Msg (File, Line, Rmsg_29'Address);
1170
   end Rcheck_29;
1171
 
1172
   procedure Rcheck_30 (File : System.Address; Line : Integer) is
1173
   begin
1174
      Raise_Storage_Error_Msg (File, Line, Rmsg_30'Address);
1175
   end Rcheck_30;
1176
 
1177
   procedure Rcheck_31 (File : System.Address; Line : Integer) is
1178
   begin
1179
      Raise_Storage_Error_Msg (File, Line, Rmsg_31'Address);
1180
   end Rcheck_31;
1181
 
1182
   procedure Rcheck_32 (File : System.Address; Line : Integer) is
1183
   begin
1184
      Raise_Storage_Error_Msg (File, Line, Rmsg_32'Address);
1185
   end Rcheck_32;
1186
 
1187
   procedure Rcheck_33 (File : System.Address; Line : Integer) is
1188
   begin
1189
      Raise_Storage_Error_Msg (File, Line, Rmsg_33'Address);
1190
   end Rcheck_33;
1191
 
1192
   -------------
1193
   -- Reraise --
1194
   -------------
1195
 
1196
   procedure Reraise is
1197
      Excep : constant EOA := Get_Current_Excep.all;
1198
 
1199
   begin
1200
      Abort_Defer.all;
1201
      Exception_Propagation.Setup_Exception (Excep, Excep, Reraised => True);
1202
      Raise_Current_Excep (Excep.Id);
1203
   end Reraise;
1204
 
1205
   ------------------------
1206
   -- Reraise_Occurrence --
1207
   ------------------------
1208
 
1209
   procedure Reraise_Occurrence (X : Exception_Occurrence) is
1210
   begin
1211
      if X.Id /= null then
1212
         Abort_Defer.all;
1213
         Exception_Propagation.Setup_Exception
1214
           (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1215
         Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1216
         Raise_Current_Excep (X.Id);
1217
      end if;
1218
   end Reraise_Occurrence;
1219
 
1220
   -------------------------------
1221
   -- Reraise_Occurrence_Always --
1222
   -------------------------------
1223
 
1224
   procedure Reraise_Occurrence_Always (X : Exception_Occurrence) is
1225
   begin
1226
      Abort_Defer.all;
1227
      Exception_Propagation.Setup_Exception
1228
        (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1229
      Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1230
      Raise_Current_Excep (X.Id);
1231
   end Reraise_Occurrence_Always;
1232
 
1233
   ---------------------------------
1234
   -- Reraise_Occurrence_No_Defer --
1235
   ---------------------------------
1236
 
1237
   procedure Reraise_Occurrence_No_Defer (X : Exception_Occurrence) is
1238
   begin
1239
      Exception_Propagation.Setup_Exception
1240
        (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1241
      Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1242
      Raise_Current_Excep (X.Id);
1243
   end Reraise_Occurrence_No_Defer;
1244
 
1245
   ---------------------
1246
   -- Save_Occurrence --
1247
   ---------------------
1248
 
1249
   procedure Save_Occurrence
1250
     (Target : out Exception_Occurrence;
1251
      Source : Exception_Occurrence)
1252
   is
1253
   begin
1254
      Save_Occurrence_No_Private (Target, Source);
1255
   end Save_Occurrence;
1256
 
1257
   function Save_Occurrence (Source : Exception_Occurrence) return EOA is
1258
      Target : constant EOA := new Exception_Occurrence;
1259
   begin
1260
      Save_Occurrence (Target.all, Source);
1261
      return Target;
1262
   end Save_Occurrence;
1263
 
1264
   --------------------------------
1265
   -- Save_Occurrence_No_Private --
1266
   --------------------------------
1267
 
1268
   procedure Save_Occurrence_No_Private
1269
     (Target : out Exception_Occurrence;
1270
      Source : Exception_Occurrence)
1271
   is
1272
   begin
1273
      Target.Id             := Source.Id;
1274
      Target.Msg_Length     := Source.Msg_Length;
1275
      Target.Num_Tracebacks := Source.Num_Tracebacks;
1276
      Target.Pid            := Source.Pid;
1277
      Target.Cleanup_Flag   := Source.Cleanup_Flag;
1278
 
1279
      Target.Msg (1 .. Target.Msg_Length) :=
1280
        Source.Msg (1 .. Target.Msg_Length);
1281
 
1282
      Target.Tracebacks (1 .. Target.Num_Tracebacks) :=
1283
        Source.Tracebacks (1 .. Target.Num_Tracebacks);
1284
   end Save_Occurrence_No_Private;
1285
 
1286
   -------------------------
1287
   -- Transfer_Occurrence --
1288
   -------------------------
1289
 
1290
   procedure Transfer_Occurrence
1291
     (Target : Exception_Occurrence_Access;
1292
      Source : Exception_Occurrence)
1293
   is
1294
   begin
1295
      --  Setup Target as an exception to be propagated in the calling task
1296
      --  (rendezvous-wise), taking care not to clobber the associated private
1297
      --  data.  Target is expected to be a pointer to the calling task's
1298
      --  fixed TSD occurrence, which is very different from Get_Current_Excep
1299
      --  here because this subprogram is called from the called task.
1300
 
1301
      Exception_Propagation.Setup_Exception (Target, Target);
1302
      Save_Occurrence_No_Private (Target.all, Source);
1303
   end Transfer_Occurrence;
1304
 
1305
   -------------------
1306
   -- String_To_EId --
1307
   -------------------
1308
 
1309
   function String_To_EId (S : String) return Exception_Id
1310
     renames Stream_Attributes.String_To_EId;
1311
 
1312
   ------------------
1313
   -- String_To_EO --
1314
   ------------------
1315
 
1316
   function String_To_EO (S : String) return Exception_Occurrence
1317
     renames Stream_Attributes.String_To_EO;
1318
 
1319
   ------------------------------
1320
   -- Raise_Exception_No_Defer --
1321
   ------------------------------
1322
 
1323
   procedure Raise_Exception_No_Defer
1324
     (E       : Exception_Id;
1325
      Message : String := "")
1326
   is
1327
   begin
1328
      Exception_Data.Set_Exception_Msg (E, Message);
1329
 
1330
      --  Do not call Abort_Defer.all, as specified by the spec
1331
 
1332
      Raise_Current_Excep (E);
1333
   end Raise_Exception_No_Defer;
1334
 
1335
   ---------------
1336
   -- To_Stderr --
1337
   ---------------
1338
 
1339
   procedure To_Stderr (C : Character) is
1340
 
1341
      type int is new Integer;
1342
 
1343
      procedure put_char_stderr (C : int);
1344
      pragma Import (C, put_char_stderr, "put_char_stderr");
1345
 
1346
   begin
1347
      put_char_stderr (Character'Pos (C));
1348
   end To_Stderr;
1349
 
1350
   procedure To_Stderr (S : String) is
1351
   begin
1352
      for J in S'Range loop
1353
         if S (J) /= ASCII.CR then
1354
            To_Stderr (S (J));
1355
         end if;
1356
      end loop;
1357
   end To_Stderr;
1358
 
1359
   -------------------------
1360
   -- Wide_Exception_Name --
1361
   -------------------------
1362
 
1363
   WC_Encoding : Character;
1364
   pragma Import (C, WC_Encoding, "__gl_wc_encoding");
1365
   --  Encoding method for source, as exported by binder
1366
 
1367
   function Wide_Exception_Name
1368
     (Id : Exception_Id) return Wide_String
1369
   is
1370
      S : constant String := Exception_Name (Id);
1371
      W : Wide_String (1 .. S'Length);
1372
      L : Natural;
1373
   begin
1374
      String_To_Wide_String
1375
        (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1376
      return W (1 .. L);
1377
   end Wide_Exception_Name;
1378
 
1379
   function Wide_Exception_Name
1380
     (X : Exception_Occurrence) return Wide_String
1381
   is
1382
      S : constant String := Exception_Name (X);
1383
      W : Wide_String (1 .. S'Length);
1384
      L : Natural;
1385
   begin
1386
      String_To_Wide_String
1387
        (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1388
      return W (1 .. L);
1389
   end Wide_Exception_Name;
1390
 
1391
   ----------------------------
1392
   -- Wide_Wide_Exception_Name --
1393
   -----------------------------
1394
 
1395
   function Wide_Wide_Exception_Name
1396
     (Id : Exception_Id) return Wide_Wide_String
1397
   is
1398
      S : constant String := Exception_Name (Id);
1399
      W : Wide_Wide_String (1 .. S'Length);
1400
      L : Natural;
1401
   begin
1402
      String_To_Wide_Wide_String
1403
        (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1404
      return W (1 .. L);
1405
   end Wide_Wide_Exception_Name;
1406
 
1407
   function Wide_Wide_Exception_Name
1408
     (X : Exception_Occurrence) return Wide_Wide_String
1409
   is
1410
      S : constant String := Exception_Name (X);
1411
      W : Wide_Wide_String (1 .. S'Length);
1412
      L : Natural;
1413
   begin
1414
      String_To_Wide_Wide_String
1415
        (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1416
      return W (1 .. L);
1417
   end Wide_Wide_Exception_Name;
1418
 
1419
   --------------------------
1420
   -- Code_Address_For_ZZZ --
1421
   --------------------------
1422
 
1423
   --  This function gives us the end of the PC range for addresses
1424
   --  within the exception unit itself. We hope that gigi/gcc keeps all the
1425
   --  procedures in their original order!
1426
 
1427
   function Code_Address_For_ZZZ return System.Address is
1428
   begin
1429
      <<Start_Of_ZZZ>>
1430
      return Start_Of_ZZZ'Address;
1431
   end Code_Address_For_ZZZ;
1432
 
1433
end Ada.Exceptions;

powered by: WebSVN 2.1.0

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