use of org.evosuite.graphs.ccg.ClassCallNode in project evosuite by EvoSuite.
the class AllUsesAnalysis method preAnalyzeMethods.
/**
* Checks if there are methods in the CCG that dont call any other methods
* except for maybe itself. For these we can predetermine free uses and
* activeDefs prior to looking for inter_method_pairs. After that we can
* even repeat this process for methods we now have determined free uses and
* activeDefs! that way you can save a lot of computation. Map activeDefs
* and freeUses according to the variable so you can easily determine which
* defs will be active and which uses are free once you encounter a
* methodCall to that method without looking at its part of the CCFG
*/
private Set<DefUseCoverageTestFitness> preAnalyzeMethods() {
// TODO after preanalyze, order the remaining methods as follows:
// first order each method by the number of instructions within them in
// ascending order. after that for each method check if there is a
// method that calls this one and also has to be analyzed still. if you
// find such a pair move the calling method in front of the called one
Set<DefUseCoverageTestFitness> r = new HashSet<DefUseCoverageTestFitness>();
LinkedList<ClassCallNode> toAnalyze = new LinkedList<ClassCallNode>();
toAnalyze.addAll(getInitialPreAnalyzeableMethods());
while (!toAnalyze.isEmpty()) {
ClassCallNode currentMethod = toAnalyze.poll();
CCFGMethodEntryNode analyzeableEntry = ccfg.getMethodEntryNodeForClassCallNode(currentMethod);
if (analyzedMethods.contains(analyzeableEntry))
continue;
r.addAll(determineIntraInterMethodPairs(analyzeableEntry));
// check if we can pre-analyze further methods now
Set<ClassCallNode> parents = ccfg.getCcg().getParents(currentMethod);
for (ClassCallNode parent : parents) {
if (toAnalyze.contains(parent))
// will be analyzed anyway
continue;
if (analyzedMethods.contains(ccfg.getMethodEntryNodeForClassCallNode(parent)))
// was already analyzed
continue;
Set<ClassCallNode> parentsChildren = ccfg.getCcg().getChildren(parent);
boolean canAnalyzeNow = true;
for (ClassCallNode parentsChild : parentsChildren) {
if (parentsChild == null)
continue;
if (!parentsChild.equals(parent) && !(toAnalyze.contains(parentsChild) || analyzedMethods.contains(ccfg.getMethodEntryNodeForClassCallNode(parentsChild)))) {
// found child of parent that will not be pre-analyzed
canAnalyzeNow = false;
break;
}
}
if (canAnalyzeNow) {
toAnalyze.offer(parent);
}
}
}
return r;
}
use of org.evosuite.graphs.ccg.ClassCallNode in project evosuite by EvoSuite.
the class ClassControlFlowGraph method connectPublicMethodsToFrame.
/**
* Adds a CCFGFrameEdge from the CCFGFrameNode CALL to the
* CCFGMethodEntryNode of each public method and from their
* CCFGMethodExitNode to the CCFGFrameNode RETURN.
*/
private void connectPublicMethodsToFrame() {
for (ClassCallNode ccgNode : ccg.vertexSet()) {
RawControlFlowGraph cfg = getRCFG(ccgNode);
if (cfg.isPublicMethod()) {
addEdge(getFrameNode(FrameNodeType.CALL), methodEntries.get(ccgNode.getMethod()), new CCFGFrameEdge());
addEdge(methodExits.get(ccgNode.getMethod()), getFrameNode(FrameNodeType.RETURN), new CCFGFrameEdge());
publicMethods.add(methodEntries.get(ccgNode.getMethod()));
}
}
}
use of org.evosuite.graphs.ccg.ClassCallNode in project evosuite by EvoSuite.
the class ClassControlFlowGraph method importCFGs.
private void importCFGs() {
Map<RawControlFlowGraph, Map<BytecodeInstruction, CCFGCodeNode>> tempMap = new HashMap<RawControlFlowGraph, Map<BytecodeInstruction, CCFGCodeNode>>();
// replace each class call node with corresponding CFG
for (ClassCallNode ccgNode : ccg.vertexSet()) {
RawControlFlowGraph cfg = getRCFG(ccgNode);
tempMap.put(cfg, importCFG(cfg));
}
connectCFGs(tempMap);
}
Aggregations