use of org.evosuite.graphs.ccfg.CCFGMethodEntryNode 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.ccfg.CCFGMethodEntryNode in project evosuite by EvoSuite.
the class AllUsesAnalysis method determineDefUsePairs.
// Definition-Use Pair computation
/**
* Makes a run of determineInterMethodPairs() for each public method. If you
* reach a use for which you have no def yet, remember that also remember
* activeDefs after each run then create intra-class pairs from these uses
* and defs and during each single run we detect intra and inter method
* pairs
*
* @return a {@link java.util.Set} object.
*/
public Set<DefUseCoverageTestFitness> determineDefUsePairs() {
// TODO clinit? id say uses dont count, defs do
Set<DefUseCoverageTestFitness> r = preAnalyzeMethods();
// create inter-method-pairs
for (CCFGMethodEntryNode publicMethodEntry : ccfg.publicMethods) {
if (analyzedMethods.contains(publicMethodEntry)) {
continue;
}
if (publicMethodEntry.getEntryInstruction() == null)
throw new IllegalStateException("expect each CCFGMethodEntryNode to have its entryInstruction set");
r.addAll(determineIntraInterMethodPairs(publicMethodEntry));
}
// create intra-method pairs
r.addAll(createIntraClassPairs());
freeMemory();
return r;
}
Aggregations