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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [a-except.adb] - Blame information for rev 708

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

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

powered by: WebSVN 2.1.0

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