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 _BASEMETRICTREENODE_H 22 #define _BASEMETRICTREENODE_H 23 24 #include "BaseMetric.h" 25 26 // Unit values 27 #define UNIT_SECONDS "SECONDS" 28 #define UNIT_SECONDS_UNAME GTXT("secs.") 29 #define UNIT_BYTES "BYTES" 30 #define UNIT_BYTES_UNAME GTXT("bytes") 31 32 // Name values for intermediate parent nodes that aren't defined elsewhere 33 #define L1_DURATION "PROFDATA_TYPE_DURATION" 34 #define L1_DURATION_UNAME GTXT("Experiment Duration") 35 #define L1_GCDURATION "PROFDATA_TYPE_GCDURATION" 36 #define L1_GCDURATION_UNAME GTXT("Java Garbage Collection Duration") 37 #define L2_HWC_DSPACE "PROFDATA_TYPE_HWC_DSPACE" 38 #define L2_HWC_DSPACE_UNAME GTXT("Memoryspace Hardware Counters") 39 #define L2_HWC_GENERAL "PROFDATA_TYPE_HWC_GENERAL" 40 #define L2_HWC_GENERAL_UNAME GTXT("General Hardware Counters") 41 #define L1_MPI_STATES "PROFDATA_TYPE_MPI_STATES" 42 #define L1_MPI_STATES_UNAME GTXT("MPI States") 43 #define L1_OTHER "PROFDATA_TYPE_OTHER" 44 #define L1_OTHER_UNAME GTXT("Derived and Other Metrics") 45 #define L1_STATIC "PROFDATA_TYPE_STATIC" 46 #define L1_STATIC_UNAME GTXT("Static") 47 #define L_CP_TOTAL "L_CP_TOTAL" 48 #define L_CP_TOTAL_CPU "L_CP_TOTAL_CPU" 49 50 class BaseMetricTreeNode 51 { 52 public: 53 BaseMetricTreeNode (); // builds basic metric tree (not including HWCs) 54 virtual ~BaseMetricTreeNode (); 55 BaseMetricTreeNode *register_metric (BaseMetric *item); 56 BaseMetricTreeNode *find (const char *name); 57 void get_nearest_registered_descendents (Vector<BaseMetricTreeNode*> *new_vec); 58 void get_all_registered_descendents (Vector<BaseMetricTreeNode*> *new_vec); 59 char *get_description(); 60 char *dump(); 61 get_root()62 BaseMetricTreeNode *get_root () { return root; } get_parent()63 BaseMetricTreeNode *get_parent () { return parent; } get_children()64 Vector<BaseMetricTreeNode*> *get_children () { return children; } is_registered()65 bool is_registered () { return registered; } get_num_registered_descendents()66 int get_num_registered_descendents () { return num_registered_descendents; } is_composite_metric()67 bool is_composite_metric () { return isCompositeMetric; } get_BaseMetric()68 BaseMetric *get_BaseMetric () { return bm; } get_name()69 char *get_name () { return name; } get_user_name()70 char *get_user_name () { return uname; } get_unit()71 char *get_unit () { return unit; } get_unit_uname()72 char *get_unit_uname () { return unit_uname; } 73 74 private: 75 BaseMetricTreeNode (BaseMetric *item); 76 BaseMetricTreeNode (const char *name, const char *uname, 77 const char *_unit, const char *_unit_uname); 78 void init_vars (); 79 void build_basic_tree (); 80 BaseMetricTreeNode *add_child (BaseMetric *item); 81 BaseMetricTreeNode *add_child (const char *name, const char *uname, 82 const char *unit = NULL, const char *unit_uname = NULL); 83 BaseMetricTreeNode *add_child (BaseMetricTreeNode *new_node); 84 void register_node (BaseMetricTreeNode *); 85 86 BaseMetricTreeNode *root; // root of tree 87 BaseMetricTreeNode *parent; // my parent 88 bool aggregation; // value is based on children's values 89 char *name; // bm->get_cmd() for metrics, unique string otherwise 90 char *uname; // user-visible text 91 char *unit; // see UNIT_* defines 92 char *unit_uname; // see UNIT_*_UNAME defines 93 Vector<BaseMetricTreeNode*> *children; // my children 94 bool isCompositeMetric; // value is sum of children 95 BaseMetric *bm; // metric for this node, or null 96 bool registered; // metric has been officially registered 97 int num_registered_descendents; // does not include self 98 }; 99 100 #endif /* _BASEMETRICTREENODE_H */ 101