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 _MEMORYSPACE_H
22 #define	_MEMORYSPACE_H
23 
24 #include <stdio.h>
25 
26 #include "dbe_structs.h"
27 #include "vec.h"
28 #include "Exp_Layout.h"
29 #include "Histable.h"
30 #include "Hist_data.h"
31 #include "Metric.h"
32 #include "HashMap.h"
33 
34 class Experiment;
35 class Expression;
36 class DataView;
37 class DbeView;
38 class MemObj;
39 
40 class MemObjType_t
41 {
42 public:
43   MemObjType_t ();
44   ~MemObjType_t ();
45   int type;
46   char *name;
47   char *index_expr;
48   char *machmodel;
49   char mnemonic;
50   char *short_description;
51   char *long_description;
52 };
53 
54 class MemorySpace
55 {
56 public:
57 
58   MemorySpace (DbeView *_dbev, int subtype);
59   ~MemorySpace ();
60 
61   void reset (void);
62 
63   int
getMemObjType(void)64   getMemObjType (void)
65   {
66     return mstype;
67   }
68 
69   char *
getMemObjTypeName(void)70   getMemObjTypeName (void)
71   {
72     return msname;
73   }
74 
75   Expression *
getMemObjDef(void)76   getMemObjDef (void)
77   {
78     return msindex_exp;
79   }
80 
81   // static members, used to define or fetch the various MemorySpaces
82   static void get_filter_keywords (Vector <void*> *res);
83   static Vector<void*> *getMemObjects (void);
84   static void set_MemTabOrder (Vector<int> *);
85   static char *mobj_define (char *, char *, char *, char *, char *);
86   static char *mobj_delete (char *);
87   static MemObjType_t *findMemSpaceByName (const char *mname);
88   static MemObjType_t *findMemSpaceByIndex (int index);
89   static char pickMnemonic (char *name);
90   static Vector<char *> *getMachineModelMemObjs (char *);
91 
92 private:
93   HashMap<uint64_t, MemObj*> *objs;
94   int findMemObject (uint64_t indx);
95   MemObj *lookupMemObject (Experiment *exp, DataView*, long);
96   MemObj *createMemObject (uint64_t, char *moname);
97 
98   int mstype;               // type of this memory space
99   char *msname;             // name of this memory space
100   Expression *msindex_exp;  // index-expression for this memory space
101   char *msindex_exp_str;    // string for index-expression
102   Hist_data *hist_data_all; // the cached data for mode=Hist_Data::ALL
103   uint64_t selected_mo_index; // which page, cacheline, etc.
104   int sel_ind;              // index of selected object in list
105   DbeView *dbev;
106   int phaseIdx;
107   uint64_t idx_min;
108   uint64_t idx_max;
109   MemObj *unk_memobj;
110   MemObj *total_memobj;
111 };
112 
113 #endif /* _MEMORYSPACE_H */
114