use of org.objectweb.asm.tree.LdcInsnNode in project evosuite by EvoSuite.
the class BooleanTestabilityTransformation method insertPush.
/**
* Insert a call to the distance function for unary comparison
*
* @param opcode
* @param position
* @param list
*/
public void insertPush(int opcode, JumpInsnNode position, InsnList list) {
list.insertBefore(position, new InsnNode(Opcodes.DUP));
// TODO: We have to put a placeholder here instead of the actual branch ID
// TODO: And then later add another transformation where we replace this with
// actual branch IDs
// list.insertBefore(position,
// new LdcInsnNode(getBranchID(currentMethodNode, position)));
insertBranchIdPlaceholder(currentMethodNode, position);
MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushPredicate", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE }), false);
list.insertBefore(position, push);
}
use of org.objectweb.asm.tree.LdcInsnNode in project evosuite by EvoSuite.
the class BooleanTestabilityTransformation method insertPushEquals.
/**
* Insert a call to the reference equality check helper function
*
* @param opcode
* @param position
* @param list
*/
public void insertPushEquals(int opcode, JumpInsnNode position, InsnList list) {
MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "isEqual", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Object.class), Type.getType(Object.class), Type.INT_TYPE }), false);
list.insertBefore(position, new InsnNode(Opcodes.DUP2));
list.insertBefore(position, new LdcInsnNode(opcode));
list.insertBefore(position, equalCheck);
// list.insertBefore(position,
// new LdcInsnNode(getBranchID(currentMethodNode, position)));
insertBranchIdPlaceholder(currentMethodNode, position);
MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushPredicate", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE }), false);
list.insertBefore(position, push);
}
use of org.objectweb.asm.tree.LdcInsnNode in project evosuite by EvoSuite.
the class BranchInstrumentation method addDefaultCaseNotCoveredCall.
/**
* <p>
* addDefaultCaseNotCoveredCall
* </p>
*
* @param v
* a {@link org.evosuite.graphs.cfg.BytecodeInstruction} object.
* @param instrumentation
* a {@link org.objectweb.asm.tree.InsnList} object.
* @param defaultCaseBranchId
* a int.
*/
protected void addDefaultCaseNotCoveredCall(BytecodeInstruction v, InsnList instrumentation, int defaultCaseBranchId) {
instrumentation.add(new LdcInsnNode(0));
instrumentation.add(new LdcInsnNode(Opcodes.IFNE));
instrumentation.add(new LdcInsnNode(defaultCaseBranchId));
instrumentation.add(new LdcInsnNode(v.getInstructionId()));
instrumentation.add(new MethodInsnNode(Opcodes.INVOKESTATIC, EXECUTION_TRACER, "passedBranch", "(IIII)V", false));
}
use of org.objectweb.asm.tree.LdcInsnNode in project evosuite by EvoSuite.
the class BranchInstrumentation method addDefaultCaseCoveredCall.
/**
* <p>
* addDefaultCaseCoveredCall
* </p>
*
* @param v
* a {@link org.evosuite.graphs.cfg.BytecodeInstruction} object.
* @param instrumentation
* a {@link org.objectweb.asm.tree.InsnList} object.
* @param defaultCaseBranchId
* a int.
*/
protected void addDefaultCaseCoveredCall(BytecodeInstruction v, InsnList instrumentation, int defaultCaseBranchId) {
instrumentation.add(new LdcInsnNode(0));
instrumentation.add(new LdcInsnNode(Opcodes.IFEQ));
instrumentation.add(new LdcInsnNode(defaultCaseBranchId));
instrumentation.add(new LdcInsnNode(v.getInstructionId()));
instrumentation.add(new MethodInsnNode(Opcodes.INVOKESTATIC, EXECUTION_TRACER, "passedBranch", "(IIII)V", false));
}
use of org.objectweb.asm.tree.LdcInsnNode in project evosuite by EvoSuite.
the class BranchInstrumentation method addInstrumentationForSwitchCases.
/**
* For each actual case <key>: of a switch this method adds instrumentation
* for the Branch corresponding to that case to the given instruction list.
*
* @param v
* a {@link org.evosuite.graphs.cfg.BytecodeInstruction} object.
* @param instrumentation
* a {@link org.objectweb.asm.tree.InsnList} object.
* @param className
* a {@link java.lang.String} object.
* @param methodName
* a {@link java.lang.String} object.
*/
protected void addInstrumentationForSwitchCases(BytecodeInstruction v, InsnList instrumentation, String className, String methodName) {
if (!v.isSwitch())
throw new IllegalArgumentException("switch instruction expected");
List<Branch> caseBranches = BranchPool.getInstance(classLoader).getCaseBranchesForSwitch(v);
if (caseBranches == null || caseBranches.isEmpty())
throw new IllegalStateException("expect BranchPool to know at least one Branch for each switch instruction");
for (Branch targetCaseBranch : caseBranches) {
if (targetCaseBranch.isDefaultCase())
// handled elsewhere
continue;
Integer targetCaseValue = targetCaseBranch.getTargetCaseValue();
Integer targetCaseBranchId = targetCaseBranch.getActualBranchId();
instrumentation.add(new InsnNode(Opcodes.DUP));
instrumentation.add(new LdcInsnNode(targetCaseValue));
instrumentation.add(new LdcInsnNode(Opcodes.IF_ICMPEQ));
instrumentation.add(new LdcInsnNode(targetCaseBranchId));
instrumentation.add(new LdcInsnNode(v.getInstructionId()));
instrumentation.add(new MethodInsnNode(Opcodes.INVOKESTATIC, EXECUTION_TRACER, "passedBranch", "(IIIII)V", false));
}
}
Aggregations