HPCToolkit
Struct-Skel.hpp
Go to the documentation of this file.
1 // -*-Mode: C++;-*-
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 // This file defines the top-level FileInfo, GroupInfo and ProcInfo
48 // classes for makeSkeleton(), doFunctionList() and the Output
49 // functions.
50 //
51 // The Inline Tree Node classes below ProcInfo: TreeNode, LoopInfo and
52 // StmtInfo are in Struct-Inline.hpp.
53 
54 //***************************************************************************
55 
56 #ifndef BAnal_Struct_Skel_hpp
57 #define BAnal_Struct_Skel_hpp
58 
59 #include <list>
60 #include <map>
61 #include <string>
62 
63 #include <CFG.h>
64 #include <Symtab.h>
65 #include <Function.h>
66 
67 #include <lib/isa/ISATypes.hpp>
69 #include "Struct-Inline.hpp"
70 
71 namespace BAnal {
72 namespace Struct {
73 
74 using namespace Dyninst;
75 using namespace Inline;
76 using namespace std;
77 
78 class FileInfo;
79 class GroupInfo;
80 class ProcInfo;
81 
82 typedef map <string, FileInfo *> FileMap;
83 typedef map <VMA, GroupInfo *> GroupMap;
84 typedef map <VMA, ProcInfo *> ProcMap;
85 
86 
87 // FileInfo and FileMap are the top-level classes for files and
88 // procedures. A FileInfo object contains the procs that belong to
89 // one file.
90 //
91 // FileMap is indexed by file name.
92 //
93 class FileInfo {
94 public:
95  string fileName;
96  GroupMap groupMap;
97 
98  FileInfo(string nm)
99  {
100  fileName = nm;
101  groupMap.clear();
102  }
103 };
104 
105 
106 // GroupInfo contains the subset of procs that belong to one binutils
107 // group as determined by the SymtabAPI::Function. Normally, this
108 // includes the unnamed procs (targ4xxxxx) within one Function symbol,
109 // eg, internal openmp regions.
110 //
111 // GroupMap is indexed by Function VMA (symtab if exists, else
112 // parseapi for plt funcs).
113 //
114 // alt_file is for outline funcs whose parseapi file name does not
115 // match the enclosing symtab file (implies no gap analysis).
116 //
117 class GroupInfo {
118 public:
119  SymtabAPI::Function * sym_func;
122  ProcMap procMap;
124  bool alt_file;
125 
126  GroupInfo(SymtabAPI::Function * sf, VMA st, VMA en, bool alt = false)
127  {
128  sym_func = sf;
129  start = st;
130  end = en;
131  procMap.clear();
132  gapSet.clear();
133  alt_file = alt;
134  }
135 };
136 
137 
138 // Info on one ParseAPI Function and Tree Node for one <P> tag as
139 // determined by the func's entry address.
140 //
141 // ProcMap is indexed by the func's entry address.
142 //
143 // gap_only is for outline funcs that exist in another file (do the
144 // full parse in the other file).
145 //
146 class ProcInfo {
147 public:
148  ParseAPI::Function * func;
150  string linkName;
151  string prettyName;
152  long line_num;
154  unsigned symbol_index;
155  bool gap_only;
156 
157  ProcInfo(ParseAPI::Function * fn, TreeNode * rt, string ln, string pn,
158  long l, unsigned symindex = 0, bool gap = false)
159  {
160  func = fn;
161  root = rt;
162  linkName = ln;
163  prettyName = pn;
164  line_num = l;
165  entry_vma = (func != NULL) ? func->addr() : 0;
166  symbol_index = symindex;
167  gap_only = gap;
168  }
169 };
170 
172 public:
173  string prettyName;
175  long num_bytes;
176  long line_num;
177 };
178 
179 } // namespace Struct
180 } // namespace BAnal
181 
182 #endif // BAnal_Struct_Skel_hpp
unsigned int ln
Definition: SrcFile.hpp:66
bfd_vma VMA
Definition: ISATypes.hpp:79
map< VMA, ProcInfo * > ProcMap
Definition: Struct-Skel.hpp:84
map< VMA, GroupInfo * > GroupMap
Definition: Struct-Skel.hpp:83
GroupInfo(SymtabAPI::Function *sf, VMA st, VMA en, bool alt=false)
map< string, FileInfo * > FileMap
Definition: Struct-Skel.hpp:80
ParseAPI::Function * func
ProcInfo(ParseAPI::Function *fn, TreeNode *rt, string ln, string pn, long l, unsigned symindex=0, bool gap=false)
SymtabAPI::Function * sym_func
#define NULL
Definition: ElfHelper.cpp:85