use of org.evosuite.graphs.cfg.BytecodeInstruction in project evosuite by EvoSuite.
the class AllUsesAnalysis method handleFieldCallNode.
private void handleFieldCallNode(CCFGMethodEntryNode investigatedMethod, CCFGNode node, Stack<MethodCall> callStack, Set<Map<String, VariableDefinition>> activeDefs, Set<BytecodeInstruction> freeUses, Set<DefUseCoverageTestFitness> foundPairs) {
BytecodeInstruction code = ((CCFGCodeNode) node).getCodeInstruction();
// LoggingUtils.getEvoLogger().debug(
// "Processing field call: " + node.toString());
handleDefUse(investigatedMethod, code, callStack, activeDefs, freeUses, foundPairs);
}
use of org.evosuite.graphs.cfg.BytecodeInstruction in project evosuite by EvoSuite.
the class AllUsesAnalysis method handleCodeNode.
private void handleCodeNode(CCFGMethodEntryNode investigatedMethod, CCFGNode node, Stack<MethodCall> callStack, Set<Map<String, VariableDefinition>> activeDefs, Set<BytecodeInstruction> freeUses, Set<DefUseCoverageTestFitness> foundPairs) {
BytecodeInstruction code = ((CCFGCodeNode) node).getCodeInstruction();
handleDefUse(investigatedMethod, code, callStack, activeDefs, freeUses, foundPairs);
}
use of org.evosuite.graphs.cfg.BytecodeInstruction in project evosuite by EvoSuite.
the class DefUseCoverageFactory method categorizeFieldMethodCalls.
/**
* Determines for all method calls on fields of the CUT whether the call is
* to a pure or impure method. For these calls Uses and Definitions are
* created respectively.
*
* Since purity analysis is used here and requires all classes along the
* call tree to be completely analyzed this part of the CUT analysis can not
* be done in the CFGMethodAdapter like the rest of it.
*/
private static void categorizeFieldMethodCalls() {
Set<BytecodeInstruction> fieldMethodCalls = DefUsePool.retrieveFieldMethodCalls();
LoggingUtils.getEvoLogger().info("Categorizing field method calls: " + fieldMethodCalls.size());
for (BytecodeInstruction fieldMethodCall : fieldMethodCalls) {
if (GraphPool.getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT()).canMakeCCFGForClass(fieldMethodCall.getCalledMethodsClass())) {
ClassControlFlowGraph ccfg = GraphPool.getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT()).getCCFG(fieldMethodCall.getCalledMethodsClass());
if (ccfg.isPure(fieldMethodCall.getCalledMethod())) {
if (!DefUsePool.addAsUse(fieldMethodCall))
throw new IllegalStateException("unable to register field method call as a use " + fieldMethodCall.toString());
} else {
if (!DefUsePool.addAsDefinition(fieldMethodCall))
throw new IllegalStateException("unable to register field method call as a definition " + fieldMethodCall.toString());
}
} else {
String toAnalyze = fieldMethodCall.getCalledMethodsClass() + "." + fieldMethodCall.getCalledMethodName();
if (toAnalyze != null && toAnalyze.startsWith("java.")) {
Type[] parameters = org.objectweb.asm.Type.getArgumentTypes(fieldMethodCall.getMethodCallDescriptor());
String newParams = "";
if (parameters.length != 0) {
for (Type i : parameters) {
newParams = newParams + "," + i.getClassName();
}
newParams = newParams.substring(1, newParams.length());
}
toAnalyze = fieldMethodCall.getCalledMethodsClass() + "." + fieldMethodCall.getCalledMethodName() + "(" + newParams + ")";
if (JdkPureMethodsList.instance.checkPurity(toAnalyze)) {
if (!DefUsePool.addAsUse(fieldMethodCall))
throw new IllegalStateException("unable to register field method call as a use " + fieldMethodCall.toString());
} else {
if (!DefUsePool.addAsDefinition(fieldMethodCall))
throw new IllegalStateException("unable to register field method call as a definition " + fieldMethodCall.toString());
}
} else {
if (!DefUsePool.addAsUse(fieldMethodCall))
throw new IllegalStateException("unable to register field method call as a use " + fieldMethodCall.toString());
}
}
}
}
use of org.evosuite.graphs.cfg.BytecodeInstruction in project evosuite by EvoSuite.
the class DefUseCoverageTestFitness method getInstructionsAfterGoalDefinition.
/**
* Returns a set containing all CFGVertices in the goal definition method
* that come after the definition.
*
* Look at ControlFlowGraph.getLaterInstructionInMethod() for details
*
* @return a {@link java.util.Set} object.
*/
public Set<BytecodeInstruction> getInstructionsAfterGoalDefinition() {
RawControlFlowGraph cfg = GraphPool.getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT()).getRawCFG(goalDefinition.getClassName(), goalDefinition.getMethodName());
BytecodeInstruction defVertex = cfg.getInstruction(goalDefinition.getInstructionId());
Set<BytecodeInstruction> r = cfg.getLaterInstructionsInMethod(defVertex);
// }
return r;
}
use of org.evosuite.graphs.cfg.BytecodeInstruction in project evosuite by EvoSuite.
the class BooleanTestabilityTransformation method getBranchID.
private int getBranchID(MethodNode mn, JumpInsnNode jumpNode) {
assert (mn.instructions.contains(jumpNode));
BytecodeInstruction insn = getBytecodeInstruction(mn, jumpNode);
logger.info("Found instruction: " + insn);
Branch branch = BranchPool.getInstance(classLoader).getBranchForInstruction(insn);
return branch.getActualBranchId();
}
Aggregations