Commit b8f2b5d9 by Quentin Ochem Committed by Arnaud Charlet

2008-07-31 Quentin Ochem <ochem@adacore.com>

	* 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
parent 9febb58f
...@@ -258,20 +258,29 @@ package body System.Stack_Usage is ...@@ -258,20 +258,29 @@ package body System.Stack_Usage is
-- big, the more an "instrumentation threshold at writing" error is -- big, the more an "instrumentation threshold at writing" error is
-- likely to happen. -- likely to happen.
Stack_Used_When_Filling : Integer;
Current_Stack_Level : aliased Integer; Current_Stack_Level : aliased Integer;
begin begin
-- Readjust the pattern size. When we arrive in this function, there is -- Readjust the pattern size. When we arrive in this function, there is
-- already a given amount of stack used, that we won't analyze. -- already a given amount of stack used, that we won't analyze.
Analyzer.Stack_Used_When_Filling := Stack_Used_When_Filling :=
Stack_Size Stack_Size
(Analyzer.Bottom_Of_Stack, (Analyzer.Bottom_Of_Stack,
To_Stack_Address (Current_Stack_Level'Address)) To_Stack_Address (Current_Stack_Level'Address))
+ Natural (Current_Stack_Level'Size); + Natural (Current_Stack_Level'Size);
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 :=
Analyzer.Pattern_Size - Analyzer.Stack_Used_When_Filling; Analyzer.Pattern_Size - Stack_Used_When_Filling;
end if;
declare declare
Stack : aliased Stack_Slots Stack : aliased Stack_Slots
...@@ -282,10 +291,15 @@ package body System.Stack_Usage is ...@@ -282,10 +291,15 @@ package body System.Stack_Usage is
Analyzer.Stack_Overlay_Address := Stack'Address; Analyzer.Stack_Overlay_Address := Stack'Address;
if Analyzer.Pattern_Size /= 0 then
Analyzer.Bottom_Pattern_Mark := Analyzer.Bottom_Pattern_Mark :=
To_Stack_Address (Stack (Bottom_Slot_Index_In (Stack))'Address); To_Stack_Address (Stack (Bottom_Slot_Index_In (Stack))'Address);
Analyzer.Top_Pattern_Mark := Analyzer.Top_Pattern_Mark :=
To_Stack_Address (Stack (Top_Slot_Index_In (Stack))'Address); 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 -- If Arr has been packed, the following assertion must be true (we
-- add the size of the element whose address is: -- add the size of the element whose address is:
...@@ -539,20 +553,28 @@ package body System.Stack_Usage is ...@@ -539,20 +553,28 @@ package body System.Stack_Usage is
------------------- -------------------
procedure Report_Result (Analyzer : Stack_Analyzer) is procedure Report_Result (Analyzer : Stack_Analyzer) is
Measure : constant Natural := Result : Task_Result :=
Stack_Size
(Analyzer.Topmost_Touched_Mark,
Analyzer.Bottom_Of_Stack)
+ Analyzer.Stack_Used_When_Filling;
Result : constant Task_Result :=
(Task_Name => Analyzer.Task_Name, (Task_Name => Analyzer.Task_Name,
Max_Size => Analyzer.Stack_Size, Max_Size => Analyzer.Stack_Size,
Min_Measure => Measure, Min_Measure => 0,
Max_Measure => Measure + Analyzer.Stack_Size Max_Measure => 0);
- Analyzer.Pattern_Size);
begin 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 Analyzer.Result_Id in Result_Array'Range then
-- If the result can be stored, then store it in Result_Array -- If the result can be stored, then store it in Result_Array
......
...@@ -304,10 +304,6 @@ private ...@@ -304,10 +304,6 @@ private
Result_Id : Positive; Result_Id : Positive;
-- Id of the result. If less than value given to gnatbind -u corresponds -- 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. -- 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; end record;
Environment_Task_Analyzer : Stack_Analyzer; Environment_Task_Analyzer : Stack_Analyzer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment