OSDN Git Service

* gcc-interface/trans.c (Subprogram_Body_to_gnu): Pop the stack of
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-stausa.ads
index 8a6e2b6..c0449e8 100644 (file)
@@ -6,25 +6,23 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---         Copyright (C) 2004-2008, Free Software Foundation, Inc.          --
+--         Copyright (C) 2004-2011, 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- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
--- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
--- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNARL; see file COPYING.  If not, write --
--- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
--- Boston, MA 02110-1301, USA.                                              --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
 --                                                                          --
--- As a special exception,  if other files  instantiate  generics from this --
--- unit, or you link  this unit with other files  to produce an executable, --
--- this  unit  does not  by itself cause  the resulting  executable  to  be --
--- covered  by the  GNU  General  Public  License.  This exception does not --
--- however invalidate  any other reasons why  the executable file  might be --
--- covered by the  GNU Public License.                                      --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
+--                                                                          --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
 --                                                                          --
 -- GNARL was developed by the GNARL team at Florida State University.       --
 -- Extensive contributions were provided by Ada Core Technologies, Inc.     --
@@ -48,6 +46,23 @@ package System.Stack_Usage is
      (Value : System.Address) return Stack_Address
       renames System.Storage_Elements.To_Integer;
 
+   Task_Name_Length : constant := 32;
+   --  The maximum length of task name displayed.
+   --  ??? Consider merging this variable with Max_Task_Image_Length.
+
+   type Task_Result is record
+      Task_Name : String (1 .. Task_Name_Length);
+
+      Value : Natural;
+      --  Amount of stack used. The value is calculated on the basis of the
+      --  mechanism used by GNAT to allocate it, and it is NOT a precise value.
+
+      Stack_Size : Natural;
+      --  Size of the stack
+   end record;
+
+   type Result_Array_Type is array (Positive range <>) of Task_Result;
+
    type Stack_Analyzer is private;
    --  Type of the stack analyzer tool. It is used to fill a portion of the
    --  stack with Pattern, and to compute the stack used after some execution.
@@ -73,8 +88,9 @@ package System.Stack_Usage is
    --  begin
    --     Initialize_Analyzer (A,
    --                          "Task t",
+   --                          A_Storage_Size,
+   --                          0,
    --                          A_Storage_Size - A_Guard,
-   --                          A_Guard
    --                          To_Stack_Address (Bottom_Of_Stack'Address));
    --     Fill_Stack (A);
    --     Some_User_Code;
@@ -97,7 +113,9 @@ package System.Stack_Usage is
    --       before the call to the instrumentation procedure.
 
    --     Strategy: The user of this package should measure the bottom of stack
-   --       before the call to Fill_Stack and pass it in parameter.
+   --       before the call to Fill_Stack and pass it in parameter. The impact
+   --       is very minor unless the stack used is very small, but in this case
+   --       you aren't very interested by the figure.
 
    --  Instrumentation threshold at writing:
 
@@ -107,7 +125,7 @@ package System.Stack_Usage is
    --       appear as used in the final measure.
 
    --     Strategy: As the user passes the value of the bottom of stack to
-   --       the instrumentation to deal with the bottom offset error, and as as
+   --       the instrumentation to deal with the bottom offset error, and as
    --       the instrumentation procedure knows where the pattern filling start
    --       on the stack, the difference between the two values is the minimum
    --       stack usage that the method can measure. If, when the results are
@@ -194,30 +212,29 @@ package System.Stack_Usage is
    --  the memory will look like that:
    --
    --                                                             Stack growing
-   --  ----------------------------------------------------------------------->
-   --  |<---------------------->|<----------------------------------->|
-   --  |  Stack frame           | Memory filled with Analyzer.Pattern |
-   --  |  of Fill_Stack         |                                     |
-   --  |  (deallocated at       |                                     |
-   --  |  the end of the call)  |                                     |
-   --  ^                        |                                     |
-   --  Analyzer.Bottom_Of_Stack ^                                     |
-   --                    Analyzer.Bottom_Pattern_Mark                 ^
-   --                                            Analyzer.Top_Pattern_Mark
+   --  ---------------------------------------------------------------------->
+   --  |<--------------------->|<----------------------------------->|
+   --  |  Stack frames to      | Memory filled with Analyzer.Pattern |
+   --  |  Fill_Stack           |                                     |
+   --  ^                       |                                     ^
+   --  Analyzer.Stack_Base     |                      Analyzer.Pattern_Limit
+   --                          ^
+   --                    Analyzer.Pattern_Limit +/- Analyzer.Pattern_Size
+   --
 
    procedure Initialize_Analyzer
      (Analyzer         : in out Stack_Analyzer;
       Task_Name        : String;
       Stack_Size       : Natural;
-      Max_Pattern_Size : Natural;
-      Bottom           : Stack_Address;
+      Stack_Base       : Stack_Address;
+      Pattern_Size     : Natural;
       Pattern          : Interfaces.Unsigned_32 := 16#DEAD_BEEF#);
    --  Should be called before any use of a Stack_Analyzer, to initialize it.
    --  Max_Pattern_Size is the size of the pattern zone, might be smaller than
-   --  the full stack size in order to take into account e.g. the secondary
-   --  stack and a guard against overflow. The actual size taken will be
-   --  readjusted with data already used at the time the stack is actually
-   --  filled.
+   --  the full stack size Stack_Size in order to take into account e.g. the
+   --  secondary stack and a guard against overflow. The actual size taken
+   --  will be readjusted with data already used at the time the stack is
+   --  actually filled.
 
    Is_Enabled : Boolean := False;
    --  When this flag is true, then stack analysis is enabled
@@ -233,16 +250,14 @@ package System.Stack_Usage is
    --                                                             Stack growing
    --  ----------------------------------------------------------------------->
    --  |<---------------------->|<-------------->|<--------->|<--------->|
-   --  |  Stack frame           | Array of       | used      |  Memory   |
-   --  |  of Compute_Result     | Analyzer.Probe | during    |   filled  |
-   --  |  (deallocated at       | elements       |  the      |    with   |
-   --  |  the end of the call)  |                | execution |  pattern  |
-   --  |                        ^                |           |           |
-   --  |                   Bottom_Pattern_Mark   |           |           |
+   --  |  Stack frames          | Array of       | used      |  Memory   |
+   --  |  to Compute_Result     | Analyzer.Probe | during    |   filled  |
+   --  |                        | elements       |  the      |    with   |
+   --  |                        |                | execution |  pattern  |
    --  |                                                     |           |
    --  |<---------------------------------------------------->           |
    --                  Stack used                                        ^
-   --                                                     Top_Pattern_Mark
+   --                                                           Pattern_Limit
 
    procedure Report_Result (Analyzer : Stack_Analyzer);
    --  Store the results of the computation in memory, at the address
@@ -258,10 +273,6 @@ package System.Stack_Usage is
 
 private
 
-   Task_Name_Length : constant := 32;
-   --  The maximum length of task name displayed.
-   --  ??? Consider merging this variable with Max_Task_Image_Length.
-
    package Unsigned_32_Addr is
      new System.Address_To_Access_Conversions (Interfaces.Unsigned_32);
 
@@ -272,6 +283,10 @@ private
       Task_Name : String (1 .. Task_Name_Length);
       --  Name of the task
 
+      Stack_Base : Stack_Address;
+      --  Address of the base of the stack, as given by the caller of
+      --  Initialize_Analyzer.
+
       Stack_Size : Natural;
       --  Entire size of the analyzed stack
 
@@ -281,11 +296,8 @@ private
       Pattern : Pattern_Type;
       --  Pattern used to recognize untouched memory
 
-      Bottom_Pattern_Mark : Stack_Address;
-      --  Bound of the pattern area on the stack closest to the bottom
-
-      Top_Pattern_Mark : Stack_Address;
-      --  Topmost bound of the pattern area on the stack
+      Pattern_Limit : Stack_Address;
+      --  Bound of the pattern area farthest to the base
 
       Topmost_Touched_Mark : Stack_Address;
       --  Topmost address of the pattern area whose value it is pointing
@@ -293,41 +305,19 @@ private
       --  compensated, it is the topmost value of the stack pointer during
       --  the execution.
 
-      Bottom_Of_Stack : Stack_Address;
-      --  Address of the bottom of the stack, as given by the caller of
-      --  Initialize_Analyzer.
-
-      Stack_Overlay_Address : System.Address;
+      Pattern_Overlay_Address : System.Address;
       --  Address of the stack abstraction object we overlay over a
       --  task's real stack, typically a pattern-initialized array.
 
       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;
 
    Compute_Environment_Task  : Boolean;
 
-   type Task_Result is record
-      Task_Name : String (1 .. Task_Name_Length);
-
-      Min_Measure : Natural;
-      --  Minimum value for the measure
-
-      Max_Measure : Natural;
-      --  Maximum value for the measure, taking into account the actual size
-      --  of the pattern filled.
-
-      Max_Size : Natural;
-   end record;
-
-   type Result_Array_Type is array (Positive range <>) of Task_Result;
    type Result_Array_Ptr is access all Result_Array_Type;
 
    Result_Array : Result_Array_Ptr;