]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gprofng/src/HeapData.h
Update year range in gprofng copyright notices
[thirdparty/binutils-gdb.git] / gprofng / src / HeapData.h
1 /* Copyright (C) 2021-2023 Free Software Foundation, Inc.
2 Contributed by Oracle.
3
4 This file is part of GNU Binutils.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
20
21 #ifndef _HEAPDATA_H
22 #define _HEAPDATA_H
23
24 #include "gp-defs.h"
25 #include "gp-time.h"
26
27 #include "vec.h"
28 #include "data_pckts.h"
29 #include "Histable.h"
30
31 #define TOTAL_HEAPNAME NTXT("<Total>")
32 #define TOTAL_STACK_ID 0
33 #define _1KB 1024
34 #define _8KB 8192
35 #define _32KB 32768
36 #define _128KB 131072
37 #define _256KB 262144
38 #define _512KB 524288
39 #define _1000KB 1048576
40 #define _10MB 10485760
41 #define _100MB 104857600
42 #define _1GB 1073741824
43 #define _10GB 10737418240
44 #define _100GB 107374182400
45 #define _1TB 1099511627776
46 #define _10TB 10995116277760
47
48 class HeapData : public Histable
49 {
50 friend class HeapActivity;
51 public:
52 HeapData (char *sName);
53 HeapData (HeapData *hData);
54 ~HeapData ();
55 char *get_raw_name (Histable::NameFormat nfmt);
56 void init ();
57 void setStackName (char* sName);
58 void setPeakMemUsage (int64_t pmu, uint64_t sId, hrtime_t ts, int procId, int uei);
59
60 virtual char *get_name (Histable::NameFormat nfmt);
61 virtual void set_name (char * _name);
62 virtual Histable *convertto (Histable_type, Histable* = NULL);
63
64 virtual Histable_type
65 get_type ()
66 {
67 return histType;
68 }
69
70 virtual uint64_t
71 get_addr ()
72 {
73 return stackId;
74 }
75
76 uint64_t
77 get_index ()
78 {
79 return stackId;
80 }
81
82 char *
83 getStackName ()
84 {
85 return stackName;
86 }
87
88 void
89 addAllocEvent (uint64_t nb)
90 {
91 allocBytes += nb;
92 allocCnt++;
93 }
94
95 uint64_t
96 getAllocBytes ()
97 {
98 return allocBytes;
99 }
100
101 int32_t
102 getAllocCnt ()
103 {
104 return allocCnt;
105 }
106
107 void
108 addLeakEvent (uint64_t nb)
109 {
110 leakBytes += nb;
111 leakCnt++;
112 }
113
114 uint64_t
115 getLeakBytes ()
116 {
117 return leakBytes;
118 }
119
120 int32_t
121 getLeakCnt ()
122 {
123 return leakCnt;
124 }
125
126 void
127 setStackId (uint64_t sId)
128 {
129 stackId = sId;
130 }
131
132 uint64_t
133 getStackId ()
134 {
135 return stackId;
136 }
137
138 void
139 setTimestamp (hrtime_t ts)
140 {
141 timestamp = ts;
142 }
143
144 hrtime_t
145 getTimestamp ()
146 {
147 return timestamp;
148 }
149
150 void
151 setHistType (Histable::Type hType)
152 {
153 histType = hType;
154 }
155
156 Histable::Type
157 getHistType ()
158 {
159 return histType;
160 }
161
162 int64_t
163 getPeakMemUsage ()
164 {
165 return peakMemUsage;
166 }
167
168 Vector<uint64_t> *
169 getPeakStackIds ()
170 {
171 return peakStackIds;
172 }
173
174 Vector<hrtime_t> *
175 getPeakTimestamps ()
176 {
177 return peakTimestamps;
178 }
179
180 void
181 setPid (int procId)
182 {
183 pid = procId;
184 }
185
186 int
187 getPid ()
188 {
189 return pid;
190 }
191
192 void
193 setUserExpId (int uei)
194 {
195 userExpId = uei;
196 }
197
198 int
199 getUserExpId ()
200 {
201 return userExpId;
202 }
203
204 void setAllocStat (int64_t nb);
205
206 int64_t
207 getASmallestBytes ()
208 {
209 return aSmallestBytes;
210 }
211
212 int64_t
213 getALargestBytes ()
214 {
215 return aLargestBytes;
216 }
217
218 int32_t
219 getA0KB1KBCnt ()
220 {
221 return a0KB1KBCnt;
222 }
223
224 int32_t
225 getA1KB8KBCnt ()
226 {
227 return a1KB8KBCnt;
228 }
229
230 int32_t
231 getA8KB32KBCnt ()
232 {
233 return a8KB32KBCnt;
234 }
235
236 int32_t
237 getA32KB128KBCnt ()
238 {
239 return a32KB128KBCnt;
240 }
241
242 int32_t
243 getA128KB256KBCnt ()
244 {
245 return a128KB256KBCnt;
246 }
247
248 int32_t
249 getA256KB512KBCnt ()
250 {
251 return a256KB512KBCnt;
252 }
253
254 int32_t
255 getA512KB1000KBCnt ()
256 {
257 return a512KB1000KBCnt;
258 }
259
260 int32_t
261 getA1000KB10MBCnt ()
262 {
263 return a1000KB10MBCnt;
264 }
265
266 int32_t
267 getA10MB100MBCnt ()
268 {
269 return a10MB100MBCnt;
270 }
271
272 int32_t
273 getA100MB1GBCnt ()
274 {
275 return a100MB1GBCnt;
276 }
277
278 int32_t
279 getA1GB10GBCnt ()
280 {
281 return a1GB10GBCnt;
282 }
283
284 int32_t
285 getA10GB100GBCnt ()
286 {
287 return a10GB100GBCnt;
288 }
289
290 int32_t
291 getA100GB1TBCnt ()
292 {
293 return a100GB1TBCnt;
294 }
295
296 int32_t
297 getA1TB10TBCnt ()
298 {
299 return a1TB10TBCnt;
300 }
301
302 void setLeakStat (int64_t nb);
303
304 int64_t
305 getLSmallestBytes ()
306 {
307 return lSmallestBytes;
308 }
309
310 int64_t
311 getLLargestBytes ()
312 {
313 return lLargestBytes;
314 }
315
316 int32_t
317 getL0KB1KBCnt ()
318 {
319 return l0KB1KBCnt;
320 }
321
322 int32_t
323 getL1KB8KBCnt ()
324 {
325 return l1KB8KBCnt;
326 }
327
328 int32_t
329 getL8KB32KBCnt ()
330 {
331 return l8KB32KBCnt;
332 }
333
334 int32_t
335 getL32KB128KBCnt ()
336 {
337 return l32KB128KBCnt;
338 }
339
340 int32_t
341 getL128KB256KBCnt ()
342 {
343 return l128KB256KBCnt;
344 }
345
346 int32_t
347 getL256KB512KBCnt ()
348 {
349 return l256KB512KBCnt;
350 }
351
352 int32_t
353 getL512KB1000KBCnt ()
354 {
355 return l512KB1000KBCnt;
356 }
357
358 int32_t
359 getL1000KB10MBCnt ()
360 {
361 return l1000KB10MBCnt;
362 }
363
364 int32_t
365 getL10MB100MBCnt ()
366 {
367 return l10MB100MBCnt;
368 }
369
370 int32_t
371 getL100MB1GBCnt ()
372 {
373 return l100MB1GBCnt;
374 }
375
376 int32_t
377 getL1GB10GBCnt ()
378 {
379 return l1GB10GBCnt;
380 }
381
382 int32_t
383 getL10GB100GBCnt ()
384 {
385 return l10GB100GBCnt;
386 }
387
388 int32_t
389 getL100GB1TBCnt ()
390 {
391 return l100GB1TBCnt;
392 }
393
394 int32_t
395 getL1TB10TBCnt ()
396 {
397 return l1TB10TBCnt;
398 }
399
400 private:
401 char *stackName; // stack name
402 uint64_t allocBytes; // The total bytes allocated
403 uint64_t leakBytes; // The total bytes leaked
404 int32_t allocCnt; // The alloc count
405 int32_t leakCnt; // The leak count
406 Histable::Type histType; // The Histable type: HEAPCALLSTACK
407 int64_t peakMemUsage; // Keep track of peak memory usage
408 uint64_t stackId;
409 Vector<uint64_t> *peakStackIds; // The peak memory usage stack ids
410 hrtime_t timestamp;
411 Vector<hrtime_t> *peakTimestamps; // The peak data
412 int pid; // The process id
413 int userExpId; // The experiment id
414
415 int64_t aSmallestBytes;
416 int64_t aLargestBytes;
417 int32_t a0KB1KBCnt;
418 int32_t a1KB8KBCnt;
419 int32_t a8KB32KBCnt;
420 int32_t a32KB128KBCnt;
421 int32_t a128KB256KBCnt;
422 int32_t a256KB512KBCnt;
423 int32_t a512KB1000KBCnt;
424 int32_t a1000KB10MBCnt;
425 int32_t a10MB100MBCnt;
426 int32_t a100MB1GBCnt;
427 int32_t a1GB10GBCnt;
428 int32_t a10GB100GBCnt;
429 int32_t a100GB1TBCnt;
430 int32_t a1TB10TBCnt;
431
432 int64_t lSmallestBytes;
433 int64_t lLargestBytes;
434 int32_t l0KB1KBCnt;
435 int32_t l1KB8KBCnt;
436 int32_t l8KB32KBCnt;
437 int32_t l32KB128KBCnt;
438 int32_t l128KB256KBCnt;
439 int32_t l256KB512KBCnt;
440 int32_t l512KB1000KBCnt;
441 int32_t l1000KB10MBCnt;
442 int32_t l10MB100MBCnt;
443 int32_t l100MB1GBCnt;
444 int32_t l1GB10GBCnt;
445 int32_t l10GB100GBCnt;
446 int32_t l100GB1TBCnt;
447 int32_t l1TB10TBCnt;
448 };
449
450 #endif