OSDN Git Service

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