Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / ada / a-except-2005.adb
blobcbf1e4deb89117509ef50fe0519c167b1e2d6eb4
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-2010, 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 ------------------------------------------------------------------------------
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.
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.
40 pragma Style_Checks (All_Checks);
41 -- No subprogram ordering check, due to logical grouping
43 pragma Polling (Off);
44 -- We must turn polling off for this unit, because otherwise we get
45 -- elaboration circularities with System.Exception_Tables.
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;
54 package body Ada.Exceptions is
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.
61 -----------------------
62 -- Local Subprograms --
63 -----------------------
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.
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
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.
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:
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.
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.
93 procedure Call_Chain (Excep : EOA);
94 -- Store up to Max_Tracebacks in Excep, corresponding to the current
95 -- call chain.
97 function Image (Index : Integer) return String;
98 -- Return string image corresponding to Index
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.
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.
111 package Exception_Data is
113 ---------------------------------
114 -- Exception messages routines --
115 ---------------------------------
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.
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.
139 --------------------------------------
140 -- Exception information subprogram --
141 --------------------------------------
143 function Exception_Information (X : Exception_Occurrence) return String;
144 -- The format of the exception information is as follows:
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)
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
158 -- The Exception_Name and Message lines are omitted in the abort
159 -- signal case, since this is not really an exception.
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.
165 ---------------------------------------
166 -- Exception backtracing subprograms --
167 ---------------------------------------
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:
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.
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.
188 pragma Export
189 (Ada, Tailored_Exception_Information,
190 "__gnat_tailored_exception_information");
191 -- This is currently used by System.Tasking.Stages
193 end Exception_Data;
195 package Exception_Traces is
197 use Exception_Data;
198 -- Imports Tailored_Exception_Information
200 ----------------------------------------------
201 -- Run-Time Exception Notification Routines --
202 ----------------------------------------------
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.
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.
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.
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.
230 end Exception_Traces;
232 package Exception_Propagation is
234 use Exception_Traces;
235 -- Imports Notify_Unhandled_Exception and
236 -- Unhandled_Exception_Terminate
238 ------------------------------------
239 -- Exception propagation routines --
240 ------------------------------------
242 procedure Setup_Exception
243 (Excep : EOA;
244 Current : EOA;
245 Reraised : Boolean := False);
246 -- Perform the necessary operations to prepare the propagation of Excep
247 -- in a task where Current is the current occurrence. Excep is assumed
248 -- to be a valid (non null) pointer.
250 -- This should be called before any (re-)setting of the current
251 -- occurrence. Any such (re-)setting shall take care *not* to clobber
252 -- the Private_Data component.
254 -- Having Current provided as an argument (instead of retrieving it via
255 -- Get_Current_Excep internally) is required to allow one task to setup
256 -- an exception for another task, which is used by Transfer_Occurrence.
258 procedure Propagate_Exception
259 (E : Exception_Id;
260 From_Signal_Handler : Boolean);
261 pragma No_Return (Propagate_Exception);
262 -- This procedure propagates the exception represented by the occurrence
263 -- referenced by Current_Excep in the TSD for the current task.
265 end Exception_Propagation;
267 package Stream_Attributes is
269 --------------------------------
270 -- Stream attributes routines --
271 --------------------------------
273 function EId_To_String (X : Exception_Id) return String;
274 function String_To_EId (S : String) return Exception_Id;
275 -- Functions for implementing Exception_Id stream attributes
277 function EO_To_String (X : Exception_Occurrence) return String;
278 function String_To_EO (S : String) return Exception_Occurrence;
279 -- Functions for implementing Exception_Occurrence stream
280 -- attributes
282 end Stream_Attributes;
284 procedure Raise_Current_Excep (E : Exception_Id);
285 pragma No_Return (Raise_Current_Excep);
286 pragma Export (C, Raise_Current_Excep, "__gnat_raise_nodefer_with_msg");
287 -- This is a simple wrapper to Exception_Propagation.Propagate_Exception
288 -- setting the From_Signal_Handler argument to False.
290 -- This external name for Raise_Current_Excep is historical, and probably
291 -- should be changed but for now we keep it, because gdb and gigi know
292 -- about it.
294 procedure Raise_Exception_No_Defer
295 (E : Exception_Id; Message : String := "");
296 pragma Export
297 (Ada, Raise_Exception_No_Defer,
298 "ada__exceptions__raise_exception_no_defer");
299 pragma No_Return (Raise_Exception_No_Defer);
300 -- Similar to Raise_Exception, but with no abort deferral
302 procedure Raise_With_Msg (E : Exception_Id);
303 pragma No_Return (Raise_With_Msg);
304 pragma Export (C, Raise_With_Msg, "__gnat_raise_with_msg");
305 -- Raises an exception with given exception id value. A message
306 -- is associated with the raise, and has already been stored in the
307 -- exception occurrence referenced by the Current_Excep in the TSD.
308 -- Abort is deferred before the raise call.
310 procedure Raise_With_Location_And_Msg
311 (E : Exception_Id;
312 F : System.Address;
313 L : Integer;
314 C : Integer := 0;
315 M : System.Address := System.Null_Address);
316 pragma No_Return (Raise_With_Location_And_Msg);
317 -- Raise an exception with given exception id value. A filename and line
318 -- number is associated with the raise and is stored in the exception
319 -- occurrence and in addition a column and a string message M may be
320 -- appended to this (if not null/0).
322 procedure Raise_Constraint_Error
323 (File : System.Address;
324 Line : Integer);
325 pragma No_Return (Raise_Constraint_Error);
326 pragma Export
327 (C, Raise_Constraint_Error, "__gnat_raise_constraint_error");
328 -- Raise constraint error with file:line information
330 procedure Raise_Constraint_Error_Msg
331 (File : System.Address;
332 Line : Integer;
333 Column : Integer;
334 Msg : System.Address);
335 pragma No_Return (Raise_Constraint_Error_Msg);
336 pragma Export
337 (C, Raise_Constraint_Error_Msg, "__gnat_raise_constraint_error_msg");
338 -- Raise constraint error with file:line:col + msg information
340 procedure Raise_Program_Error
341 (File : System.Address;
342 Line : Integer);
343 pragma No_Return (Raise_Program_Error);
344 pragma Export
345 (C, Raise_Program_Error, "__gnat_raise_program_error");
346 -- Raise program error with file:line information
348 procedure Raise_Program_Error_Msg
349 (File : System.Address;
350 Line : Integer;
351 Msg : System.Address);
352 pragma No_Return (Raise_Program_Error_Msg);
353 pragma Export
354 (C, Raise_Program_Error_Msg, "__gnat_raise_program_error_msg");
355 -- Raise program error with file:line + msg information
357 procedure Raise_Storage_Error
358 (File : System.Address;
359 Line : Integer);
360 pragma No_Return (Raise_Storage_Error);
361 pragma Export
362 (C, Raise_Storage_Error, "__gnat_raise_storage_error");
363 -- Raise storage error with file:line information
365 procedure Raise_Storage_Error_Msg
366 (File : System.Address;
367 Line : Integer;
368 Msg : System.Address);
369 pragma No_Return (Raise_Storage_Error_Msg);
370 pragma Export
371 (C, Raise_Storage_Error_Msg, "__gnat_raise_storage_error_msg");
372 -- Raise storage error with file:line + reason msg information
374 -- The exception raising process and the automatic tracing mechanism rely
375 -- on some careful use of flags attached to the exception occurrence. The
376 -- graph below illustrates the relations between the Raise_ subprograms
377 -- and identifies the points where basic flags such as Exception_Raised
378 -- are initialized.
380 -- (i) signs indicate the flags initialization points. R stands for Raise,
381 -- W for With, and E for Exception.
383 -- R_No_Msg R_E R_Pe R_Ce R_Se
384 -- | | | | |
385 -- +--+ +--+ +---+ | +---+
386 -- | | | | |
387 -- R_E_No_Defer(i) R_W_Msg(i) R_W_Loc
388 -- | | | |
389 -- +------------+ | +-----------+ +--+
390 -- | | | |
391 -- | | | Set_E_C_Msg(i)
392 -- | | |
393 -- Raise_Current_Excep
395 procedure Reraise;
396 pragma No_Return (Reraise);
397 pragma Export (C, Reraise, "__gnat_reraise");
398 -- Reraises the exception referenced by the Current_Excep field of
399 -- the TSD (all fields of this exception occurrence are set). Abort
400 -- is deferred before the reraise operation.
402 -- Save_Occurrence variations: As the management of the private data
403 -- attached to occurrences is delicate, whether or not pointers to such
404 -- data has to be copied in various situations is better made explicit.
405 -- The following procedures provide an internal interface to help making
406 -- this explicit.
408 procedure Save_Occurrence_No_Private
409 (Target : out Exception_Occurrence;
410 Source : Exception_Occurrence);
411 -- Copy all the components of Source to Target, except the
412 -- Private_Data pointer.
414 procedure Transfer_Occurrence
415 (Target : Exception_Occurrence_Access;
416 Source : Exception_Occurrence);
417 pragma Export (C, Transfer_Occurrence, "__gnat_transfer_occurrence");
418 -- Called from System.Tasking.RendezVous.Exceptional_Complete_RendezVous
419 -- to setup Target from Source as an exception to be propagated in the
420 -- caller task. Target is expected to be a pointer to the fixed TSD
421 -- occurrence for this task.
423 -----------------------------
424 -- Run-Time Check Routines --
425 -----------------------------
427 -- These routines raise a specific exception with a reason message
428 -- attached. The parameters are the file name and line number in each
429 -- case. The names are keyed to the codes defined in types.ads and
430 -- a-types.h (for example, the name Rcheck_05 refers to the Reason
431 -- RT_Exception_Code'Val (5)).
433 procedure Rcheck_00 (File : System.Address; Line : Integer);
434 procedure Rcheck_01 (File : System.Address; Line : Integer);
435 procedure Rcheck_02 (File : System.Address; Line : Integer);
436 procedure Rcheck_03 (File : System.Address; Line : Integer);
437 procedure Rcheck_04 (File : System.Address; Line : Integer);
438 procedure Rcheck_05 (File : System.Address; Line : Integer);
439 procedure Rcheck_06 (File : System.Address; Line : Integer);
440 procedure Rcheck_07 (File : System.Address; Line : Integer);
441 procedure Rcheck_08 (File : System.Address; Line : Integer);
442 procedure Rcheck_09 (File : System.Address; Line : Integer);
443 procedure Rcheck_10 (File : System.Address; Line : Integer);
444 procedure Rcheck_11 (File : System.Address; Line : Integer);
445 procedure Rcheck_12 (File : System.Address; Line : Integer);
446 procedure Rcheck_13 (File : System.Address; Line : Integer);
447 procedure Rcheck_14 (File : System.Address; Line : Integer);
448 procedure Rcheck_15 (File : System.Address; Line : Integer);
449 procedure Rcheck_16 (File : System.Address; Line : Integer);
450 procedure Rcheck_17 (File : System.Address; Line : Integer);
451 procedure Rcheck_18 (File : System.Address; Line : Integer);
452 procedure Rcheck_19 (File : System.Address; Line : Integer);
453 procedure Rcheck_20 (File : System.Address; Line : Integer);
454 procedure Rcheck_21 (File : System.Address; Line : Integer);
455 procedure Rcheck_22 (File : System.Address; Line : Integer);
456 procedure Rcheck_23 (File : System.Address; Line : Integer);
457 procedure Rcheck_24 (File : System.Address; Line : Integer);
458 procedure Rcheck_25 (File : System.Address; Line : Integer);
459 procedure Rcheck_26 (File : System.Address; Line : Integer);
460 procedure Rcheck_27 (File : System.Address; Line : Integer);
461 procedure Rcheck_28 (File : System.Address; Line : Integer);
462 procedure Rcheck_29 (File : System.Address; Line : Integer);
463 procedure Rcheck_30 (File : System.Address; Line : Integer);
464 procedure Rcheck_31 (File : System.Address; Line : Integer);
465 procedure Rcheck_32 (File : System.Address; Line : Integer);
466 procedure Rcheck_33 (File : System.Address; Line : Integer);
467 procedure Rcheck_34 (File : System.Address; Line : Integer);
469 procedure Rcheck_00_Ext
470 (File : System.Address; Line, Column : Integer);
471 procedure Rcheck_05_Ext
472 (File : System.Address; Line, Column, Index, First, Last : Integer);
473 procedure Rcheck_06_Ext
474 (File : System.Address; Line, Column, Index, First, Last : Integer);
475 procedure Rcheck_12_Ext
476 (File : System.Address; Line, Column, Index, First, Last : Integer);
478 pragma Export (C, Rcheck_00, "__gnat_rcheck_00");
479 pragma Export (C, Rcheck_01, "__gnat_rcheck_01");
480 pragma Export (C, Rcheck_02, "__gnat_rcheck_02");
481 pragma Export (C, Rcheck_03, "__gnat_rcheck_03");
482 pragma Export (C, Rcheck_04, "__gnat_rcheck_04");
483 pragma Export (C, Rcheck_05, "__gnat_rcheck_05");
484 pragma Export (C, Rcheck_06, "__gnat_rcheck_06");
485 pragma Export (C, Rcheck_07, "__gnat_rcheck_07");
486 pragma Export (C, Rcheck_08, "__gnat_rcheck_08");
487 pragma Export (C, Rcheck_09, "__gnat_rcheck_09");
488 pragma Export (C, Rcheck_10, "__gnat_rcheck_10");
489 pragma Export (C, Rcheck_11, "__gnat_rcheck_11");
490 pragma Export (C, Rcheck_12, "__gnat_rcheck_12");
491 pragma Export (C, Rcheck_13, "__gnat_rcheck_13");
492 pragma Export (C, Rcheck_14, "__gnat_rcheck_14");
493 pragma Export (C, Rcheck_15, "__gnat_rcheck_15");
494 pragma Export (C, Rcheck_16, "__gnat_rcheck_16");
495 pragma Export (C, Rcheck_17, "__gnat_rcheck_17");
496 pragma Export (C, Rcheck_18, "__gnat_rcheck_18");
497 pragma Export (C, Rcheck_19, "__gnat_rcheck_19");
498 pragma Export (C, Rcheck_20, "__gnat_rcheck_20");
499 pragma Export (C, Rcheck_21, "__gnat_rcheck_21");
500 pragma Export (C, Rcheck_22, "__gnat_rcheck_22");
501 pragma Export (C, Rcheck_23, "__gnat_rcheck_23");
502 pragma Export (C, Rcheck_24, "__gnat_rcheck_24");
503 pragma Export (C, Rcheck_25, "__gnat_rcheck_25");
504 pragma Export (C, Rcheck_26, "__gnat_rcheck_26");
505 pragma Export (C, Rcheck_27, "__gnat_rcheck_27");
506 pragma Export (C, Rcheck_28, "__gnat_rcheck_28");
507 pragma Export (C, Rcheck_29, "__gnat_rcheck_29");
508 pragma Export (C, Rcheck_30, "__gnat_rcheck_30");
509 pragma Export (C, Rcheck_31, "__gnat_rcheck_31");
510 pragma Export (C, Rcheck_32, "__gnat_rcheck_32");
511 pragma Export (C, Rcheck_33, "__gnat_rcheck_33");
512 pragma Export (C, Rcheck_34, "__gnat_rcheck_34");
514 pragma Export (C, Rcheck_00_Ext, "__gnat_rcheck_00_ext");
515 pragma Export (C, Rcheck_05_Ext, "__gnat_rcheck_05_ext");
516 pragma Export (C, Rcheck_06_Ext, "__gnat_rcheck_06_ext");
517 pragma Export (C, Rcheck_12_Ext, "__gnat_rcheck_12_ext");
519 -- None of these procedures ever returns (they raise an exception!). By
520 -- using pragma No_Return, we ensure that any junk code after the call,
521 -- such as normal return epilog stuff, can be eliminated).
523 pragma No_Return (Rcheck_00);
524 pragma No_Return (Rcheck_01);
525 pragma No_Return (Rcheck_02);
526 pragma No_Return (Rcheck_03);
527 pragma No_Return (Rcheck_04);
528 pragma No_Return (Rcheck_05);
529 pragma No_Return (Rcheck_06);
530 pragma No_Return (Rcheck_07);
531 pragma No_Return (Rcheck_08);
532 pragma No_Return (Rcheck_09);
533 pragma No_Return (Rcheck_10);
534 pragma No_Return (Rcheck_11);
535 pragma No_Return (Rcheck_12);
536 pragma No_Return (Rcheck_13);
537 pragma No_Return (Rcheck_14);
538 pragma No_Return (Rcheck_15);
539 pragma No_Return (Rcheck_16);
540 pragma No_Return (Rcheck_17);
541 pragma No_Return (Rcheck_18);
542 pragma No_Return (Rcheck_19);
543 pragma No_Return (Rcheck_20);
544 pragma No_Return (Rcheck_21);
545 pragma No_Return (Rcheck_22);
546 pragma No_Return (Rcheck_23);
547 pragma No_Return (Rcheck_24);
548 pragma No_Return (Rcheck_25);
549 pragma No_Return (Rcheck_26);
550 pragma No_Return (Rcheck_27);
551 pragma No_Return (Rcheck_28);
552 pragma No_Return (Rcheck_29);
553 pragma No_Return (Rcheck_30);
554 pragma No_Return (Rcheck_32);
555 pragma No_Return (Rcheck_33);
556 pragma No_Return (Rcheck_34);
558 pragma No_Return (Rcheck_00_Ext);
559 pragma No_Return (Rcheck_05_Ext);
560 pragma No_Return (Rcheck_06_Ext);
561 pragma No_Return (Rcheck_12_Ext);
563 ---------------------------------------------
564 -- Reason Strings for Run-Time Check Calls --
565 ---------------------------------------------
567 -- These strings are null-terminated and are used by Rcheck_nn. The
568 -- strings correspond to the definitions for Types.RT_Exception_Code.
570 use ASCII;
572 Rmsg_00 : constant String := "access check failed" & NUL;
573 Rmsg_01 : constant String := "access parameter is null" & NUL;
574 Rmsg_02 : constant String := "discriminant check failed" & NUL;
575 Rmsg_03 : constant String := "divide by zero" & NUL;
576 Rmsg_04 : constant String := "explicit raise" & NUL;
577 Rmsg_05 : constant String := "index check failed" & NUL;
578 Rmsg_06 : constant String := "invalid data" & NUL;
579 Rmsg_07 : constant String := "length check failed" & NUL;
580 Rmsg_08 : constant String := "null Exception_Id" & NUL;
581 Rmsg_09 : constant String := "null-exclusion check failed" & NUL;
582 Rmsg_10 : constant String := "overflow check failed" & NUL;
583 Rmsg_11 : constant String := "partition check failed" & NUL;
584 Rmsg_12 : constant String := "range check failed" & NUL;
585 Rmsg_13 : constant String := "tag check failed" & NUL;
586 Rmsg_14 : constant String := "access before elaboration" & NUL;
587 Rmsg_15 : constant String := "accessibility check failed" & NUL;
588 Rmsg_16 : constant String := "attempt to take address of" &
589 " intrinsic subprogram" & NUL;
590 Rmsg_17 : constant String := "all guards closed" & NUL;
591 Rmsg_18 : constant String := "improper use of generic subtype" &
592 " with predicate" & NUL;
593 Rmsg_19 : constant String := "Current_Task referenced in entry" &
594 " body" & NUL;
595 Rmsg_20 : constant String := "duplicated entry address" & NUL;
596 Rmsg_21 : constant String := "explicit raise" & NUL;
597 Rmsg_22 : constant String := "finalize/adjust raised exception" & NUL;
598 Rmsg_23 : constant String := "implicit return with No_Return" & NUL;
599 Rmsg_24 : constant String := "misaligned address value" & NUL;
600 Rmsg_25 : constant String := "missing return" & NUL;
601 Rmsg_26 : constant String := "overlaid controlled object" & NUL;
602 Rmsg_27 : constant String := "potentially blocking operation" & NUL;
603 Rmsg_28 : constant String := "stubbed subprogram called" & NUL;
604 Rmsg_29 : constant String := "unchecked union restriction" & NUL;
605 Rmsg_30 : constant String := "actual/returned class-wide" &
606 " value not transportable" & NUL;
607 Rmsg_31 : constant String := "empty storage pool" & NUL;
608 Rmsg_32 : constant String := "explicit raise" & NUL;
609 Rmsg_33 : constant String := "infinite recursion" & NUL;
610 Rmsg_34 : constant String := "object too large" & NUL;
612 -----------------------
613 -- Polling Interface --
614 -----------------------
616 type Unsigned is mod 2 ** 32;
618 Counter : Unsigned := 0;
619 pragma Warnings (Off, Counter);
620 -- This counter is provided for convenience. It can be used in Poll to
621 -- perform periodic but not systematic operations.
623 procedure Poll is separate;
624 -- The actual polling routine is separate, so that it can easily
625 -- be replaced with a target dependent version.
627 --------------------------
628 -- Code_Address_For_AAA --
629 --------------------------
631 -- This function gives us the start of the PC range for addresses
632 -- within the exception unit itself. We hope that gigi/gcc keep all the
633 -- procedures in their original order!
635 function Code_Address_For_AAA return System.Address is
636 begin
637 -- We are using a label instead of merely using
638 -- Code_Address_For_AAA'Address because on some platforms the latter
639 -- does not yield the address we want, but the address of a stub or of
640 -- a descriptor instead. This is the case at least on Alpha-VMS and
641 -- PA-HPUX.
643 <<Start_Of_AAA>>
644 return Start_Of_AAA'Address;
645 end Code_Address_For_AAA;
647 ----------------
648 -- Call_Chain --
649 ----------------
651 procedure Call_Chain (Excep : EOA) is separate;
652 -- The actual Call_Chain routine is separate, so that it can easily
653 -- be dummied out when no exception traceback information is needed.
655 ------------------------------
656 -- Current_Target_Exception --
657 ------------------------------
659 function Current_Target_Exception return Exception_Occurrence is
660 begin
661 return Null_Occurrence;
662 end Current_Target_Exception;
664 -------------------
665 -- EId_To_String --
666 -------------------
668 function EId_To_String (X : Exception_Id) return String
669 renames Stream_Attributes.EId_To_String;
671 ------------------
672 -- EO_To_String --
673 ------------------
675 -- We use the null string to represent the null occurrence, otherwise
676 -- we output the Exception_Information string for the occurrence.
678 function EO_To_String (X : Exception_Occurrence) return String
679 renames Stream_Attributes.EO_To_String;
681 ------------------------
682 -- Exception_Identity --
683 ------------------------
685 function Exception_Identity
686 (X : Exception_Occurrence) return Exception_Id
688 begin
689 -- Note that the following test used to be here for the original
690 -- Ada 95 semantics, but these were modified by AI-241 to require
691 -- returning Null_Id instead of raising Constraint_Error.
693 -- if X.Id = Null_Id then
694 -- raise Constraint_Error;
695 -- end if;
697 return X.Id;
698 end Exception_Identity;
700 ---------------------------
701 -- Exception_Information --
702 ---------------------------
704 function Exception_Information (X : Exception_Occurrence) return String is
705 begin
706 if X.Id = Null_Id then
707 raise Constraint_Error;
708 end if;
710 return Exception_Data.Exception_Information (X);
711 end Exception_Information;
713 -----------------------
714 -- Exception_Message --
715 -----------------------
717 function Exception_Message (X : Exception_Occurrence) return String is
718 begin
719 if X.Id = Null_Id then
720 raise Constraint_Error;
721 end if;
723 return X.Msg (1 .. X.Msg_Length);
724 end Exception_Message;
726 --------------------
727 -- Exception_Name --
728 --------------------
730 function Exception_Name (Id : Exception_Id) return String is
731 begin
732 if Id = null then
733 raise Constraint_Error;
734 end if;
736 return To_Ptr (Id.Full_Name) (1 .. Id.Name_Length - 1);
737 end Exception_Name;
739 function Exception_Name (X : Exception_Occurrence) return String is
740 begin
741 return Exception_Name (X.Id);
742 end Exception_Name;
744 ---------------------------
745 -- Exception_Name_Simple --
746 ---------------------------
748 function Exception_Name_Simple (X : Exception_Occurrence) return String is
749 Name : constant String := Exception_Name (X);
750 P : Natural;
752 begin
753 P := Name'Length;
754 while P > 1 loop
755 exit when Name (P - 1) = '.';
756 P := P - 1;
757 end loop;
759 -- Return result making sure lower bound is 1
761 declare
762 subtype Rname is String (1 .. Name'Length - P + 1);
763 begin
764 return Rname (Name (P .. Name'Length));
765 end;
766 end Exception_Name_Simple;
768 --------------------
769 -- Exception_Data --
770 --------------------
772 package body Exception_Data is separate;
773 -- This package can be easily dummied out if we do not want the
774 -- basic support for exception messages (such as in Ada 83).
776 ---------------------------
777 -- Exception_Propagation --
778 ---------------------------
780 package body Exception_Propagation is separate;
781 -- Depending on the actual exception mechanism used (front-end or
782 -- back-end based), the implementation will differ, which is why this
783 -- package is separated.
785 ----------------------
786 -- Exception_Traces --
787 ----------------------
789 package body Exception_Traces is separate;
790 -- Depending on the underlying support for IO the implementation
791 -- will differ. Moreover we would like to dummy out this package
792 -- in case we do not want any exception tracing support. This is
793 -- why this package is separated.
795 -----------------------
796 -- Stream Attributes --
797 -----------------------
799 package body Stream_Attributes is separate;
800 -- This package can be easily dummied out if we do not want the
801 -- support for streaming Exception_Ids and Exception_Occurrences.
803 ----------------------------
804 -- Raise_Constraint_Error --
805 ----------------------------
807 procedure Raise_Constraint_Error (File : System.Address; Line : Integer) is
808 begin
809 Raise_With_Location_And_Msg (Constraint_Error_Def'Access, File, Line);
810 end Raise_Constraint_Error;
812 --------------------------------
813 -- Raise_Constraint_Error_Msg --
814 --------------------------------
816 procedure Raise_Constraint_Error_Msg
817 (File : System.Address;
818 Line : Integer;
819 Column : Integer;
820 Msg : System.Address)
822 begin
823 Raise_With_Location_And_Msg
824 (Constraint_Error_Def'Access, File, Line, Column, Msg);
825 end Raise_Constraint_Error_Msg;
827 -------------------------
828 -- Raise_Current_Excep --
829 -------------------------
831 procedure Raise_Current_Excep (E : Exception_Id) is
833 pragma Inspection_Point (E);
834 -- This is so the debugger can reliably inspect the parameter when
835 -- inserting a breakpoint at the start of this procedure.
837 -- To provide support for breakpoints on unhandled exceptions, the
838 -- debugger will also need to be able to inspect the value of E from
839 -- inner frames so we need to make sure that its value is also spilled
840 -- on stack. We take the address and dereference using volatile local
841 -- objects for this purpose.
843 -- The pragma Warnings (Off) are needed because the compiler knows that
844 -- these locals are not referenced and that this use of pragma Volatile
845 -- is peculiar!
847 type EID_Access is access Exception_Id;
849 Access_To_E : EID_Access := E'Unrestricted_Access;
850 pragma Volatile (Access_To_E);
851 pragma Warnings (Off, Access_To_E);
853 Id : Exception_Id := Access_To_E.all;
854 pragma Volatile (Id);
855 pragma Warnings (Off, Id);
857 begin
858 Debug_Raise_Exception (E => SSL.Exception_Data_Ptr (E));
859 Exception_Propagation.Propagate_Exception
860 (E => E, From_Signal_Handler => False);
861 end Raise_Current_Excep;
863 ---------------------
864 -- Raise_Exception --
865 ---------------------
867 procedure Raise_Exception
868 (E : Exception_Id;
869 Message : String := "")
871 EF : Exception_Id := E;
873 begin
874 -- Raise CE if E = Null_ID (AI-446)
876 if E = null then
877 EF := Constraint_Error'Identity;
878 end if;
880 -- Go ahead and raise appropriate exception
882 Exception_Data.Set_Exception_Msg (EF, Message);
883 Abort_Defer.all;
884 Raise_Current_Excep (EF);
885 end Raise_Exception;
887 ----------------------------
888 -- Raise_Exception_Always --
889 ----------------------------
891 procedure Raise_Exception_Always
892 (E : Exception_Id;
893 Message : String := "")
895 begin
896 Exception_Data.Set_Exception_Msg (E, Message);
897 Abort_Defer.all;
898 Raise_Current_Excep (E);
899 end Raise_Exception_Always;
901 -------------------------------------
902 -- Raise_From_Controlled_Operation --
903 -------------------------------------
905 procedure Raise_From_Controlled_Operation
906 (X : Ada.Exceptions.Exception_Occurrence)
908 Prefix : constant String := "adjust/finalize raised ";
909 Orig_Msg : constant String := Exception_Message (X);
910 New_Msg : constant String := Prefix & Exception_Name (X);
912 begin
913 if Orig_Msg'Length >= Prefix'Length
914 and then
915 Orig_Msg (Orig_Msg'First .. Orig_Msg'First + Prefix'Length - 1) =
916 Prefix
917 then
918 -- Message already has proper prefix, just re-reraise PROGRAM_ERROR
920 Raise_Exception_No_Defer
921 (E => Program_Error'Identity,
922 Message => Orig_Msg);
924 elsif Orig_Msg = "" then
926 -- No message present: just provide our own
928 Raise_Exception_No_Defer
929 (E => Program_Error'Identity,
930 Message => New_Msg);
932 else
933 -- Message present, add informational prefix
935 Raise_Exception_No_Defer
936 (E => Program_Error'Identity,
937 Message => New_Msg & ": " & Orig_Msg);
938 end if;
939 end Raise_From_Controlled_Operation;
941 -------------------------------
942 -- Raise_From_Signal_Handler --
943 -------------------------------
945 procedure Raise_From_Signal_Handler
946 (E : Exception_Id;
947 M : System.Address)
949 begin
950 Exception_Data.Set_Exception_C_Msg (E, M);
951 Abort_Defer.all;
952 Exception_Propagation.Propagate_Exception
953 (E => E, From_Signal_Handler => True);
954 end Raise_From_Signal_Handler;
956 -------------------------
957 -- Raise_Program_Error --
958 -------------------------
960 procedure Raise_Program_Error
961 (File : System.Address;
962 Line : Integer)
964 begin
965 Raise_With_Location_And_Msg (Program_Error_Def'Access, File, Line);
966 end Raise_Program_Error;
968 -----------------------------
969 -- Raise_Program_Error_Msg --
970 -----------------------------
972 procedure Raise_Program_Error_Msg
973 (File : System.Address;
974 Line : Integer;
975 Msg : System.Address)
977 begin
978 Raise_With_Location_And_Msg
979 (Program_Error_Def'Access, File, Line, M => Msg);
980 end Raise_Program_Error_Msg;
982 -------------------------
983 -- Raise_Storage_Error --
984 -------------------------
986 procedure Raise_Storage_Error
987 (File : System.Address;
988 Line : Integer)
990 begin
991 Raise_With_Location_And_Msg (Storage_Error_Def'Access, File, Line);
992 end Raise_Storage_Error;
994 -----------------------------
995 -- Raise_Storage_Error_Msg --
996 -----------------------------
998 procedure Raise_Storage_Error_Msg
999 (File : System.Address;
1000 Line : Integer;
1001 Msg : System.Address)
1003 begin
1004 Raise_With_Location_And_Msg
1005 (Storage_Error_Def'Access, File, Line, M => Msg);
1006 end Raise_Storage_Error_Msg;
1008 ---------------------------------
1009 -- Raise_With_Location_And_Msg --
1010 ---------------------------------
1012 procedure Raise_With_Location_And_Msg
1013 (E : Exception_Id;
1014 F : System.Address;
1015 L : Integer;
1016 C : Integer := 0;
1017 M : System.Address := System.Null_Address)
1019 begin
1020 Exception_Data.Set_Exception_C_Msg (E, F, L, C, M);
1021 Abort_Defer.all;
1022 Raise_Current_Excep (E);
1023 end Raise_With_Location_And_Msg;
1025 --------------------
1026 -- Raise_With_Msg --
1027 --------------------
1029 procedure Raise_With_Msg (E : Exception_Id) is
1030 Excep : constant EOA := Get_Current_Excep.all;
1032 begin
1033 Exception_Propagation.Setup_Exception (Excep, Excep);
1035 Excep.Exception_Raised := False;
1036 Excep.Id := E;
1037 Excep.Num_Tracebacks := 0;
1038 Excep.Cleanup_Flag := False;
1039 Excep.Pid := Local_Partition_ID;
1040 Abort_Defer.all;
1041 Raise_Current_Excep (E);
1042 end Raise_With_Msg;
1044 -----------
1045 -- Image --
1046 -----------
1048 function Image (Index : Integer) return String is
1049 Result : constant String := Integer'Image (Index);
1050 begin
1051 if Result (1) = ' ' then
1052 return Result (2 .. Result'Last);
1053 else
1054 return Result;
1055 end if;
1056 end Image;
1058 --------------------------------------
1059 -- Calls to Run-Time Check Routines --
1060 --------------------------------------
1062 procedure Rcheck_00 (File : System.Address; Line : Integer) is
1063 begin
1064 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_00'Address);
1065 end Rcheck_00;
1067 procedure Rcheck_01 (File : System.Address; Line : Integer) is
1068 begin
1069 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_01'Address);
1070 end Rcheck_01;
1072 procedure Rcheck_02 (File : System.Address; Line : Integer) is
1073 begin
1074 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_02'Address);
1075 end Rcheck_02;
1077 procedure Rcheck_03 (File : System.Address; Line : Integer) is
1078 begin
1079 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_03'Address);
1080 end Rcheck_03;
1082 procedure Rcheck_04 (File : System.Address; Line : Integer) is
1083 begin
1084 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_04'Address);
1085 end Rcheck_04;
1087 procedure Rcheck_05 (File : System.Address; Line : Integer) is
1088 begin
1089 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_05'Address);
1090 end Rcheck_05;
1092 procedure Rcheck_06 (File : System.Address; Line : Integer) is
1093 begin
1094 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_06'Address);
1095 end Rcheck_06;
1097 procedure Rcheck_07 (File : System.Address; Line : Integer) is
1098 begin
1099 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_07'Address);
1100 end Rcheck_07;
1102 procedure Rcheck_08 (File : System.Address; Line : Integer) is
1103 begin
1104 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_08'Address);
1105 end Rcheck_08;
1107 procedure Rcheck_09 (File : System.Address; Line : Integer) is
1108 begin
1109 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_09'Address);
1110 end Rcheck_09;
1112 procedure Rcheck_10 (File : System.Address; Line : Integer) is
1113 begin
1114 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_10'Address);
1115 end Rcheck_10;
1117 procedure Rcheck_11 (File : System.Address; Line : Integer) is
1118 begin
1119 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_11'Address);
1120 end Rcheck_11;
1122 procedure Rcheck_12 (File : System.Address; Line : Integer) is
1123 begin
1124 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_12'Address);
1125 end Rcheck_12;
1127 procedure Rcheck_13 (File : System.Address; Line : Integer) is
1128 begin
1129 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_13'Address);
1130 end Rcheck_13;
1132 procedure Rcheck_14 (File : System.Address; Line : Integer) is
1133 begin
1134 Raise_Program_Error_Msg (File, Line, Rmsg_14'Address);
1135 end Rcheck_14;
1137 procedure Rcheck_15 (File : System.Address; Line : Integer) is
1138 begin
1139 Raise_Program_Error_Msg (File, Line, Rmsg_15'Address);
1140 end Rcheck_15;
1142 procedure Rcheck_16 (File : System.Address; Line : Integer) is
1143 begin
1144 Raise_Program_Error_Msg (File, Line, Rmsg_16'Address);
1145 end Rcheck_16;
1147 procedure Rcheck_17 (File : System.Address; Line : Integer) is
1148 begin
1149 Raise_Program_Error_Msg (File, Line, Rmsg_17'Address);
1150 end Rcheck_17;
1152 procedure Rcheck_18 (File : System.Address; Line : Integer) is
1153 begin
1154 Raise_Program_Error_Msg (File, Line, Rmsg_18'Address);
1155 end Rcheck_18;
1157 procedure Rcheck_19 (File : System.Address; Line : Integer) is
1158 begin
1159 Raise_Program_Error_Msg (File, Line, Rmsg_19'Address);
1160 end Rcheck_19;
1162 procedure Rcheck_20 (File : System.Address; Line : Integer) is
1163 begin
1164 Raise_Program_Error_Msg (File, Line, Rmsg_20'Address);
1165 end Rcheck_20;
1167 procedure Rcheck_21 (File : System.Address; Line : Integer) is
1168 begin
1169 Raise_Program_Error_Msg (File, Line, Rmsg_21'Address);
1170 end Rcheck_21;
1172 procedure Rcheck_22 (File : System.Address; Line : Integer) is
1173 begin
1174 Raise_Program_Error_Msg (File, Line, Rmsg_22'Address);
1175 end Rcheck_22;
1177 procedure Rcheck_23 (File : System.Address; Line : Integer) is
1178 begin
1179 Raise_Program_Error_Msg (File, Line, Rmsg_23'Address);
1180 end Rcheck_23;
1182 procedure Rcheck_24 (File : System.Address; Line : Integer) is
1183 begin
1184 Raise_Program_Error_Msg (File, Line, Rmsg_24'Address);
1185 end Rcheck_24;
1187 procedure Rcheck_25 (File : System.Address; Line : Integer) is
1188 begin
1189 Raise_Program_Error_Msg (File, Line, Rmsg_25'Address);
1190 end Rcheck_25;
1192 procedure Rcheck_26 (File : System.Address; Line : Integer) is
1193 begin
1194 Raise_Program_Error_Msg (File, Line, Rmsg_26'Address);
1195 end Rcheck_26;
1197 procedure Rcheck_27 (File : System.Address; Line : Integer) is
1198 begin
1199 Raise_Program_Error_Msg (File, Line, Rmsg_27'Address);
1200 end Rcheck_27;
1202 procedure Rcheck_28 (File : System.Address; Line : Integer) is
1203 begin
1204 Raise_Program_Error_Msg (File, Line, Rmsg_28'Address);
1205 end Rcheck_28;
1207 procedure Rcheck_29 (File : System.Address; Line : Integer) is
1208 begin
1209 Raise_Program_Error_Msg (File, Line, Rmsg_29'Address);
1210 end Rcheck_29;
1212 procedure Rcheck_30 (File : System.Address; Line : Integer) is
1213 begin
1214 Raise_Program_Error_Msg (File, Line, Rmsg_30'Address);
1215 end Rcheck_30;
1217 procedure Rcheck_31 (File : System.Address; Line : Integer) is
1218 begin
1219 Raise_Storage_Error_Msg (File, Line, Rmsg_31'Address);
1220 end Rcheck_31;
1222 procedure Rcheck_32 (File : System.Address; Line : Integer) is
1223 begin
1224 Raise_Storage_Error_Msg (File, Line, Rmsg_32'Address);
1225 end Rcheck_32;
1227 procedure Rcheck_33 (File : System.Address; Line : Integer) is
1228 begin
1229 Raise_Storage_Error_Msg (File, Line, Rmsg_33'Address);
1230 end Rcheck_33;
1232 procedure Rcheck_34 (File : System.Address; Line : Integer) is
1233 begin
1234 Raise_Storage_Error_Msg (File, Line, Rmsg_34'Address);
1235 end Rcheck_34;
1237 procedure Rcheck_00_Ext (File : System.Address; Line, Column : Integer) is
1238 begin
1239 Raise_Constraint_Error_Msg (File, Line, Column, Rmsg_00'Address);
1240 end Rcheck_00_Ext;
1242 procedure Rcheck_05_Ext
1243 (File : System.Address; Line, Column, Index, First, Last : Integer)
1245 Msg : constant String :=
1246 Rmsg_05 (Rmsg_05'First .. Rmsg_05'Last - 1) & ASCII.LF &
1247 "index " & Image (Index) & " not in " & Image (First) &
1248 ".." & Image (Last) & ASCII.NUL;
1249 begin
1250 Raise_Constraint_Error_Msg (File, Line, Column, Msg'Address);
1251 end Rcheck_05_Ext;
1253 procedure Rcheck_06_Ext
1254 (File : System.Address; Line, Column, Index, First, Last : Integer)
1256 Msg : constant String :=
1257 Rmsg_06 (Rmsg_06'First .. Rmsg_06'Last - 1) & ASCII.LF &
1258 "value " & Image (Index) & " not in " & Image (First) &
1259 ".." & Image (Last) & ASCII.NUL;
1260 begin
1261 Raise_Constraint_Error_Msg (File, Line, Column, Msg'Address);
1262 end Rcheck_06_Ext;
1264 procedure Rcheck_12_Ext
1265 (File : System.Address; Line, Column, Index, First, Last : Integer)
1267 Msg : constant String :=
1268 Rmsg_12 (Rmsg_12'First .. Rmsg_12'Last - 1) & ASCII.LF &
1269 "value " & Image (Index) & " not in " & Image (First) &
1270 ".." & Image (Last) & ASCII.NUL;
1271 begin
1272 Raise_Constraint_Error_Msg (File, Line, Column, Msg'Address);
1273 end Rcheck_12_Ext;
1275 -------------
1276 -- Reraise --
1277 -------------
1279 procedure Reraise is
1280 Excep : constant EOA := Get_Current_Excep.all;
1281 begin
1282 Abort_Defer.all;
1283 Exception_Propagation.Setup_Exception (Excep, Excep, Reraised => True);
1284 Raise_Current_Excep (Excep.Id);
1285 end Reraise;
1287 ------------------------
1288 -- Reraise_Occurrence --
1289 ------------------------
1291 procedure Reraise_Occurrence (X : Exception_Occurrence) is
1292 begin
1293 if X.Id /= null then
1294 Abort_Defer.all;
1295 Exception_Propagation.Setup_Exception
1296 (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1297 Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1298 Raise_Current_Excep (X.Id);
1299 end if;
1300 end Reraise_Occurrence;
1302 -------------------------------
1303 -- Reraise_Occurrence_Always --
1304 -------------------------------
1306 procedure Reraise_Occurrence_Always (X : Exception_Occurrence) is
1307 begin
1308 Abort_Defer.all;
1309 Exception_Propagation.Setup_Exception
1310 (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1311 Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1312 Raise_Current_Excep (X.Id);
1313 end Reraise_Occurrence_Always;
1315 ---------------------------------
1316 -- Reraise_Occurrence_No_Defer --
1317 ---------------------------------
1319 procedure Reraise_Occurrence_No_Defer (X : Exception_Occurrence) is
1320 begin
1321 Exception_Propagation.Setup_Exception
1322 (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1323 Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1324 Raise_Current_Excep (X.Id);
1325 end Reraise_Occurrence_No_Defer;
1327 ---------------------
1328 -- Save_Occurrence --
1329 ---------------------
1331 procedure Save_Occurrence
1332 (Target : out Exception_Occurrence;
1333 Source : Exception_Occurrence)
1335 begin
1336 Save_Occurrence_No_Private (Target, Source);
1337 end Save_Occurrence;
1339 function Save_Occurrence (Source : Exception_Occurrence) return EOA is
1340 Target : constant EOA := new Exception_Occurrence;
1341 begin
1342 Save_Occurrence (Target.all, Source);
1343 return Target;
1344 end Save_Occurrence;
1346 --------------------------------
1347 -- Save_Occurrence_No_Private --
1348 --------------------------------
1350 procedure Save_Occurrence_No_Private
1351 (Target : out Exception_Occurrence;
1352 Source : Exception_Occurrence)
1354 begin
1355 Target.Id := Source.Id;
1356 Target.Msg_Length := Source.Msg_Length;
1357 Target.Num_Tracebacks := Source.Num_Tracebacks;
1358 Target.Pid := Source.Pid;
1359 Target.Cleanup_Flag := Source.Cleanup_Flag;
1361 Target.Msg (1 .. Target.Msg_Length) :=
1362 Source.Msg (1 .. Target.Msg_Length);
1364 Target.Tracebacks (1 .. Target.Num_Tracebacks) :=
1365 Source.Tracebacks (1 .. Target.Num_Tracebacks);
1366 end Save_Occurrence_No_Private;
1368 -------------------------
1369 -- Transfer_Occurrence --
1370 -------------------------
1372 procedure Transfer_Occurrence
1373 (Target : Exception_Occurrence_Access;
1374 Source : Exception_Occurrence)
1376 begin
1377 -- Setup Target as an exception to be propagated in the calling task
1378 -- (rendezvous-wise), taking care not to clobber the associated private
1379 -- data. Target is expected to be a pointer to the calling task's
1380 -- fixed TSD occurrence, which is very different from Get_Current_Excep
1381 -- here because this subprogram is called from the called task.
1383 Exception_Propagation.Setup_Exception (Target, Target);
1384 Save_Occurrence_No_Private (Target.all, Source);
1385 end Transfer_Occurrence;
1387 -------------------
1388 -- String_To_EId --
1389 -------------------
1391 function String_To_EId (S : String) return Exception_Id
1392 renames Stream_Attributes.String_To_EId;
1394 ------------------
1395 -- String_To_EO --
1396 ------------------
1398 function String_To_EO (S : String) return Exception_Occurrence
1399 renames Stream_Attributes.String_To_EO;
1401 ------------------------------
1402 -- Raise_Exception_No_Defer --
1403 ------------------------------
1405 procedure Raise_Exception_No_Defer
1406 (E : Exception_Id;
1407 Message : String := "")
1409 begin
1410 Exception_Data.Set_Exception_Msg (E, Message);
1412 -- Do not call Abort_Defer.all, as specified by the spec
1414 Raise_Current_Excep (E);
1415 end Raise_Exception_No_Defer;
1417 ---------------
1418 -- To_Stderr --
1419 ---------------
1421 procedure To_Stderr (C : Character) is
1422 type int is new Integer;
1424 procedure put_char_stderr (C : int);
1425 pragma Import (C, put_char_stderr, "put_char_stderr");
1427 begin
1428 put_char_stderr (Character'Pos (C));
1429 end To_Stderr;
1431 procedure To_Stderr (S : String) is
1432 begin
1433 for J in S'Range loop
1434 if S (J) /= ASCII.CR then
1435 To_Stderr (S (J));
1436 end if;
1437 end loop;
1438 end To_Stderr;
1440 -------------------------
1441 -- Wide_Exception_Name --
1442 -------------------------
1444 WC_Encoding : Character;
1445 pragma Import (C, WC_Encoding, "__gl_wc_encoding");
1446 -- Encoding method for source, as exported by binder
1448 function Wide_Exception_Name
1449 (Id : Exception_Id) return Wide_String
1451 S : constant String := Exception_Name (Id);
1452 W : Wide_String (1 .. S'Length);
1453 L : Natural;
1454 begin
1455 String_To_Wide_String
1456 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1457 return W (1 .. L);
1458 end Wide_Exception_Name;
1460 function Wide_Exception_Name
1461 (X : Exception_Occurrence) return Wide_String
1463 S : constant String := Exception_Name (X);
1464 W : Wide_String (1 .. S'Length);
1465 L : Natural;
1466 begin
1467 String_To_Wide_String
1468 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1469 return W (1 .. L);
1470 end Wide_Exception_Name;
1472 ----------------------------
1473 -- Wide_Wide_Exception_Name --
1474 -----------------------------
1476 function Wide_Wide_Exception_Name
1477 (Id : Exception_Id) return Wide_Wide_String
1479 S : constant String := Exception_Name (Id);
1480 W : Wide_Wide_String (1 .. S'Length);
1481 L : Natural;
1482 begin
1483 String_To_Wide_Wide_String
1484 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1485 return W (1 .. L);
1486 end Wide_Wide_Exception_Name;
1488 function Wide_Wide_Exception_Name
1489 (X : Exception_Occurrence) return Wide_Wide_String
1491 S : constant String := Exception_Name (X);
1492 W : Wide_Wide_String (1 .. S'Length);
1493 L : Natural;
1494 begin
1495 String_To_Wide_Wide_String
1496 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1497 return W (1 .. L);
1498 end Wide_Wide_Exception_Name;
1500 --------------------------
1501 -- Code_Address_For_ZZZ --
1502 --------------------------
1504 -- This function gives us the end of the PC range for addresses
1505 -- within the exception unit itself. We hope that gigi/gcc keeps all the
1506 -- procedures in their original order!
1508 function Code_Address_For_ZZZ return System.Address is
1509 begin
1510 <<Start_Of_ZZZ>>
1511 return Start_Of_ZZZ'Address;
1512 end Code_Address_For_ZZZ;
1514 end Ada.Exceptions;