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. */
24 #include "dbe_structs.h"
28 // METRIC_*_PRECISION determine the least threshold value
29 // for time measured metrics. Any event that counts for less
30 // than 1sec/METRIC_PRECISION is discarded.
31 #define METRIC_SIG_PRECISION MICROSEC
32 #define METRIC_HR_PRECISION MICROSEC
37 template <class ITEM> class Vector;
42 // sync enum changes with AnMetric.java
44 { // Subtype==STATIC metrics:
45 ONAME = 1, //ONAME must be 1
48 // Clock Profiling, Derived Metrics:
51 // Clock profiling, Solaris Microstates (LMS_* defines)
62 // Kernel clock profiling
111 // Races and Deadlocks
118 // sync enum changes with AnMetric.java
121 STATIC = 1, // Type==SIZES, ADDRESS, ONAME
125 DATASPACE = 16 // Can be accessed in dataspace views
129 BaseMetric (Hwcentry *ctr, const char* _aux, const char* _cmdname,
130 const char* _username, int v_styles); // depended bm
131 BaseMetric (Hwcentry *ctr, const char* _aux, const char* _username,
132 int v_styles, BaseMetric* _depended_bm = NULL); // master bm
133 BaseMetric (const char *_cmd, const char *_username, Definition *def); // derived metrics
134 BaseMetric (const BaseMetric& m);
135 virtual ~BaseMetric ();
137 int get_id () { return id; }
138 Type get_type () { return type; }
139 Hwcentry *get_hw_ctr () { return hw_ctr; }
140 char *get_aux () { return aux; }
141 char *get_username () { return username; }
142 char *get_cmd () { return cmd; }
143 int get_flavors () { return flavors; }
144 int get_clock_unit () { return clock_unit; }
145 long long get_precision () { return precision; }
146 ValueTag get_vtype () { return valtype; }
147 int get_value_styles () { return value_styles; }
148 bool is_zeroThreshold () { return zeroThreshold; }
149 ProfData_type get_packet_type () { return packet_type; }
150 Expression *get_cond () { return cond; }
151 Expression *get_val () { return val; }
152 Expression *get_expr () { return expr; }
153 char *get_expr_spec () { return expr_spec; }
154 Definition *get_definition () { return definition; };
155 BaseMetric *get_dependent_bm () { return dependent_bm; };
160 return val_spec != NULL || type == DERIVED || type == SIZES || type == ADDRESS;
164 void set_default_visbits (SubType subtype, int _visbits);
165 void set_id (int _id) { id = _id; } //TBR, if possible
166 // For comparison, set which packets to eval:
167 void set_expr_spec (char *_expr_spec);
168 void set_cond_spec (char *_cond_spec);
169 int get_default_visbits (SubType subtype);
171 Histable *get_comparable_obj (Histable *obj);
172 bool is_internal (); // Invisible for users
174 char *legend; // for comparison: add'l column text
177 BaseMetric *dependent_bm; // for HWCs only: a link to the timecvt metric
178 Expression *cond; // determines which packets to evaluate
179 char *cond_spec; // used to generate "cond"
180 Expression *val; // determines the numeric value for packet
181 char *val_spec; // used to generate "val"
182 Expression *expr; // for comparison: an additional expression to determine
183 // which packets to eval. Should be NULL otherwise.
184 char *expr_spec; // used to generate "expr"
185 int id; // unique id (assigned to last_id @ "new")
186 Type type; // e.g. HWCNTR
187 char *aux; // for HWCs only: Hwcentry ctr->name
188 char *cmd; // the .rc metric command, e.g. "total"
189 char *username; // e.g. "GTXT("Total Wait Time")"
190 int flavors; // bitmask of SubType capabilities
191 int value_styles; // bitmask of ValueType capabilities
192 static const int NSUBTYPES = 2; // STATIC/EXCLUSIVE, INCLUSIVE
193 int default_visbits[NSUBTYPES]; // ValueType, e.g. VAL_VALUE|VAL_TIMEVAL
194 ValueTag valtype; // e.g. VT_LLONG
195 long long precision; // e.g. METRIC_SIG_PRECISION, 1, etc.
196 Hwcentry *hw_ctr; // HWC definition
197 ProfData_type packet_type; // e.g. DATA_HWC, or -1 for N/A
198 bool zeroThreshold; // deadlock stuff
199 Presentation_clock_unit clock_unit;
201 static int last_id; // incremented by 1 w/ every "new". Not MT-safe
202 Definition *definition;
204 void hwc_init (Hwcentry *ctr, const char* _aux, const char* _cmdname, const char* _username, int v_styles);
206 char *get_basetype_name ();
208 void specify_metric (char *_cond_spec, char *_val_spec);
209 void set_val_spec (char *_val_spec);
210 void specify_mstate_metric (int st);
211 void specify_ompstate_metric (int st);
212 void specify_prof_metric (char *_cond_spec);
226 Definition (opType _op);
228 static Definition *add_definition (char *_def);
229 Vector<BaseMetric *> *get_dependencies ();
231 double eval (long *indexes, TValue *values);
241 Vector<BaseMetric *> *dependencies;
245 #endif /* _BASEMETRIC_H */