1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
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)
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.
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. */
36 histType = Histable::HEAPCALLSTACK;
41 aSmallestBytes = _10TB;
58 lSmallestBytes = _10TB;
76 HeapData::HeapData (char *sName)
78 stackName = dbe_strdup (sName);
79 peakStackIds = new Vector<uint64_t>;
80 peakTimestamps = new Vector<hrtime_t>;
84 HeapData::HeapData (HeapData *hData)
86 stackName = dbe_strdup (hData->stackName);
87 stackId = hData->stackId;
88 histType = hData->histType;
89 allocBytes = hData->allocBytes;
90 leakBytes = hData->leakBytes;
91 allocCnt = hData->allocCnt;
92 leakCnt = hData->leakCnt;
93 peakMemUsage = hData->peakMemUsage;
94 timestamp = hData->timestamp;
95 pid = hData->getPid ();
96 userExpId = hData->getUserExpId ();
97 peakStackIds = new Vector<uint64_t>;
98 Vector<uint64_t> *sIds = hData->peakStackIds;
101 for (int i = 0; i < sIds->size (); i++)
103 sId = sIds->fetch (i);
104 peakStackIds->append (sId);
107 peakTimestamps = new Vector<hrtime_t>;
108 Vector<hrtime_t> *pts = hData->peakTimestamps;
111 for (int i = 0; i < pts->size (); i++)
114 peakTimestamps->append (ts);
117 aSmallestBytes = hData->aSmallestBytes;
118 aLargestBytes = hData->aLargestBytes;
119 a0KB1KBCnt = hData->a0KB1KBCnt;
120 a1KB8KBCnt = hData->a1KB8KBCnt;
121 a8KB32KBCnt = hData->a8KB32KBCnt;
122 a32KB128KBCnt = hData->a32KB128KBCnt;
123 a128KB256KBCnt = hData->a128KB256KBCnt;
124 a256KB512KBCnt = hData->a256KB512KBCnt;
125 a512KB1000KBCnt = hData->a512KB1000KBCnt;
126 a1000KB10MBCnt = hData->a1000KB10MBCnt;
127 a10MB100MBCnt = hData->a10MB100MBCnt;
128 a100MB1GBCnt = hData->a100MB1GBCnt;
129 a1GB10GBCnt = hData->a1GB10GBCnt;
130 a10GB100GBCnt = hData->a10GB100GBCnt;
131 a100GB1TBCnt = hData->a100GB1TBCnt;
132 a1TB10TBCnt = hData->a1TB10TBCnt;
134 lSmallestBytes = hData->lSmallestBytes;
135 lLargestBytes = hData->lLargestBytes;
136 l0KB1KBCnt = hData->l0KB1KBCnt;
137 l1KB8KBCnt = hData->l1KB8KBCnt;
138 l8KB32KBCnt = hData->l8KB32KBCnt;
139 l32KB128KBCnt = hData->l32KB128KBCnt;
140 l128KB256KBCnt = hData->l128KB256KBCnt;
141 l256KB512KBCnt = hData->l256KB512KBCnt;
142 l512KB1000KBCnt = hData->l512KB1000KBCnt;
143 l1000KB10MBCnt = hData->l1000KB10MBCnt;
144 l10MB100MBCnt = hData->l10MB100MBCnt;
145 l100MB1GBCnt = hData->l100MB1GBCnt;
146 l1GB10GBCnt = hData->l1GB10GBCnt;
147 l10GB100GBCnt = hData->l10GB100GBCnt;
148 l100GB1TBCnt = hData->l100GB1TBCnt;
149 l1TB10TBCnt = hData->l1TB10TBCnt;
152 HeapData::~HeapData ()
156 delete peakTimestamps;
160 HeapData::convertto (Histable_type type, Histable*)
162 return type == histType ? this : NULL;
166 HeapData::get_name (Histable::NameFormat /*_nfmt*/)
172 HeapData::get_raw_name (Histable::NameFormat /*_nfmt*/)
178 HeapData::set_name (char* _name)
181 stackName = dbe_strdup (_name);
185 HeapData::setPeakMemUsage (int64_t pmu, uint64_t sId, hrtime_t ts, int procId, int uei)
187 if (peakMemUsage < pmu)
190 peakStackIds->reset ();
191 peakStackIds->append (sId);
192 peakTimestamps->reset ();
193 peakTimestamps->append (ts);
197 else if (peakMemUsage == pmu)
199 for (int i = 0; i < peakStackIds->size (); i++)
201 uint64_t curSId = peakStackIds->fetch (i);
205 peakStackIds->append (sId);
206 peakTimestamps->append (ts);
213 HeapData::setAllocStat (int64_t nb)
215 if (aSmallestBytes > nb)
217 if (aLargestBytes < nb)
219 if (nb >= 0 && nb <= _1KB)
223 else if (nb <= _32KB)
225 else if (nb <= _128KB)
227 else if (nb <= _256KB)
229 else if (nb <= _512KB)
231 else if (nb <= _1000KB)
233 else if (nb <= _10MB)
235 else if (nb <= _100MB)
239 else if (nb <= _10GB)
241 else if (nb <= _100GB)
245 else if (nb <= _10TB)
250 HeapData::setLeakStat (int64_t nb)
252 if (lSmallestBytes > nb)
254 if (lLargestBytes < nb)
256 if (nb >= 0 && nb <= _1KB)
260 else if (nb <= _32KB)
262 else if (nb <= _128KB)
264 else if (nb <= _256KB)
266 else if (nb <= _512KB)
268 else if (nb <= _1000KB)
270 else if (nb <= _10MB)
272 else if (nb <= _100MB)
276 else if (nb <= _10GB)
278 else if (nb <= _100GB)
282 else if (nb <= _10TB)