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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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