diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-12-05 10:24:05 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-12-05 10:24:05 +0000 |
commit | cc5c9949892dee7758258051c644c3fb13a177b0 (patch) | |
tree | 5224f98552233f79c9df85272ca71ff1d098452a /gcc/ada/a-elchha.adb | |
parent | d3c486373e40434140490031575cb895e7b1cc2a (diff) | |
download | gcc-cc5c9949892dee7758258051c644c3fb13a177b0.tar.gz |
2003-12-05 Thomas Quinot <quinot@act-europe.fr>
* 3ssoliop.ads: Fix comment (this is the Solaris, not the UnixWare,
version of this unit).
2003-12-05 Olivier Hainque <hainque@act-europe.fr>
* 53osinte.ads, 54osinte.ads, 55osinte.ads, 56osinte.ads, 5bosinte.ads,
5cosinte.ads, 5hosinte.ads, 5iosinte.ads, 5losinte.ads,
5tosinte.ads: Define the SA_SIGINFO constant, to allow references from
the body of System.Interrupt_Management common to several targets.
Update copyright notice when appropriate.
* 52osinte.ads, 5posinte.ads: Define a dummy value for the SA_SIGINFO
constant.
* 7sintman.adb (elaboration): Set SA_SIGINFO in the sigaction flags,
to ensure that the kernel fills in the interrupted context structure
before calling a signal handler, which is necessary to be able to
unwind past it. Update the copyright notice.
2003-12-05 Jerome Guitton <guitton@act-europe.fr>
* a-elchha.ads: New file.
* a-elchha.adb: New default last chance handler. Contents taken from
Ada.Exceptions.Exception_Traces.Unhandled_Exception_Terminate.
* a-exextr.adb (Unhandled_Exception_Terminate): Most of this routine
is moved to a-elchha.adb to provide a target-independent default last
chance handler.
* Makefile.rtl: Add a-elchha.o
* Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS): Add a-elchha.o.
2003-12-05 Ed Schonberg <schonberg@gnat.com>
* exp_ch6.adb (Expand_Call): If the subprogram is inlined and is
declared in an instance, do not inline the call if the instance is not
frozen yet, to prevent order of elaboration problems.
* sem_prag.adb: Add comments for previous fix.
2003-12-05 Samuel Tardieu <tardieu@act-europe.fr>
* g-table.adb: Use the right variable in Set_Item.
Update copyright notice.
2003-12-05 Arnaud Charlet <charlet@act-europe.fr>
* Makefile.in: Remove unused rules.
2003-12-05 Vincent Celier <celier@gnat.com>
* switch-c.adb (Scan_Front_End_Switches): Remove processing of
-nostdlib. Not needed here after all.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74319 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-elchha.adb')
-rw-r--r-- | gcc/ada/a-elchha.adb | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/gcc/ada/a-elchha.adb b/gcc/ada/a-elchha.adb new file mode 100644 index 00000000000..12699fee225 --- /dev/null +++ b/gcc/ada/a-elchha.adb @@ -0,0 +1,169 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- A D A . E X C E P T I O N S . L A S T _ C H A N C E _ H A N D L E R -- +-- -- +-- B o d y -- +-- -- +-- Copyright (C) 2003 Free Software Foundation, Inc. -- +-- -- +-- This specification is derived from the Ada Reference Manual for use with -- +-- GNAT. The copyright notice above, and the license provisions that follow -- +-- apply solely to the contents of the part following the private keyword. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 2, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- +-- for more details. You should have received a copy of the GNU General -- +-- Public License distributed with GNAT; see file COPYING. If not, write -- +-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- +-- MA 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from this -- +-- unit, or you link this unit with other files to produce an executable, -- +-- this unit does not by itself cause the resulting executable to be -- +-- covered by the GNU General Public License. This exception does not -- +-- however invalidate any other reasons why the executable file might be -- +-- covered by the GNU Public License. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- Default version for most targets + +procedure Ada.Exceptions.Last_Chance_Handler + (Except : Exception_Occurrence) is + + procedure Unhandled_Terminate; + pragma No_Return (Unhandled_Terminate); + pragma Import (C, Unhandled_Terminate, "__gnat_unhandled_terminate"); + -- Perform system dependent shutdown code + + function Tailored_Exception_Information + (X : Exception_Occurrence) + return String; + -- Exception information to be output in the case of automatic tracing + -- requested through GNAT.Exception_Traces. + -- + -- This is the same as Exception_Information if no backtrace decorator + -- is currently in place. Otherwise, this is Exception_Information with + -- the call chain raw addresses replaced by the result of a call to the + -- current decorator provided with the call chain addresses. + + pragma Import + (Ada, Tailored_Exception_Information, + "__gnat_tailored_exception_information"); + + procedure Tailored_Exception_Information + (X : Exception_Occurrence; + Buff : in out String; + Last : in out Integer); + -- Procedural version of the above function. Instead of returning the + -- result, this one is put in Buff (Buff'first .. Buff'first + Last) + + procedure To_Stderr (S : String); + pragma Import (Ada, To_Stderr, "__gnat_to_stderr"); + -- Little routine to output string to stderr + + Nline : constant String := String'(1 => ASCII.LF); + -- Convenient shortcut + + Msg : constant String := Except.Msg (1 .. Except.Msg_Length); + + Max_Static_Exc_Info : constant := 1024; + -- This should be enough for most exception information cases + -- even though tailoring introduces some uncertainty. The + -- name+message should not exceed 320 chars, so that leaves at + -- least 35 backtrace slots (each slot needs 19 chars for + -- representing a 64 bit address). + + subtype Exc_Info_Type is String (1 .. Max_Static_Exc_Info); + type Str_Ptr is access Exc_Info_Type; + Exc_Info : Str_Ptr; + Exc_Info_Last : Natural := 0; + -- Buffer that is allocated to store the tailored exception + -- information while Adafinal is run. This buffer is allocated + -- on the heap only when it is needed. It is better to allocate + -- on the heap than on the stack since stack overflows are more + -- common than heap overflows. + + procedure Tailored_Exception_Information + (X : Exception_Occurrence; + Buff : in out String; + Last : in out Integer) is + + Info : String := Tailored_Exception_Information (X); + begin + Last := Info'Last; + Buff (1 .. Last) := Info; + end Tailored_Exception_Information; + + + +begin + -- First allocate & store the exception info in a buffer when + -- we know it will be needed. This needs to be done before + -- Adafinal because it implicitly uses the secondary stack. + + if Except.Id.Full_Name.all (1) /= '_' + and then Except.Num_Tracebacks /= 0 + then + Exc_Info := new Exc_Info_Type; + if Exc_Info /= null then + Tailored_Exception_Information + (Except, Exc_Info.all, Exc_Info_Last); + end if; + end if; + + -- Let's shutdown the runtime now. The rest of the procedure + -- needs to be careful not to use anything that would require + -- runtime support. In particular, functions returning strings + -- are banned since the sec stack is no longer functional. + System.Standard_Library.Adafinal; + + -- Check for special case of raising _ABORT_SIGNAL, which is not + -- really an exception at all. We recognize this by the fact that + -- it is the only exception whose name starts with underscore. + + if Except.Id.Full_Name.all (1) = '_' then + To_Stderr (Nline); + To_Stderr ("Execution terminated by abort of environment task"); + To_Stderr (Nline); + + -- If no tracebacks, we print the unhandled exception in the old style + -- (i.e. the style used before ZCX was implemented). We do this to + -- retain compatibility. + + elsif Except.Num_Tracebacks = 0 then + To_Stderr (Nline); + To_Stderr ("raised "); + To_Stderr (Except.Id.Full_Name.all (1 .. Except.Id.Name_Length - 1)); + + if Msg'Length /= 0 then + To_Stderr (" : "); + To_Stderr (Msg); + end if; + + To_Stderr (Nline); + + else + -- Traceback exists + + -- Note we can have this whole information output twice if + -- this occurrence gets reraised up to here. + + To_Stderr (Nline); + To_Stderr ("Execution terminated by unhandled exception"); + To_Stderr (Nline); + To_Stderr (Exc_Info (1 .. Exc_Info_Last)); + end if; + + Unhandled_Terminate; + +end Ada.Exceptions.Last_Chance_Handler; |