diff options
Diffstat (limited to 'gcc/ada/s-stausa.adb')
-rw-r--r-- | gcc/ada/s-stausa.adb | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/gcc/ada/s-stausa.adb b/gcc/ada/s-stausa.adb index 859a9de8564..dfa8a1fc6bb 100644 --- a/gcc/ada/s-stausa.adb +++ b/gcc/ada/s-stausa.adb @@ -173,7 +173,7 @@ package body System.Stack_Usage is Index_Str : constant String := "Index"; Task_Name_Str : constant String := "Task Name"; Stack_Size_Str : constant String := "Stack Size"; - Actual_Size_Str : constant String := "Stack usage [min - max]"; + Actual_Size_Str : constant String := "Stack usage"; function Get_Usage_Range (Result : Task_Result) return String; -- Return string representing the range of possible result of stack usage @@ -203,10 +203,10 @@ package body System.Stack_Usage is Result_Array := new Result_Array_Type (1 .. Buffer_Size); Result_Array.all := (others => - (Task_Name => (others => ASCII.NUL), - Min_Measure => 0, - Max_Measure => 0, - Max_Size => 0)); + (Task_Name => (others => ASCII.NUL), + Variation => 0, + Value => 0, + Max_Size => 0)); -- Set the Is_Enabled flag to true, so that the task wrapper knows that -- it has to handle dynamic stack analysis @@ -222,16 +222,16 @@ package body System.Stack_Usage is if Stack_Size_Chars /= Null_Address then declare - Stack_Size : Integer; + My_Stack_Size : Integer; begin - Stack_Size := System.CRTL.atoi (Stack_Size_Chars) * 1024; + My_Stack_Size := System.CRTL.atoi (Stack_Size_Chars) * 1024; Initialize_Analyzer (Environment_Task_Analyzer, "ENVIRONMENT TASK", - Stack_Size, - Stack_Size, + My_Stack_Size, + My_Stack_Size, System.Storage_Elements.To_Integer (Bottom_Of_Stack'Address)); Fill_Stack (Environment_Task_Analyzer); @@ -318,7 +318,7 @@ package body System.Stack_Usage is procedure Initialize_Analyzer (Analyzer : in out Stack_Analyzer; Task_Name : String; - Stack_Size : Natural; + My_Stack_Size : Natural; Max_Pattern_Size : Natural; Bottom : Stack_Address; Pattern : Unsigned_32 := 16#DEAD_BEEF#) @@ -327,12 +327,11 @@ package body System.Stack_Usage is -- Initialize the analyzer fields Analyzer.Bottom_Of_Stack := Bottom; - Analyzer.Stack_Size := Stack_Size; - Analyzer.Pattern_Size := Max_Pattern_Size; - Analyzer.Pattern := Pattern; - Analyzer.Result_Id := Next_Id; - - Analyzer.Task_Name := (others => ' '); + Analyzer.Stack_Size := My_Stack_Size; + Analyzer.Pattern_Size := Max_Pattern_Size; + Analyzer.Pattern := Pattern; + Analyzer.Result_Id := Next_Id; + Analyzer.Task_Name := (others => ' '); -- Compute the task name, and truncate if bigger than Task_Name_Length @@ -414,11 +413,12 @@ package body System.Stack_Usage is --------------------- function Get_Usage_Range (Result : Task_Result) return String is - Min_Used_Str : constant String := Natural'Image (Result.Min_Measure); - Max_Used_Str : constant String := Natural'Image (Result.Max_Measure); + Variation_Used_Str : constant String := + Natural'Image (Result.Variation); + Value_Used_Str : constant String := + Natural'Image (Result.Value); begin - return "[" & Min_Used_Str (2 .. Min_Used_Str'Last) & " -" - & Max_Used_Str & "]"; + return Value_Used_Str & " +/- " & Variation_Used_Str; end Get_Usage_Range; --------------------- @@ -431,16 +431,16 @@ package body System.Stack_Usage is Max_Stack_Size_Len : Natural; Max_Actual_Use_Len : Natural) is - Result_Id_Str : constant String := Natural'Image (Result_Id); - Stack_Size_Str : constant String := Natural'Image (Result.Max_Size); - Actual_Use_Str : constant String := Get_Usage_Range (Result); + Result_Id_Str : constant String := Natural'Image (Result_Id); + My_Stack_Size_Str : constant String := Natural'Image (Result.Max_Size); + Actual_Use_Str : constant String := Get_Usage_Range (Result); Result_Id_Blanks : constant String (1 .. Index_Str'Length - Result_Id_Str'Length) := (others => ' '); Stack_Size_Blanks : constant - String (1 .. Max_Stack_Size_Len - Stack_Size_Str'Length) := + String (1 .. Max_Stack_Size_Len - My_Stack_Size_Str'Length) := (others => ' '); Actual_Use_Blanks : constant @@ -453,7 +453,7 @@ package body System.Stack_Usage is Put (" | "); Put (Result.Task_Name); Put (" | "); - Put (Stack_Size_Blanks & Stack_Size_Str); + Put (Stack_Size_Blanks & My_Stack_Size_Str); Put (" | "); Put (Actual_Use_Blanks & Actual_Use_Str); New_Line; @@ -488,8 +488,8 @@ package body System.Stack_Usage is for J in Result_Array'Range loop exit when J >= Next_Id; - if Result_Array (J).Max_Measure - > Result_Array (Max_Actual_Use_Result_Id).Max_Measure + if Result_Array (J).Value > + Result_Array (Max_Actual_Use_Result_Id).Value then Max_Actual_Use_Result_Id := J; end if; @@ -559,28 +559,34 @@ package body System.Stack_Usage is Result : Task_Result := (Task_Name => Analyzer.Task_Name, Max_Size => Analyzer.Stack_Size, - Min_Measure => 0, - Max_Measure => 0); + Variation => 0, + Value => 0); Overflow_Guard : constant Integer := Analyzer.Stack_Size - Stack_Size (Analyzer.Top_Pattern_Mark, Analyzer.Bottom_Of_Stack); + Max, Min : Positive; 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 - Overflow_Guard; - Result.Max_Measure := Analyzer.Stack_Size; + Min := Analyzer.Stack_Size - Overflow_Guard; + Max := Analyzer.Stack_Size; + else - Result.Min_Measure := Stack_Size - (Analyzer.Topmost_Touched_Mark, - Analyzer.Bottom_Of_Stack); - Result.Max_Measure := Result.Min_Measure + Overflow_Guard; + Min := + Stack_Size + (Analyzer.Topmost_Touched_Mark, Analyzer.Bottom_Of_Stack); + Max := Min + Overflow_Guard; end if; + Result.Value := (Max + Min) / 2; + Result.Variation := (Max - Min) / 2; + if Analyzer.Result_Id in Result_Array'Range then -- If the result can be stored, then store it in Result_Array |