ROSE 0.11.145.147
FunctionCallGraph.h
1#ifndef ROSE_BinaryAnalysis_Partitioner2_FunctionCallGraph_H
2#define ROSE_BinaryAnalysis_Partitioner2_FunctionCallGraph_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
6
7#include <Sawyer/Graph.h>
8#include <Sawyer/Map.h>
9
10namespace Rose {
11namespace BinaryAnalysis {
12namespace Partitioner2 {
13
22public:
24 class Edge {
25 friend class FunctionCallGraph;
26 EdgeType type_;
27 size_t count_;
28 public:
29 explicit Edge(EdgeType type): type_(type), count_(1) {}
30
32 EdgeType type() const { return type_; }
33
35 size_t count() const { return count_; }
36 };
37
38 class VertexKey {
39 public:
40 rose_addr_t address;
41 VertexKey();
42 explicit VertexKey(rose_addr_t);
43 explicit VertexKey(const FunctionPtr&);
44 bool operator<(VertexKey) const;
45 };
46
49
50private:
51 Graph graph_;
52
53public:
58 const Graph& graph() const { return graph_; }
59
62
64
66 boost::iterator_range<Graph::ConstVertexValueIterator> functions() {
67 return graph_.vertexValues();
68 }
69
76 Graph::ConstVertexIterator findFunction(const FunctionPtr &function) const;
77 Graph::ConstVertexIterator findFunction(rose_addr_t entryVa) const;
86 bool exists(const FunctionPtr &function) const;
87 bool exists(rose_addr_t entryVa) const;
94 Graph::VertexIterator insertFunction(const FunctionPtr &function);
95
108 Graph::EdgeIterator insertCall(const FunctionPtr &source, const FunctionPtr &target,
109 EdgeType type = E_FUNCTION_CALL, size_t edgeCount = 0);
110 Graph::EdgeIterator insertCall(const Graph::VertexIterator &source, const Graph::VertexIterator &target,
111 EdgeType type = E_FUNCTION_CALL, size_t edgeCount = 0);
119 std::vector<FunctionPtr> callers(const FunctionPtr &target) const;
120 std::vector<FunctionPtr> callers(const Graph::ConstVertexIterator &target) const;
128 size_t nCallers(const FunctionPtr &target) const;
129 size_t nCallers(const Graph::ConstVertexIterator &target) const;
138 std::vector<FunctionPtr> callees(const FunctionPtr &source) const;
139 std::vector<FunctionPtr> callees(const Graph::ConstVertexIterator &source) const;
147 size_t nCallees(const FunctionPtr &source) const;
148 size_t nCallees(const Graph::ConstVertexIterator &source) const;
157 size_t nCallsIn(const FunctionPtr &target) const;
158 size_t nCallsIn(const Graph::ConstVertexIterator &target) const;
167 size_t nCallsOut(const FunctionPtr &source) const;
168 size_t nCallsOut(const Graph::ConstVertexIterator &source) const;
176 size_t nCalls(const FunctionPtr &source, const FunctionPtr &target) const;
177 size_t nCalls(const Graph::ConstVertexIterator &source, const Graph::ConstVertexIterator &target) const;
179};
180
181} // namespace
182} // namespace
183} // namespace
184
185#endif
186#endif
Information about each edge in the call graph.
size_t count() const
Number of inter-function control flow edges represented by this edge.
const Graph & graph() const
Underlying function call graph.
Graph::EdgeIterator insertCall(const FunctionPtr &source, const FunctionPtr &target, EdgeType type=E_FUNCTION_CALL, size_t edgeCount=0)
Insert a call edge.
Graph::EdgeIterator insertCall(const Graph::VertexIterator &source, const Graph::VertexIterator &target, EdgeType type=E_FUNCTION_CALL, size_t edgeCount=0)
Insert a call edge.
size_t nCallers(const Graph::ConstVertexIterator &target) const
Number of functions that call the specified function.
size_t nCallsOut(const Graph::ConstVertexIterator &source) const
Total number of calls from a function.
std::vector< FunctionPtr > callers(const FunctionPtr &target) const
List of all functions that call the specified function.
std::vector< FunctionPtr > callees(const FunctionPtr &source) const
List of all functions called by the specified function.
size_t nCalls(const FunctionPtr &source, const FunctionPtr &target) const
Number of calls between two specific functions.
size_t nCalls(const Graph::ConstVertexIterator &source, const Graph::ConstVertexIterator &target) const
Number of calls between two specific functions.
size_t nCallees(const Graph::ConstVertexIterator &source) const
Number of functions that the specified function calls.
size_t nCallsIn(const Graph::ConstVertexIterator &target) const
Total number of calls to a function.
boost::iterator_range< Graph::ConstVertexValueIterator > functions()
Return all functions in the call graph.
size_t nCallers(const FunctionPtr &target) const
Number of functions that call the specified function.
Graph::ConstVertexIterator findFunction(const FunctionPtr &function) const
Find function in call graph.
size_t nCallsIn(const FunctionPtr &target) const
Total number of calls to a function.
size_t nCallsOut(const FunctionPtr &source) const
Total number of calls from a function.
std::vector< FunctionPtr > callees(const Graph::ConstVertexIterator &source) const
List of all functions called by the specified function.
FunctionCallGraph()
Constructs an empty function call graph.
bool exists(const FunctionPtr &function) const
Determine if a function exists in the call graph.
size_t nCallees(const FunctionPtr &source) const
Number of functions that the specified function calls.
Graph::VertexIterator insertFunction(const FunctionPtr &function)
Insert a function vertex.
bool exists(rose_addr_t entryVa) const
Determine if a function exists in the call graph.
std::vector< FunctionPtr > callers(const Graph::ConstVertexIterator &target) const
List of all functions that call the specified function.
Sawyer::Container::Graph< FunctionPtr, Edge, VertexKey > Graph
Function call graph.
Graph::ConstVertexIterator findFunction(rose_addr_t entryVa) const
Find function in call graph.
Graph containing user-defined vertices and edges.
Definition Graph.h:634
boost::iterator_range< VertexValueIterator > vertexValues()
Iterators for all vertices.
Definition Graph.h:1565
The ROSE library.