diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2010-10-18 12:18:07 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2010-10-18 12:18:07 +0200 |
commit | e57ab5507b20632ae70b0ce192cbeca049133a1a (patch) | |
tree | e04e4d582f301e695971081ecc83be8cd8ed59e1 /gcc/ada/s-stausa.adb | |
parent | 468ee96a95a470c06e0f646f0a7c83b189b7fbe6 (diff) | |
download | gcc-e57ab5507b20632ae70b0ce192cbeca049133a1a.zip gcc-e57ab5507b20632ae70b0ce192cbeca049133a1a.tar.gz gcc-e57ab5507b20632ae70b0ce192cbeca049133a1a.tar.bz2 |
[multiple changes]
2010-10-18 Vincent Celier <celier@adacore.com>
* prj.ads (Source_Data): New Boolean flag In_The_Queue.
2010-10-18 Tristan Gingold <gingold@adacore.com>
* s-stausa.ads: Add the Top parameter to Initialize_Analyzer.
* s-stausa.adb: Use the top parameter. In Fill_Stack, use the
stack top if known.
* s-tassta.adb (Task_Wrapper): Call Initialize_Analyzer after Enter_Task
so that Pri_Stack_Info.Limit can be set and used.
2010-10-18 Robert Dewar <dewar@adacore.com>
* einfo.ads: Minor reformatting.
* sem_res.adb (Resolve_Allocator): Add test for violating
No_Anonymous_Allocators.
From-SVN: r165624
Diffstat (limited to 'gcc/ada/s-stausa.adb')
-rw-r--r-- | gcc/ada/s-stausa.adb | 129 |
1 files changed, 83 insertions, 46 deletions
diff --git a/gcc/ada/s-stausa.adb b/gcc/ada/s-stausa.adb index 37dda6f..d533e0c 100644 --- a/gcc/ada/s-stausa.adb +++ b/gcc/ada/s-stausa.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2004-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2010, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- @@ -232,7 +232,8 @@ package body System.Stack_Usage is "ENVIRONMENT TASK", My_Stack_Size, My_Stack_Size, - System.Storage_Elements.To_Integer (Bottom_Of_Stack'Address)); + System.Storage_Elements.To_Integer (Bottom_Of_Stack'Address), + 0); Fill_Stack (Environment_Task_Analyzer); @@ -259,56 +260,90 @@ package body System.Stack_Usage is Stack_Used_When_Filling : Integer; Current_Stack_Level : aliased Integer; + Guard : constant Integer := 256; + -- Guard space between the Current_Stack_Level'Address and the last + -- allocated byte on the stack. begin - -- Readjust the pattern size. When we arrive in this function, there is - -- already a given amount of stack used, that we won't analyze. + if Analyzer.Top_Pattern_Mark /= 0 then + -- Easiest and most accurate method: the top of the stack is known. - Stack_Used_When_Filling := - Stack_Size - (Analyzer.Bottom_Of_Stack, - To_Stack_Address (Current_Stack_Level'Address)) - + Natural (Current_Stack_Level'Size); + Analyzer.Pattern_Size := + Stack_Size (Analyzer.Top_Pattern_Mark, + To_Stack_Address (Current_Stack_Level'Address)) + - Guard; - if Stack_Used_When_Filling > Analyzer.Pattern_Size then - -- In this case, the known size of the stack is too small, we've - -- already taken more than expected, so there's no possible - -- computation + if System.Parameters.Stack_Grows_Down then + Analyzer.Stack_Overlay_Address := + To_Address (Analyzer.Top_Pattern_Mark); + else + Analyzer.Stack_Overlay_Address := + To_Address (Analyzer.Top_Pattern_Mark + - Stack_Address (Analyzer.Pattern_Size)); + end if; - Analyzer.Pattern_Size := 0; - else - Analyzer.Pattern_Size := - Analyzer.Pattern_Size - Stack_Used_When_Filling; - end if; + declare + Pattern : aliased Stack_Slots + (1 .. Analyzer.Pattern_Size / Bytes_Per_Pattern); + for Pattern'Address use Analyzer.Stack_Overlay_Address; + begin + if System.Parameters.Stack_Grows_Down then + for I in reverse Pattern'Range loop + Pattern (I) := Analyzer.Pattern; + end loop; + Analyzer.Bottom_Pattern_Mark := + To_Stack_Address (Pattern (Pattern'Last)'Address); + else + for I in Pattern'Range loop + Pattern (I) := Analyzer.Pattern; + end loop; + Analyzer.Bottom_Pattern_Mark := + To_Stack_Address (Pattern (Pattern'First)'Address); + end if; + end; - declare - Stack : aliased Stack_Slots - (1 .. Analyzer.Pattern_Size / Bytes_Per_Pattern); + else + -- Readjust the pattern size. When we arrive in this function, there + -- is already a given amount of stack used, that we won't analyze. - begin - Stack := (others => Analyzer.Pattern); + Stack_Used_When_Filling := + Stack_Size (Analyzer.Bottom_Of_Stack, + To_Stack_Address (Current_Stack_Level'Address)); - Analyzer.Stack_Overlay_Address := Stack'Address; + if Stack_Used_When_Filling > Analyzer.Pattern_Size then + -- In this case, the known size of the stack is too small, we've + -- already taken more than expected, so there's no possible + -- computation - if Analyzer.Pattern_Size /= 0 then - Analyzer.Bottom_Pattern_Mark := - To_Stack_Address (Stack (Bottom_Slot_Index_In (Stack))'Address); - Analyzer.Top_Pattern_Mark := - To_Stack_Address (Stack (Top_Slot_Index_In (Stack))'Address); + Analyzer.Pattern_Size := 0; else - Analyzer.Bottom_Pattern_Mark := To_Stack_Address (Stack'Address); - Analyzer.Top_Pattern_Mark := To_Stack_Address (Stack'Address); + Analyzer.Pattern_Size := + Analyzer.Pattern_Size - Stack_Used_When_Filling; end if; - -- If Arr has been packed, the following assertion must be true (we - -- add the size of the element whose address is: - -- Min (Analyzer.Inner_Pattern_Mark, Analyzer.Outer_Pattern_Mark)): + declare + Stack : aliased Stack_Slots + (1 .. Analyzer.Pattern_Size / Bytes_Per_Pattern); - pragma Assert - (Analyzer.Pattern_Size = 0 or else - Analyzer.Pattern_Size = - Stack_Size - (Analyzer.Top_Pattern_Mark, Analyzer.Bottom_Pattern_Mark)); - end; + begin + Stack := (others => Analyzer.Pattern); + + Analyzer.Stack_Overlay_Address := Stack'Address; + + if Analyzer.Pattern_Size /= 0 then + Analyzer.Bottom_Pattern_Mark := + To_Stack_Address + (Stack (Bottom_Slot_Index_In (Stack))'Address); + Analyzer.Top_Pattern_Mark := + To_Stack_Address + (Stack (Top_Slot_Index_In (Stack))'Address); + else + Analyzer.Bottom_Pattern_Mark := + To_Stack_Address (Stack'Address); + Analyzer.Top_Pattern_Mark := + To_Stack_Address (Stack'Address); + end if; + end; + end if; end Fill_Stack; ------------------------- @@ -321,17 +356,19 @@ package body System.Stack_Usage is My_Stack_Size : Natural; Max_Pattern_Size : Natural; Bottom : Stack_Address; + Top : Stack_Address; Pattern : Unsigned_32 := 16#DEAD_BEEF#) is begin -- Initialize the analyzer fields - Analyzer.Bottom_Of_Stack := Bottom; - Analyzer.Stack_Size := My_Stack_Size; - Analyzer.Pattern_Size := Max_Pattern_Size; - Analyzer.Pattern := Pattern; - Analyzer.Result_Id := Next_Id; - Analyzer.Task_Name := (others => ' '); + Analyzer.Bottom_Of_Stack := Bottom; + Analyzer.Stack_Size := My_Stack_Size; + Analyzer.Pattern_Size := Max_Pattern_Size; + Analyzer.Pattern := Pattern; + Analyzer.Result_Id := Next_Id; + Analyzer.Task_Name := (others => ' '); + Analyzer.Top_Pattern_Mark := Top; -- Compute the task name, and truncate if bigger than Task_Name_Length |