38 using namespace SVFUtil;
50 directCalls.insert(call);
56 indirectCalls.insert(call);
63 std::stringstream rawstr(str);
64 rawstr <<
"CallSite ID: " << getCallSiteID();
65 if(isDirectCallEdge())
66 rawstr <<
"direct call";
68 rawstr <<
"indirect call";
69 rawstr <<
"[" << getDstID() <<
"<--" << getSrcID() <<
"]\t";
76 std::stringstream rawstr(str);
77 rawstr <<
"PTACallGraphNode ID: " << getId() <<
" {fun: " << fun->getName() <<
"}";
83 std::stack<const PTACallGraphNode*> nodeStack;
86 visitedNodes.
set(getId());
88 while (nodeStack.empty() ==
false)
123 for (
const auto&
item : other)
177 if (outEdge && inEdge)
179 assert(outEdge == inEdge &&
"edges not match");
193 for (PTACallGraphEdge::CallGraphEdgeSet::iterator iter = src->
OutEdgeBegin();
254 for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->directCallsBegin(),
255 ecit = (*it)->directCallsEnd(); cit!=ecit; ++cit)
257 csSet.insert((*cit));
259 for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->indirectCallsBegin(),
260 ecit = (*it)->indirectCallsEnd(); cit!=ecit; ++cit)
262 csSet.insert((*cit));
276 for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->directCallsBegin(),
277 ecit = (*it)->directCallsEnd(); cit!=ecit; ++cit)
279 csSet.insert((*cit));
293 for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->indirectCallsBegin(),
294 ecit = (*it)->indirectCallsEnd(); cit!=ecit; ++cit)
296 csSet.insert((*cit));
308 for (; it != eit; ++it)
311 if (targets.empty() ==
false)
328 std::stack<const PTACallGraphNode*> nodeStack;
330 nodeStack.push(dstNode);
333 while (nodeStack.empty() ==
false)
401 return "shape=Mrecord";
404 template<
class EdgeIter>
411 assert(edge &&
"No edge found!!");
417 color =
"color=green";
421 color =
"color=blue";
425 color =
"color=black";
434 template<
class EdgeIter>
438 assert(edge &&
"No edge found!!");
441 std::stringstream rawstr(str);
const SVFFunction * getCalledFunction() const
const SVFFunction * getCaller() const
Return callsite.
NodeType * getSrcNode() const
GEdgeKind getEdgeKind() const
NodeID getSrcID() const
get methods of the components
void addGNode(NodeID id, NodeType *node)
Add a Node.
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
iterator OutEdgeBegin()
iterators
GEdgeSetTy::const_iterator const_iterator
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
virtual const std::string toString() const
CallInstSet & getIndirectCalls()
void addDirectCallSite(const CallICFGNode *call)
Add direct and indirect callsite.
void addInDirectCallSite(const CallICFGNode *call)
Set< const CallICFGNode * > CallInstSet
CallSiteID getCallSiteID() const
Get direct and indirect calls.
virtual const std::string toString() const
PTACallGraphEdge::CallGraphEdgeSet::iterator iterator
const SVFFunction * getFunction() const
Get function of this call node.
bool isReachableFromProgEntry() const
Return TRUE if this function can be reached from main.
void getDirCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
PTACallGraphEdge * getGraphEdge(PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId)
Get call graph edge via nodes.
static CallSiteID totalCallSiteNum
CallSiteIDs, start from 1;.
void addEdge(PTACallGraphEdge *edge)
Add call graph edge.
void addIndirectCallGraphEdge(const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
static IdToCallSiteMap idToCSMap
Map a callsite ID to a pair of call instruction and callee.
Set< const SVFFunction * > FunctionSet
Map< CallSiteID, CallSitePair > IdToCallSiteMap
PTACallGraph(CGEK k=NormCallGraph)
Constructor.
void addDirectCallGraphEdge(const CallICFGNode *call, const SVFFunction *callerFun, const SVFFunction *calleeFun)
Add direct/indirect call edges.
void destroy()
Clean up memory.
PTACallGraphEdge * hasGraphEdge(PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const
Whether we have already created this call graph edge.
static CallSiteToIdMap csToIdMap
Call site information.
void view()
View the graph from the debugger.
void getAllCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
Get callsites invoking the callee.
void dump(const std::string &filename)
Dump the graph.
void addCallGraphNode(const SVFFunction *fun)
CallSiteID addCallSite(const CallICFGNode *cs, const SVFFunction *callee)
Add/Get CallSiteID.
FunToCallGraphNodeMap funToCallGraphNodeMap
Call Graph node map.
void getIndCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter
bool isReachableBetweenFunctions(const SVFFunction *srcFn, const SVFFunction *dstFn) const
Whether its reachable between two functions.
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
Map a call instruction to its corresponding call edges.
void verifyCallGraph()
Issue a warning if the function which has indirect call sites can not be reached from program entry.
CallEdgeMap indirectCallMap
Indirect call map.
u32_t numOfResolvedIndCallEdge
Map< CallSitePair, CallSiteID > CallSiteToIdMap
NodeID getId() const
Get ID.
const std::string & getName() const
const SVFValue * getValue() const
Get/has methods of the components.
bool test_and_set(unsigned Idx)
bool isExtCall(const SVFFunction *fun)
bool isProgEntryFunction(const SVFFunction *fun)
Program entry function e.g. main.
const SVFVar * getForkedFun(const CallICFGNode *inst)
Return thread fork function.
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
std::ostream & outs()
Overwrite llvm::outs()
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)
static std::string getEdgeSourceLabel(NodeType *, EdgeIter EI)
static std::string getEdgeAttributes(PTACallGraphNode *, EdgeIter EI, PTACallGraph *)
PTACallGraphNode NodeType
static std::string getGraphName(PTACallGraph *)
Return name of the graph.
DOTGraphTraits(bool isSimple=false)
static std::string getNodeLabel(PTACallGraphNode *node, PTACallGraph *)
Return function name;.
NodeType::iterator ChildIteratorType
static std::string getNodeAttributes(PTACallGraphNode *node, PTACallGraph *)