diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-09 17:10:03 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-09 17:10:03 +0000 |
commit | 0b8fc818b5441eab63489374a3da6b31d648bf58 (patch) | |
tree | 8d0ebcc73d5b00e238ee100be97600475908b083 /gcc/ada/s-tassta.adb | |
parent | 84301fedaf2400699bafe91b8c405ad5db683b91 (diff) | |
download | gcc-0b8fc818b5441eab63489374a3da6b31d648bf58.tar.gz |
2005-12-05 Doug Rupp <rupp@adacore.com>
* mlib-tgt-vms-ia64.adb, mlib-tgt-vms-alpha.adb (Is_Interface): Change
Ada bind file prefix on VMS from b$ to b__.
(Build_Dynamic_Library): Change Init file suffix on VMS from $init to
__init.
* prj-nmsc.adb: Change some Hostparm.OpenVMS checks to
Targparm.OpenVMS_On_Target.
(Object_Suffix): Initialize with target object suffix.
(Get_Unit): Change Ada bind file prefix on VMS from b$ to b__.
* butil.adb: Change some Hostparm.OpenVMS checks to
Targparm.OpenVMS_On_Target.
* clean.adb: Change some Hostparm.OpenVMS checks to
Targparm.OpenVMS_On_Target.
(Object_Suffix): Initialize with call to Get_Target_Object_Suffix.
({declaraction},Delete_Binder_Generated_Files,{initialization}): Change
Ada bind file prefix on VMS from b$ to b__.
* gnatlink.adb (Process_Args): Call Add_Src_Search_Dir for -I in
--GCC so that Get_Target_Parameters can find system.ads.
(Gnatlink): Call Get_Target_Parameters in mainline.
Initialize standard packages for Targparm.
Change some Hostparm.OpenVMS checks to Targparm.OpenVMS_On_Target.
(Process_Args): Also Check for object files with target object
extension.
(Make_Binder_File_Names): Create with target object extension.
(Make_Binder_File_Names): Change Ada bind file prefix on VMS from b$
to b__.
* mlib-prj.adb: Change some Hostparm.OpenVMS checks to
Targparm.OpenVMS_On_Target.
({declaration},Build_Library,Check_Library): Change Ada bind file
prefix on VMS from b$ to b__.
* osint-b.adb: Change some Hostparm.OpenVMS checks to
Targparm.OpenVMS_On_Target.
(Create_Binder_Output): Change Ada bind file prefix on VMS from b$ to
b__.
* targext.c: New file.
* Makefile.in: add support for vxworks653 builds
(../../vxaddr2line): gnatlink with targext.o.
(TOOLS_LIBS): Move targext.o to precede libgnat.
(init.o, initialize.o): Minor clean up in dependencies.
(GNATLINK_OBJS): Add targparm.o, snames.o
Add rules fo building targext.o and linking it explicitly with all
tools.
Also add targext.o to gnatlib.
* Make-lang.in: Add rules for building targext.o and linking it in
with gnat1 and gnatbind.
Add entry for exp_sel.o.
* osint.adb Change some Hostparm.OpenVMS checks to
Targparm.OpenVMS_On_Target.
(Object_File_Name): Use target object suffix.
* osint.ads (Object_Suffix): Remove, no longer used.
(Target_Object_Suffix): Initialize with target object suffix.
* rident.ads: Add special exception to license.
* targparm.adb (Get_Target_Parameters): Set the value of
Multi_Unit_Index_Character after OpenVMS_On_Target gets its definitive
value.
(Get_Target_Parameters): Set OpenVMS_On_Target if openvms.
* targparm.ads: Add special exception to license.
* g-os_lib.ads, g-os_lib.adb (Get_Target_Debuggable_Suffix): New
function.
(Copy_File): Make sure from file is closed if error on to file
(Get_Target_Executable_Suffix, Get_Target_Object_Suffix): New functions.
* make.adb (Object_Suffix): Intialize with Get_Target_Object_Suffix.
(Executable_Suffix): Intialize with Get_Target_Executable_Suffix.
* osint-c.adb (Set_Output_Object_File_Name): Initialize extension with
target object suffix.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108282 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-tassta.adb')
-rw-r--r-- | gcc/ada/s-tassta.adb | 172 |
1 files changed, 141 insertions, 31 deletions
diff --git a/gcc/ada/s-tassta.adb b/gcc/ada/s-tassta.adb index 54f92ebcde8..4ceea414a6d 100644 --- a/gcc/ada/s-tassta.adb +++ b/gcc/ada/s-tassta.adb @@ -68,7 +68,7 @@ with System.Soft_Links; -- specific data. In the absence of tasking, these routines refer to global -- data. In the presense of tasking, they must be replaced with pointers to -- task-specific versions. Also used for Create_TSD, Destroy_TSD, --- Get_Current_Excep +-- Get_Current_Excep, Finalize_Global_List, Task_Termination, Handler. with System.Tasking.Initialization; -- Used for Remove_From_All_Tasks_List @@ -84,6 +84,7 @@ pragma Elaborate_All (System.Tasking.Initialization); with System.Tasking.Utilities; -- Used for Make_Passive -- Abort_One_Task +-- Abort_Tasks with System.Tasking.Queuing; -- Used for Dequeue_Head @@ -94,9 +95,6 @@ with System.Tasking.Rendezvous; with System.OS_Primitives; -- Used for Delay_Modes -with System.Finalization_Implementation; --- Used for System.Finalization_Implementation.Finalize_Global_List - with System.Secondary_Stack; -- Used for SS_Init @@ -115,6 +113,8 @@ with System.Traces.Tasking; with Unchecked_Deallocation; -- To recover from failure of ATCB initialization +with System.Stack_Usage; + package body System.Tasking.Stages is package STPO renames System.Task_Primitives.Operations; @@ -232,17 +232,6 @@ package body System.Tasking.Stages is procedure Abort_Tasks (Tasks : Task_List) is begin - -- If pragma Detect_Blocking is active then Program_Error must be - -- raised if this potentially blocking operation is called from a - -- protected action. - - if System.Tasking.Detect_Blocking - and then STPO.Self.Common.Protected_Action_Nesting > 0 - then - Ada.Exceptions.Raise_Exception - (Program_Error'Identity, "potentially blocking operation"); - end if; - Utilities.Abort_Tasks (Tasks); end Abort_Tasks; @@ -826,7 +815,19 @@ package body System.Tasking.Stages is Vulnerable_Complete_Task (Self_ID); - System.Finalization_Implementation.Finalize_Global_List; + -- Handle normal task termination by the environment task, but only + -- for the normal task termination. In the case of Abnormal and + -- Unhandled_Exception they must have been handled before, and the + -- task termination soft link must have been changed so the task + -- termination routine is not executed twice. + + SSL.Task_Termination_Handler.all (Ada.Exceptions.Null_Occurrence); + + -- Finalize the global list for controlled objects if needed + + SSL.Finalize_Global_List.all; + + -- Reset the soft links to non-tasking SSL.Abort_Defer := SSL.Abort_Defer_NT'Access; SSL.Abort_Undefer := SSL.Abort_Undefer_NT'Access; @@ -890,14 +891,32 @@ package body System.Tasking.Stages is use type System.Parameters.Size_Type; use type SSE.Storage_Offset; use System.Standard_Library; + use System.Stack_Usage; + + Bottom_Of_Stack : aliased Integer; + + Secondary_Stack_Size : + constant SSE.Storage_Offset := + Self_ID.Common.Compiler_Data.Pri_Stack_Info.Size * + SSE.Storage_Offset (Parameters.Sec_Stack_Ratio) / 100; Secondary_Stack : aliased SSE.Storage_Array - (1 .. Self_ID.Common.Compiler_Data.Pri_Stack_Info.Size * - SSE.Storage_Offset (Parameters.Sec_Stack_Ratio) / 100); + (1 .. Secondary_Stack_Size); + pragma Warnings (Off); Secondary_Stack_Address : System.Address := Secondary_Stack'Address; + Overflow_Guard : constant := 16#1_000#; + + Size : + Natural := Natural (Self_ID.Common.Compiler_Data.Pri_Stack_Info.Size); + + pragma Warnings (On); + -- Address of secondary stack. In the fixed secondary stack case, this + -- value is not modified, causing a warning, hence the bracketing with + -- Warnings (Off/On). + SEH_Table : aliased SSE.Storage_Array (1 .. 8); -- Structured Exception Registration table (2 words) @@ -905,6 +924,43 @@ package body System.Tasking.Stages is pragma Import (C, Install_SEH_Handler, "__gnat_install_SEH_handler"); -- Install the SEH (Structured Exception Handling) handler + Cause : Cause_Of_Termination := Normal; + -- Indicates the reason why this task terminates. Normal corresponds to + -- a task terminating due to completing the last statement of its body, + -- or as a result of waiting on a terminate alternative. If the task + -- terminates because it is being aborted then Cause will be set to + -- Abnormal. If the task terminates because of an exception raised by + -- the execution of its task body, then Cause is set to + -- Unhandled_Exception. + + EO : Exception_Occurrence; + -- If the task terminates because of an exception raised by the + -- execution of its task body, then EO will contain the associated + -- exception occurrence. Otherwise, it will contain Null_Occurrence. + + procedure Search_Fall_Back_Handler (ID : Task_Id); + -- Procedure that searches recursively a fall-back handler through the + -- master relationship. + + procedure Search_Fall_Back_Handler (ID : Task_Id) is + begin + -- If there is a fall back handler, execute it + + if ID.Common.Fall_Back_Handler /= null then + ID.Common.Fall_Back_Handler.all (Cause, Self_ID, EO); + + -- Otherwise look for a fall back handler in the parent + + elsif ID.Common.Parent /= null then + Search_Fall_Back_Handler (ID.Common.Parent); + + -- Otherwise, do nothing + + else + return; + end if; + end Search_Fall_Back_Handler; + begin pragma Assert (Self_ID.Deferral_Level = 1); @@ -912,10 +968,24 @@ package body System.Tasking.Stages is Self_ID.Common.Compiler_Data.Sec_Stack_Addr := Secondary_Stack'Address; SST.SS_Init (Secondary_Stack_Address, Integer (Secondary_Stack'Last)); + Size := Size - Natural (Secondary_Stack_Size); + end if; + + Size := Size - Overflow_Guard; + + if System.Stack_Usage.Is_Enabled then + STPO.Lock_RTS; + Initialize_Analyzer (Self_ID.Common.Analyzer, + Self_ID.Common.Task_Image + (1 .. Self_ID.Common.Task_Image_Len), + Size, + SSE.To_Integer (Bottom_Of_Stack'Address)); + STPO.Unlock_RTS; + Fill_Stack (Self_ID.Common.Analyzer); end if; - -- Set the guard page at the bottom of the stack. The call to - -- unprotect the page is done in Terminate_Task + -- Set the guard page at the bottom of the stack. The call to unprotect + -- the page is done in Terminate_Task Stack_Guard (Self_ID, True); @@ -930,9 +1000,13 @@ package body System.Tasking.Stages is Install_SEH_Handler (SEH_Table'Address); - -- We lock RTS_Lock to wait for activator to finish activating - -- the rest of the chain, so that everyone in the chain comes out - -- in priority order. + -- Initialize exception occurrence + + Save_Occurrence (EO, Ada.Exceptions.Null_Occurrence); + + -- We lock RTS_Lock to wait for activator to finish activating the rest + -- of the chain, so that everyone in the chain comes out in priority + -- order. -- This also protects the value of -- Self_ID.Common.Activator.Common.Wait_Count. @@ -980,6 +1054,17 @@ package body System.Tasking.Stages is when Standard'Abort_Signal => Initialization.Defer_Abort_Nestable (Self_ID); + -- Update the cause that motivated the task termination so that + -- the appropriate information is passed to the task termination + -- procedure. Task termination as a result of waiting on a + -- terminate alternative is a normal termination, although it is + -- implemented using the abort mechanisms. + + if Self_ID.Terminate_Alternative then + Cause := Normal; + else + Cause := Abnormal; + end if; when others => -- ??? Using an E : others here causes CD2C11A to fail on -- DEC Unix, see 7925-005. @@ -998,8 +1083,33 @@ package body System.Tasking.Stages is if Exception_Trace = Unhandled_Raise then Trace_Unhandled_Exception_In_Task (Self_ID); end if; + + -- Update the cause that motivated the task termination so that + -- the appropriate information is passed to the task termination + -- procedure, as well as the associated Exception_Occurrence. + + Cause := Unhandled_Exception; + Save_Occurrence (EO, SSL.Get_Current_Excep.all.all); end; + -- Look for a task termination handler. This code is for all tasks but + -- the environment task. The task termination code for the environment + -- task is executed by SSL.Task_Termination_Handler. + + if Self_ID.Common.Specific_Handler /= null then + Self_ID.Common.Specific_Handler.all (Cause, Self_ID, EO); + else + -- Look for a fall-back handler following the master relationship + -- for the task. + + Search_Fall_Back_Handler (Self_ID); + end if; + + if System.Stack_Usage.Is_Enabled then + Compute_Result (Self_ID.Common.Analyzer); + Report_Result (Self_ID.Common.Analyzer); + end if; + Terminate_Task (Self_ID); end Task_Wrapper; @@ -1021,16 +1131,16 @@ package body System.Tasking.Stages is -- We can't call Destroy_TSD while we are holding any other locks, because -- it locks Global_Task_Lock, and our deadlock prevention rules require -- that to be the outermost lock. Our first "solution" was to just lock - -- Global_Task_Lock in addition to the other locks, and force the parent - -- to also lock this lock between its wakeup and its freeing of the ATCB. - -- See Complete_Task for the parent-side of the code that has the matching + -- Global_Task_Lock in addition to the other locks, and force the parent to + -- also lock this lock between its wakeup and its freeing of the ATCB. See + -- Complete_Task for the parent-side of the code that has the matching -- calls to Task_Lock and Task_Unlock. That was not really a solution, -- since the operation Task_Unlock continued to access the ATCB after - -- unlocking, after which the parent was observed to race ahead, - -- deallocate the ATCB, and then reallocate it to another task. The - -- call to Undefer_Abortion in Task_Unlock by the "terminated" task was - -- overwriting the data of the new task that reused the ATCB! To solve - -- this problem, we introduced the new operation Final_Task_Unlock. + -- unlocking, after which the parent was observed to race ahead, deallocate + -- the ATCB, and then reallocate it to another task. The call to + -- Undefer_Abortion in Task_Unlock by the "terminated" task was overwriting + -- the data of the new task that reused the ATCB! To solve this problem, we + -- introduced the new operation Final_Task_Unlock. procedure Terminate_Task (Self_ID : Task_Id) is Environment_Task : constant Task_Id := STPO.Environment_Task; |