summaryrefslogtreecommitdiff
path: root/gcc/ada/a-elchha.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-20 10:26:51 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-20 10:26:51 +0000
commitf62ed60b214f15bdb21842816457e0a6ad09c056 (patch)
tree238119d8dcbfc65df92cc128baf647ad882d0617 /gcc/ada/a-elchha.adb
parent2ca392fdcafbdcf6e7fd18ccd7189425c2248081 (diff)
downloadgcc-f62ed60b214f15bdb21842816457e0a6ad09c056.tar.gz
2004-07-20 Olivier Hainque <hainque@act-europe.fr>
* a-elchha.adb (Last_Chance_Handler): Remove the bogus buffer dynamic allocation and potentially overflowing update with Tailored_Exception_Information. Use the sec-stack free procedural interface to output Exception_Information instead. * a-except.adb (To_Stderr): New subprogram for character, and string version moved from a-exextr to be visible from other separate units. (Tailored_Exception_Information): Remove the procedural version, previously used by the default Last_Chance_Handler and not any more. Adjust various comments. * a-exexda.adb: Generalize the exception information procedural interface, to minimize the use of secondary stack and the need for local buffers when the info is to be output to stderr: (Address_Image): Removed. (Append_Info_Character): New subprogram, checking for overflows and outputing to stderr if buffer to fill is of length 0. (Append_Info_String): Output to stderr if buffer to fill is of length 0. (Append_Info_Address, Append_Info_Exception_Name, Append_Info_Exception_Message, Append_Info_Basic_Exception_Information, Append_Info_Basic_Exception_Traceback, Append_Info_Exception_Information): New subprograms. (Append_Info_Nat, Append_Info_NL): Use Append_Info_Character. (Basic_Exception_Info_Maxlength, Basic_Exception_Tback_Maxlength, Exception_Info_Maxlength, Exception_Name_Length, Exception_Message_Length): New subprograms. (Exception_Information): Use Append_Info_Exception_Information. (Tailored_Exception_Information): Use Append_Info_Basic_Exception_Information. Export services for the default Last_Chance_Handler. * a-exextr.adb (To_Stderr): Remove. Now in a-except to be usable by other separate units. 2004-07-20 Vincent Celier <celier@gnat.com> * clean.adb, mlib-utl.adb, osint.adb, makegpr.adb: Minor reformatting. 2004-07-20 Ed Schonberg <schonberg@gnat.com> * freeze.adb (Freeze_Entity): If entity is a discriminated record type, emit itype references for the designated types of component types that are declared outside of the full record declaration, and that may denote a partial view of that record type. 2004-07-20 Ed Schonberg <schonberg@gnat.com> PR ada/15607 * sem_ch3.adb (Build_Discriminated_Subtype): Do not attach a subtype which is the designated type in an access component declaration, to the list of incomplete dependents of the parent type, to avoid elaboration issues with out-of-scope subtypes. (Complete_Private_Subtype): Recompute Has_Unknown_Discriminants from the full view of the parent. 2004-07-20 Ed Schonberg <schonberg@gnat.com> PR ada/15610 * sem_ch8.adb (Find_Expanded_Name): If name is overloaded, reject entities that are hidden, such as references to generic actuals outside an instance. 2004-07-20 Javier Miranda <miranda@gnat.com> * sem_ch4.adb (Try_Object_Operation): New subprogram that gives support to the new notation. (Analyze_Selected_Component): Add call to Try_Object_Operation. 2004-07-20 Jose Ruiz <ruiz@act-europe.fr> * s-taprob.adb: Adding the elaboration code required for initializing the tasking soft links that are common to the full and the restricted run times. * s-tarest.adb (Init_RTS): Tasking soft links that are shared with the restricted run time has been moved to the package System.Soft_Links.Tasking. * s-tasini.adb (Init_RTS): Tasking soft links that are shared with the restricted run time has been moved to the package System.Soft_Links.Tasking. * Makefile.rtl: Add entry for s-solita.o in run-time library list. * s-solita.ads, s-solita.adb: New files. 2004-07-20 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * trans.c (Identifier_to_gnu, Pragma_to_gnu, Attribute_to_gnu, Case_Statement_to_gnu): Split off from gnat_to_gnu. (Loop_Statement_to_gnu, Subprogram_Body_to_gnu, call_to_gnu, Handled_Sequence_Of_Statements_to_gnu, Exception_Handler_to_gnu_sjlj, Exception_Handler_to_gnu_zcx): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84948 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-elchha.adb')
-rw-r--r--gcc/ada/a-elchha.adb100
1 files changed, 29 insertions, 71 deletions
diff --git a/gcc/ada/a-elchha.adb b/gcc/ada/a-elchha.adb
index 6e2da234a4b..e7eb65c3ea5 100644
--- a/gcc/ada/a-elchha.adb
+++ b/gcc/ada/a-elchha.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2003 Free Software Foundation, Inc. --
+-- Copyright (C) 2003-2004 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 --
@@ -45,83 +45,43 @@ is
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.
+ function Exception_Message_Length
+ (X : Exception_Occurrence) return Natural;
+ pragma Import (Ada, Exception_Message_Length, "__gnat_exception_msg_len");
+ procedure Append_Info_Exception_Message
+ (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural);
pragma Import
- (Ada, Tailored_Exception_Information,
- "__gnat_tailored_exception_information");
+ (Ada, Append_Info_Exception_Message, "__gnat_append_info_e_msg");
- 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 Append_Info_Exception_Information
+ (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural);
+ pragma Import
+ (Ada, Append_Info_Exception_Information, "__gnat_append_info_e_info");
procedure To_Stderr (S : String);
pragma Import (Ada, To_Stderr, "__gnat_to_stderr");
-- Little routine to output string to stderr
+ Ptr : Natural := 0;
+ Nobuf : String (1 .. 0);
+
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 : constant 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. This is particularly important to note for the
+ -- Exception_Information output. We used to allow the tailored version to
+ -- show up here, which turned out to be a bad idea as it might involve a
+ -- traceback decorator the length of which we don't control. Potentially
+ -- heavy primary/secondary stack use or dynamic allocations right before
+ -- this point are not welcome, moving the output before the finalization
+ -- raises order of outputs concerns, and decorators are intended to only
+ -- be used with exception traces, which should have been issued already.
- -- 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
@@ -142,9 +102,9 @@ begin
To_Stderr ("raised ");
To_Stderr (Except.Id.Full_Name.all (1 .. Except.Id.Name_Length - 1));
- if Msg'Length /= 0 then
+ if Exception_Message_Length (Except) /= 0 then
To_Stderr (" : ");
- To_Stderr (Msg);
+ Append_Info_Exception_Message (Except, Nobuf, Ptr);
end if;
To_Stderr (Nline);
@@ -152,13 +112,11 @@ begin
-- Traceback exists
else
- -- 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));
+
+ Append_Info_Exception_Information (Except, Nobuf, Ptr);
end if;
Unhandled_Terminate;