From: Quentin Ochem Date: Thu, 31 Jul 2008 13:26:20 +0000 (+0200) Subject: 2008-07-31 Quentin Ochem X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b8f2b5d9acf05785e007cdf15ee4c14f1895c01a;p=gcc.git 2008-07-31 Quentin Ochem * s-stausa.ad? (Fill_Stack): Stack_Used_When_Filling is now stored anymore - just used internally. Added handling of very small tasks - when the theoretical size is already full at the point of the call. (Report_Result): Fixed result computation, Stack_Used_When_Filling does not need to be added to the result. From-SVN: r138405 --- diff --git a/gcc/ada/s-stausa.adb b/gcc/ada/s-stausa.adb index 700c685ea27..d9b972d8b28 100644 --- a/gcc/ada/s-stausa.adb +++ b/gcc/ada/s-stausa.adb @@ -258,20 +258,29 @@ package body System.Stack_Usage is -- big, the more an "instrumentation threshold at writing" error is -- likely to happen. - Current_Stack_Level : aliased Integer; + Stack_Used_When_Filling : Integer; + Current_Stack_Level : aliased Integer; 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. - Analyzer.Stack_Used_When_Filling := + 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 := - Analyzer.Pattern_Size - Analyzer.Stack_Used_When_Filling; + 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 + + Analyzer.Pattern_Size := 0; + else + Analyzer.Pattern_Size := + Analyzer.Pattern_Size - Stack_Used_When_Filling; + end if; declare Stack : aliased Stack_Slots @@ -282,10 +291,15 @@ package body System.Stack_Usage is Analyzer.Stack_Overlay_Address := Stack'Address; - 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); + 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.Bottom_Pattern_Mark := To_Stack_Address (Stack'Address); + end if; -- If Arr has been packed, the following assertion must be true (we -- add the size of the element whose address is: @@ -539,20 +553,28 @@ package body System.Stack_Usage is ------------------- procedure Report_Result (Analyzer : Stack_Analyzer) is - Measure : constant Natural := - Stack_Size - (Analyzer.Topmost_Touched_Mark, - Analyzer.Bottom_Of_Stack) - + Analyzer.Stack_Used_When_Filling; - - Result : constant Task_Result := + Result : Task_Result := (Task_Name => Analyzer.Task_Name, Max_Size => Analyzer.Stack_Size, - Min_Measure => Measure, - Max_Measure => Measure + Analyzer.Stack_Size - - Analyzer.Pattern_Size); + Min_Measure => 0, + Max_Measure => 0); begin + if Analyzer.Pattern_Size = 0 then + -- If we have that result, it means that we didn't do any computation + -- at all. In other words, we used at least everything (and possibly + -- more). + + Result.Min_Measure := Analyzer.Stack_Size; + Result.Max_Measure := Analyzer.Stack_Size; + else + Result.Min_Measure := Stack_Size + (Analyzer.Topmost_Touched_Mark, + Analyzer.Bottom_Of_Stack); + Result.Max_Measure := Result.Min_Measure + + (Analyzer.Stack_Size - Analyzer.Pattern_Size); + end if; + if Analyzer.Result_Id in Result_Array'Range then -- If the result can be stored, then store it in Result_Array diff --git a/gcc/ada/s-stausa.ads b/gcc/ada/s-stausa.ads index 8a6e2b67cb5..2aa9dd70d2d 100644 --- a/gcc/ada/s-stausa.ads +++ b/gcc/ada/s-stausa.ads @@ -304,10 +304,6 @@ private Result_Id : Positive; -- Id of the result. If less than value given to gnatbind -u corresponds -- to the location in the result array of result for the current task. - - Stack_Used_When_Filling : Natural := 0; - -- Amount of stack that was already used when actually filling the - -- memory, and therefore not analyzed. end record; Environment_Task_Analyzer : Stack_Analyzer;