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 _EXP_LAYOUT_H 22 #define _EXP_LAYOUT_H 23 24 #include <sys/time.h> 25 #include <sys/types.h> 26 27 #include "dbe_types.h" 28 #include "gp-experiment.h" 29 #include "data_pckts.h" 30 #include "ABS.h" 31 #include "Data_window.h" 32 #include "Histable.h" 33 #include "vec.h" 34 35 class PrUsage 36 { 37 public: 38 PrUsage (); 39 PrUsage *bind32 (void *p, bool need_swap_endian); 40 PrUsage *bind64 (void *p, bool need_swap_endian); 41 static uint64_t bind32Size (); 42 static uint64_t bind64Size (); 43 Vector<long long> * getMstateValues (); 44 45 hrtime_t pr_tstamp; 46 hrtime_t pr_create; 47 hrtime_t pr_term; 48 hrtime_t pr_rtime; 49 50 // the following correspond to PROP_MSTATE LMS_* offsets; see newMstateVec() 51 hrtime_t pr_utime; 52 hrtime_t pr_stime; 53 hrtime_t pr_ttime; 54 hrtime_t pr_tftime; 55 hrtime_t pr_dftime; 56 hrtime_t pr_kftime; 57 hrtime_t pr_ltime; 58 hrtime_t pr_slptime; 59 hrtime_t pr_wtime; 60 hrtime_t pr_stoptime; 61 62 uint64_t pr_minf; 63 uint64_t pr_majf; 64 uint64_t pr_nswap; 65 uint64_t pr_inblk; 66 uint64_t pr_oublk; 67 uint64_t pr_msnd; 68 uint64_t pr_mrcv; 69 uint64_t pr_sigs; 70 uint64_t pr_vctx; 71 uint64_t pr_ictx; 72 uint64_t pr_sysc; 73 uint64_t pr_ioch; 74 }; 75 76 class DataView; 77 extern void *getStack (VMode, DataView*, long); 78 extern int stackSize (VMode, DataView*, long); 79 extern Histable *getStackPC (int, VMode, DataView*, long); 80 extern Vector<Histable*> *getStackPCs (VMode, DataView*, long); 81 82 class CommonPacket // use only for RacePacket, please 83 { 84 public: 85 CommonPacket (); 86 void *getStack (VMode); 87 Histable *getStackPC (int, VMode); 88 Vector<Histable*>*getStackPCs (VMode); 89 static int cmp (const void *a, const void *b); 90 91 enum Tag_type { LWP, THR, CPU }; 92 static const int NTAGS = 3; 93 uint32_t tags[NTAGS]; // lwp_id, thr_id, cpu_id 94 hrtime_t tstamp; 95 struct JThread *jthread_TBR; // pointer to JThread or NULL 96 uint64_t frinfo; // frame info 97 Vaddr leafpc; // raw leaf PC if availabe 98 void *nat_stack; // native stack 99 void *user_stack; // user stack (Java, OMP, etc.) 100 static void *jvm_overhead; 101 }; 102 103 class FramePacket 104 { 105 public: 106 int 107 stackSize (bool java = false) 108 { 109 return java ? jstack->size () / 2 : stack->size (); 110 } 111 112 Vaddr getFromStack(int n)113 getFromStack (int n) 114 { 115 return stack->fetch (n); 116 } 117 118 Vaddr getMthdFromStack(int n)119 getMthdFromStack (int n) 120 { 121 return jstack->fetch (2 * n + 1); 122 } 123 124 int getBciFromStack(int n)125 getBciFromStack (int n) 126 { 127 return (int) jstack->fetch (2 * n); 128 } 129 130 bool isLeafMark(int n)131 isLeafMark (int n) 132 { 133 return stack->fetch (n) == (Vaddr) SP_LEAF_CHECK_MARKER; 134 } 135 136 bool 137 isTruncatedStack (bool java = false) 138 { 139 return java ? jtruncated : truncated == (Vaddr) SP_TRUNC_STACK_MARKER; 140 } 141 142 bool isFailedUnwindStack()143 isFailedUnwindStack () 144 { 145 return truncated == (Vaddr) SP_FAILED_UNWIND_MARKER; 146 } 147 uint32_t omp_state; // OpenMP thread state 148 uint32_t mpi_state; // MPI state 149 uint64_t omp_cprid; // OpenMP parallel region id (omptrace) 150 Vector<Vaddr> *stack; 151 Vaddr truncated; 152 Vector<Vaddr> *jstack; 153 bool jtruncated; 154 Vector<Vaddr> *ompstack; 155 Vaddr omptruncated; 156 }; 157 158 #endif /* _EXP_LAYOUT_H */ 159