]> gcc.gnu.org Git - gcc.git/blame - gcc/ada/memroot.ads
3psoccon.ads, [...]: Files added.
[gcc.git] / gcc / ada / memroot.ads
CommitLineData
84481f76
RK
1------------------------------------------------------------------------------
2-- --
3-- GNAT COMPILER COMPONENTS --
4-- --
5-- M E M R O O T --
6-- --
7-- S p e c --
8-- --
fbf5a39b 9-- Copyright (C) 1997-2003 Ada Core Technologies, Inc. --
84481f76
RK
10-- --
11-- GNAT is free software; you can redistribute it and/or modify it under --
12-- terms of the GNU General Public License as published by the Free Soft- --
13-- ware Foundation; either version 2, or (at your option) any later ver- --
14-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17-- for more details. You should have received a copy of the GNU General --
18-- Public License distributed with GNAT; see file COPYING. If not, write --
19-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20-- MA 02111-1307, USA. --
21-- --
22-- GNAT was originally developed by the GNAT team at New York University. --
fbf5a39b 23-- Extensive contributions were provided by Ada Core Technologies Inc. --
84481f76
RK
24-- --
25------------------------------------------------------------------------------
26
27-- This package offers basic types that deal with gdb backtraces related
28-- to memory allocation. A memory root (root_id) is a backtrace
29-- referencing the actual point of allocation along with counters
30-- recording various information concerning allocation at this root.
31
32-- A back trace is composed of Frames (Frame_Id) which themselves are
33-- nothing else than a subprogram call at a source location which can be
34-- represented by three strings: subprogram name, file name and line
35-- number. All the needed strings are entered in a table and referenced
36-- through a Name_Id in order to avoid duplication.
37
38with System.Storage_Elements; use System.Storage_Elements;
84481f76
RK
39
40package Memroot is
41
84481f76
RK
42 -- Simple abstract type for names. A name is a sequence of letters.
43
44 type Name_Id is new Natural;
45 No_Name_Id : constant Name_Id := 0;
46
47 function Enter_Name (S : String) return Name_Id;
48 function Image (N : Name_Id) return String;
49
50 -- Simple abstract type for a backtrace frame. A frame is composed by
51 -- a subprogram name, a file name and a line reference.
52
53 type Frame_Id is new Natural;
54 No_Frame_Id : constant Frame_Id := 0;
55
fbf5a39b
AC
56 function Enter_Frame
57 (Addr : System.Address;
58 Name : Name_Id;
59 File : Name_Id;
60 Line : Name_Id)
61 return Frame_Id;
84481f76
RK
62
63 type Frame_Array is array (Natural range <>) of Frame_Id;
64
65 -- Simple abstract type for an allocation root. It is composed by a set
66 -- of frames, the number of allocation, the total size of allocated
67 -- memory, and the high water mark. An iterator is also provided to
68 -- iterate over all the entered allocation roots.
69
70 type Root_Id is new Natural;
71 No_Root_Id : constant Root_Id := 0;
72
fbf5a39b
AC
73 function Read_BT (BT_Depth : Integer) return Root_Id;
74 -- Reads a backtrace whose maximum frame number is given by
84481f76
RK
75 -- BT_Depth and returns the corresponding Allocation root.
76
77 function Enter_Root (Fr : Frame_Array) return Root_Id;
78 -- Create an allocation root from the frames that compose it
79
80 function Frames_Of (B : Root_Id) return Frame_Array;
81 -- Retreives the Frames of the root's backtrace
82
fbf5a39b 83 procedure Print_BT (B : Root_Id; Short : Boolean := False);
84481f76 84 -- Prints on standard out the backtrace associated with the root B
fbf5a39b
AC
85 -- When Short is set to True, only the filename & line info is printed.
86 -- When it is set to false, the subprogram name is also printed.
84481f76
RK
87
88 function Get_First return Root_Id;
89 function Get_Next return Root_Id;
90 -- Iterator to iterate over roots
91
92 procedure Set_Nb_Alloc (B : Root_Id; V : Integer);
93 function Nb_Alloc (B : Root_Id) return Integer;
94 -- Access and modify the number of allocation counter associated with
95 -- this allocation root. If the value is negative, it means that this is
96 -- not an allocation root but a deallocation root (this can only happen
97 -- in erroneous situations where there are more frees than allocations).
98
99 procedure Set_Alloc_Size (B : Root_Id; V : Storage_Count);
100 function Alloc_Size (B : Root_Id) return Storage_Count;
101 -- Access and modify the total allocated memory counter associated with
102 -- this allocation root.
103
104 procedure Set_High_Water_Mark (B : Root_Id; V : Storage_Count);
105 function High_Water_Mark (B : Root_Id) return Storage_Count;
106 -- Access and modify the high water mark associated with this
107 -- allocation root. The high water mark is the maximum value, over
108 -- time, of the Alloc_Size.
109
110end Memroot;
This page took 0.483917 seconds and 5 git commands to generate.