ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Callgraph.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * ROSE Global Database Test
4  *
5  * Callgraph implementation
6  *
7  *****************************************************************************/
8 
9 
10 #ifndef CALLGRAPH_H
11 #define CALLGRAPH_H
12 
13 #include "/home/thuerey1/local/include/config.h"
14 
15 #include "DatabaseGraph.h"
16 #include "Classhierarchy.h"
17 
18 #include "TableDefinitions.h"
19 #ifndef TABLES_DEFINED
21 #endif
22 
23 //typedef set<SgMemberFunctionType *> chVertexData;
24 //typedef set<SgNode *> chVertexData;
25 
27  public:
29  int dummy;
30 };
31 
32 // install boost database graph property map types
33 namespace boost {
35  BOOST_INSTALL_PROPERTY( vertex, callgraph );
36 }
37 
38 
40 class Callgraph :
41 public DatabaseGraph<functionsRowdata, EdgeTypeEmpty,
42  vecS, vecS, bidirectionalS, property< vertex_callgraph_t, callgraphVertexData, GraphvizVertexProperty>,
43  GraphvizEdgeProperty,
44  GraphvizGraphProperty >
45 {
46  public:
48  Callgraph( long pid, long type, GlobalDatabaseConnection *gdb ) :
49  DatabaseGraph<functionsRowdata, EdgeTypeEmpty, vecS, vecS, bidirectionalS,
50  property< vertex_callgraph_t, callgraphVertexData, GraphvizVertexProperty>,
51  GraphvizEdgeProperty,
52  GraphvizGraphProperty >(pid,type,gdb) { };
53 
55  ~Callgraph() { };
56 
57  private:
58 };
59 
60 
61 
62 
63 /******************************************************************************
64  * callgraph generation traversal classes
65  *****************************************************************************/
66 
68 #define SIDEEFFECTS_UNDECIDED 1
69 #define SIDEEFFECTS_NO 2
70 #define SIDEEFFECTS_YES 3
71 
72 
74 #define FUNCCALL_IMPLICIT 1
75 #define FUNCCALL_EXPLICIT 2
76 
77 
78 // Build an inherited attribute for the callgraph traversal
80 {
81  public:
83  CallgraphInhAttr ( SgNode* astNode ) :
84  mFunctionScopes() { };
85 
86  CallgraphInhAttr ( const CallgraphInhAttr & X, SgNode* astNode ) {
88  };
89 
91  bool hasValidFunctionScope( void ){
92  return ( mFunctionScopes.size() > 0); }
93 
95  long getCurrentFunctionScope( void ){
96  assert( mFunctionScopes.size() > 0);
97  return mFunctionScopes[ mFunctionScopes.size()-1 ];
98  }
100  long pushFunctionScope(long id){ mFunctionScopes.push_back( id ); }
101 
102  private:
103 
105  vector<long> mFunctionScopes;
106 
107 };
108 
109 
110 
111 
112 // tree traversal for callgraph generation
114 : public SgTopDownProcessing<CallgraphInhAttr>
115 {
116  public:
119  {
120  mProjectId = -1;
121  mFileId = -1;
122  mCallgraph = NULL;
123  mClasshierarchy = NULL;
124  mpFunctionDefinitions = NULL;
125  mpSgProject = NULL;
126  };
127 
128  // Functions required by the tree traversal mechanism
130  SgNode* astNode,
131  CallgraphInhAttr inheritedAttribute );
132 
133 
135  void removeDeletedFunctionRows( void );
136 
137 
139  void setFunctionDefinitions( vector<long> *set ){ mpFunctionDefinitions = set; };
141  vector<long> *getFunctionDefinitions( void ) { return mpFunctionDefinitions; };
142 
144  void setFileScopes( vector<long> *set ){ mpFileScopes = set; };
146  vector<long> *getFileScopes( void ) { return mpFileScopes; };
147 
149  void setDB( GlobalDatabaseConnection *set ){ mpGDB = set; };
151  GlobalDatabaseConnection *getDB( void ) { return mpGDB; };
152 
154  void setProjectId( long set ){ mProjectId = set; };
156  long getProjectId( void ){ return mProjectId; };
157 
159  void setFileId( long set ){ mFileId = set; };
161  long getFileId( void ){ return mFileId; };
162 
164  //void setCallgraph( DatabaseGraph<functionsRowdata, EdgeTypeEmpty> *set ) { mCallgraph = set; }
165  void setCallgraph( Callgraph *set ) { mCallgraph = set; }
167  Callgraph *getCallgraph( void ) { return mCallgraph; }
168 
173 
175  void setSgProject( SgProject *set ) { mpSgProject = set; }
177  SgProject *getSgProject( void ) { return mpSgProject; }
178 
180  set<int> *getCGFileSubgraphs( void ){ return &mCGFileSubgraphs; }
181 
183  void setDeclList( list<SgNode*> *set ) { mpDeclQList = set; }
184 
185 
186  private:
187 
189  void addCallEdge(SgFunctionDeclaration *funcDec, long functionScope);
190 
191 
192  // ! DB connection pointer
193  GlobalDatabaseConnection *mpGDB;
194 
197 
199  long mFileId;
200 
202  //DatabaseGraph<functionsRowdata, EdgeTypeEmpty> *mCallgraph;
204 
207 
209  vector<long> *mpFunctionDefinitions;
210 
212  vector<long> *mpFileScopes;
213 
216 
219 
221  list<SgNode*> *mpDeclQList;
222 
223 };
224 
225 
226 
227 #endif
228 
229 
230