Automatic date update in version.in
[binutils-gdb.git] / gprofng / src / data_pckts.h
blob93d0307f9295e82ccee4f00e1cad23d4bd4e7351
1 /* Copyright (C) 2021 Free Software Foundation, Inc.
2 Contributed by Oracle.
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)
9 any later version.
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. */
21 #ifndef _DATA_PCKTS_H
22 #define _DATA_PCKTS_H
25 * This file contains structure definitions for the binary file formats
26 * used in the experiment. It is implemented as C header file so that
27 * it can be processed by both ANSI-C and C++.
30 #include <pthread.h>
31 #include <stdint.h>
33 #include "gp-defs.h"
34 #include "gp-time.h"
36 #if WSIZE(64)
37 typedef uint64_t Vaddr_type; /* process address for 64 bit apps */
38 typedef uint64_t Size_type; /* size_t for 64 bit apps */
39 #else
40 typedef uint32_t Vaddr_type; /* process address */
41 typedef uint32_t Size_type; /* size_t for 32 bit apps */
42 #endif
44 /* marker to indicate dump of O7 register on stack (support for leaf routines) */
45 #define SP_LEAF_CHECK_MARKER ((uint64_t)(-1))
47 /* marker to indicate truncated stack */
48 #define SP_TRUNC_STACK_MARKER ((uint64_t)(-2))
50 /* marker to indicate failed stack unwind */
51 #define SP_FAILED_UNWIND_MARKER ((uint64_t)(-3))
53 #define PROFILE_BUFFER_CHUNK 16384
55 typedef enum
57 MASTER_SMPL = 0,
58 PROGRAM_SMPL,
59 PERIOD_SMPL,
60 MANUAL_SMPL
61 } Smpl_type;
63 typedef enum
64 { /* values for "profpckt kind" stored in log.xml */
65 EMPTY_PCKT = 0,
66 PROF_PCKT,
67 SYNC_PCKT,
68 HW_PCKT,
69 XHWC_PCKT,
70 HEAP_PCKT,
71 MPI_PCKT,
72 MHWC_PCKT,
73 OPROF_PCKT,
74 OMP_PCKT,
75 RACE_PCKT,
76 FRAME_PCKT,
77 OMP2_PCKT,
78 DEADLOCK_PCKT,
79 OMP3_PCKT,
80 OMP4_PCKT,
81 OMP5_PCKT,
82 UID_PCKT,
83 FRAME2_PCKT,
84 IOTRACE_PCKT,
85 LAST_PCKT, /* last data packet type */
86 CLOSED_PCKT = 65535 /* -1, this packet closes a block */
87 } Pckt_type;
89 typedef enum
91 EMPTY_INFO = 0,
92 STACK_INFO,
93 JAVA_INFO,
94 OMP_INFO,
95 MPI_INFO,
96 OMP2_INFO,
97 LAST_INFO /* keep this one last */
98 } Info_type;
100 #define COMPRESSED_INFO 0x80000000
102 #define JAVA_PCKT 0x80
103 #define OMPS_PCKT 0x40 /* packet contains OMP state info */
104 #define PCKT_TYPE(x) ((x) & 0x1f)
106 typedef struct CommonHead_packet
108 unsigned int tsize : 16;
109 unsigned int type : 16;
110 } CommonHead_packet;
112 // All collector modules record their packets as extensions of CM_Packet
113 typedef struct CM_Packet
115 unsigned int tsize : 16;
116 unsigned int type : 16;
117 } CM_Packet;
119 typedef struct Common_packet
121 unsigned int tsize : 16; /* packet size */
122 unsigned int type : 16;
123 pthread_t lwp_id;
124 pthread_t thr_id;
125 uint32_t cpu_id;
126 hrtime_t tstamp;
127 uint64_t frinfo;
128 } Common_packet;
130 /* Definition of values stored in the experiment PROP_MSTATE field */
131 /* They include:
132 * LWP microstates (copied from msacct.h). Also see PrUsage class.
133 * Linux's CPU time
134 * er_kernel time
136 /* Can be used with LMS_STATE_STRINGS (below) */
137 #define LMS_USER 0 /* running in user mode */
138 #define LMS_SYSTEM 1 /* running in sys call or page fault */
139 #define LMS_TRAP 2 /* running in other trap */
140 #define LMS_TFAULT 3 /* asleep in user text page fault */
141 #define LMS_DFAULT 4 /* asleep in user data page fault */
142 #define LMS_KFAULT 5 /* asleep in kernel page fault */
143 #define LMS_USER_LOCK 6 /* asleep waiting for user-mode lock */
144 #define LMS_SLEEP 7 /* asleep for any other reason */
145 #define LMS_WAIT_CPU 8 /* waiting for CPU (latency) */
146 #define LMS_STOPPED 9 /* stopped (/proc, jobcontrol, or lwp_stop) */
147 #define LMS_LINUX_CPU 10 /* LINUX timer_create(CLOCK_THREAD_CPUTIME_ID) */
148 #define LMS_KERNEL_CPU 11 /* LINUX timer_create(CLOCK_THREAD_CPUTIME_ID) */
149 #define LMS_NUM_STATES 12 /* total number of above states */
150 #define LMS_NUM_SOLARIS_MSTATES 10 /* LMS microstates thru LMS_STOPPED */
152 // Magic value stored in experiments that identifies which LMS states are valid
153 #define LMS_MAGIC_ID_SOLARIS 10 // Solaris: LMS_USER thru LMS_STOPPED
154 #define LMS_MAGIC_ID_ERKERNEL_USER 2 // er_kernel user: LMS_USER, LMS_SYSTEM
155 #define LMS_MAGIC_ID_ERKERNEL_KERNEL 3 // er_kernel kernel: LMS_KERNEL_CPU
156 #define LMS_MAGIC_ID_LINUX 1 // Linux: LMS_LINUX_CPU
158 #define LMS_STATE_STRINGS \
160 NTXT("USER"), /* LMS_USER */ \
161 NTXT("SYSTEM"), /* LMS_SYSTEM */ \
162 NTXT("TRAP"), /* LMS_TRAP */ \
163 NTXT("TFAULT"), /* LMS_TFAULT */ \
164 NTXT("DFAULT"), /* LMS_DFAULT */ \
165 NTXT("KFAULT"), /* LMS_KFAULT */ \
166 NTXT("USER_LOCK"), /* LMS_USER_LOCK */ \
167 NTXT("SLEEP"), /* LMS_SLEEP */ \
168 NTXT("WAIT_CPU"), /* LMS_WAIT_CPU */ \
169 NTXT("STOPPED"), /* LMS_STOPPED */ \
170 NTXT("LINUX_CPU"), /* LMS_LINUX_CPU */ \
171 NTXT("KERNEL_CPU") /* LMS_KERNEL_CPU */ \
173 #define LMS_STATE_USTRINGS \
175 GTXT("User CPU"), /* LMS_USER */ \
176 GTXT("System CPU"), /* LMS_SYSTEM */ \
177 GTXT("Trap CPU"), /* LMS_TRAP */ \
178 GTXT("Text Page Fault"), /* LMS_TFAULT */ \
179 GTXT("Data Page Fault"), /* LMS_DFAULT */ \
180 GTXT("Kernel Page Fault"), /* LMS_KFAULT */ \
181 GTXT("User Lock"), /* LMS_USER_LOCK */ \
182 GTXT("Sleep"), /* LMS_SLEEP */ \
183 GTXT("Wait CPU"), /* LMS_WAIT_CPU */ \
184 GTXT("Stopped"), /* LMS_STOPPED */ \
185 GTXT("User+System CPU"), /* LMS_LINUX_CPU */ \
186 GTXT("Kernel CPU") /* LMS_KERNEL_CPU */ \
189 typedef enum
191 MALLOC_TRACE = 0,
192 FREE_TRACE,
193 REALLOC_TRACE,
194 MMAP_TRACE,
195 MUNMAP_TRACE,
196 HEAPTYPE_LAST
197 } Heap_type;
199 #define HEAPTYPE_STATE_STRINGS \
201 NTXT("MALLOC"), \
202 NTXT("FREE"), \
203 NTXT("REALLOC"), \
204 NTXT("MMAP"), \
205 NTXT("MUNMAP") \
207 #define HEAPTYPE_STATE_USTRINGS \
209 GTXT("malloc"), \
210 GTXT("free"), \
211 GTXT("realloc"), \
212 GTXT("mmap"), \
213 GTXT("munmap") \
216 typedef enum
218 ZFS_TYPE = 0,
219 NFS_TYPE,
220 UFS_TYPE,
221 UDFS_TYPE,
222 LOFS_TYPE,
223 VXFS_TYPE,
224 TMPFS_TYPE,
225 PCFS_TYPE,
226 HSFS_TYPE,
227 PROCFS_TYPE,
228 FIFOFS_TYPE,
229 SWAPFS_TYPE,
230 CACHEFS_TYPE,
231 AUTOFS_TYPE,
232 SPECFS_TYPE,
233 SOCKFS_TYPE,
234 FDFS_TYPE,
235 MNTFS_TYPE,
236 NAMEFS_TYPE,
237 OBJFS_TYPE,
238 SHAREFS_TYPE,
239 EXT2FS_TYPE,
240 EXT3FS_TYPE,
241 EXT4FS_TYPE,
242 UNKNOWNFS_TYPE,
243 FSTYPE_LAST
244 } FileSystem_type;
246 typedef enum
248 READ_TRACE = 0,
249 WRITE_TRACE,
250 OPEN_TRACE,
251 CLOSE_TRACE,
252 OTHERIO_TRACE,
253 READ_TRACE_ERROR,
254 WRITE_TRACE_ERROR,
255 OPEN_TRACE_ERROR,
256 CLOSE_TRACE_ERROR,
257 OTHERIO_TRACE_ERROR,
258 IOTRACETYPE_LAST
259 } IOTrace_type;
261 #define IOTRACETYPE_STATE_STRINGS \
263 NTXT("READ"), \
264 NTXT("WRITE"), \
265 NTXT("OPEN"), \
266 NTXT("CLOSE"), \
267 NTXT("OTHERIO"), \
268 NTXT("READERROR"), \
269 NTXT("WRITEERROR"), \
270 NTXT("OPENERROR"), \
271 NTXT("CLOSEERROR"), \
272 NTXT("OTHERIOERROR") \
274 #define IOTRACETYPE_STATE_USTRINGS \
276 GTXT("Read"), \
277 GTXT("Write"), \
278 GTXT("Open"), \
279 GTXT("Close"), \
280 GTXT("Other I/O"), \
281 GTXT("Read error"), \
282 GTXT("Write error"), \
283 GTXT("Open error"), \
284 GTXT("Close error"), \
285 GTXT("Other I/O error") \
288 // the type of racing memory access with redundance flag
289 typedef enum
291 WRITE_RACE = 0,
292 WRITE_RACE_RED,
293 READ_RACE,
294 READ_RACE_RED,
295 RACETYPE_LAST
296 } Race_type;
298 typedef struct Frame_packet
300 unsigned int tsize : 16; /* packet size */
301 unsigned int type : 16;
302 uint32_t hsize; /* header size */
303 uint64_t uid; /* unique id (experiment wide) */
304 } Frame_packet;
306 typedef struct Uid_packet
308 unsigned int tsize : 16; /* packet size */
309 unsigned int type : 16;
310 uint32_t flags;
311 uint64_t uid; /* unique id (experiment wide) */
312 } Uid_packet;
315 * Components of the variable part of Frame_packet
317 typedef struct Common_info
319 unsigned int hsize; /* size of this info */
320 unsigned int kind;
321 uint64_t uid; /* unique id of this info if any */
322 } Common_info;
324 typedef struct Stack_info
325 { /* Native call stack */
326 unsigned int hsize;
327 unsigned int kind;
328 uint64_t uid;
329 } Stack_info;
331 typedef struct Java_info
332 { /* Java call stack */
333 unsigned int hsize;
334 unsigned int kind;
335 uint64_t uid;
336 } Java_info;
338 typedef struct OMP_info
339 { /* OMP thread state */
340 unsigned int hsize;
341 unsigned int kind;
342 uint32_t omp_state;
343 uint32_t pad;
344 } OMP_info;
346 typedef struct OMP2_info
347 { /* OpenMP user call stack */
348 unsigned int hsize;
349 unsigned int kind;
350 uint32_t omp_state;
351 uint32_t pad;
352 uint64_t uid;
353 } OMP2_info;
355 /* OMP thread states as recorded in the experiment */
356 /* Definition of values stored in the experiment PROP_OMPSTATE field */
358 /* Can be used with OMP_THR_STATE_STRINGS (below) */
359 typedef enum
361 OMP_NO_STATE = 0, /* Not initialized */
362 OMP_OVHD_STATE, /* Overhead */
363 OMP_WORK_STATE, /* Useful work, excluding reduction, master, single, critical */
364 OMP_IBAR_STATE, /* In an implicit barrier */
365 OMP_EBAR_STATE, /* In an explicit barrier */
366 OMP_IDLE_STATE, /* Slave waiting */
367 OMP_SERL_STATE, /* User OMPead not in any OMP parallel region */
368 OMP_RDUC_STATE, /* Reduction */
369 OMP_LKWT_STATE, /* Waiting for lock */
370 OMP_CTWT_STATE, /* Waiting to enter critical section */
371 OMP_ODWT_STATE, /* Waiting to execute an ordered section */
372 OMP_ATWT_STATE, /* Wait for atomic */
373 OMP_TSKWT_STATE, /* Task wait */
374 OMP_LAST_STATE
375 } OMP_THR_STATE;
376 #define OMP_THR_STATE_STRINGS \
378 NTXT("NO"), /* OMP_NO_STATE */ \
379 NTXT("OVHD"), /* OMP_OVHD_STATE */ \
380 NTXT("WORK"), /* OMP_WORK_STATE */ \
381 NTXT("IBAR"), /* OMP_IBAR_STATE */ \
382 NTXT("EBAR"), /* OMP_EBAR_STATE */ \
383 NTXT("IDLE"), /* OMP_IDLE_STATE */ \
384 NTXT("SERL"), /* OMP_SERL_STATE */ \
385 NTXT("RDUC"), /* OMP_RDUC_STATE */ \
386 NTXT("LKWT"), /* OMP_LKWT_STATE */ \
387 NTXT("CTWT"), /* OMP_CTWT_STATE */ \
388 NTXT("ODWT"), /* OMP_ODWT_STATE */ \
389 NTXT("ATWT"), /* OMP_ATWT_STATE */ \
390 NTXT("TSKWT") /* OMP_TSKWT_STATE */ \
392 #define OMP_THR_STATE_USTRINGS \
394 GTXT("None"), /* OMP_NO_STATE */ \
395 GTXT("Overhead"), /* OMP_OVHD_STATE */ \
396 GTXT("Work"), /* OMP_WORK_STATE */ \
397 GTXT("Implicit Barrier"), /* OMP_IBAR_STATE */ \
398 GTXT("Explicit Barrier"), /* OMP_EBAR_STATE */ \
399 GTXT("Idle"), /* OMP_IDLE_STATE */ \
400 GTXT("Serial"), /* OMP_SERL_STATE */ \
401 GTXT("Reduction"), /* OMP_RDUC_STATE */ \
402 GTXT("Lock Wait"), /* OMP_LKWT_STATE */ \
403 GTXT("Critical Section Wait"), /* OMP_CTWT_STATE */ \
404 GTXT("Ordered Section Wait"), /* OMP_ODWT_STATE */ \
405 GTXT("Atomic Wait"), /* OMP_ATWT_STATE */ \
406 GTXT("Task Wait") /* OMP_TSKWT_STATE */ \
409 /* sub-packet for MPI state information */
410 typedef struct MPI_info
411 { /* MPI thread state */
412 unsigned int hsize;
413 unsigned int kind;
414 uint32_t mpi_state;
415 uint32_t pad;
416 } MPI_info;
418 /* MPI thread states, as recorded in the experiment */
419 typedef enum
421 MPI_NO_STATE = 0, /* Not initialized */
422 MPI_USER, /* Executing user code, not in MPI */
423 MPI_PROG, /* Executing in the MPI library (progressing) */
424 MPI_WAIT /* Waiting in the MPI library */
425 } MPI_THR_STATE;
428 * Dyntext file structure
430 typedef enum
432 DT_HEADER = 1,
433 DT_CODE,
434 DT_LTABLE,
435 DT_SRCFILE
436 } DT_type;
438 typedef struct DT_common
440 DT_type type;
441 unsigned int size;
442 } DT_common;
444 typedef struct DT_header
446 DT_type type;
447 unsigned int size;
448 hrtime_t time; /* time of loading */
449 uint64_t vaddr;
450 } DT_header;
452 typedef struct DT_code
454 DT_type type;
455 unsigned int size;
456 } DT_code;
458 typedef struct DT_ltable
460 DT_type type;
461 unsigned int size;
462 } DT_ltable;
464 typedef struct DT_lineno
466 unsigned int offset;
467 unsigned int lineno;
468 } DT_lineno;
470 typedef struct DT_srcfile
472 DT_type type;
473 unsigned int size;
474 } DT_srcfile;
477 * Archive file structure
479 #define ARCH_VERSION 0x100 /* version 1.0 */
481 /* For compatibility with older archives append new types only */
482 typedef enum
484 ARCH_SEGMENT_TYPE = 1,
485 ARCH_MSG_TYPE,
486 ARCH_PLT_TYPE,
487 ARCH_MODULE_TYPE,
488 ARCH_FUNCTION_TYPE,
489 ARCH_LDINSTR_TYPE,
490 ARCH_STINSTR_TYPE,
491 ARCH_PREFETCH_TYPE,
492 ARCH_BRTARGET_TYPE,
493 ARCH_JCLASS_TYPE,
494 ARCH_JMETHOD_TYPE,
495 ARCH_JUNLOAD_TYPE,
496 ARCH_INF_TYPE,
497 ARCH_JCLASS_LOCATION_TYPE
498 } ARCH_type;
500 #define ARCH_TYPE(x,y) ((ARCH_##x##_TYPE<<8)|y)
502 typedef struct
504 unsigned int type : 16;
505 unsigned int size : 16;
506 } ARCH_common;
508 /* The maximum value that fits into ARCH_common.size */
509 #define ARCH_MAX_SIZE 0xffff
511 #define ARCH_SEGMENT ARCH_TYPE(SEGMENT, 0)
513 typedef struct
515 ARCH_common common;
516 int version;
517 uint32_t inode;
518 uint32_t textsz; /* text segment size */
519 uint32_t platform; /* sparc, intel, etc. */
520 } ARCH_segment;
522 #define ARCH_MSG ARCH_TYPE(MSG, 0)
524 typedef struct
526 ARCH_common common;
527 uint32_t errcode;
528 } ARCH_message;
530 #define ARCH_INF ARCH_TYPE(INF, 0)
532 typedef struct
534 ARCH_common common;
535 } ARCH_info;
537 #define ARCH_MODULE ARCH_TYPE(MODULE, 0)
539 typedef struct
541 ARCH_common common;
542 unsigned int lang_code;
543 unsigned int fragmented;
544 } ARCH_module;
546 #define ARCH_FUNCTION ARCH_TYPE(FUNCTION, 0)
548 typedef struct
550 ARCH_common common;
551 uint32_t offset;
552 uint32_t size;
553 uint32_t save_addr;
554 } ARCH_function;
556 #define ARCH_LDINSTR ARCH_TYPE(LDINSTR, 0)
557 #define ARCH_STINSTR ARCH_TYPE(STINSTR, 0)
558 #define ARCH_PREFETCH ARCH_TYPE(PREFETCH, 0)
559 #define ARCH_BRTARGET ARCH_TYPE(BRTARGET, 0)
561 typedef struct
563 ARCH_common common;
564 } ARCH_aninfo;
566 #define ARCH_JCLASS_LOCATION ARCH_TYPE(JCLASS_LOCATION, 3)
568 typedef struct
570 CM_Packet comm;
571 uint32_t pad;
572 uint64_t class_id;
573 } ARCH_jclass_location;
575 #define ARCH_JCLASS ARCH_TYPE(JCLASS, 3)
577 typedef struct
579 CM_Packet comm;
580 uint32_t pad;
581 uint64_t class_id;
582 hrtime_t tstamp;
583 } ARCH_jclass;
585 #define ARCH_JMETHOD ARCH_TYPE(JMETHOD, 3)
587 typedef struct
589 CM_Packet comm;
590 uint32_t pad;
591 uint64_t class_id;
592 uint64_t method_id;
593 } ARCH_jmethod;
595 #endif /* _DATA_PCKTS_H */