1/* Copyright (C) 2021-2024 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 _HEAPACTIVITY_H
22#define _HEAPACTIVITY_H
23
24
25#include <stdio.h>
26
27#include "vec.h"
28#include "Histable.h"
29#include "Hist_data.h"
30#include "Metric.h"
31#include "HeapData.h"
32#include "DefaultMap.h"
33#include "dbe_types.h"
34
35class Experiment;
36class Expression;
37class DataView;
38class DbeView;
39
40class HeapActivity
41{
42public:
43
44  HeapActivity (DbeView *_dbev);
45
46  ~HeapActivity ()
47  {
48    this->reset ();
49  }
50
51  void reset (void);
52  Hist_data *compute_metrics (MetricList *, Histable::Type,
53			      Hist_data::Mode, Histable*);
54
55private:
56
57  void computeCallStack (Histable::Type, VMode viewMode);
58  void createHistItemTotals (Hist_data *, MetricList *, Histable::Type, bool);
59  void computeHistTotals (Hist_data *, MetricList *);
60  void computeHistData (Hist_data *, MetricList *, Hist_data::Mode, Histable *);
61
62  Vector<HeapData*> *hDataObjs;
63  Vector<HeapData*> *hDataObjsCallStack;
64  bool hasCallStack;
65  HeapData *hDataTotal;
66
67  // list of HeapData objects using the stack id as the key
68  DefaultMap<uint64_t, HeapData*> *hDataCalStkMap;
69
70  // the cached data for mode=Hist_Data::ALL
71  Hist_data *hist_data_callstack_all;
72
73  DbeView *dbev;
74};
75
76#endif /* _HEAPACTIVITY_H */
77