OSDN Git Service

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