1*cb63e24eSchristos /* Copyright (C) 2021-2024 Free Software Foundation, Inc. 24f645668Schristos Contributed by Oracle. 34f645668Schristos 44f645668Schristos This file is part of GNU Binutils. 54f645668Schristos 64f645668Schristos This program is free software; you can redistribute it and/or modify 74f645668Schristos it under the terms of the GNU General Public License as published by 84f645668Schristos the Free Software Foundation; either version 3, or (at your option) 94f645668Schristos any later version. 104f645668Schristos 114f645668Schristos This program is distributed in the hope that it will be useful, 124f645668Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 134f645668Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 144f645668Schristos GNU General Public License for more details. 154f645668Schristos 164f645668Schristos You should have received a copy of the GNU General Public License 174f645668Schristos along with this program; if not, write to the Free Software 184f645668Schristos Foundation, 51 Franklin Street - Fifth Floor, Boston, 194f645668Schristos MA 02110-1301, USA. */ 204f645668Schristos 214f645668Schristos #ifndef _METRICLIST_H 224f645668Schristos #define _METRICLIST_H 234f645668Schristos 244f645668Schristos #include "dbe_structs.h" 254f645668Schristos #include "vec.h" 264f645668Schristos #include "enums.h" 274f645668Schristos #include "Metric.h" 284f645668Schristos #include "DerivedMetrics.h" 294f645668Schristos #include <stdio.h> 304f645668Schristos 314f645668Schristos // 324f645668Schristos // The MetricList class is used to manage a list of metrics 334f645668Schristos 344f645668Schristos class MetricList 354f645668Schristos { 364f645668Schristos public: 374f645668Schristos 384f645668Schristos MetricList (Vector<BaseMetric*> *base_metrics, MetricType type); 394f645668Schristos MetricList (MetricList *old); 404f645668Schristos MetricList (MetricType _mtype); 414f645668Schristos ~MetricList (); 424f645668Schristos 434f645668Schristos // Methods concerning a list of metrics 444f645668Schristos // set metrics -- text, caller-callee, data, and index flavors 454f645668Schristos // flavor depends on mtype in the list 464f645668Schristos // returns NULL if OK, or an error string if not 474f645668Schristos // always returns NULL if fromRcFile is TRUE 484f645668Schristos char *set_metrics (const char *metric_cmd, bool fromRcFile, DerivedMetrics *derived_metrics); 494f645668Schristos 504f645668Schristos // update the caller-callee or dataspace metrics to match normal metrics 514f645668Schristos // It is assumed that this->mtype is MET_CALL, MET_DATA, or MET_INDX and 524f645668Schristos // that metrics_list->mtype is MET_NORMAL 534f645668Schristos void set_metrics (MetricList *metrics_list); 544f645668Schristos 554f645668Schristos // produce a string for the metrics from a vector 564f645668Schristos char *get_metrics (); 574f645668Schristos 584f645668Schristos // set the sort metric for a list from a metric string 594f645668Schristos // returns NULL if OK, or an error string if not 604f645668Schristos char *set_sort (const char *metric_cmd, bool fromRcFile); 614f645668Schristos 624f645668Schristos // set the sort metric for a list from the first visible index 634f645668Schristos void set_fallback_sort (); 644f645668Schristos 654f645668Schristos // set the sort metric for a list from a visible index 664f645668Schristos void set_sort (int visindex, bool reverse); 674f645668Schristos 684f645668Schristos char *get_sort_name (); // get the name of the sort metric from a vector 694f645668Schristos 704f645668Schristos bool get_sort_rev()714f645668Schristos get_sort_rev () // get the boolean reverse for the sort metric 724f645668Schristos { 734f645668Schristos return sort_reverse; 744f645668Schristos } 754f645668Schristos 764f645668Schristos void set_sort_rev(bool v)774f645668Schristos set_sort_rev (bool v) 784f645668Schristos { 794f645668Schristos sort_reverse = v; 804f645668Schristos } 814f645668Schristos 824f645668Schristos int get_sort_ref_index()834f645668Schristos get_sort_ref_index () 844f645668Schristos { 854f645668Schristos return sort_ref_index; 864f645668Schristos } 874f645668Schristos 884f645668Schristos void set_sort_ref_index(int ind)894f645668Schristos set_sort_ref_index (int ind) 904f645668Schristos { 914f645668Schristos sort_ref_index = ind; 924f645668Schristos } 934f645668Schristos 944f645668Schristos bool set_sort_metric (char *metric_cmd, BaseMetric::SubType mst, bool reverse); 954f645668Schristos Metric *find_metric (char *cmd, BaseMetric::SubType st); 964f645668Schristos Metric *find_metric_by_name (char *cmd); 974f645668Schristos int get_listorder (char *cmd, BaseMetric::SubType st, const char *expr = NULL); 984f645668Schristos int get_listorder (Metric *mtr); 994f645668Schristos Metric *get_sort_metric (); // get the sort metric from a vector 1004f645668Schristos char *get_sort_cmd (); // get the command name of the sort metric 1014f645668Schristos 1024f645668Schristos MetricType get_type()1034f645668Schristos get_type () 1044f645668Schristos { 1054f645668Schristos return mtype; 1064f645668Schristos } 1074f645668Schristos 1084f645668Schristos Vector<Metric*> * get_items()1094f645668Schristos get_items () // get the vector of metrics from the list 1104f645668Schristos { 1114f645668Schristos return items; 1124f645668Schristos } 1134f645668Schristos 1144f645668Schristos Metric * get(long i)1154f645668Schristos get (long i) 1164f645668Schristos { 1174f645668Schristos return items->get (i); 1184f645668Schristos } 1194f645668Schristos 1204f645668Schristos void put(long i,Metric * m)1214f645668Schristos put (long i, Metric *m) 1224f645668Schristos { 1234f645668Schristos items->put (i, m); 1244f645668Schristos } 1254f645668Schristos 1264f645668Schristos void append(Metric * m)1274f645668Schristos append (Metric *m) 1284f645668Schristos { 1294f645668Schristos items->append (m); 1304f645668Schristos } 1314f645668Schristos 1324f645668Schristos long size()1334f645668Schristos size () 1344f645668Schristos { 1354f645668Schristos return items ? items->size () : 0; 1364f645668Schristos } 1374f645668Schristos 1384f645668Schristos Metric *append (BaseMetric *bm, BaseMetric::SubType st, int visbits); 1394f645668Schristos 1404f645668Schristos // produce a list of all metrics from a vector 1414f645668Schristos void print_metric_list (FILE *dis_file, char *leader, int debug); 1424f645668Schristos 1434f645668Schristos // Add any and all matching metrics to the growing list 1444f645668Schristos // return value is zero for OK, 1 for no match 1454f645668Schristos int add_matching_dmetrics (Vector<BaseMetric*> *base_items, char *cmd, 1464f645668Schristos BaseMetric::SubType *subtypes, int nsubtypes, 1474f645668Schristos int dmetrics_vis, // literal translation of dmetrics +. etc. 1484f645668Schristos bool fromRcFile); 1494f645668Schristos 1504f645668Schristos private: 1514f645668Schristos // parse a metric specification substring, based on type of list 1524f645668Schristos char *parse_metric_spec (char *cmd, BaseMetric::SubType *subtypes, 1534f645668Schristos int *nsubtypes, int *dmetrics_visb, bool *isOK); 1544f645668Schristos 1554f645668Schristos Vector<Metric*> *items; 1564f645668Schristos MetricType mtype; 1574f645668Schristos 1584f645668Schristos // the sort reference index 1594f645668Schristos int sort_ref_index; 1604f645668Schristos bool sort_reverse; 1614f645668Schristos }; 1624f645668Schristos 1634f645668Schristos #endif /* _METRICLIST_H */ 164