OSDN Git Service

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