Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / ada / a-except-2005.adb
blob69e6406a634c9cb0effb914343c4f08ac857e0d9
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-2007, 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This version is used for all Ada 2005 builds. It differs from a-except.ads
35 -- only with respect to the addition of Wide_[Wide]Exception_Name functions.
37 -- The reason for this splitting off of a separate version is that bootstrap
38 -- compilers often will be used that do not support Ada 2005 features, and
39 -- Ada.Exceptions is part of the compiler sources.
41 -- The base version of this unit Ada.Exceptions omits the Wide version of
42 -- Exception_Name and is used to build the compiler and other basic tools.
44 pragma Style_Checks (All_Checks);
45 -- No subprogram ordering check, due to logical grouping
47 pragma Polling (Off);
48 -- We must turn polling off for this unit, because otherwise we get
49 -- elaboration circularities with System.Exception_Tables.
51 with System; use System;
52 with System.Exceptions; use System.Exceptions;
53 with System.Standard_Library; use System.Standard_Library;
54 with System.Soft_Links; use System.Soft_Links;
55 with System.WCh_Con; use System.WCh_Con;
56 with System.WCh_StW; use System.WCh_StW;
58 package body Ada.Exceptions is
60 pragma Suppress (All_Checks);
61 -- We definitely do not want exceptions occurring within this unit, or
62 -- we are in big trouble. If an exceptional situation does occur, better
63 -- that it not be raised, since raising it can cause confusing chaos.
65 -----------------------
66 -- Local Subprograms --
67 -----------------------
69 -- Note: the exported subprograms in this package body are called directly
70 -- from C clients using the given external name, even though they are not
71 -- technically visible in the Ada sense.
73 function Code_Address_For_AAA return System.Address;
74 function Code_Address_For_ZZZ return System.Address;
75 -- Return start and end of procedures in this package
77 -- These procedures are used to provide exclusion bounds in
78 -- calls to Call_Chain at exception raise points from this unit. The
79 -- purpose is to arrange for the exception tracebacks not to include
80 -- frames from routines involved in the raise process, as these are
81 -- meaningless from the user's standpoint.
83 -- For these bounds to be meaningful, we need to ensure that the object
84 -- code for the routines involved in processing a raise is located after
85 -- the object code Code_Address_For_AAA and before the object code
86 -- Code_Address_For_ZZZ. This will indeed be the case as long as the
87 -- following rules are respected:
89 -- 1) The bodies of the subprograms involved in processing a raise
90 -- are located after the body of Code_Address_For_AAA and before the
91 -- body of Code_Address_For_ZZZ.
93 -- 2) No pragma Inline applies to any of these subprograms, as this
94 -- could delay the corresponding assembly output until the end of
95 -- the unit.
97 procedure Call_Chain (Excep : EOA);
98 -- Store up to Max_Tracebacks in Excep, corresponding to the current
99 -- call chain.
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
119 (Id : Exception_Id;
120 Msg1 : System.Address;
121 Line : 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. When Msg2 is non-null, a space and this additional null
129 -- 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 M : System.Address := System.Null_Address);
315 pragma No_Return (Raise_With_Location_And_Msg);
316 -- Raise an exception with given exception id value. A filename and line
317 -- number is associated with the raise and is stored in the exception
318 -- occurrence and in addition a string message M is appended to
319 -- this (if M is not null).
321 procedure Raise_Constraint_Error
322 (File : System.Address;
323 Line : Integer);
324 pragma No_Return (Raise_Constraint_Error);
325 pragma Export
326 (C, Raise_Constraint_Error, "__gnat_raise_constraint_error");
327 -- Raise constraint error with file:line information
329 procedure Raise_Constraint_Error_Msg
330 (File : System.Address;
331 Line : Integer;
332 Msg : System.Address);
333 pragma No_Return (Raise_Constraint_Error_Msg);
334 pragma Export
335 (C, Raise_Constraint_Error_Msg, "__gnat_raise_constraint_error_msg");
336 -- Raise constraint error with file:line + msg information
338 procedure Raise_Program_Error
339 (File : System.Address;
340 Line : Integer);
341 pragma No_Return (Raise_Program_Error);
342 pragma Export
343 (C, Raise_Program_Error, "__gnat_raise_program_error");
344 -- Raise program error with file:line information
346 procedure Raise_Program_Error_Msg
347 (File : System.Address;
348 Line : Integer;
349 Msg : System.Address);
350 pragma No_Return (Raise_Program_Error_Msg);
351 pragma Export
352 (C, Raise_Program_Error_Msg, "__gnat_raise_program_error_msg");
353 -- Raise program error with file:line + msg information
355 procedure Raise_Storage_Error
356 (File : System.Address;
357 Line : Integer);
358 pragma No_Return (Raise_Storage_Error);
359 pragma Export
360 (C, Raise_Storage_Error, "__gnat_raise_storage_error");
361 -- Raise storage error with file:line information
363 procedure Raise_Storage_Error_Msg
364 (File : System.Address;
365 Line : Integer;
366 Msg : System.Address);
367 pragma No_Return (Raise_Storage_Error_Msg);
368 pragma Export
369 (C, Raise_Storage_Error_Msg, "__gnat_raise_storage_error_msg");
370 -- Raise storage error with file:line + reason msg information
372 -- The exception raising process and the automatic tracing mechanism rely
373 -- on some careful use of flags attached to the exception occurrence. The
374 -- graph below illustrates the relations between the Raise_ subprograms
375 -- and identifies the points where basic flags such as Exception_Raised
376 -- are initialized.
378 -- (i) signs indicate the flags initialization points. R stands for Raise,
379 -- W for With, and E for Exception.
381 -- R_No_Msg R_E R_Pe R_Ce R_Se
382 -- | | | | |
383 -- +--+ +--+ +---+ | +---+
384 -- | | | | |
385 -- R_E_No_Defer(i) R_W_Msg(i) R_W_Loc
386 -- | | | |
387 -- +------------+ | +-----------+ +--+
388 -- | | | |
389 -- | | | Set_E_C_Msg(i)
390 -- | | |
391 -- Raise_Current_Excep
393 procedure Reraise;
394 pragma No_Return (Reraise);
395 pragma Export (C, Reraise, "__gnat_reraise");
396 -- Reraises the exception referenced by the Current_Excep field of
397 -- the TSD (all fields of this exception occurrence are set). Abort
398 -- is deferred before the reraise operation.
400 -- Save_Occurrence variations: As the management of the private data
401 -- attached to occurrences is delicate, wether or not pointers to such
402 -- data has to be copied in various situations is better made explicit.
403 -- The following procedures provide an internal interface to help making
404 -- this explicit.
406 procedure Save_Occurrence_No_Private
407 (Target : out Exception_Occurrence;
408 Source : Exception_Occurrence);
409 -- Copy all the components of Source to Target, except the
410 -- Private_Data pointer.
412 procedure Transfer_Occurrence
413 (Target : Exception_Occurrence_Access;
414 Source : Exception_Occurrence);
415 pragma Export (C, Transfer_Occurrence, "__gnat_transfer_occurrence");
416 -- Called from System.Tasking.RendezVous.Exceptional_Complete_RendezVous
417 -- to setup Target from Source as an exception to be propagated in the
418 -- caller task. Target is expected to be a pointer to the fixed TSD
419 -- occurrence for this task.
421 -----------------------------
422 -- Run-Time Check Routines --
423 -----------------------------
425 -- These routines are called from the runtime to raise a specific
426 -- exception with a reason message attached. The parameters are
427 -- the file name and line number in each case. The names are keyed
428 -- to the codes defined in Types.ads and a-types.h (for example,
429 -- the name Rcheck_05 refers to the Reason whose Pos code is 5).
431 procedure Rcheck_00 (File : System.Address; Line : Integer);
432 procedure Rcheck_01 (File : System.Address; Line : Integer);
433 procedure Rcheck_02 (File : System.Address; Line : Integer);
434 procedure Rcheck_03 (File : System.Address; Line : Integer);
435 procedure Rcheck_04 (File : System.Address; Line : Integer);
436 procedure Rcheck_05 (File : System.Address; Line : Integer);
437 procedure Rcheck_06 (File : System.Address; Line : Integer);
438 procedure Rcheck_07 (File : System.Address; Line : Integer);
439 procedure Rcheck_08 (File : System.Address; Line : Integer);
440 procedure Rcheck_09 (File : System.Address; Line : Integer);
441 procedure Rcheck_10 (File : System.Address; Line : Integer);
442 procedure Rcheck_11 (File : System.Address; Line : Integer);
443 procedure Rcheck_12 (File : System.Address; Line : Integer);
444 procedure Rcheck_13 (File : System.Address; Line : Integer);
445 procedure Rcheck_14 (File : System.Address; Line : Integer);
446 procedure Rcheck_15 (File : System.Address; Line : Integer);
447 procedure Rcheck_16 (File : System.Address; Line : Integer);
448 procedure Rcheck_17 (File : System.Address; Line : Integer);
449 procedure Rcheck_18 (File : System.Address; Line : Integer);
450 procedure Rcheck_19 (File : System.Address; Line : Integer);
451 procedure Rcheck_20 (File : System.Address; Line : Integer);
452 procedure Rcheck_21 (File : System.Address; Line : Integer);
453 procedure Rcheck_22 (File : System.Address; Line : Integer);
454 procedure Rcheck_23 (File : System.Address; Line : Integer);
455 procedure Rcheck_24 (File : System.Address; Line : Integer);
456 procedure Rcheck_25 (File : System.Address; Line : Integer);
457 procedure Rcheck_26 (File : System.Address; Line : Integer);
458 procedure Rcheck_27 (File : System.Address; Line : Integer);
459 procedure Rcheck_28 (File : System.Address; Line : Integer);
460 procedure Rcheck_29 (File : System.Address; Line : Integer);
461 procedure Rcheck_30 (File : System.Address; Line : Integer);
462 procedure Rcheck_31 (File : System.Address; Line : Integer);
463 procedure Rcheck_32 (File : System.Address; Line : Integer);
465 pragma Export (C, Rcheck_00, "__gnat_rcheck_00");
466 pragma Export (C, Rcheck_01, "__gnat_rcheck_01");
467 pragma Export (C, Rcheck_02, "__gnat_rcheck_02");
468 pragma Export (C, Rcheck_03, "__gnat_rcheck_03");
469 pragma Export (C, Rcheck_04, "__gnat_rcheck_04");
470 pragma Export (C, Rcheck_05, "__gnat_rcheck_05");
471 pragma Export (C, Rcheck_06, "__gnat_rcheck_06");
472 pragma Export (C, Rcheck_07, "__gnat_rcheck_07");
473 pragma Export (C, Rcheck_08, "__gnat_rcheck_08");
474 pragma Export (C, Rcheck_09, "__gnat_rcheck_09");
475 pragma Export (C, Rcheck_10, "__gnat_rcheck_10");
476 pragma Export (C, Rcheck_11, "__gnat_rcheck_11");
477 pragma Export (C, Rcheck_12, "__gnat_rcheck_12");
478 pragma Export (C, Rcheck_13, "__gnat_rcheck_13");
479 pragma Export (C, Rcheck_14, "__gnat_rcheck_14");
480 pragma Export (C, Rcheck_15, "__gnat_rcheck_15");
481 pragma Export (C, Rcheck_16, "__gnat_rcheck_16");
482 pragma Export (C, Rcheck_17, "__gnat_rcheck_17");
483 pragma Export (C, Rcheck_18, "__gnat_rcheck_18");
484 pragma Export (C, Rcheck_19, "__gnat_rcheck_19");
485 pragma Export (C, Rcheck_20, "__gnat_rcheck_20");
486 pragma Export (C, Rcheck_21, "__gnat_rcheck_21");
487 pragma Export (C, Rcheck_22, "__gnat_rcheck_22");
488 pragma Export (C, Rcheck_23, "__gnat_rcheck_23");
489 pragma Export (C, Rcheck_24, "__gnat_rcheck_24");
490 pragma Export (C, Rcheck_25, "__gnat_rcheck_25");
491 pragma Export (C, Rcheck_26, "__gnat_rcheck_26");
492 pragma Export (C, Rcheck_27, "__gnat_rcheck_27");
493 pragma Export (C, Rcheck_28, "__gnat_rcheck_28");
494 pragma Export (C, Rcheck_29, "__gnat_rcheck_29");
495 pragma Export (C, Rcheck_30, "__gnat_rcheck_30");
496 pragma Export (C, Rcheck_31, "__gnat_rcheck_31");
497 pragma Export (C, Rcheck_32, "__gnat_rcheck_32");
499 -- None of these procedures ever returns (they raise an exception!). By
500 -- using pragma No_Return, we ensure that any junk code after the call,
501 -- such as normal return epilog stuff, can be eliminated).
503 pragma No_Return (Rcheck_00);
504 pragma No_Return (Rcheck_01);
505 pragma No_Return (Rcheck_02);
506 pragma No_Return (Rcheck_03);
507 pragma No_Return (Rcheck_04);
508 pragma No_Return (Rcheck_05);
509 pragma No_Return (Rcheck_06);
510 pragma No_Return (Rcheck_07);
511 pragma No_Return (Rcheck_08);
512 pragma No_Return (Rcheck_09);
513 pragma No_Return (Rcheck_10);
514 pragma No_Return (Rcheck_11);
515 pragma No_Return (Rcheck_12);
516 pragma No_Return (Rcheck_13);
517 pragma No_Return (Rcheck_14);
518 pragma No_Return (Rcheck_15);
519 pragma No_Return (Rcheck_16);
520 pragma No_Return (Rcheck_17);
521 pragma No_Return (Rcheck_18);
522 pragma No_Return (Rcheck_19);
523 pragma No_Return (Rcheck_20);
524 pragma No_Return (Rcheck_21);
525 pragma No_Return (Rcheck_22);
526 pragma No_Return (Rcheck_23);
527 pragma No_Return (Rcheck_24);
528 pragma No_Return (Rcheck_25);
529 pragma No_Return (Rcheck_26);
530 pragma No_Return (Rcheck_27);
531 pragma No_Return (Rcheck_28);
532 pragma No_Return (Rcheck_29);
533 pragma No_Return (Rcheck_30);
534 pragma No_Return (Rcheck_32);
536 ---------------------------------------------
537 -- Reason Strings for Run-Time Check Calls --
538 ---------------------------------------------
540 -- These strings are null-terminated and are used by Rcheck_nn. The
541 -- strings correspond to the definitions for Types.RT_Exception_Code.
543 use ASCII;
545 Rmsg_00 : constant String := "access check failed" & NUL;
546 Rmsg_01 : constant String := "access parameter is null" & NUL;
547 Rmsg_02 : constant String := "discriminant check failed" & NUL;
548 Rmsg_03 : constant String := "divide by zero" & NUL;
549 Rmsg_04 : constant String := "explicit raise" & NUL;
550 Rmsg_05 : constant String := "index check failed" & NUL;
551 Rmsg_06 : constant String := "invalid data" & NUL;
552 Rmsg_07 : constant String := "length check failed" & NUL;
553 Rmsg_08 : constant String := "null Exception_Id" & NUL;
554 Rmsg_09 : constant String := "null-exclusion check failed" & NUL;
555 Rmsg_10 : constant String := "overflow check failed" & NUL;
556 Rmsg_11 : constant String := "partition check failed" & NUL;
557 Rmsg_12 : constant String := "range check failed" & NUL;
558 Rmsg_13 : constant String := "tag check failed" & NUL;
559 Rmsg_14 : constant String := "access before elaboration" & NUL;
560 Rmsg_15 : constant String := "accessibility check failed" & NUL;
561 Rmsg_16 : constant String := "all guards closed" & NUL;
562 Rmsg_17 : constant String := "Current_Task referenced in entry" &
563 " body" & NUL;
564 Rmsg_18 : constant String := "duplicated entry address" & NUL;
565 Rmsg_19 : constant String := "explicit raise" & NUL;
566 Rmsg_20 : constant String := "finalize/adjust raised exception" & NUL;
567 Rmsg_21 : constant String := "implicit return with No_Return" & NUL;
568 Rmsg_22 : constant String := "misaligned address value" & NUL;
569 Rmsg_23 : constant String := "missing return" & NUL;
570 Rmsg_24 : constant String := "overlaid controlled object" & NUL;
571 Rmsg_25 : constant String := "potentially blocking operation" & NUL;
572 Rmsg_26 : constant String := "stubbed subprogram called" & NUL;
573 Rmsg_27 : constant String := "unchecked union restriction" & NUL;
574 Rmsg_28 : constant String := "actual/returned class-wide value "
575 & "not transportable" & NUL;
576 Rmsg_29 : constant String := "empty storage pool" & NUL;
577 Rmsg_30 : constant String := "explicit raise" & NUL;
578 Rmsg_31 : constant String := "infinite recursion" & NUL;
579 Rmsg_32 : constant String := "object too large" & NUL;
581 -----------------------
582 -- Polling Interface --
583 -----------------------
585 type Unsigned is mod 2 ** 32;
587 Counter : Unsigned := 0;
588 pragma Warnings (Off, Counter);
589 -- This counter is provided for convenience. It can be used in Poll to
590 -- perform periodic but not systematic operations.
592 procedure Poll is separate;
593 -- The actual polling routine is separate, so that it can easily
594 -- be replaced with a target dependent version.
596 --------------------------
597 -- Code_Address_For_AAA --
598 --------------------------
600 -- This function gives us the start of the PC range for addresses
601 -- within the exception unit itself. We hope that gigi/gcc keep all the
602 -- procedures in their original order!
604 function Code_Address_For_AAA return System.Address is
605 begin
606 -- We are using a label instead of merely using
607 -- Code_Address_For_AAA'Address because on some platforms the latter
608 -- does not yield the address we want, but the address of a stub or of
609 -- a descriptor instead. This is the case at least on Alpha-VMS and
610 -- PA-HPUX.
612 <<Start_Of_AAA>>
613 return Start_Of_AAA'Address;
614 end Code_Address_For_AAA;
616 ----------------
617 -- Call_Chain --
618 ----------------
620 procedure Call_Chain (Excep : EOA) is separate;
621 -- The actual Call_Chain routine is separate, so that it can easily
622 -- be dummied out when no exception traceback information is needed.
624 ------------------------------
625 -- Current_Target_Exception --
626 ------------------------------
628 function Current_Target_Exception return Exception_Occurrence is
629 begin
630 return Null_Occurrence;
631 end Current_Target_Exception;
633 -------------------
634 -- EId_To_String --
635 -------------------
637 function EId_To_String (X : Exception_Id) return String
638 renames Stream_Attributes.EId_To_String;
640 ------------------
641 -- EO_To_String --
642 ------------------
644 -- We use the null string to represent the null occurrence, otherwise
645 -- we output the Exception_Information string for the occurrence.
647 function EO_To_String (X : Exception_Occurrence) return String
648 renames Stream_Attributes.EO_To_String;
650 ------------------------
651 -- Exception_Identity --
652 ------------------------
654 function Exception_Identity
655 (X : Exception_Occurrence) return Exception_Id
657 begin
658 -- Note that the following test used to be here for the original
659 -- Ada 95 semantics, but these were modified by AI-241 to require
660 -- returning Null_Id instead of raising Constraint_Error.
662 -- if X.Id = Null_Id then
663 -- raise Constraint_Error;
664 -- end if;
666 return X.Id;
667 end Exception_Identity;
669 ---------------------------
670 -- Exception_Information --
671 ---------------------------
673 function Exception_Information (X : Exception_Occurrence) return String is
674 begin
675 if X.Id = Null_Id then
676 raise Constraint_Error;
677 end if;
679 return Exception_Data.Exception_Information (X);
680 end Exception_Information;
682 -----------------------
683 -- Exception_Message --
684 -----------------------
686 function Exception_Message (X : Exception_Occurrence) return String is
687 begin
688 if X.Id = Null_Id then
689 raise Constraint_Error;
690 end if;
692 return X.Msg (1 .. X.Msg_Length);
693 end Exception_Message;
695 --------------------
696 -- Exception_Name --
697 --------------------
699 function Exception_Name (Id : Exception_Id) return String is
700 begin
701 if Id = null then
702 raise Constraint_Error;
703 end if;
705 return To_Ptr (Id.Full_Name) (1 .. Id.Name_Length - 1);
706 end Exception_Name;
708 function Exception_Name (X : Exception_Occurrence) return String is
709 begin
710 return Exception_Name (X.Id);
711 end Exception_Name;
713 ---------------------------
714 -- Exception_Name_Simple --
715 ---------------------------
717 function Exception_Name_Simple (X : Exception_Occurrence) return String is
718 Name : constant String := Exception_Name (X);
719 P : Natural;
721 begin
722 P := Name'Length;
723 while P > 1 loop
724 exit when Name (P - 1) = '.';
725 P := P - 1;
726 end loop;
728 -- Return result making sure lower bound is 1
730 declare
731 subtype Rname is String (1 .. Name'Length - P + 1);
732 begin
733 return Rname (Name (P .. Name'Length));
734 end;
735 end Exception_Name_Simple;
737 --------------------
738 -- Exception_Data --
739 --------------------
741 package body Exception_Data is separate;
742 -- This package can be easily dummied out if we do not want the
743 -- basic support for exception messages (such as in Ada 83).
745 ---------------------------
746 -- Exception_Propagation --
747 ---------------------------
749 package body Exception_Propagation is separate;
750 -- Depending on the actual exception mechanism used (front-end or
751 -- back-end based), the implementation will differ, which is why this
752 -- package is separated.
754 ----------------------
755 -- Exception_Traces --
756 ----------------------
758 package body Exception_Traces is separate;
759 -- Depending on the underlying support for IO the implementation
760 -- will differ. Moreover we would like to dummy out this package
761 -- in case we do not want any exception tracing support. This is
762 -- why this package is separated.
764 -----------------------
765 -- Stream Attributes --
766 -----------------------
768 package body Stream_Attributes is separate;
769 -- This package can be easily dummied out if we do not want the
770 -- support for streaming Exception_Ids and Exception_Occurrences.
772 ----------------------------
773 -- Raise_Constraint_Error --
774 ----------------------------
776 procedure Raise_Constraint_Error
777 (File : System.Address;
778 Line : Integer)
780 begin
781 Raise_With_Location_And_Msg
782 (Constraint_Error_Def'Access, File, Line);
783 end Raise_Constraint_Error;
785 --------------------------------
786 -- Raise_Constraint_Error_Msg --
787 --------------------------------
789 procedure Raise_Constraint_Error_Msg
790 (File : System.Address;
791 Line : Integer;
792 Msg : System.Address)
794 begin
795 Raise_With_Location_And_Msg
796 (Constraint_Error_Def'Access, File, Line, Msg);
797 end Raise_Constraint_Error_Msg;
799 -------------------------
800 -- Raise_Current_Excep --
801 -------------------------
803 procedure Raise_Current_Excep (E : Exception_Id) is
805 pragma Inspection_Point (E);
806 -- This is so the debugger can reliably inspect the parameter when
807 -- inserting a breakpoint at the start of this procedure.
809 -- To provide support for breakpoints on unhandled exceptions, the
810 -- debugger will also need to be able to inspect the value of E from
811 -- inner frames so we need to make sure that its value is also spilled
812 -- on stack. We take the address and dereference using volatile local
813 -- objects for this purpose.
815 -- The pragma Warnings (Off) are needed because the compiler knows that
816 -- these locals are not referenced and that this use of pragma Volatile
817 -- is peculiar!
819 type EID_Access is access Exception_Id;
821 Access_To_E : EID_Access := E'Unrestricted_Access;
822 pragma Volatile (Access_To_E);
823 pragma Warnings (Off, Access_To_E);
825 Id : Exception_Id := Access_To_E.all;
826 pragma Volatile (Id);
827 pragma Warnings (Off, Id);
829 begin
830 Debug_Raise_Exception (E => SSL.Exception_Data_Ptr (E));
831 Exception_Propagation.Propagate_Exception
832 (E => E, From_Signal_Handler => False);
833 end Raise_Current_Excep;
835 ---------------------
836 -- Raise_Exception --
837 ---------------------
839 procedure Raise_Exception
840 (E : Exception_Id;
841 Message : String := "")
843 begin
844 if E /= null then
845 Exception_Data.Set_Exception_Msg (E, Message);
846 Abort_Defer.all;
847 Raise_Current_Excep (E);
848 end if;
850 -- Note: if E is null, then we simply return, which is correct Ada 95
851 -- semantics. If we are operating in Ada 2005 mode, then the expander
852 -- generates a raise Constraint_Error immediately following the call
853 -- to provide the required Ada 2005 semantics (see AI-329). We do it
854 -- this way to avoid having run time dependencies on the Ada version.
856 return;
857 end Raise_Exception;
859 ----------------------------
860 -- Raise_Exception_Always --
861 ----------------------------
863 procedure Raise_Exception_Always
864 (E : Exception_Id;
865 Message : String := "")
867 begin
868 Exception_Data.Set_Exception_Msg (E, Message);
869 Abort_Defer.all;
870 Raise_Current_Excep (E);
871 end Raise_Exception_Always;
873 -------------------------------------
874 -- Raise_From_Controlled_Operation --
875 -------------------------------------
877 procedure Raise_From_Controlled_Operation
878 (X : Ada.Exceptions.Exception_Occurrence)
880 Prefix : constant String := "adjust/finalize raised ";
881 Orig_Msg : constant String := Exception_Message (X);
882 New_Msg : constant String := Prefix & Exception_Name (X);
884 begin
885 if Orig_Msg'Length >= Prefix'Length
886 and then
887 Orig_Msg (Orig_Msg'First .. Orig_Msg'First + Prefix'Length - 1) =
888 Prefix
889 then
890 -- Message already has proper prefix, just re-reraise PROGRAM_ERROR
892 Raise_Exception_No_Defer
893 (E => Program_Error'Identity,
894 Message => Orig_Msg);
896 elsif Orig_Msg = "" then
898 -- No message present: just provide our own
900 Raise_Exception_No_Defer
901 (E => Program_Error'Identity,
902 Message => New_Msg);
904 else
905 -- Message present, add informational prefix
907 Raise_Exception_No_Defer
908 (E => Program_Error'Identity,
909 Message => New_Msg & ": " & Orig_Msg);
910 end if;
911 end Raise_From_Controlled_Operation;
913 -------------------------------
914 -- Raise_From_Signal_Handler --
915 -------------------------------
917 procedure Raise_From_Signal_Handler
918 (E : Exception_Id;
919 M : System.Address)
921 begin
922 Exception_Data.Set_Exception_C_Msg (E, M);
923 Abort_Defer.all;
924 Exception_Propagation.Propagate_Exception
925 (E => E, From_Signal_Handler => True);
926 end Raise_From_Signal_Handler;
928 -------------------------
929 -- Raise_Program_Error --
930 -------------------------
932 procedure Raise_Program_Error
933 (File : System.Address;
934 Line : Integer)
936 begin
937 Raise_With_Location_And_Msg
938 (Program_Error_Def'Access, File, Line);
939 end Raise_Program_Error;
941 -----------------------------
942 -- Raise_Program_Error_Msg --
943 -----------------------------
945 procedure Raise_Program_Error_Msg
946 (File : System.Address;
947 Line : Integer;
948 Msg : System.Address)
950 begin
951 Raise_With_Location_And_Msg
952 (Program_Error_Def'Access, File, Line, Msg);
953 end Raise_Program_Error_Msg;
955 -------------------------
956 -- Raise_Storage_Error --
957 -------------------------
959 procedure Raise_Storage_Error
960 (File : System.Address;
961 Line : Integer)
963 begin
964 Raise_With_Location_And_Msg
965 (Storage_Error_Def'Access, File, Line);
966 end Raise_Storage_Error;
968 -----------------------------
969 -- Raise_Storage_Error_Msg --
970 -----------------------------
972 procedure Raise_Storage_Error_Msg
973 (File : System.Address;
974 Line : Integer;
975 Msg : System.Address)
977 begin
978 Raise_With_Location_And_Msg
979 (Storage_Error_Def'Access, File, Line, Msg);
980 end Raise_Storage_Error_Msg;
982 ---------------------------------
983 -- Raise_With_Location_And_Msg --
984 ---------------------------------
986 procedure Raise_With_Location_And_Msg
987 (E : Exception_Id;
988 F : System.Address;
989 L : Integer;
990 M : System.Address := System.Null_Address)
992 begin
993 Exception_Data.Set_Exception_C_Msg (E, F, L, M);
994 Abort_Defer.all;
995 Raise_Current_Excep (E);
996 end Raise_With_Location_And_Msg;
998 --------------------
999 -- Raise_With_Msg --
1000 --------------------
1002 procedure Raise_With_Msg (E : Exception_Id) is
1003 Excep : constant EOA := Get_Current_Excep.all;
1005 begin
1006 Exception_Propagation.Setup_Exception (Excep, Excep);
1008 Excep.Exception_Raised := False;
1009 Excep.Id := E;
1010 Excep.Num_Tracebacks := 0;
1011 Excep.Cleanup_Flag := False;
1012 Excep.Pid := Local_Partition_ID;
1013 Abort_Defer.all;
1014 Raise_Current_Excep (E);
1015 end Raise_With_Msg;
1017 --------------------------------------
1018 -- Calls to Run-Time Check Routines --
1019 --------------------------------------
1021 procedure Rcheck_00 (File : System.Address; Line : Integer) is
1022 begin
1023 Raise_Constraint_Error_Msg (File, Line, Rmsg_00'Address);
1024 end Rcheck_00;
1026 procedure Rcheck_01 (File : System.Address; Line : Integer) is
1027 begin
1028 Raise_Constraint_Error_Msg (File, Line, Rmsg_01'Address);
1029 end Rcheck_01;
1031 procedure Rcheck_02 (File : System.Address; Line : Integer) is
1032 begin
1033 Raise_Constraint_Error_Msg (File, Line, Rmsg_02'Address);
1034 end Rcheck_02;
1036 procedure Rcheck_03 (File : System.Address; Line : Integer) is
1037 begin
1038 Raise_Constraint_Error_Msg (File, Line, Rmsg_03'Address);
1039 end Rcheck_03;
1041 procedure Rcheck_04 (File : System.Address; Line : Integer) is
1042 begin
1043 Raise_Constraint_Error_Msg (File, Line, Rmsg_04'Address);
1044 end Rcheck_04;
1046 procedure Rcheck_05 (File : System.Address; Line : Integer) is
1047 begin
1048 Raise_Constraint_Error_Msg (File, Line, Rmsg_05'Address);
1049 end Rcheck_05;
1051 procedure Rcheck_06 (File : System.Address; Line : Integer) is
1052 begin
1053 Raise_Constraint_Error_Msg (File, Line, Rmsg_06'Address);
1054 end Rcheck_06;
1056 procedure Rcheck_07 (File : System.Address; Line : Integer) is
1057 begin
1058 Raise_Constraint_Error_Msg (File, Line, Rmsg_07'Address);
1059 end Rcheck_07;
1061 procedure Rcheck_08 (File : System.Address; Line : Integer) is
1062 begin
1063 Raise_Constraint_Error_Msg (File, Line, Rmsg_08'Address);
1064 end Rcheck_08;
1066 procedure Rcheck_09 (File : System.Address; Line : Integer) is
1067 begin
1068 Raise_Constraint_Error_Msg (File, Line, Rmsg_09'Address);
1069 end Rcheck_09;
1071 procedure Rcheck_10 (File : System.Address; Line : Integer) is
1072 begin
1073 Raise_Constraint_Error_Msg (File, Line, Rmsg_10'Address);
1074 end Rcheck_10;
1076 procedure Rcheck_11 (File : System.Address; Line : Integer) is
1077 begin
1078 Raise_Constraint_Error_Msg (File, Line, Rmsg_11'Address);
1079 end Rcheck_11;
1081 procedure Rcheck_12 (File : System.Address; Line : Integer) is
1082 begin
1083 Raise_Constraint_Error_Msg (File, Line, Rmsg_12'Address);
1084 end Rcheck_12;
1086 procedure Rcheck_13 (File : System.Address; Line : Integer) is
1087 begin
1088 Raise_Constraint_Error_Msg (File, Line, Rmsg_13'Address);
1089 end Rcheck_13;
1091 procedure Rcheck_14 (File : System.Address; Line : Integer) is
1092 begin
1093 Raise_Program_Error_Msg (File, Line, Rmsg_14'Address);
1094 end Rcheck_14;
1096 procedure Rcheck_15 (File : System.Address; Line : Integer) is
1097 begin
1098 Raise_Program_Error_Msg (File, Line, Rmsg_15'Address);
1099 end Rcheck_15;
1101 procedure Rcheck_16 (File : System.Address; Line : Integer) is
1102 begin
1103 Raise_Program_Error_Msg (File, Line, Rmsg_16'Address);
1104 end Rcheck_16;
1106 procedure Rcheck_17 (File : System.Address; Line : Integer) is
1107 begin
1108 Raise_Program_Error_Msg (File, Line, Rmsg_17'Address);
1109 end Rcheck_17;
1111 procedure Rcheck_18 (File : System.Address; Line : Integer) is
1112 begin
1113 Raise_Program_Error_Msg (File, Line, Rmsg_18'Address);
1114 end Rcheck_18;
1116 procedure Rcheck_19 (File : System.Address; Line : Integer) is
1117 begin
1118 Raise_Program_Error_Msg (File, Line, Rmsg_19'Address);
1119 end Rcheck_19;
1121 procedure Rcheck_20 (File : System.Address; Line : Integer) is
1122 begin
1123 Raise_Program_Error_Msg (File, Line, Rmsg_20'Address);
1124 end Rcheck_20;
1126 procedure Rcheck_21 (File : System.Address; Line : Integer) is
1127 begin
1128 Raise_Program_Error_Msg (File, Line, Rmsg_21'Address);
1129 end Rcheck_21;
1131 procedure Rcheck_22 (File : System.Address; Line : Integer) is
1132 begin
1133 Raise_Program_Error_Msg (File, Line, Rmsg_22'Address);
1134 end Rcheck_22;
1136 procedure Rcheck_23 (File : System.Address; Line : Integer) is
1137 begin
1138 Raise_Program_Error_Msg (File, Line, Rmsg_23'Address);
1139 end Rcheck_23;
1141 procedure Rcheck_24 (File : System.Address; Line : Integer) is
1142 begin
1143 Raise_Program_Error_Msg (File, Line, Rmsg_24'Address);
1144 end Rcheck_24;
1146 procedure Rcheck_25 (File : System.Address; Line : Integer) is
1147 begin
1148 Raise_Program_Error_Msg (File, Line, Rmsg_25'Address);
1149 end Rcheck_25;
1151 procedure Rcheck_26 (File : System.Address; Line : Integer) is
1152 begin
1153 Raise_Program_Error_Msg (File, Line, Rmsg_26'Address);
1154 end Rcheck_26;
1156 procedure Rcheck_27 (File : System.Address; Line : Integer) is
1157 begin
1158 Raise_Program_Error_Msg (File, Line, Rmsg_27'Address);
1159 end Rcheck_27;
1161 procedure Rcheck_28 (File : System.Address; Line : Integer) is
1162 begin
1163 Raise_Program_Error_Msg (File, Line, Rmsg_28'Address);
1164 end Rcheck_28;
1166 procedure Rcheck_29 (File : System.Address; Line : Integer) is
1167 begin
1168 Raise_Storage_Error_Msg (File, Line, Rmsg_29'Address);
1169 end Rcheck_29;
1171 procedure Rcheck_30 (File : System.Address; Line : Integer) is
1172 begin
1173 Raise_Storage_Error_Msg (File, Line, Rmsg_30'Address);
1174 end Rcheck_30;
1176 procedure Rcheck_31 (File : System.Address; Line : Integer) is
1177 begin
1178 Raise_Storage_Error_Msg (File, Line, Rmsg_31'Address);
1179 end Rcheck_31;
1181 procedure Rcheck_32 (File : System.Address; Line : Integer) is
1182 begin
1183 Raise_Storage_Error_Msg (File, Line, Rmsg_32'Address);
1184 end Rcheck_32;
1186 -------------
1187 -- Reraise --
1188 -------------
1190 procedure Reraise is
1191 Excep : constant EOA := Get_Current_Excep.all;
1193 begin
1194 Abort_Defer.all;
1195 Exception_Propagation.Setup_Exception (Excep, Excep, Reraised => True);
1196 Raise_Current_Excep (Excep.Id);
1197 end Reraise;
1199 ------------------------
1200 -- Reraise_Occurrence --
1201 ------------------------
1203 procedure Reraise_Occurrence (X : Exception_Occurrence) is
1204 begin
1205 if X.Id /= null then
1206 Abort_Defer.all;
1207 Exception_Propagation.Setup_Exception
1208 (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1209 Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1210 Raise_Current_Excep (X.Id);
1211 end if;
1212 end Reraise_Occurrence;
1214 -------------------------------
1215 -- Reraise_Occurrence_Always --
1216 -------------------------------
1218 procedure Reraise_Occurrence_Always (X : Exception_Occurrence) is
1219 begin
1220 Abort_Defer.all;
1221 Exception_Propagation.Setup_Exception
1222 (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1223 Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1224 Raise_Current_Excep (X.Id);
1225 end Reraise_Occurrence_Always;
1227 ---------------------------------
1228 -- Reraise_Occurrence_No_Defer --
1229 ---------------------------------
1231 procedure Reraise_Occurrence_No_Defer (X : Exception_Occurrence) is
1232 begin
1233 Exception_Propagation.Setup_Exception
1234 (X'Unrestricted_Access, Get_Current_Excep.all, Reraised => True);
1235 Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1236 Raise_Current_Excep (X.Id);
1237 end Reraise_Occurrence_No_Defer;
1239 ---------------------
1240 -- Save_Occurrence --
1241 ---------------------
1243 procedure Save_Occurrence
1244 (Target : out Exception_Occurrence;
1245 Source : Exception_Occurrence)
1247 begin
1248 Save_Occurrence_No_Private (Target, Source);
1249 end Save_Occurrence;
1251 function Save_Occurrence (Source : Exception_Occurrence) return EOA is
1252 Target : constant EOA := new Exception_Occurrence;
1253 begin
1254 Save_Occurrence (Target.all, Source);
1255 return Target;
1256 end Save_Occurrence;
1258 --------------------------------
1259 -- Save_Occurrence_No_Private --
1260 --------------------------------
1262 procedure Save_Occurrence_No_Private
1263 (Target : out Exception_Occurrence;
1264 Source : Exception_Occurrence)
1266 begin
1267 Target.Id := Source.Id;
1268 Target.Msg_Length := Source.Msg_Length;
1269 Target.Num_Tracebacks := Source.Num_Tracebacks;
1270 Target.Pid := Source.Pid;
1271 Target.Cleanup_Flag := Source.Cleanup_Flag;
1273 Target.Msg (1 .. Target.Msg_Length) :=
1274 Source.Msg (1 .. Target.Msg_Length);
1276 Target.Tracebacks (1 .. Target.Num_Tracebacks) :=
1277 Source.Tracebacks (1 .. Target.Num_Tracebacks);
1278 end Save_Occurrence_No_Private;
1280 -------------------------
1281 -- Transfer_Occurrence --
1282 -------------------------
1284 procedure Transfer_Occurrence
1285 (Target : Exception_Occurrence_Access;
1286 Source : Exception_Occurrence)
1288 begin
1289 -- Setup Target as an exception to be propagated in the calling task
1290 -- (rendezvous-wise), taking care not to clobber the associated private
1291 -- data. Target is expected to be a pointer to the calling task's
1292 -- fixed TSD occurrence, which is very different from Get_Current_Excep
1293 -- here because this subprogram is called from the called task.
1295 Exception_Propagation.Setup_Exception (Target, Target);
1296 Save_Occurrence_No_Private (Target.all, Source);
1297 end Transfer_Occurrence;
1299 -------------------
1300 -- String_To_EId --
1301 -------------------
1303 function String_To_EId (S : String) return Exception_Id
1304 renames Stream_Attributes.String_To_EId;
1306 ------------------
1307 -- String_To_EO --
1308 ------------------
1310 function String_To_EO (S : String) return Exception_Occurrence
1311 renames Stream_Attributes.String_To_EO;
1313 ------------------------------
1314 -- Raise_Exception_No_Defer --
1315 ------------------------------
1317 procedure Raise_Exception_No_Defer
1318 (E : Exception_Id;
1319 Message : String := "")
1321 begin
1322 Exception_Data.Set_Exception_Msg (E, Message);
1324 -- Do not call Abort_Defer.all, as specified by the spec
1326 Raise_Current_Excep (E);
1327 end Raise_Exception_No_Defer;
1329 ---------------
1330 -- To_Stderr --
1331 ---------------
1333 procedure To_Stderr (C : Character) is
1335 type int is new Integer;
1337 procedure put_char_stderr (C : int);
1338 pragma Import (C, put_char_stderr, "put_char_stderr");
1340 begin
1341 put_char_stderr (Character'Pos (C));
1342 end To_Stderr;
1344 procedure To_Stderr (S : String) is
1345 begin
1346 for J in S'Range loop
1347 if S (J) /= ASCII.CR then
1348 To_Stderr (S (J));
1349 end if;
1350 end loop;
1351 end To_Stderr;
1353 -------------------------
1354 -- Wide_Exception_Name --
1355 -------------------------
1357 WC_Encoding : Character;
1358 pragma Import (C, WC_Encoding, "__gl_wc_encoding");
1359 -- Encoding method for source, as exported by binder
1361 function Wide_Exception_Name
1362 (Id : Exception_Id) return Wide_String
1364 S : constant String := Exception_Name (Id);
1365 W : Wide_String (1 .. S'Length);
1366 L : Natural;
1367 begin
1368 String_To_Wide_String
1369 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1370 return W (1 .. L);
1371 end Wide_Exception_Name;
1373 function Wide_Exception_Name
1374 (X : Exception_Occurrence) return Wide_String
1376 S : constant String := Exception_Name (X);
1377 W : Wide_String (1 .. S'Length);
1378 L : Natural;
1379 begin
1380 String_To_Wide_String
1381 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1382 return W (1 .. L);
1383 end Wide_Exception_Name;
1385 ----------------------------
1386 -- Wide_Wide_Exception_Name --
1387 -----------------------------
1389 function Wide_Wide_Exception_Name
1390 (Id : Exception_Id) return Wide_Wide_String
1392 S : constant String := Exception_Name (Id);
1393 W : Wide_Wide_String (1 .. S'Length);
1394 L : Natural;
1395 begin
1396 String_To_Wide_Wide_String
1397 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1398 return W (1 .. L);
1399 end Wide_Wide_Exception_Name;
1401 function Wide_Wide_Exception_Name
1402 (X : Exception_Occurrence) return Wide_Wide_String
1404 S : constant String := Exception_Name (X);
1405 W : Wide_Wide_String (1 .. S'Length);
1406 L : Natural;
1407 begin
1408 String_To_Wide_Wide_String
1409 (S, W, L, Get_WC_Encoding_Method (WC_Encoding));
1410 return W (1 .. L);
1411 end Wide_Wide_Exception_Name;
1413 --------------------------
1414 -- Code_Address_For_ZZZ --
1415 --------------------------
1417 -- This function gives us the end of the PC range for addresses
1418 -- within the exception unit itself. We hope that gigi/gcc keeps all the
1419 -- procedures in their original order!
1421 function Code_Address_For_ZZZ return System.Address is
1422 begin
1423 <<Start_Of_ZZZ>>
1424 return Start_Of_ZZZ'Address;
1425 end Code_Address_For_ZZZ;
1427 end Ada.Exceptions;