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. */
42 wSmallestBytes = _10TB;
59 rSmallestBytes = _10TB;
77 FileData::FileData (const char *fName)
79 fileName = dbe_strdup (fName);
80 fileDesList = new Vector<int>;
81 virtualFds = new Vector<int64_t>;
85 histType = Histable::IOACTVFD;
89 FileData::FileData (FileData *fData)
91 fileName = dbe_strdup (fData->fileName);
92 fileDesList = new Vector<int>;
93 Vector<int> *fdList = fData->fileDesList;
96 for (int i = 0; i < fdList->size (); i++)
97 if ((fd = fdList->fetch (i)) == -1)
98 fileDesList->append (fd);
100 virtualFds = new Vector<int64_t>;
101 Vector<int64_t> *vfds = fData->virtualFds;
104 for (int i = 0; i < vfds->size (); i++)
105 if ((vfd = vfds->fetch (i)) == -1)
106 virtualFds->append (vfd);
107 virtualFd = fData->virtualFd;
108 fileDes = fData->fileDes;
109 histType = fData->histType;
111 for (int i = 0; i < FSTYPESZ; i++)
112 fsType[i] = fData->fsType[i];
114 readTime = fData->readTime;
115 writeTime = fData->writeTime;
116 otherTime = fData->otherTime;
117 errorTime = fData->errorTime;
118 readBytes = fData->readBytes;
119 writeBytes = fData->writeBytes;
120 readCnt = fData->readCnt;
121 writeCnt = fData->writeCnt;
122 otherCnt = fData->otherCnt;
123 errorCnt = fData->errorCnt;
124 wSlowestBytes = fData->wSlowestBytes;
125 wSmallestBytes = fData->wSmallestBytes;
126 wLargestBytes = fData->wLargestBytes;
127 w0KB1KBCnt = fData->w0KB1KBCnt;
128 w1KB8KBCnt = fData->w1KB8KBCnt;
129 w8KB32KBCnt = fData->w8KB32KBCnt;
130 w32KB128KBCnt = fData->w32KB128KBCnt;
131 w128KB256KBCnt = fData->w128KB256KBCnt;
132 w256KB512KBCnt = fData->w256KB512KBCnt;
133 w512KB1000KBCnt = fData->w512KB1000KBCnt;
134 w1000KB10MBCnt = fData->w1000KB10MBCnt;
135 w10MB100MBCnt = fData->w10MB100MBCnt;
136 w100MB1GBCnt = fData->w100MB1GBCnt;
137 w1GB10GBCnt = fData->w1GB10GBCnt;
138 w10GB100GBCnt = fData->w10GB100GBCnt;
139 w100GB1TBCnt = fData->w100GB1TBCnt;
140 w1TB10TBCnt = fData->w1TB10TBCnt;
141 rSlowestBytes = fData->rSlowestBytes;
142 rSmallestBytes = fData->rSmallestBytes;
143 rLargestBytes = fData->rLargestBytes;
144 r0KB1KBCnt = fData->r0KB1KBCnt;
145 r1KB8KBCnt = fData->r1KB8KBCnt;
146 r8KB32KBCnt = fData->r8KB32KBCnt;
147 r32KB128KBCnt = fData->r32KB128KBCnt;
148 r128KB256KBCnt = fData->r128KB256KBCnt;
149 r256KB512KBCnt = fData->r256KB512KBCnt;
150 r512KB1000KBCnt = fData->r512KB1000KBCnt;
151 r1000KB10MBCnt = fData->r1000KB10MBCnt;
152 r10MB100MBCnt = fData->r10MB100MBCnt;
153 r100MB1GBCnt = fData->r100MB1GBCnt;
154 r1GB10GBCnt = fData->r1GB10GBCnt;
155 r10GB100GBCnt = fData->r10GB100GBCnt;
156 r100GB1TBCnt = fData->r100GB1TBCnt;
157 r1TB10TBCnt = fData->r1TB10TBCnt;
160 FileData::~FileData ()
168 FileData::setVirtualFds (int64_t vfd)
170 for (int i = 0; i < virtualFds->size (); i++)
171 if (vfd == virtualFds->fetch (i))
173 virtualFds->append (vfd);
177 FileData::setFileDesList (int fd)
179 for (int i = 0; i < fileDesList->size (); i++)
180 if (fd == fileDesList->fetch (i))
182 fileDesList->append (fd);
186 FileData::setFsType (const char* fst)
188 size_t len = strlen (fst);
189 if (len > 0 && len < FSTYPESZ)
190 snprintf (fsType, sizeof (fsType), NTXT ("%s"), fst);
192 snprintf (fsType, sizeof (fsType), GTXT ("error"));
196 FileData::convertto (Histable_type type, Histable*)
198 return (type == histType ? this : NULL);
202 FileData::get_name (Histable::NameFormat /*_nfmt*/)
204 if (histType == Histable::IOACTVFD)
206 if (!streq (fileName, NTXT ("<Total>")))
209 return dbe_sprintf (GTXT ("%s (IOVFD=%lld, FD=%d)"), fileName,
210 (long long) virtualFd, (int) fileDes);
211 return dbe_sprintf (GTXT ("%s (IOVFD=%lld)"), fileName,
212 (long long) virtualFd);
217 else if (histType == Histable::IOACTFILE)
219 if (!streq (fileName, NTXT ("<Total>")))
221 if (!streq (fsType, NTXT ("N/A")))
222 return dbe_sprintf (GTXT ("%s (FS=%s)"), fileName, fsType);
231 FileData::get_raw_name (Histable::NameFormat /*_nfmt*/)
237 FileData::setFsType (FileSystem_type fst)
325 FileData::setWriteStat (hrtime_t wt, int64_t nb)
327 if (wSlowestBytes < wt)
329 if (nb != 0 && wSmallestBytes > nb)
331 if (wLargestBytes < nb)
333 if (nb >= 0 && nb <= _1KB)
337 else if (nb <= _32KB)
339 else if (nb <= _128KB)
341 else if (nb <= _256KB)
343 else if (nb <= _512KB)
345 else if (nb <= _1000KB)
347 else if (nb <= _10MB)
349 else if (nb <= _100MB)
353 else if (nb <= _10GB)
355 else if (nb <= _100GB)
359 else if (nb <= _10TB)
364 FileData::setReadStat (hrtime_t rt, int64_t nb)
366 if (rSlowestBytes < rt)
368 if (nb != 0 && rSmallestBytes > nb)
370 if (rLargestBytes < nb)
372 if (nb >= 0 && nb <= _1KB)
376 else if (nb <= _32KB)
378 else if (nb <= _128KB)
380 else if (nb <= _256KB)
382 else if (nb <= _512KB)
384 else if (nb <= _1000KB)
386 else if (nb <= _10MB)
388 else if (nb <= _100MB)
392 else if (nb <= _10GB)
394 else if (nb <= _100GB)
398 else if (nb <= _10TB)