]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gprofng/src/FileData.h
gprofng: a new GNU profiler
[thirdparty/binutils-gdb.git] / gprofng / src / FileData.h
1 /* Copyright (C) 2021 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 _FILEDATA_H
22 #define _FILEDATA_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 FSTYPESZ 16
32
33 #define VIRTUAL_FD_TOTAL 0
34 #define VIRTUAL_FD_STDIN 1
35 #define VIRTUAL_FD_STDOUT 2
36 #define VIRTUAL_FD_STDERR 3
37 #define VIRTUAL_FD_OTHERIO 4
38 #define VIRTUAL_FD_NONE -1
39
40 #define STDIN_FD 0
41 #define STDOUT_FD 1
42 #define STDERR_FD 2
43 #define OTHERIO_FD -1
44
45 #define OTHERIO_FILENAME "<Other IO activity>"
46 #define STDIN_FILENAME "<stdin>"
47 #define STDOUT_FILENAME "<stdout>"
48 #define STDERR_FILENAME "<stderr>"
49 #define TOTAL_FILENAME NTXT("<Total>")
50 #define UNKNOWNFD_FILENAME "<pipe(), socket(), or other fds>"
51
52 #define _1KB 1024
53 #define _8KB 8192
54 #define _32KB 32768
55 #define _128KB 131072
56 #define _256KB 262144
57 #define _512KB 524288
58 #define _1000KB 1048576
59 #define _10MB 10485760
60 #define _100MB 104857600
61 #define _1GB 1073741824
62 #define _10GB 10737418240
63 #define _100GB 107374182400
64 #define _1TB 1099511627776
65 #define _10TB 10995116277760
66
67 class FileData : public Histable
68 {
69 friend class IOActivity;
70 public:
71 FileData (const char *fName);
72 FileData (FileData *fData);
73 ~FileData ();
74
75 virtual char *get_name (Histable::NameFormat nfmt);
76 virtual Histable *convertto (Histable_type, Histable* = NULL);
77
78 char *get_raw_name (Histable::NameFormat nfmt);
79 void setFsType (FileSystem_type fst);
80 void setFsType (const char* fst);
81
82 virtual Histable_type
83 get_type ()
84 {
85 return histType;
86 };
87
88 virtual uint64_t
89 get_addr ()
90 {
91 return virtualFd;
92 };
93
94 uint64_t
95 get_index ()
96 {
97 return virtualFd;
98 };
99
100 void init ();
101
102 char *
103 getFileName ()
104 {
105 return fileName;
106 }
107
108 void
109 addReadEvent (hrtime_t rt, int64_t nb)
110 {
111 readTime += rt;
112 readBytes += nb;
113 readCnt++;
114 }
115
116 hrtime_t
117 getReadTime ()
118 {
119 return readTime;
120 }
121
122 int64_t
123 getReadBytes ()
124 {
125 return readBytes;
126 }
127
128 int32_t
129 getReadCnt ()
130 {
131 return readCnt;
132 }
133
134 void
135 addWriteEvent (hrtime_t wt, int64_t nb)
136 {
137 writeTime += wt;
138 writeBytes += nb;
139 writeCnt++;
140 }
141
142 hrtime_t
143 getWriteTime ()
144 {
145 return writeTime;
146 }
147
148 int64_t
149 getWriteBytes ()
150 {
151 return writeBytes;
152 }
153
154 int32_t
155 getWriteCnt ()
156 {
157 return writeCnt;
158 }
159
160 void
161 addOtherEvent (hrtime_t ot)
162 {
163 otherTime += ot;
164 otherCnt++;
165 }
166
167 hrtime_t
168 getOtherTime ()
169 {
170 return otherTime;
171 }
172
173 int32_t
174 getOtherCnt ()
175 {
176 return otherCnt;
177 }
178
179 void
180 addErrorEvent (hrtime_t er)
181 {
182 errorTime += er;
183 errorCnt++;
184 }
185
186 hrtime_t
187 getErrorTime ()
188 {
189 return errorTime;
190 }
191
192 int32_t
193 getErrorCnt ()
194 {
195 return errorCnt;
196 }
197
198 void setFileDesList (int fd);
199
200 Vector<int> *
201 getFileDesList ()
202 {
203 return fileDesList;
204 }
205
206 void
207 setFileDes (int fd)
208 {
209 fileDes = fd;
210 }
211
212 int32_t
213 getFileDes ()
214 {
215 return fileDes;
216 }
217
218 void setVirtualFds (int64_t vfd);
219
220 Vector<int64_t> *
221 getVirtualFds ()
222 {
223 return virtualFds;
224 }
225
226 char *
227 getFsType ()
228 {
229 return fsType;
230 }
231
232 void
233 setVirtualFd (int64_t vFd)
234 {
235 virtualFd = vFd;
236 }
237
238 int64_t
239 getVirtualFd ()
240 {
241 return virtualFd;
242 }
243
244 void
245 setHistType (Histable::Type hType)
246 {
247 histType = hType;
248 }
249
250 Histable::Type
251 getHistType ()
252 {
253 return histType;
254 }
255
256 void setWriteStat (hrtime_t wt, int64_t nb);
257
258 hrtime_t
259 getWSlowestBytes ()
260 {
261 return wSlowestBytes;
262 }
263
264 int64_t
265 getWSmallestBytes ()
266 {
267 return wSmallestBytes;
268 }
269
270 int64_t
271 getWLargestBytes ()
272 {
273 return wLargestBytes;
274 }
275
276 int32_t
277 getW0KB1KBCnt ()
278 {
279 return w0KB1KBCnt;
280 }
281
282 int32_t
283 getW1KB8KBCnt ()
284 {
285 return w1KB8KBCnt;
286 }
287
288 int32_t
289 getW8KB32KBCnt ()
290 {
291 return w8KB32KBCnt;
292 }
293
294 int32_t
295 getW32KB128KBCnt ()
296 {
297 return w32KB128KBCnt;
298 }
299
300 int32_t
301 getW128KB256KBCnt ()
302 {
303 return w128KB256KBCnt;
304 }
305
306 int32_t
307 getW256KB512KBCnt ()
308 {
309 return w256KB512KBCnt;
310 }
311
312 int32_t
313 getW512KB1000KBCnt ()
314 {
315 return w512KB1000KBCnt;
316 }
317
318 int32_t
319 getW1000KB10MBCnt ()
320 {
321 return w1000KB10MBCnt;
322 }
323
324 int32_t
325 getW10MB100MBCnt ()
326 {
327 return w10MB100MBCnt;
328 }
329
330 int32_t
331 getW100MB1GBCnt ()
332 {
333 return w100MB1GBCnt;
334 }
335
336 int32_t
337 getW1GB10GBCnt ()
338 {
339 return w1GB10GBCnt;
340 }
341
342 int32_t
343 getW10GB100GBCnt ()
344 {
345 return w10GB100GBCnt;
346 }
347
348 int32_t
349 getW100GB1TBCnt ()
350 {
351 return w100GB1TBCnt;
352 }
353
354 int32_t
355 getW1TB10TBCnt ()
356 {
357 return w1TB10TBCnt;
358 }
359
360 void setReadStat (hrtime_t rt, int64_t nb);
361
362 hrtime_t
363 getRSlowestBytes ()
364 {
365 return rSlowestBytes;
366 }
367
368 int64_t
369 getRSmallestBytes ()
370 {
371 return rSmallestBytes;
372 }
373
374 int64_t
375 getRLargestBytes ()
376 {
377 return rLargestBytes;
378 }
379
380 int32_t
381 getR0KB1KBCnt ()
382 {
383 return r0KB1KBCnt;
384 }
385
386 int32_t
387 getR1KB8KBCnt ()
388 {
389 return r1KB8KBCnt;
390 }
391
392 int32_t
393 getR8KB32KBCnt ()
394 {
395 return r8KB32KBCnt;
396 }
397
398 int32_t
399 getR32KB128KBCnt ()
400 {
401 return r32KB128KBCnt;
402 }
403
404 int32_t
405 getR128KB256KBCnt ()
406 {
407 return r128KB256KBCnt;
408 }
409
410 int32_t
411 getR256KB512KBCnt ()
412 {
413 return r256KB512KBCnt;
414 }
415
416 int32_t
417 getR512KB1000KBCnt ()
418 {
419 return r512KB1000KBCnt;
420 }
421
422 int32_t
423 getR1000KB10MBCnt ()
424 {
425 return r1000KB10MBCnt;
426 }
427
428 int32_t
429 getR10MB100MBCnt ()
430 {
431 return r10MB100MBCnt;
432 }
433
434 int32_t
435 getR100MB1GBCnt ()
436 {
437 return r100MB1GBCnt;
438 }
439
440 int32_t
441 getR1GB10GBCnt ()
442 {
443 return r1GB10GBCnt;
444 }
445
446 int32_t
447 getR10GB100GBCnt ()
448 {
449 return r10GB100GBCnt;
450 }
451
452 int32_t
453 getR100GB1TBCnt ()
454 {
455 return r100GB1TBCnt;
456 }
457
458 int32_t
459 getR1TB10TBCnt ()
460 {
461 return r1TB10TBCnt;
462 }
463
464 private:
465 char *fileName; // File name
466 hrtime_t readTime; // The Total time for read operations;
467 hrtime_t writeTime; // The Total time for write operations;
468 hrtime_t otherTime; // The Total time for other IO operations;
469 hrtime_t errorTime; // The Total time for failed IO operations;
470 int64_t readBytes; //The total bytes read
471 int64_t writeBytes; //The total bytes written
472 int32_t readCnt; // The read count
473 int32_t writeCnt; // The write count
474 int32_t otherCnt; // The other IO count
475 int32_t errorCnt; // The failed IO count
476 Vector<int> *fileDesList; // The list of file descriptors
477 Vector<int64_t> *virtualFds; // The list of file virtual descriptors
478 char fsType[FSTYPESZ]; // The file system type
479 int64_t virtualFd; // The virtual file descriptor
480 int32_t fileDes; // The file descriptor
481 Histable::Type histType; // The Histable type: IOACTFILE, IOACTVFD, ...
482
483 // Write statistics
484 hrtime_t wSlowestBytes;
485 int64_t wSmallestBytes;
486 int64_t wLargestBytes;
487 int32_t w0KB1KBCnt;
488 int32_t w1KB8KBCnt;
489 int32_t w8KB32KBCnt;
490 int32_t w32KB128KBCnt;
491 int32_t w128KB256KBCnt;
492 int32_t w256KB512KBCnt;
493 int32_t w512KB1000KBCnt;
494 int32_t w1000KB10MBCnt;
495 int32_t w10MB100MBCnt;
496 int32_t w100MB1GBCnt;
497 int32_t w1GB10GBCnt;
498 int32_t w10GB100GBCnt;
499 int32_t w100GB1TBCnt;
500 int32_t w1TB10TBCnt;
501
502 // Read statistics
503 hrtime_t rSlowestBytes;
504 int64_t rSmallestBytes;
505 int64_t rLargestBytes;
506 int32_t r0KB1KBCnt;
507 int32_t r1KB8KBCnt;
508 int32_t r8KB32KBCnt;
509 int32_t r32KB128KBCnt;
510 int32_t r128KB256KBCnt;
511 int32_t r256KB512KBCnt;
512 int32_t r512KB1000KBCnt;
513 int32_t r1000KB10MBCnt;
514 int32_t r10MB100MBCnt;
515 int32_t r100MB1GBCnt;
516 int32_t r1GB10GBCnt;
517 int32_t r10GB100GBCnt;
518 int32_t r100GB1TBCnt;
519 int32_t r1TB10TBCnt;
520 };
521
522 #endif