-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcallgraph.h
executable file
·85 lines (66 loc) · 1.83 KB
/
callgraph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef __CALLGRAPH_H__
#define __CALLGRAPH_H__
using namespace std;
#include <new>
#include "debug.h"
#include "graph.h"
#include "func.h"
class Prog;
class CallGraphEdge {
private:
Function *source;
Function *target;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & source;
ar & target;
(void)version;
}
public:
CallGraphEdge() {;}
~CallGraphEdge() {;}
CallGraphEdge(Function *s, Function *t) {
source = s;
target = t;
}
Function *getSource() {
return source;
}
Function *getTarget() {
return target;
}
};
class CallGraph : public Graph<Function *, CallGraphEdge *> {
private:
typedef Graph<Function *, CallGraphEdge *> callgraph_t;
std::map<addr_t, Function *> addr2func;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
callgraph_t::serialize(ar, version);
ar & addr2func;
ar & main;
}
Function *main;
public:
CallGraph() { main = NULL; }
~CallGraph() {;}
void addCall(Function *caller, Function *callee);
std::string dot();
std::string vcg();
Function *getMain() const { return main; }
void setMain(Function *m) { main = m; callgraph_t::setEntry(m); }
typedef callgraph_t::const_vertex_iterator const_func_iterator;
typedef callgraph_t::const_edge_iterator const_edge_iterator;
const_func_iterator func_begin() { return vertices_begin(); }
const_func_iterator func_end() { return vertices_end(); }
const_edge_iterator edge_begin() { return edges_begin(); }
const_edge_iterator edge_end() { return edges_end(); }
};
#endif
// Local Variables:
// mode: c++
// c-basic-offset: 4
// compile-command: "dchroot -c typeinfer -d make"
// End: