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 _DBE_STRUCTS_H
22 #define _DBE_STRUCTS_H
23 
24 #include "dbe_types.h"
25 #include "enums.h"
26 
27 typedef enum
28 {
29   Sp_lang_unknown   = 0,
30   Sp_lang_asm       = 1,
31   Sp_lang_c         = 2,
32   Sp_lang_ansic     = 3,
33   Sp_lang_cplusplus = 4,
34   Sp_lang_fortran   = 5,
35   Sp_lang_pascal    = 6,
36   Sp_lang_fortran90 = 7,
37   Sp_lang_java      = 8,
38   Sp_lang_c99       = 9,
39   Sp_lang_gcc       = 16,
40   Sp_lang_KAI_KPTS  = 32,
41   Sp_lang_KAI_KCC   = 33,
42   Sp_lang_KAI_Kcc   = 34
43 } Sp_lang_code;
44 
45 struct Value
46 {
47   union
48   {
49     short s;
50     int i;
51     float f;
52     double d;
53     timestruc_t t;
54     char *l;                // Label
55     unsigned long long ll;  // address
56   };
57 };
58 
59 // sync enum changes with both AnMetric.java and AnVariable.java
60 enum ValueTag
61 {
62   VT_SHORT = 1,
63   VT_INT,
64   VT_LLONG,
65   VT_FLOAT,
66   VT_DOUBLE,
67   VT_HRTIME,
68   VT_LABEL,
69   VT_ADDRESS,
70   VT_OFFSET,
71   VT_ULLONG
72 };
73 
74 // Tagged numeric value
75 struct TValue
76 {
77   ValueTag tag;
78   bool sign;    // The print result will always begin with a sign (+ or -).
79   union
80   {
81     short s;
82     int i;
83     float f;
84     double d;
85     char *l;
86     void *p;
87     long long ll;
88     unsigned long long ull;
89   };
90   double to_double ();
91   int to_int ();
92   char *to_str (char *str, size_t strsz);
93   size_t get_len ();
94   void make_delta (TValue *v1, TValue *v2);
95   void make_ratio (TValue *v1, TValue *v2);
96   int compare (TValue *v);
97 };
98 
99 // XXX MAX_HWCOUNT may need to be managed dynamically, not #defined
100 #define MAX_HWCOUNT 64
101 
102 // Experiment collection parameters
103 struct Collection_params
104 {
105   int profile_mode;     // if clock-profiling is on
106   long long ptimer_usec; // Clock profile timer interval (microseconds)
107   int lms_magic_id;     // identifies which LMS_* states are live
108   int sync_mode;        // if synctrace is on
109   int sync_threshold;   // value of synctrace threshold, in microseconds
110   int sync_scope;       // value of synctrace scope: Java and/or native
111 
112   int heap_mode;        // if heaptrace is on
113   int io_mode;          // if iotrace is on
114   int race_mode;        // if race-detection is on
115   int race_stack;       // setting for stack data collection
116   int deadlock_mode;    // if deadlock-detection is on
117   int omp_mode;         // if omptrace is on
118 
119   int hw_mode;          // if hw-counter profiling is on
120   int xhw_mode;    // if extended (true-PC) HW counter profiling for any counter
121 
122   char *hw_aux_name[MAX_HWCOUNT];
123   char *hw_username[MAX_HWCOUNT];
124   int hw_interval[MAX_HWCOUNT];     // nominal interval for count
125   int hw_tpc[MAX_HWCOUNT];          // non-zero, if aggressive TPC/VA requested
126   int hw_metric_tag[MAX_HWCOUNT];   // tag as used for finding metrics
127   int hw_cpu_ver[MAX_HWCOUNT];      // Chip version number for this metric
128 
129   int sample_periodic;      // if periodic sampling is on
130   int sample_timer;         // Sample timer (sec)
131   int limit;                // experiment size limit
132   const char *pause_sig;    // Pause/resume signal string
133   const char *sample_sig;   // Sampling signal string
134   const char *start_delay;  // Data collect start delay string
135   const char *terminate;    // Data collection termination time string
136   char *linetrace;
137 };
138 
139 const hrtime_t ZERO_TIME = (hrtime_t) 0;
140 const hrtime_t MAX_TIME = (hrtime_t) 0x7fffffffffffffffLL;
141 
142 #define PCInvlFlag              ((int) 0x8LL)
143 #define PCLineFlag              ((int) 0x4LL)
144 #define PCTrgtFlag              ((int) 0x2LL)
145 #define MAKE_ADDRESS(idx, off)  (((unsigned long long)(idx)<<32) | off)
146 #define ADDRESS_SEG(x)          ((unsigned int)(((x)>>32) & 0xffffffff))
147 #define ADDRESS_OFF(x)          ((unsigned int)((x) & 0xffffffff))
148 
149 //
150 //	Analyzer info
151 #define AnalyzerInfoVersion 2
152 
153 typedef struct
154 {
155   uint64_t text_labelref;
156   int32_t entries;
157   uint32_t version;
158 } AnalyzerInfoHdr;      // => header from .__analyzer_info
159 
160 typedef struct
161 {
162   uint32_t offset;      // offset relative to text_labelref
163   uint32_t id;          // profiled instruction identifier
164   uint32_t signature;   // signature of profiled instruction
165   uint32_t datatype_id; // referenced datatype identifier
166 } memop_info_t;         // => used for table_type=0,1,2
167 
168 typedef struct
169 {
170   uint32_t offset;      // offset relative to text_labelref
171 } target_info_t;        // => used for table_type=3
172 
173 typedef struct
174 {
175   uint32_t type;
176   uint32_t offset;
177   union
178   {
179     memop_info_t *memop;
180     target_info_t *target;
181   };
182 } inst_info_t;
183 
184 class DataObject;
185 
186 typedef struct
187 {
188   uint32_t datatype_id; // datatype identifier (local)
189   uint32_t memop_refs;  // count of referencing memops
190   uint32_t event_data;  // count of event data
191   DataObject *dobj;     // corresponding dataobject (unique)
192 } datatype_t;
193 
194 typedef struct
195 {
196   uint32_t offset;      // entry offset in compilation unit
197   uint32_t extent;      // sibling offset
198   void *parent;         // container symbol
199   void *object;         // resolved object
200 } symbol_t;
201 
202 typedef struct
203 {
204   char *old_prefix;
205   char *new_prefix;
206 } pathmap_t;
207 
208 typedef struct
209 {
210   char *libname;
211   enum LibExpand expand;
212 } lo_expand_t;
213 
214 typedef struct
215 {
216   int index1;
217   int index2;
218 } int_pair_t;
219 #endif /* _DBE_STRUCTS_H */
220