45 #ifndef CALL_GRAPH_MANAGER_HPP 46 #define CALL_GRAPH_MANAGER_HPP 53 #include <boost/graph/depth_first_search.hpp> 85 std::map<unsigned int, CustomSet<unsigned int>>
called_by;
118 void AddCallPoint(
unsigned int caller_id,
unsigned int called_id,
unsigned int call_id,
138 bool IsCallPoint(
unsigned int caller_id,
unsigned int called_id,
unsigned int call_id,
159 CallGraphManager(
const FunctionExpanderConstRef function_expander,
const bool allow_recursive_functions,
255 bool IsVertex(
unsigned int functionID)
const;
280 void RemoveCallPoint(
const unsigned int caller_id,
const unsigned int called_id,
const unsigned int call_id);
320 unsigned int f_id,
int DL);
322 unsigned int caller_id,
unsigned int called_id,
unsigned int call_id,
bool IsCallPoint(unsigned int caller_id, unsigned int called_id, unsigned int call_id, enum FunctionEdgeInfo::CallType call_type) const
Returns true if the call point is present.
const CustomSet< unsigned int > & GetReachedBodyFunctions() const
Returns the source code functions called by the root functions.
CustomSet< unsigned int > GetRootFunctions() const
Returns the root functions (i.e., the functions that are not called by any other ones.
CustomSet< unsigned int > reached_body_functions
source code functions directly or indirectly called by the root functions
This class manages the tree structures extracted from the raw file.
CustomSet< unsigned int > addressed_functions
set of functions whose address is taken
Class specification of the graph structures.
const tree_managerConstRef tree_manager
The tree manager.
CallGraphManager(const FunctionExpanderConstRef function_expander, const bool allow_recursive_functions, const tree_managerConstRef tree_manager, const ParameterConstRef Param)
Constructor.
CustomSet< unsigned int > GetAddressedFunctions() const
Returns a set containing all the reachable addressed_functions.
std::map< unsigned int, vertex > functionID_vertex_map
put into relation function F_i and the vertex in the call graph representing it
redefinition of map to manage ordered/unordered structures
CustomSet< unsigned int > root_functions
Root functions.
Build call graph structures starting from the tree_manager.
Abstract pure class for the tree structure.
unsigned int get_function(vertex node) const
Given a vertex of the call graph, this returns the index of the corresponding function.
const FunctionExpanderConstRef function_expander
Functor used to check if the analysis should consider the body of a function.
static void addCallPointAndExpand(CustomUnorderedSet< unsigned int > &AV, const application_managerRef AM, unsigned int caller_id, unsigned int called_id, unsigned int call_id, enum FunctionEdgeInfo::CallType call_type, int DL)
This class is the view of a call graph.
const bool allow_recursive_functions
True if recursive calls are allowed.
std::map< unsigned int, CustomSet< unsigned int > > called_by
put into relation function F_i and the list of functions called by F_i
static void call_graph_computation_recursive(CustomUnorderedSet< unsigned int > &AV, const application_managerRef AM, unsigned int current, const tree_managerRef &TM, const tree_nodeRef &tn, unsigned int node_stmt, enum FunctionEdgeInfo::CallType call_type, int DL)
Recursive analysis of the tree nodes looking for call expressions.
CustomSet< unsigned int > reached_library_functions
library functions directly or indirectly called by the root functions
redefinition of set to manage ordered/unordered structures
This class collects information concerning the set of functions that will be analyzed by the PandA fr...
void ReplaceCallPoint(const EdgeDescriptor e, const unsigned int orig, const unsigned int repl)
Replaces a call point.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
void AddCallPoint(unsigned int caller_id, unsigned int called_id, unsigned int call_id, enum FunctionEdgeInfo::CallType call_type)
Creates a new call point.
CallGraphConstRef CGetCallGraph() const
Return the call graph.
used to avoid expansion of c library function or type
Template definition of refcount.
bool ExistsAddressedFunction() const
Returns true is there is at least a reachable function that is called through a function pointer or i...
CustomSet< unsigned int > GetReachedFunctionsFrom(unsigned int from_f, bool with_body=true) const
compute the list of reached function starting from a given function
const int debug_level
the debug level
void AddFunctionAndCallPoint(unsigned int caller_id, unsigned int called_id, unsigned int call_id, const FunctionBehaviorRef called_function_behavior, enum FunctionEdgeInfo::CallType call_type)
Creates a new called function and directly adds the call to the call graph.
CustomSet< unsigned int > get_called_by(unsigned int index) const
Returns the set of functions called by a function.
const ParameterConstRef Param
set of input parameters
const application_managerRef AppM
The application manager.
REF_FORWARD_DECL(application_manager)
CustomSet< unsigned int > GetReachedLibraryFunctions() const
Returns the library functions called by the root functions.
~CallGraphManager()
Destructor.
This class manages the accesses to the CallGraph.
void RemoveCallPoint(const unsigned int caller_id, const unsigned int called_id, const unsigned int call_id)
Remove a function call, like RemoveCallPoint with a different API.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
void ComputeRootAndReachedFunctions()
Compute the root and reached functions, maintaining the internal data structures coherent.
unsigned int GetRootFunction(unsigned int fid) const
Get the parent root function.
CallGraphConstRef CGetCallSubGraph(const CustomUnorderedSet< vertex > &vertices) const
Return a subset of the call graph.
void AddFunction(unsigned int new_function_id, const FunctionBehaviorRef fun_behavior)
Class used to describe a particular graph with operations as nodes.
vertex GetVertex(const unsigned int index) const
Return the vertex given the function id.
CallGraphConstRef CGetAcyclicCallGraph() const
Return an acyclic version of the call graph.
bool IsVertex(unsigned int functionID) const
return true in case the vertex has been already created
void SetRootFunctions(const CustomSet< unsigned int > &root_functions)
Set the root functions.
const CallGraphsCollectionRef call_graphs_collection
static void expandCallGraphFromFunction(CustomUnorderedSet< unsigned int > &AV, const application_managerRef AM, unsigned int f_id, int DL)
const CallGraphRef call_graph
The view of call graph with all the edges.
CONSTREF_FORWARD_DECL(application_manager)
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.