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