1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- A D A . E X C E P T I O N S --
9 -- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
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
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.Exceptions_Debug; use System.Exceptions_Debug;
50 with System.Standard_Library; use System.Standard_Library;
51 with System.Soft_Links; use System.Soft_Links;
52 with System.WCh_Con; use System.WCh_Con;
53 with System.WCh_StW; use System.WCh_StW;
55 package body Ada.Exceptions is
57 pragma Suppress (All_Checks);
58 -- We definitely do not want exceptions occurring within this unit, or
59 -- we are in big trouble. If an exceptional situation does occur, better
60 -- that it not be raised, since raising it can cause confusing chaos.
62 -----------------------
63 -- Local Subprograms --
64 -----------------------
66 -- Note: the exported subprograms in this package body are called directly
67 -- from C clients using the given external name, even though they are not
68 -- technically visible in the Ada sense.
70 function Code_Address_For_AAA return System.Address;
71 function Code_Address_For_ZZZ return System.Address;
72 -- Return start and end of procedures in this package
74 -- These procedures are used to provide exclusion bounds in
75 -- calls to Call_Chain at exception raise points from this unit. The
76 -- purpose is to arrange for the exception tracebacks not to include
77 -- frames from routines involved in the raise process, as these are
78 -- meaningless from the user's standpoint.
80 -- For these bounds to be meaningful, we need to ensure that the object
81 -- code for the routines involved in processing a raise is located after
82 -- the object code Code_Address_For_AAA and before the object code
83 -- Code_Address_For_ZZZ. This will indeed be the case as long as the
84 -- following rules are respected:
86 -- 1) The bodies of the subprograms involved in processing a raise
87 -- are located after the body of Code_Address_For_AAA and before the
88 -- body of Code_Address_For_ZZZ.
90 -- 2) No pragma Inline applies to any of these subprograms, as this
91 -- could delay the corresponding assembly output until the end of
94 procedure Call_Chain (Excep : EOA);
95 -- Store up to Max_Tracebacks in Excep, corresponding to the current
98 function Image (Index : Integer) return String;
99 -- Return string image corresponding to Index
101 procedure To_Stderr (S : String);
102 pragma Export (Ada, To_Stderr, "__gnat_to_stderr");
103 -- Little routine to output string to stderr that is also used
104 -- in the tasking run time.
106 procedure To_Stderr (C : Character);
107 pragma Inline (To_Stderr);
108 pragma Export (Ada, To_Stderr, "__gnat_to_stderr_char");
109 -- Little routine to output a character to stderr, used by some of
110 -- the separate units below.
112 package Exception_Data is
114 ---------------------------------
115 -- Exception messages routines --
116 ---------------------------------
118 procedure Set_Exception_C_Msg
120 Msg1 : System.Address;
122 Column : Integer := 0;
123 Msg2 : System.Address := System.Null_Address);
124 -- This routine is called to setup the exception referenced by the
125 -- Current_Excep field in the TSD to contain the indicated Id value
126 -- and message. Msg1 is a null terminated string which is generated
127 -- as the exception message. If line is non-zero, then a colon and
128 -- the decimal representation of this integer is appended to the
129 -- message. Ditto for Column. When Msg2 is non-null, a space and this
130 -- additional null terminated string is added to the message.
132 procedure Set_Exception_Msg
135 -- This routine is called to setup the exception referenced by the
136 -- Current_Excep field in the TSD to contain the indicated Id value
137 -- and message. Message is a string which is generated as the
138 -- exception message.
140 --------------------------------------
141 -- Exception information subprogram --
142 --------------------------------------
144 function Exception_Information (X : Exception_Occurrence) return String;
145 -- The format of the exception information is as follows:
147 -- Exception_Name: <exception name> (as in Exception_Name)
148 -- Message: <message> (only if Exception_Message is empty)
149 -- PID=nnnn (only if != 0)
150 -- Call stack traceback locations: (only if at least one location)
151 -- <0xyyyyyyyy 0xyyyyyyyy ...> (is recorded)
153 -- The lines are separated by a ASCII.LF character.
154 -- The nnnn is the partition Id given as decimal digits.
155 -- The 0x... line represents traceback program counter locations, in
156 -- execution order with the first one being the exception location. It
159 -- The Exception_Name and Message lines are omitted in the abort
160 -- signal case, since this is not really an exception.
162 -- !! If the format of the generated string is changed, please note
163 -- !! that an equivalent modification to the routine String_To_EO must
164 -- !! be made to preserve proper functioning of the stream attributes.
166 ---------------------------------------
167 -- Exception backtracing subprograms --
168 ---------------------------------------
170 -- What is automatically output when exception tracing is on is the
171 -- usual exception information with the call chain backtrace possibly
172 -- tailored by a backtrace decorator. Modifying Exception_Information
173 -- itself is not a good idea because the decorated output is completely
174 -- out of control and would break all our code related to the streaming
175 -- of exceptions. We then provide an alternative function to compute
176 -- the possibly tailored output, which is equivalent if no decorator is
179 function Tailored_Exception_Information
180 (X : Exception_Occurrence) return String;
181 -- Exception information to be output in the case of automatic tracing
182 -- requested through GNAT.Exception_Traces.
184 -- This is the same as Exception_Information if no backtrace decorator
185 -- is currently in place. Otherwise, this is Exception_Information with
186 -- the call chain raw addresses replaced by the result of a call to the
187 -- current decorator provided with the call chain addresses.
190 (Ada, Tailored_Exception_Information,
191 "__gnat_tailored_exception_information");
192 -- This is currently used by System.Tasking.Stages
196 package Exception_Traces is
199 -- Imports Tailored_Exception_Information
201 ----------------------------------------------
202 -- Run-Time Exception Notification Routines --
203 ----------------------------------------------
205 -- These subprograms provide a common run-time interface to trigger the
206 -- actions required when an exception is about to be propagated (e.g.
207 -- user specified actions or output of exception information). They are
208 -- exported to be usable by the Ada exception handling personality
209 -- routine when the GCC 3 mechanism is used.
211 procedure Notify_Handled_Exception;
213 (C, Notify_Handled_Exception, "__gnat_notify_handled_exception");
214 -- This routine is called for a handled occurrence is about to be
217 procedure Notify_Unhandled_Exception;
219 (C, Notify_Unhandled_Exception, "__gnat_notify_unhandled_exception");
220 -- This routine is called when an unhandled occurrence is about to be
223 procedure Unhandled_Exception_Terminate;
224 pragma No_Return (Unhandled_Exception_Terminate);
225 -- This procedure is called to terminate execution following an
226 -- unhandled exception. The exception information, including
227 -- traceback if available is output, and execution is then
228 -- terminated. Note that at the point where this routine is
229 -- called, the stack has typically been destroyed.
231 end Exception_Traces;
233 package Exception_Propagation is
235 use Exception_Traces;
236 -- Imports Notify_Unhandled_Exception and
237 -- Unhandled_Exception_Terminate
239 ------------------------------------
240 -- Exception propagation routines --
241 ------------------------------------
243 procedure Propagate_Exception;
244 pragma No_Return (Propagate_Exception);
245 -- This procedure propagates the exception represented by the occurrence
246 -- referenced by Current_Excep in the TSD for the current task.
248 end Exception_Propagation;
250 package Stream_Attributes is
252 --------------------------------
253 -- Stream attributes routines --
254 --------------------------------
256 function EId_To_String (X : Exception_Id) return String;
257 function String_To_EId (S : String) return Exception_Id;
258 -- Functions for implementing Exception_Id stream attributes
260 function EO_To_String (X : Exception_Occurrence) return String;
261 function String_To_EO (S : String) return Exception_Occurrence;
262 -- Functions for implementing Exception_Occurrence stream
265 end Stream_Attributes;
267 procedure Raise_Current_Excep (E : Exception_Id);
268 pragma No_Return (Raise_Current_Excep);
269 pragma Export (C, Raise_Current_Excep, "__gnat_raise_nodefer_with_msg");
270 -- This is a simple wrapper to Exception_Propagation.Propagate_Exception.
272 -- This external name for Raise_Current_Excep is historical, and probably
273 -- should be changed but for now we keep it, because gdb and gigi know
276 procedure Raise_Exception_No_Defer
277 (E : Exception_Id; Message : String := "");
279 (Ada, Raise_Exception_No_Defer,
280 "ada__exceptions__raise_exception_no_defer");
281 pragma No_Return (Raise_Exception_No_Defer);
282 -- Similar to Raise_Exception, but with no abort deferral
284 procedure Raise_With_Msg (E : Exception_Id);
285 pragma No_Return (Raise_With_Msg);
286 pragma Export (C, Raise_With_Msg, "__gnat_raise_with_msg");
287 -- Raises an exception with given exception id value. A message
288 -- is associated with the raise, and has already been stored in the
289 -- exception occurrence referenced by the Current_Excep in the TSD.
290 -- Abort is deferred before the raise call.
292 procedure Raise_With_Location_And_Msg
297 M : System.Address := System.Null_Address);
298 pragma No_Return (Raise_With_Location_And_Msg);
299 -- Raise an exception with given exception id value. A filename and line
300 -- number is associated with the raise and is stored in the exception
301 -- occurrence and in addition a column and a string message M may be
302 -- appended to this (if not null/0).
304 procedure Raise_Constraint_Error
305 (File : System.Address;
307 pragma No_Return (Raise_Constraint_Error);
309 (C, Raise_Constraint_Error, "__gnat_raise_constraint_error");
310 -- Raise constraint error with file:line information
312 procedure Raise_Constraint_Error_Msg
313 (File : System.Address;
316 Msg : System.Address);
317 pragma No_Return (Raise_Constraint_Error_Msg);
319 (C, Raise_Constraint_Error_Msg, "__gnat_raise_constraint_error_msg");
320 -- Raise constraint error with file:line:col + msg information
322 procedure Raise_Program_Error
323 (File : System.Address;
325 pragma No_Return (Raise_Program_Error);
327 (C, Raise_Program_Error, "__gnat_raise_program_error");
328 -- Raise program error with file:line information
330 procedure Raise_Program_Error_Msg
331 (File : System.Address;
333 Msg : System.Address);
334 pragma No_Return (Raise_Program_Error_Msg);
336 (C, Raise_Program_Error_Msg, "__gnat_raise_program_error_msg");
337 -- Raise program error with file:line + msg information
339 procedure Raise_Storage_Error
340 (File : System.Address;
342 pragma No_Return (Raise_Storage_Error);
344 (C, Raise_Storage_Error, "__gnat_raise_storage_error");
345 -- Raise storage error with file:line information
347 procedure Raise_Storage_Error_Msg
348 (File : System.Address;
350 Msg : System.Address);
351 pragma No_Return (Raise_Storage_Error_Msg);
353 (C, Raise_Storage_Error_Msg, "__gnat_raise_storage_error_msg");
354 -- Raise storage error with file:line + reason msg information
356 -- The exception raising process and the automatic tracing mechanism rely
357 -- on some careful use of flags attached to the exception occurrence. The
358 -- graph below illustrates the relations between the Raise_ subprograms
359 -- and identifies the points where basic flags such as Exception_Raised
362 -- (i) signs indicate the flags initialization points. R stands for Raise,
363 -- W for With, and E for Exception.
365 -- R_No_Msg R_E R_Pe R_Ce R_Se
367 -- +--+ +--+ +---+ | +---+
369 -- R_E_No_Defer(i) R_W_Msg(i) R_W_Loc
371 -- +------------+ | +-----------+ +--+
373 -- | | | Set_E_C_Msg(i)
375 -- Raise_Current_Excep
378 pragma No_Return (Reraise);
379 pragma Export (C, Reraise, "__gnat_reraise");
380 -- Reraises the exception referenced by the Current_Excep field of
381 -- the TSD (all fields of this exception occurrence are set). Abort
382 -- is deferred before the reraise operation.
384 procedure Transfer_Occurrence
385 (Target : Exception_Occurrence_Access;
386 Source : Exception_Occurrence);
387 pragma Export (C, Transfer_Occurrence, "__gnat_transfer_occurrence");
388 -- Called from System.Tasking.RendezVous.Exceptional_Complete_RendezVous
389 -- to setup Target from Source as an exception to be propagated in the
390 -- caller task. Target is expected to be a pointer to the fixed TSD
391 -- occurrence for this task.
393 -----------------------------
394 -- Run-Time Check Routines --
395 -----------------------------
397 -- These routines raise a specific exception with a reason message
398 -- attached. The parameters are the file name and line number in each
399 -- case. The names are defined by Exp_Ch11.Get_RT_Exception_Name.
401 procedure Rcheck_CE_Access_Check
402 (File : System.Address; Line : Integer);
403 procedure Rcheck_CE_Null_Access_Parameter
404 (File : System.Address; Line : Integer);
405 procedure Rcheck_CE_Discriminant_Check
406 (File : System.Address; Line : Integer);
407 procedure Rcheck_CE_Divide_By_Zero
408 (File : System.Address; Line : Integer);
409 procedure Rcheck_CE_Explicit_Raise
410 (File : System.Address; Line : Integer);
411 procedure Rcheck_CE_Index_Check
412 (File : System.Address; Line : Integer);
413 procedure Rcheck_CE_Invalid_Data
414 (File : System.Address; Line : Integer);
415 procedure Rcheck_CE_Length_Check
416 (File : System.Address; Line : Integer);
417 procedure Rcheck_CE_Null_Exception_Id
418 (File : System.Address; Line : Integer);
419 procedure Rcheck_CE_Null_Not_Allowed
420 (File : System.Address; Line : Integer);
421 procedure Rcheck_CE_Overflow_Check
422 (File : System.Address; Line : Integer);
423 procedure Rcheck_CE_Partition_Check
424 (File : System.Address; Line : Integer);
425 procedure Rcheck_CE_Range_Check
426 (File : System.Address; Line : Integer);
427 procedure Rcheck_CE_Tag_Check
428 (File : System.Address; Line : Integer);
429 procedure Rcheck_PE_Access_Before_Elaboration
430 (File : System.Address; Line : Integer);
431 procedure Rcheck_PE_Accessibility_Check
432 (File : System.Address; Line : Integer);
433 procedure Rcheck_PE_Address_Of_Intrinsic
434 (File : System.Address; Line : Integer);
435 procedure Rcheck_PE_All_Guards_Closed
436 (File : System.Address; Line : Integer);
437 procedure Rcheck_PE_Bad_Predicated_Generic_Type
438 (File : System.Address; Line : Integer);
439 procedure Rcheck_PE_Current_Task_In_Entry_Body
440 (File : System.Address; Line : Integer);
441 procedure Rcheck_PE_Duplicated_Entry_Address
442 (File : System.Address; Line : Integer);
443 procedure Rcheck_PE_Explicit_Raise
444 (File : System.Address; Line : Integer);
445 procedure Rcheck_PE_Implicit_Return
446 (File : System.Address; Line : Integer);
447 procedure Rcheck_PE_Misaligned_Address_Value
448 (File : System.Address; Line : Integer);
449 procedure Rcheck_PE_Missing_Return
450 (File : System.Address; Line : Integer);
451 procedure Rcheck_PE_Overlaid_Controlled_Object
452 (File : System.Address; Line : Integer);
453 procedure Rcheck_PE_Potentially_Blocking_Operation
454 (File : System.Address; Line : Integer);
455 procedure Rcheck_PE_Stubbed_Subprogram_Called
456 (File : System.Address; Line : Integer);
457 procedure Rcheck_PE_Unchecked_Union_Restriction
458 (File : System.Address; Line : Integer);
459 procedure Rcheck_PE_Non_Transportable_Actual
460 (File : System.Address; Line : Integer);
461 procedure Rcheck_SE_Empty_Storage_Pool
462 (File : System.Address; Line : Integer);
463 procedure Rcheck_SE_Explicit_Raise
464 (File : System.Address; Line : Integer);
465 procedure Rcheck_SE_Infinite_Recursion
466 (File : System.Address; Line : Integer);
467 procedure Rcheck_SE_Object_Too_Large
468 (File : System.Address; Line : Integer);
470 procedure Rcheck_CE_Access_Check_Ext
471 (File : System.Address; Line, Column : Integer);
472 procedure Rcheck_CE_Index_Check_Ext
473 (File : System.Address; Line, Column, Index, First, Last : Integer);
474 procedure Rcheck_CE_Invalid_Data_Ext
475 (File : System.Address; Line, Column, Index, First, Last : Integer);
476 procedure Rcheck_CE_Range_Check_Ext
477 (File : System.Address; Line, Column, Index, First, Last : Integer);
479 procedure Rcheck_PE_Finalize_Raised_Exception
480 (File : System.Address; Line : Integer);
481 -- This routine is separated out because it has quite different behavior
482 -- from the others. This is the "finalize/adjust raised exception". This
483 -- subprogram is always called with abort deferred, unlike all other
484 -- Rcheck_* routines, it needs to call Raise_Exception_No_Defer.
486 pragma Export (C, Rcheck_CE_Access_Check,
487 "__gnat_rcheck_CE_Access_Check");
488 pragma Export (C, Rcheck_CE_Null_Access_Parameter,
489 "__gnat_rcheck_CE_Null_Access_Parameter");
490 pragma Export (C, Rcheck_CE_Discriminant_Check,
491 "__gnat_rcheck_CE_Discriminant_Check");
492 pragma Export (C, Rcheck_CE_Divide_By_Zero,
493 "__gnat_rcheck_CE_Divide_By_Zero");
494 pragma Export (C, Rcheck_CE_Explicit_Raise,
495 "__gnat_rcheck_CE_Explicit_Raise");
496 pragma Export (C, Rcheck_CE_Index_Check,
497 "__gnat_rcheck_CE_Index_Check");
498 pragma Export (C, Rcheck_CE_Invalid_Data,
499 "__gnat_rcheck_CE_Invalid_Data");
500 pragma Export (C, Rcheck_CE_Length_Check,
501 "__gnat_rcheck_CE_Length_Check");
502 pragma Export (C, Rcheck_CE_Null_Exception_Id,
503 "__gnat_rcheck_CE_Null_Exception_Id");
504 pragma Export (C, Rcheck_CE_Null_Not_Allowed,
505 "__gnat_rcheck_CE_Null_Not_Allowed");
506 pragma Export (C, Rcheck_CE_Overflow_Check,
507 "__gnat_rcheck_CE_Overflow_Check");
508 pragma Export (C, Rcheck_CE_Partition_Check,
509 "__gnat_rcheck_CE_Partition_Check");
510 pragma Export (C, Rcheck_CE_Range_Check,
511 "__gnat_rcheck_CE_Range_Check");
512 pragma Export (C, Rcheck_CE_Tag_Check,
513 "__gnat_rcheck_CE_Tag_Check");
514 pragma Export (C, Rcheck_PE_Access_Before_Elaboration,
515 "__gnat_rcheck_PE_Access_Before_Elaboration");
516 pragma Export (C, Rcheck_PE_Accessibility_Check,
517 "__gnat_rcheck_PE_Accessibility_Check");
518 pragma Export (C, Rcheck_PE_Address_Of_Intrinsic,
519 "__gnat_rcheck_PE_Address_Of_Intrinsic");
520 pragma Export (C, Rcheck_PE_All_Guards_Closed,
521 "__gnat_rcheck_PE_All_Guards_Closed");
522 pragma Export (C, Rcheck_PE_Bad_Predicated_Generic_Type,
523 "__gnat_rcheck_PE_Bad_Predicated_Generic_Type");
524 pragma Export (C, Rcheck_PE_Current_Task_In_Entry_Body,
525 "__gnat_rcheck_PE_Current_Task_In_Entry_Body");
526 pragma Export (C, Rcheck_PE_Duplicated_Entry_Address,
527 "__gnat_rcheck_PE_Duplicated_Entry_Address");
528 pragma Export (C, Rcheck_PE_Explicit_Raise,
529 "__gnat_rcheck_PE_Explicit_Raise");
530 pragma Export (C, Rcheck_PE_Finalize_Raised_Exception,
531 "__gnat_rcheck_PE_Finalize_Raised_Exception");
532 pragma Export (C, Rcheck_PE_Implicit_Return,
533 "__gnat_rcheck_PE_Implicit_Return");
534 pragma Export (C, Rcheck_PE_Misaligned_Address_Value,
535 "__gnat_rcheck_PE_Misaligned_Address_Value");
536 pragma Export (C, Rcheck_PE_Missing_Return,
537 "__gnat_rcheck_PE_Missing_Return");
538 pragma Export (C, Rcheck_PE_Overlaid_Controlled_Object,
539 "__gnat_rcheck_PE_Overlaid_Controlled_Object");
540 pragma Export (C, Rcheck_PE_Potentially_Blocking_Operation,
541 "__gnat_rcheck_PE_Potentially_Blocking_Operation");
542 pragma Export (C, Rcheck_PE_Stubbed_Subprogram_Called,
543 "__gnat_rcheck_PE_Stubbed_Subprogram_Called");
544 pragma Export (C, Rcheck_PE_Unchecked_Union_Restriction,
545 "__gnat_rcheck_PE_Unchecked_Union_Restriction");
546 pragma Export (C, Rcheck_PE_Non_Transportable_Actual,
547 "__gnat_rcheck_PE_Non_Transportable_Actual");
548 pragma Export (C, Rcheck_SE_Empty_Storage_Pool,
549 "__gnat_rcheck_SE_Empty_Storage_Pool");
550 pragma Export (C, Rcheck_SE_Explicit_Raise,
551 "__gnat_rcheck_SE_Explicit_Raise");
552 pragma Export (C, Rcheck_SE_Infinite_Recursion,
553 "__gnat_rcheck_SE_Infinite_Recursion");
554 pragma Export (C, Rcheck_SE_Object_Too_Large,
555 "__gnat_rcheck_SE_Object_Too_Large");
557 pragma Export (C, Rcheck_CE_Access_Check_Ext,
558 "__gnat_rcheck_CE_Access_Check_ext");
559 pragma Export (C, Rcheck_CE_Index_Check_Ext,
560 "__gnat_rcheck_CE_Index_Check_ext");
561 pragma Export (C, Rcheck_CE_Invalid_Data_Ext,
562 "__gnat_rcheck_CE_Invalid_Data_ext");
563 pragma Export (C, Rcheck_CE_Range_Check_Ext,
564 "__gnat_rcheck_CE_Range_Check_ext");
566 -- None of these procedures ever returns (they raise an exception!). By
567 -- using pragma No_Return, we ensure that any junk code after the call,
568 -- such as normal return epilog stuff, can be eliminated).
570 pragma No_Return (Rcheck_CE_Access_Check);
571 pragma No_Return (Rcheck_CE_Null_Access_Parameter);
572 pragma No_Return (Rcheck_CE_Discriminant_Check);
573 pragma No_Return (Rcheck_CE_Divide_By_Zero);
574 pragma No_Return (Rcheck_CE_Explicit_Raise);
575 pragma No_Return (Rcheck_CE_Index_Check);
576 pragma No_Return (Rcheck_CE_Invalid_Data);
577 pragma No_Return (Rcheck_CE_Length_Check);
578 pragma No_Return (Rcheck_CE_Null_Exception_Id);
579 pragma No_Return (Rcheck_CE_Null_Not_Allowed);
580 pragma No_Return (Rcheck_CE_Overflow_Check);
581 pragma No_Return (Rcheck_CE_Partition_Check);
582 pragma No_Return (Rcheck_CE_Range_Check);
583 pragma No_Return (Rcheck_CE_Tag_Check);
584 pragma No_Return (Rcheck_PE_Access_Before_Elaboration);
585 pragma No_Return (Rcheck_PE_Accessibility_Check);
586 pragma No_Return (Rcheck_PE_Address_Of_Intrinsic);
587 pragma No_Return (Rcheck_PE_All_Guards_Closed);
588 pragma No_Return (Rcheck_PE_Bad_Predicated_Generic_Type);
589 pragma No_Return (Rcheck_PE_Current_Task_In_Entry_Body);
590 pragma No_Return (Rcheck_PE_Duplicated_Entry_Address);
591 pragma No_Return (Rcheck_PE_Explicit_Raise);
592 pragma No_Return (Rcheck_PE_Implicit_Return);
593 pragma No_Return (Rcheck_PE_Misaligned_Address_Value);
594 pragma No_Return (Rcheck_PE_Missing_Return);
595 pragma No_Return (Rcheck_PE_Overlaid_Controlled_Object);
596 pragma No_Return (Rcheck_PE_Potentially_Blocking_Operation);
597 pragma No_Return (Rcheck_PE_Stubbed_Subprogram_Called);
598 pragma No_Return (Rcheck_PE_Unchecked_Union_Restriction);
599 pragma No_Return (Rcheck_PE_Non_Transportable_Actual);
600 pragma No_Return (Rcheck_PE_Finalize_Raised_Exception);
601 pragma No_Return (Rcheck_SE_Empty_Storage_Pool);
602 pragma No_Return (Rcheck_SE_Explicit_Raise);
603 pragma No_Return (Rcheck_SE_Infinite_Recursion);
604 pragma No_Return (Rcheck_SE_Object_Too_Large);
606 pragma No_Return (Rcheck_CE_Access_Check_Ext);
607 pragma No_Return (Rcheck_CE_Index_Check_Ext);
608 pragma No_Return (Rcheck_CE_Invalid_Data_Ext);
609 pragma No_Return (Rcheck_CE_Range_Check_Ext);
611 ---------------------------------------------
612 -- Reason Strings for Run-Time Check Calls --
613 ---------------------------------------------
615 -- These strings are null-terminated and are used by Rcheck_nn. The
616 -- strings correspond to the definitions for Types.RT_Exception_Code.
620 Rmsg_00 : constant String := "access check failed" & NUL;
621 Rmsg_01 : constant String := "access parameter is null" & NUL;
622 Rmsg_02 : constant String := "discriminant check failed" & NUL;
623 Rmsg_03 : constant String := "divide by zero" & NUL;
624 Rmsg_04 : constant String := "explicit raise" & NUL;
625 Rmsg_05 : constant String := "index check failed" & NUL;
626 Rmsg_06 : constant String := "invalid data" & NUL;
627 Rmsg_07 : constant String := "length check failed" & NUL;
628 Rmsg_08 : constant String := "null Exception_Id" & NUL;
629 Rmsg_09 : constant String := "null-exclusion check failed" & NUL;
630 Rmsg_10 : constant String := "overflow check failed" & NUL;
631 Rmsg_11 : constant String := "partition check failed" & NUL;
632 Rmsg_12 : constant String := "range check failed" & NUL;
633 Rmsg_13 : constant String := "tag check failed" & NUL;
634 Rmsg_14 : constant String := "access before elaboration" & NUL;
635 Rmsg_15 : constant String := "accessibility check failed" & NUL;
636 Rmsg_16 : constant String := "attempt to take address of" &
637 " intrinsic subprogram" & NUL;
638 Rmsg_17 : constant String := "all guards closed" & NUL;
639 Rmsg_18 : constant String := "improper use of generic subtype" &
640 " with predicate" & NUL;
641 Rmsg_19 : constant String := "Current_Task referenced in entry" &
643 Rmsg_20 : constant String := "duplicated entry address" & NUL;
644 Rmsg_21 : constant String := "explicit raise" & NUL;
645 Rmsg_22 : constant String := "finalize/adjust raised exception" & NUL;
646 Rmsg_23 : constant String := "implicit return with No_Return" & NUL;
647 Rmsg_24 : constant String := "misaligned address value" & NUL;
648 Rmsg_25 : constant String := "missing return" & NUL;
649 Rmsg_26 : constant String := "overlaid controlled object" & NUL;
650 Rmsg_27 : constant String := "potentially blocking operation" & NUL;
651 Rmsg_28 : constant String := "stubbed subprogram called" & NUL;
652 Rmsg_29 : constant String := "unchecked union restriction" & NUL;
653 Rmsg_30 : constant String := "actual/returned class-wide" &
654 " value not transportable" & NUL;
655 Rmsg_31 : constant String := "empty storage pool" & NUL;
656 Rmsg_32 : constant String := "explicit raise" & NUL;
657 Rmsg_33 : constant String := "infinite recursion" & NUL;
658 Rmsg_34 : constant String := "object too large" & NUL;
660 -----------------------
661 -- Polling Interface --
662 -----------------------
664 type Unsigned is mod 2 ** 32;
666 Counter : Unsigned := 0;
667 pragma Warnings (Off, Counter);
668 -- This counter is provided for convenience. It can be used in Poll to
669 -- perform periodic but not systematic operations.
671 procedure Poll is separate;
672 -- The actual polling routine is separate, so that it can easily
673 -- be replaced with a target dependent version.
675 --------------------------
676 -- Code_Address_For_AAA --
677 --------------------------
679 -- This function gives us the start of the PC range for addresses
680 -- within the exception unit itself. We hope that gigi/gcc keep all the
681 -- procedures in their original order!
683 function Code_Address_For_AAA return System.Address is
685 -- We are using a label instead of merely using
686 -- Code_Address_For_AAA'Address because on some platforms the latter
687 -- does not yield the address we want, but the address of a stub or of
688 -- a descriptor instead. This is the case at least on Alpha-VMS and
692 return Start_Of_AAA'Address;
693 end Code_Address_For_AAA;
699 procedure Call_Chain (Excep : EOA) is separate;
700 -- The actual Call_Chain routine is separate, so that it can easily
701 -- be dummied out when no exception traceback information is needed.
703 ------------------------------
704 -- Current_Target_Exception --
705 ------------------------------
707 function Current_Target_Exception return Exception_Occurrence is
709 return Null_Occurrence;
710 end Current_Target_Exception;
716 function EId_To_String (X : Exception_Id) return String
717 renames Stream_Attributes.EId_To_String;
723 -- We use the null string to represent the null occurrence, otherwise
724 -- we output the Exception_Information string for the occurrence.
726 function EO_To_String (X : Exception_Occurrence) return String
727 renames Stream_Attributes.EO_To_String;
729 ------------------------
730 -- Exception_Identity --
731 ------------------------
733 function Exception_Identity
734 (X : Exception_Occurrence) return Exception_Id
737 -- Note that the following test used to be here for the original
738 -- Ada 95 semantics, but these were modified by AI-241 to require
739 -- returning Null_Id instead of raising Constraint_Error.
741 -- if X.Id = Null_Id then
742 -- raise Constraint_Error;
746 end Exception_Identity;
748 ---------------------------
749 -- Exception_Information --
750 ---------------------------
752 function Exception_Information (X : Exception_Occurrence) return String is
754 if X.Id = Null_Id then
755 raise Constraint_Error;
758 return Exception_Data.Exception_Information (X);
759 end Exception_Information;
761 -----------------------
762 -- Exception_Message --
763 -----------------------
765 function Exception_Message (X : Exception_Occurrence) return String is
767 if X.Id = Null_Id then
768 raise Constraint_Error;
771 return X.Msg (1 .. X.Msg_Length);
772 end Exception_Message;
778 function Exception_Name (Id : Exception_Id) return String is
781 raise Constraint_Error;
784 return To_Ptr (Id.Full_Name) (1 .. Id.Name_Length - 1);
787 function Exception_Name (X : Exception_Occurrence) return String is
789 return Exception_Name (X.Id);
792 ---------------------------
793 -- Exception_Name_Simple --
794 ---------------------------
796 function Exception_Name_Simple (X : Exception_Occurrence) return String is
797 Name : constant String := Exception_Name (X);
803 exit when Name (P - 1) = '.';
807 -- Return result making sure lower bound is 1
810 subtype Rname is String (1 .. Name'Length - P + 1);
812 return Rname (Name (P .. Name'Length));
814 end Exception_Name_Simple;
820 package body Exception_Data is separate;
821 -- This package can be easily dummied out if we do not want the
822 -- basic support for exception messages (such as in Ada 83).
824 ---------------------------
825 -- Exception_Propagation --
826 ---------------------------
828 package body Exception_Propagation is separate;
829 -- Depending on the actual exception mechanism used (front-end or
830 -- back-end based), the implementation will differ, which is why this
831 -- package is separated.
833 ----------------------
834 -- Exception_Traces --
835 ----------------------
837 package body Exception_Traces is separate;
838 -- Depending on the underlying support for IO the implementation
839 -- will differ. Moreover we would like to dummy out this package
840 -- in case we do not want any exception tracing support. This is
841 -- why this package is separated.
847 function Image (Index : Integer) return String is
848 Result : constant String := Integer'Image (Index);
850 if Result (1) = ' ' then
851 return Result (2 .. Result'Last);
857 -----------------------
858 -- Stream Attributes --
859 -----------------------
861 package body Stream_Attributes is separate;
862 -- This package can be easily dummied out if we do not want the
863 -- support for streaming Exception_Ids and Exception_Occurrences.
865 ----------------------------
866 -- Raise_Constraint_Error --
867 ----------------------------
869 procedure Raise_Constraint_Error (File : System.Address; Line : Integer) is
871 Raise_With_Location_And_Msg (Constraint_Error_Def'Access, File, Line);
872 end Raise_Constraint_Error;
874 --------------------------------
875 -- Raise_Constraint_Error_Msg --
876 --------------------------------
878 procedure Raise_Constraint_Error_Msg
879 (File : System.Address;
882 Msg : System.Address)
885 Raise_With_Location_And_Msg
886 (Constraint_Error_Def'Access, File, Line, Column, Msg);
887 end Raise_Constraint_Error_Msg;
889 -------------------------
890 -- Raise_Current_Excep --
891 -------------------------
893 procedure Raise_Current_Excep (E : Exception_Id) is
895 Debug_Raise_Exception (E => SSL.Exception_Data_Ptr (E));
896 Exception_Propagation.Propagate_Exception;
897 end Raise_Current_Excep;
899 ---------------------
900 -- Raise_Exception --
901 ---------------------
903 procedure Raise_Exception
905 Message : String := "")
907 EF : Exception_Id := E;
910 -- Raise CE if E = Null_ID (AI-446)
913 EF := Constraint_Error'Identity;
916 -- Go ahead and raise appropriate exception
918 Exception_Data.Set_Exception_Msg (EF, Message);
920 if not ZCX_By_Default then
924 Raise_Current_Excep (EF);
927 ----------------------------
928 -- Raise_Exception_Always --
929 ----------------------------
931 procedure Raise_Exception_Always
933 Message : String := "")
936 Exception_Data.Set_Exception_Msg (E, Message);
937 if not ZCX_By_Default then
940 Raise_Current_Excep (E);
941 end Raise_Exception_Always;
943 ------------------------------
944 -- Raise_Exception_No_Defer --
945 ------------------------------
947 procedure Raise_Exception_No_Defer
949 Message : String := "")
952 Exception_Data.Set_Exception_Msg (E, Message);
954 -- Do not call Abort_Defer.all, as specified by the spec
956 Raise_Current_Excep (E);
957 end Raise_Exception_No_Defer;
959 -------------------------------------
960 -- Raise_From_Controlled_Operation --
961 -------------------------------------
963 procedure Raise_From_Controlled_Operation
964 (X : Ada.Exceptions.Exception_Occurrence)
966 Prefix : constant String := "adjust/finalize raised ";
967 Orig_Msg : constant String := Exception_Message (X);
968 Orig_Prefix_Length : constant Natural :=
969 Integer'Min (Prefix'Length, Orig_Msg'Length);
970 Orig_Prefix : String renames Orig_Msg
972 Orig_Msg'First + Orig_Prefix_Length - 1);
974 -- Message already has the proper prefix, just re-raise
976 if Orig_Prefix = Prefix then
977 Raise_Exception_No_Defer
978 (E => Program_Error'Identity,
979 Message => Orig_Msg);
983 New_Msg : constant String := Prefix & Exception_Name (X);
986 -- No message present, just provide our own
988 if Orig_Msg = "" then
989 Raise_Exception_No_Defer
990 (E => Program_Error'Identity,
993 -- Message present, add informational prefix
996 Raise_Exception_No_Defer
997 (E => Program_Error'Identity,
998 Message => New_Msg & ": " & Orig_Msg);
1002 end Raise_From_Controlled_Operation;
1004 -------------------------------
1005 -- Raise_From_Signal_Handler --
1006 -------------------------------
1008 procedure Raise_From_Signal_Handler
1013 Exception_Data.Set_Exception_C_Msg (E, M);
1015 if not ZCX_By_Default then
1019 Raise_Current_Excep (E);
1020 end Raise_From_Signal_Handler;
1022 -------------------------
1023 -- Raise_Program_Error --
1024 -------------------------
1026 procedure Raise_Program_Error
1027 (File : System.Address;
1031 Raise_With_Location_And_Msg (Program_Error_Def'Access, File, Line);
1032 end Raise_Program_Error;
1034 -----------------------------
1035 -- Raise_Program_Error_Msg --
1036 -----------------------------
1038 procedure Raise_Program_Error_Msg
1039 (File : System.Address;
1041 Msg : System.Address)
1044 Raise_With_Location_And_Msg
1045 (Program_Error_Def'Access, File, Line, M => Msg);
1046 end Raise_Program_Error_Msg;
1048 -------------------------
1049 -- Raise_Storage_Error --
1050 -------------------------
1052 procedure Raise_Storage_Error
1053 (File : System.Address;
1057 Raise_With_Location_And_Msg (Storage_Error_Def'Access, File, Line);
1058 end Raise_Storage_Error;
1060 -----------------------------
1061 -- Raise_Storage_Error_Msg --
1062 -----------------------------
1064 procedure Raise_Storage_Error_Msg
1065 (File : System.Address;
1067 Msg : System.Address)
1070 Raise_With_Location_And_Msg
1071 (Storage_Error_Def'Access, File, Line, M => Msg);
1072 end Raise_Storage_Error_Msg;
1074 ---------------------------------
1075 -- Raise_With_Location_And_Msg --
1076 ---------------------------------
1078 procedure Raise_With_Location_And_Msg
1083 M : System.Address := System.Null_Address)
1086 Exception_Data.Set_Exception_C_Msg (E, F, L, C, M);
1088 if not ZCX_By_Default then
1092 Raise_Current_Excep (E);
1093 end Raise_With_Location_And_Msg;
1095 --------------------
1096 -- Raise_With_Msg --
1097 --------------------
1099 procedure Raise_With_Msg (E : Exception_Id) is
1100 Excep : constant EOA := Get_Current_Excep.all;
1103 Excep.Exception_Raised := False;
1105 Excep.Num_Tracebacks := 0;
1106 Excep.Pid := Local_Partition_ID;
1108 -- The following is a common pattern, should be abstracted
1109 -- into a procedure call ???
1111 if not ZCX_By_Default then
1115 Raise_Current_Excep (E);
1118 --------------------------------------
1119 -- Calls to Run-Time Check Routines --
1120 --------------------------------------
1122 procedure Rcheck_CE_Access_Check
1123 (File : System.Address; Line : Integer)
1126 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_00'Address);
1127 end Rcheck_CE_Access_Check;
1129 procedure Rcheck_CE_Null_Access_Parameter
1130 (File : System.Address; Line : Integer)
1133 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_01'Address);
1134 end Rcheck_CE_Null_Access_Parameter;
1136 procedure Rcheck_CE_Discriminant_Check
1137 (File : System.Address; Line : Integer)
1140 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_02'Address);
1141 end Rcheck_CE_Discriminant_Check;
1143 procedure Rcheck_CE_Divide_By_Zero
1144 (File : System.Address; Line : Integer)
1147 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_03'Address);
1148 end Rcheck_CE_Divide_By_Zero;
1150 procedure Rcheck_CE_Explicit_Raise
1151 (File : System.Address; Line : Integer)
1154 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_04'Address);
1155 end Rcheck_CE_Explicit_Raise;
1157 procedure Rcheck_CE_Index_Check
1158 (File : System.Address; Line : Integer)
1161 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_05'Address);
1162 end Rcheck_CE_Index_Check;
1164 procedure Rcheck_CE_Invalid_Data
1165 (File : System.Address; Line : Integer)
1168 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_06'Address);
1169 end Rcheck_CE_Invalid_Data;
1171 procedure Rcheck_CE_Length_Check
1172 (File : System.Address; Line : Integer)
1175 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_07'Address);
1176 end Rcheck_CE_Length_Check;
1178 procedure Rcheck_CE_Null_Exception_Id
1179 (File : System.Address; Line : Integer)
1182 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_08'Address);
1183 end Rcheck_CE_Null_Exception_Id;
1185 procedure Rcheck_CE_Null_Not_Allowed
1186 (File : System.Address; Line : Integer)
1189 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_09'Address);
1190 end Rcheck_CE_Null_Not_Allowed;
1192 procedure Rcheck_CE_Overflow_Check
1193 (File : System.Address; Line : Integer)
1196 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_10'Address);
1197 end Rcheck_CE_Overflow_Check;
1199 procedure Rcheck_CE_Partition_Check
1200 (File : System.Address; Line : Integer)
1203 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_11'Address);
1204 end Rcheck_CE_Partition_Check;
1206 procedure Rcheck_CE_Range_Check
1207 (File : System.Address; Line : Integer)
1210 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_12'Address);
1211 end Rcheck_CE_Range_Check;
1213 procedure Rcheck_CE_Tag_Check
1214 (File : System.Address; Line : Integer)
1217 Raise_Constraint_Error_Msg (File, Line, 0, Rmsg_13'Address);
1218 end Rcheck_CE_Tag_Check;
1220 procedure Rcheck_PE_Access_Before_Elaboration
1221 (File : System.Address; Line : Integer)
1224 Raise_Program_Error_Msg (File, Line, Rmsg_14'Address);
1225 end Rcheck_PE_Access_Before_Elaboration;
1227 procedure Rcheck_PE_Accessibility_Check
1228 (File : System.Address; Line : Integer)
1231 Raise_Program_Error_Msg (File, Line, Rmsg_15'Address);
1232 end Rcheck_PE_Accessibility_Check;
1234 procedure Rcheck_PE_Address_Of_Intrinsic
1235 (File : System.Address; Line : Integer)
1238 Raise_Program_Error_Msg (File, Line, Rmsg_16'Address);
1239 end Rcheck_PE_Address_Of_Intrinsic;
1241 procedure Rcheck_PE_All_Guards_Closed
1242 (File : System.Address; Line : Integer)
1245 Raise_Program_Error_Msg (File, Line, Rmsg_17'Address);
1246 end Rcheck_PE_All_Guards_Closed;
1248 procedure Rcheck_PE_Bad_Predicated_Generic_Type
1249 (File : System.Address; Line : Integer)
1252 Raise_Program_Error_Msg (File, Line, Rmsg_18'Address);
1253 end Rcheck_PE_Bad_Predicated_Generic_Type;
1255 procedure Rcheck_PE_Current_Task_In_Entry_Body
1256 (File : System.Address; Line : Integer)
1259 Raise_Program_Error_Msg (File, Line, Rmsg_19'Address);
1260 end Rcheck_PE_Current_Task_In_Entry_Body;
1262 procedure Rcheck_PE_Duplicated_Entry_Address
1263 (File : System.Address; Line : Integer)
1266 Raise_Program_Error_Msg (File, Line, Rmsg_20'Address);
1267 end Rcheck_PE_Duplicated_Entry_Address;
1269 procedure Rcheck_PE_Explicit_Raise
1270 (File : System.Address; Line : Integer)
1273 Raise_Program_Error_Msg (File, Line, Rmsg_21'Address);
1274 end Rcheck_PE_Explicit_Raise;
1276 procedure Rcheck_PE_Implicit_Return
1277 (File : System.Address; Line : Integer)
1280 Raise_Program_Error_Msg (File, Line, Rmsg_23'Address);
1281 end Rcheck_PE_Implicit_Return;
1283 procedure Rcheck_PE_Misaligned_Address_Value
1284 (File : System.Address; Line : Integer)
1287 Raise_Program_Error_Msg (File, Line, Rmsg_24'Address);
1288 end Rcheck_PE_Misaligned_Address_Value;
1290 procedure Rcheck_PE_Missing_Return
1291 (File : System.Address; Line : Integer)
1294 Raise_Program_Error_Msg (File, Line, Rmsg_25'Address);
1295 end Rcheck_PE_Missing_Return;
1297 procedure Rcheck_PE_Overlaid_Controlled_Object
1298 (File : System.Address; Line : Integer)
1301 Raise_Program_Error_Msg (File, Line, Rmsg_26'Address);
1302 end Rcheck_PE_Overlaid_Controlled_Object;
1304 procedure Rcheck_PE_Potentially_Blocking_Operation
1305 (File : System.Address; Line : Integer)
1308 Raise_Program_Error_Msg (File, Line, Rmsg_27'Address);
1309 end Rcheck_PE_Potentially_Blocking_Operation;
1311 procedure Rcheck_PE_Stubbed_Subprogram_Called
1312 (File : System.Address; Line : Integer)
1315 Raise_Program_Error_Msg (File, Line, Rmsg_28'Address);
1316 end Rcheck_PE_Stubbed_Subprogram_Called;
1318 procedure Rcheck_PE_Unchecked_Union_Restriction
1319 (File : System.Address; Line : Integer)
1322 Raise_Program_Error_Msg (File, Line, Rmsg_29'Address);
1323 end Rcheck_PE_Unchecked_Union_Restriction;
1325 procedure Rcheck_PE_Non_Transportable_Actual
1326 (File : System.Address; Line : Integer)
1329 Raise_Program_Error_Msg (File, Line, Rmsg_30'Address);
1330 end Rcheck_PE_Non_Transportable_Actual;
1332 procedure Rcheck_SE_Empty_Storage_Pool
1333 (File : System.Address; Line : Integer)
1336 Raise_Storage_Error_Msg (File, Line, Rmsg_31'Address);
1337 end Rcheck_SE_Empty_Storage_Pool;
1339 procedure Rcheck_SE_Explicit_Raise
1340 (File : System.Address; Line : Integer)
1343 Raise_Storage_Error_Msg (File, Line, Rmsg_32'Address);
1344 end Rcheck_SE_Explicit_Raise;
1346 procedure Rcheck_SE_Infinite_Recursion
1347 (File : System.Address; Line : Integer)
1350 Raise_Storage_Error_Msg (File, Line, Rmsg_33'Address);
1351 end Rcheck_SE_Infinite_Recursion;
1353 procedure Rcheck_SE_Object_Too_Large
1354 (File : System.Address; Line : Integer)
1357 Raise_Storage_Error_Msg (File, Line, Rmsg_34'Address);
1358 end Rcheck_SE_Object_Too_Large;
1360 procedure Rcheck_CE_Access_Check_Ext
1361 (File : System.Address; Line, Column : Integer)
1364 Raise_Constraint_Error_Msg (File, Line, Column, Rmsg_00'Address);
1365 end Rcheck_CE_Access_Check_Ext;
1367 procedure Rcheck_CE_Index_Check_Ext
1368 (File : System.Address; Line, Column, Index, First, Last : Integer)
1370 Msg : constant String :=
1371 Rmsg_05 (Rmsg_05'First .. Rmsg_05'Last - 1) & ASCII.LF &
1372 "index " & Image (Index) & " not in " & Image (First) &
1373 ".." & Image (Last) & ASCII.NUL;
1375 Raise_Constraint_Error_Msg (File, Line, Column, Msg'Address);
1376 end Rcheck_CE_Index_Check_Ext;
1378 procedure Rcheck_CE_Invalid_Data_Ext
1379 (File : System.Address; Line, Column, Index, First, Last : Integer)
1381 Msg : constant String :=
1382 Rmsg_06 (Rmsg_06'First .. Rmsg_06'Last - 1) & ASCII.LF &
1383 "value " & Image (Index) & " not in " & Image (First) &
1384 ".." & Image (Last) & ASCII.NUL;
1386 Raise_Constraint_Error_Msg (File, Line, Column, Msg'Address);
1387 end Rcheck_CE_Invalid_Data_Ext;
1389 procedure Rcheck_CE_Range_Check_Ext
1390 (File : System.Address; Line, Column, Index, First, Last : Integer)
1392 Msg : constant String :=
1393 Rmsg_12 (Rmsg_12'First .. Rmsg_12'Last - 1) & ASCII.LF &
1394 "value " & Image (Index) & " not in " & Image (First) &
1395 ".." & Image (Last) & ASCII.NUL;
1397 Raise_Constraint_Error_Msg (File, Line, Column, Msg'Address);
1398 end Rcheck_CE_Range_Check_Ext;
1400 procedure Rcheck_PE_Finalize_Raised_Exception
1401 (File : System.Address; Line : Integer)
1403 E : constant Exception_Id := Program_Error_Def'Access;
1406 -- This is "finalize/adjust raised exception". This subprogram is always
1407 -- called with abort deferred, unlike all other Rcheck_* routines, it
1408 -- needs to call Raise_Exception_No_Defer.
1410 -- This is consistent with Raise_From_Controlled_Operation
1412 Exception_Data.Set_Exception_C_Msg (E, File, Line, 0, Rmsg_22'Address);
1413 Raise_Current_Excep (E);
1414 end Rcheck_PE_Finalize_Raised_Exception;
1420 procedure Reraise is
1421 Excep : constant EOA := Get_Current_Excep.all;
1423 if not ZCX_By_Default then
1426 Raise_Current_Excep (Excep.Id);
1429 --------------------------------------
1430 -- Reraise_Library_Exception_If_Any --
1431 --------------------------------------
1433 procedure Reraise_Library_Exception_If_Any is
1434 LE : Exception_Occurrence;
1436 if Library_Exception_Set then
1437 LE := Library_Exception;
1438 if LE.Id = Null_Id then
1439 Raise_Exception_No_Defer
1440 (E => Program_Error'Identity,
1441 Message => "finalize/adjust raised exception");
1443 Raise_From_Controlled_Operation (LE);
1446 end Reraise_Library_Exception_If_Any;
1448 ------------------------
1449 -- Reraise_Occurrence --
1450 ------------------------
1452 procedure Reraise_Occurrence (X : Exception_Occurrence) is
1454 if X.Id /= null then
1455 if not ZCX_By_Default then
1459 Save_Occurrence (Get_Current_Excep.all.all, X);
1460 Raise_Current_Excep (X.Id);
1462 end Reraise_Occurrence;
1464 -------------------------------
1465 -- Reraise_Occurrence_Always --
1466 -------------------------------
1468 procedure Reraise_Occurrence_Always (X : Exception_Occurrence) is
1470 if not ZCX_By_Default then
1474 Save_Occurrence (Get_Current_Excep.all.all, X);
1475 Raise_Current_Excep (X.Id);
1476 end Reraise_Occurrence_Always;
1478 ---------------------------------
1479 -- Reraise_Occurrence_No_Defer --
1480 ---------------------------------
1482 procedure Reraise_Occurrence_No_Defer (X : Exception_Occurrence) is
1484 Save_Occurrence (Get_Current_Excep.all.all, X);
1485 Raise_Current_Excep (X.Id);
1486 end Reraise_Occurrence_No_Defer;
1488 ---------------------
1489 -- Save_Occurrence --
1490 ---------------------
1492 procedure Save_Occurrence
1493 (Target : out Exception_Occurrence;
1494 Source : Exception_Occurrence)
1497 Target.Id := Source.Id;
1498 Target.Msg_Length := Source.Msg_Length;
1499 Target.Num_Tracebacks := Source.Num_Tracebacks;
1500 Target.Pid := Source.Pid;
1502 Target.Msg (1 .. Target.Msg_Length) :=
1503 Source.Msg (1 .. Target.Msg_Length);
1505 Target.Tracebacks (1 .. Target.Num_Tracebacks) :=
1506 Source.Tracebacks (1 .. Target.Num_Tracebacks);
1507 end Save_Occurrence;
1509 function Save_Occurrence (Source : Exception_Occurrence) return EOA is
1510 Target : constant EOA := new Exception_Occurrence;
1512 Save_Occurrence (Target.all, Source);
1514 end Save_Occurrence;
1520 function String_To_EId (S : String) return Exception_Id
1521 renames Stream_Attributes.String_To_EId;
1527 function String_To_EO (S : String) return Exception_Occurrence
1528 renames Stream_Attributes.String_To_EO;
1534 procedure To_Stderr (C : Character) is
1535 type int is new Integer;
1537 procedure put_char_stderr (C : int);
1538 pragma Import (C, put_char_stderr, "put_char_stderr");
1541 put_char_stderr (Character'Pos (C));
1544 procedure To_Stderr (S : String) is
1546 for J in S'Range loop
1547 if S (J) /= ASCII.CR then
1553 -------------------------
1554 -- Transfer_Occurrence --
1555 -------------------------
1557 procedure Transfer_Occurrence
1558 (Target : Exception_Occurrence_Access;
1559 Source : Exception_Occurrence)
1562 Save_Occurrence (Target.all, Source);
1563 end Transfer_Occurrence;
1565 ------------------------
1566 -- Triggered_By_Abort --
1567 ------------------------
1569 function Triggered_By_Abort return Boolean is
1570 Ex : constant Exception_Occurrence_Access := Get_Current_Excep.all;
1574 and then Exception_Identity (Ex.all) = Standard'Abort_Signal'Identity;
1575 end Triggered_By_Abort;
1577 -------------------------
1578 -- Wide_Exception_Name --
1579 -------------------------
1581 WC_Encoding : Character;
1582 pragma Import (C, WC_Encoding, "__gl_wc_encoding");
1583 -- Encoding method for source, as exported by binder
1585 function Wide_Exception_Name
1586 (Id : Exception_Id) return Wide_String
1588 S : constant String := Exception_Name (Id);
1589 W : Wide_String (1 .. S'Length);
1592 String_To_Wide_String
1593 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1595 end Wide_Exception_Name;
1597 function Wide_Exception_Name
1598 (X : Exception_Occurrence) return Wide_String
1600 S : constant String := Exception_Name (X);
1601 W : Wide_String (1 .. S'Length);
1604 String_To_Wide_String
1605 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1607 end Wide_Exception_Name;
1609 ----------------------------
1610 -- Wide_Wide_Exception_Name --
1611 -----------------------------
1613 function Wide_Wide_Exception_Name
1614 (Id : Exception_Id) return Wide_Wide_String
1616 S : constant String := Exception_Name (Id);
1617 W : Wide_Wide_String (1 .. S'Length);
1620 String_To_Wide_Wide_String
1621 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1623 end Wide_Wide_Exception_Name;
1625 function Wide_Wide_Exception_Name
1626 (X : Exception_Occurrence) return Wide_Wide_String
1628 S : constant String := Exception_Name (X);
1629 W : Wide_Wide_String (1 .. S'Length);
1632 String_To_Wide_Wide_String
1633 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1635 end Wide_Wide_Exception_Name;
1637 --------------------------
1638 -- Code_Address_For_ZZZ --
1639 --------------------------
1641 -- This function gives us the end of the PC range for addresses
1642 -- within the exception unit itself. We hope that gigi/gcc keeps all the
1643 -- procedures in their original order!
1645 function Code_Address_For_ZZZ return System.Address is
1648 return Start_Of_ZZZ'Address;
1649 end Code_Address_For_ZZZ;