ROSE  0.9.9.109
Classes | Public Types | Public Member Functions | List of all members
Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph Class Reference

Description

Function call information.

This class provides methods that operate on a function call graph, such as constructing a function call graph from a control flow graph. The graph vertices are function pointers (Function::Ptr) and the edges contain information about the type of inter-function edge (function call, function transfer, etc) and the number of such edges. Function call graphs can be built so that inter-function control transfer is represented by its own edge, or so that multiple transfers share an edge.

Definition at line 18 of file FunctionCallGraph.h.

#include <FunctionCallGraph.h>

Classes

class  Edge
 Information about each edge in the call graph. More...
 

Public Types

typedef Sawyer::Container::Graph< FunctionPtr, EdgeGraph
 Function call graph. More...
 
typedef Sawyer::Container::Map< rose_addr_t, Graph::VertexIterator > Index
 Maps function address to function call graph vertex. More...
 

Public Member Functions

const Graphgraph () const
 Underlying function call graph. More...
 
const Indexindex () const
 Function-to-vertex index. More...
 
 FunctionCallGraph ()
 Constructs an empty function call graph. More...
 
 FunctionCallGraph (const FunctionCallGraph &other)
 Copy constructor. More...
 
FunctionCallGraphoperator= (const FunctionCallGraph &other)
 Assignment operator. More...
 
boost::iterator_range< Graph::ConstVertexValueIterator > functions ()
 Return all functions in the call graph. More...
 
Graph::VertexIterator insertFunction (const FunctionPtr &function)
 Insert a function vertex. More...
 
Graph::ConstVertexIterator findFunction (const FunctionPtr &function) const
 Find function in call graph. More...
 
Graph::ConstVertexIterator findFunction (rose_addr_t entryVa) const
 Find function in call graph. More...
 
bool exists (const FunctionPtr &function) const
 Determine if a function exists in the call graph. More...
 
bool exists (rose_addr_t entryVa) const
 Determine if a function exists in the call graph. More...
 
Graph::EdgeIterator insertCall (const FunctionPtr &source, const FunctionPtr &target, EdgeType type=E_FUNCTION_CALL, size_t edgeCount=0)
 Insert a call edge. More...
 
Graph::EdgeIterator insertCall (const Graph::VertexIterator &source, const Graph::VertexIterator &target, EdgeType type=E_FUNCTION_CALL, size_t edgeCount=0)
 Insert a call edge. More...
 
std::vector< FunctionPtrcallers (const FunctionPtr &target) const
 List of all functions that call the specified function. More...
 
std::vector< FunctionPtrcallers (const Graph::ConstVertexIterator &target) const
 List of all functions that call the specified function. More...
 
size_t nCallers (const FunctionPtr &target) const
 Number of functions that call the specified function. More...
 
size_t nCallers (const Graph::ConstVertexIterator &target) const
 Number of functions that call the specified function. More...
 
std::vector< FunctionPtrcallees (const FunctionPtr &source) const
 List of all functions called by the specified function. More...
 
std::vector< FunctionPtrcallees (const Graph::ConstVertexIterator &source) const
 List of all functions called by the specified function. More...
 
size_t nCallees (const FunctionPtr &source) const
 Number of functions that the specified function calls. More...
 
size_t nCallees (const Graph::ConstVertexIterator &source) const
 Number of functions that the specified function calls. More...
 
size_t nCallsIn (const FunctionPtr &target) const
 Total number of calls to a function. More...
 
size_t nCallsIn (const Graph::ConstVertexIterator &target) const
 Total number of calls to a function. More...
 
size_t nCallsOut (const FunctionPtr &source) const
 Total number of calls from a function. More...
 
size_t nCallsOut (const Graph::ConstVertexIterator &source) const
 Total number of calls from a function. More...
 
size_t nCalls (const FunctionPtr &source, const FunctionPtr &target) const
 Number of calls between two specific functions. More...
 
size_t nCalls (const Graph::ConstVertexIterator &source, const Graph::ConstVertexIterator &target) const
 Number of calls between two specific functions. More...
 

Member Typedef Documentation

Function call graph.

Definition at line 36 of file FunctionCallGraph.h.

Maps function address to function call graph vertex.

Definition at line 39 of file FunctionCallGraph.h.

Constructor & Destructor Documentation

Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::FunctionCallGraph ( )

Constructs an empty function call graph.

Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::FunctionCallGraph ( const FunctionCallGraph other)

Copy constructor.

Member Function Documentation

const Graph& Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::graph ( ) const
inline

Underlying function call graph.

This returns the Sawyer::Container::Graph representing inter-function edges. It is read-only since modifying the graph must be done in conjunction with updating the function-to-vertex index.

Definition at line 50 of file FunctionCallGraph.h.

const Index& Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::index ( ) const
inline

Function-to-vertex index.

Returns the index mapping function addresses to function call graph vertices. The index is read-only since updating the index must be done in conjunction with updating the graph.

Definition at line 56 of file FunctionCallGraph.h.

FunctionCallGraph& Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::operator= ( const FunctionCallGraph other)

Assignment operator.

boost::iterator_range<Graph::ConstVertexValueIterator> Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::functions ( )
inline

Return all functions in the call graph.

Definition at line 70 of file FunctionCallGraph.h.

References Sawyer::Container::Graph< V, E, VKey, EKey, Alloc >::vertexValues().

Graph::ConstVertexIterator Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::findFunction ( const FunctionPtr function) const

Find function in call graph.

Returns the call graph vertex (as an iterator) for the specified function, or the end vertex iterator if the function does not exist in the call graph. The function can be specified by its pointer or entry address.

Graph::ConstVertexIterator Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::findFunction ( rose_addr_t  entryVa) const

Find function in call graph.

Returns the call graph vertex (as an iterator) for the specified function, or the end vertex iterator if the function does not exist in the call graph. The function can be specified by its pointer or entry address.

bool Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::exists ( const FunctionPtr function) const

Determine if a function exists in the call graph.

Returns true if the function is a member of the call graph and false otherwise. A function can be a member of a call graph even if it has no incident edges.

bool Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::exists ( rose_addr_t  entryVa) const

Determine if a function exists in the call graph.

Returns true if the function is a member of the call graph and false otherwise. A function can be a member of a call graph even if it has no incident edges.

Graph::VertexIterator Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::insertFunction ( const FunctionPtr function)

Insert a function vertex.

Inserts the specified function into the call graph if it is not a member of the call graph, otherwise does nothing. In any case, it returns the vertex for the function.

Graph::EdgeIterator Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::insertCall ( const FunctionPtr source,
const FunctionPtr target,
EdgeType  type = E_FUNCTION_CALL,
size_t  edgeCount = 0 
)

Insert a call edge.

Inserts an edge representing a call from source (caller) to target (callee). The type can be E_FUNCTION_CALL or E_FUNCTION_XFER.

If edgeCount is non-zero an an edge of the correct type already exists between the source and target, then the count on that edge is incremented instead. Otherwise, when edgeCount is zero, a new edge with unit count is inserted even if it means creating an edge parallel to an existing edge.

Returns the edge that was inserted or incremented.

Graph::EdgeIterator Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::insertCall ( const Graph::VertexIterator &  source,
const Graph::VertexIterator &  target,
EdgeType  type = E_FUNCTION_CALL,
size_t  edgeCount = 0 
)

Insert a call edge.

Inserts an edge representing a call from source (caller) to target (callee). The type can be E_FUNCTION_CALL or E_FUNCTION_XFER.

If edgeCount is non-zero an an edge of the correct type already exists between the source and target, then the count on that edge is incremented instead. Otherwise, when edgeCount is zero, a new edge with unit count is inserted even if it means creating an edge parallel to an existing edge.

Returns the edge that was inserted or incremented.

std::vector<FunctionPtr> Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::callers ( const FunctionPtr target) const

List of all functions that call the specified function.

Returns a sorted list of distinct functions that call the specified function.

std::vector<FunctionPtr> Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::callers ( const Graph::ConstVertexIterator &  target) const

List of all functions that call the specified function.

Returns a sorted list of distinct functions that call the specified function.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCallers ( const FunctionPtr target) const

Number of functions that call the specified function.

This is the number of distinct functions that call the specified target function.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCallers ( const Graph::ConstVertexIterator &  target) const

Number of functions that call the specified function.

This is the number of distinct functions that call the specified target function.

std::vector<FunctionPtr> Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::callees ( const FunctionPtr source) const

List of all functions called by the specified function.

Returns a sorted list of distinct functions that call the function specified by entry address or call graph vertex. If the specified function does not exist in the call graph then an empty list is returned.

std::vector<FunctionPtr> Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::callees ( const Graph::ConstVertexIterator &  source) const

List of all functions called by the specified function.

Returns a sorted list of distinct functions that call the function specified by entry address or call graph vertex. If the specified function does not exist in the call graph then an empty list is returned.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCallees ( const FunctionPtr source) const

Number of functions that the specified function calls.

This is the number of distinct functions called from the specified source function.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCallees ( const Graph::ConstVertexIterator &  source) const

Number of functions that the specified function calls.

This is the number of distinct functions called from the specified source function.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCallsIn ( const FunctionPtr target) const

Total number of calls to a function.

Returns the total number of calls to the specified function, counting each call when a single function calls more than once. I.e., it is the sum of the count fields of all the incoming edges for target.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCallsIn ( const Graph::ConstVertexIterator &  target) const

Total number of calls to a function.

Returns the total number of calls to the specified function, counting each call when a single function calls more than once. I.e., it is the sum of the count fields of all the incoming edges for target.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCallsOut ( const FunctionPtr source) const

Total number of calls from a function.

Returns the total number of calls from the specified function, counting each call when a single function is called more than once. I.e., it is the sum of the count fields of all the outgoing edges for source.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCallsOut ( const Graph::ConstVertexIterator &  source) const

Total number of calls from a function.

Returns the total number of calls from the specified function, counting each call when a single function is called more than once. I.e., it is the sum of the count fields of all the outgoing edges for source.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCalls ( const FunctionPtr source,
const FunctionPtr target 
) const

Number of calls between two specific functions.

This is the sum of the count fields for all edges between source and target.

size_t Rose::BinaryAnalysis::Partitioner2::FunctionCallGraph::nCalls ( const Graph::ConstVertexIterator &  source,
const Graph::ConstVertexIterator &  target 
) const

Number of calls between two specific functions.

This is the sum of the count fields for all edges between source and target.


The documentation for this class was generated from the following file: