Search in sources :

Example 56 with LabelNode

use of org.objectweb.asm.tree.LabelNode in project phosphor by gmu-swe.

the class LocalVariableManager method remapLocal.

@Override
public void remapLocal(int local, Type type) {
    Label lbl = new Label();
    super.visitLabel(lbl);
    curLocalIdxToLVNode.get(local).end = new LabelNode(lbl);
    super.remapLocal(local, type);
    LocalVariableNode newLVN = new LocalVariableNode("phosphorShadowLV" + createdLVIdx, type.getDescriptor(), null, new LabelNode(lbl), new LabelNode(end), local);
    createdLVs.add(newLVN);
    curLocalIdxToLVNode.put(local, newLVN);
    createdLVIdx++;
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) Label(org.objectweb.asm.Label) LocalVariableNode(org.objectweb.asm.tree.LocalVariableNode)

Example 57 with LabelNode

use of org.objectweb.asm.tree.LabelNode in project phosphor by gmu-swe.

the class LocalVariableManager method createMasterControlTaintLV.

public int createMasterControlTaintLV() {
    int idx = super.newLocal(Type.getType(ControlTaintTagStack.class));
    if (ctrlTagStartLbl == null) {
        ctrlTagStartLbl = new Label();
        super.visitLabel(ctrlTagStartLbl);
    }
    LocalVariableNode newLVN = new LocalVariableNode("phosphorJumpControlTag" + jumpIdx, Type.getDescriptor(ControlTaintTagStack.class), null, new LabelNode(ctrlTagStartLbl), new LabelNode(end), idx);
    createdLVs.add(newLVN);
    analyzer.locals.add(idx, Type.getInternalName(ControlTaintTagStack.class));
    this.idxOfMasterControlLV = idx;
    jumpIdx++;
    return idx;
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) ControlTaintTagStack(edu.columbia.cs.psl.phosphor.struct.ControlTaintTagStack) Label(org.objectweb.asm.Label) LocalVariableNode(org.objectweb.asm.tree.LocalVariableNode)

Example 58 with LabelNode

use of org.objectweb.asm.tree.LabelNode in project phosphor by gmu-swe.

the class LocalVariableManager method newPreAllocedReturnType.

private int newPreAllocedReturnType(Type type) {
    int idx = super.newLocal(type);
    Label lbl = new Label();
    super.visitLabel(lbl);
    // System.out.println("End is going to be " + end);
    LocalVariableNode newLVN = new LocalVariableNode("phosphorReturnPreAlloc" + createdLVIdx, type.getDescriptor(), null, new LabelNode(lbl), new LabelNode(end), idx);
    createdLVs.add(newLVN);
    curLocalIdxToLVNode.put(idx, newLVN);
    createdLVIdx++;
    analyzer.locals.add(idx, type.getInternalName());
    return idx;
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) Label(org.objectweb.asm.Label) LocalVariableNode(org.objectweb.asm.tree.LocalVariableNode)

Example 59 with LabelNode

use of org.objectweb.asm.tree.LabelNode in project phosphor by gmu-swe.

the class LocalVariableManager method newControlTaintLV.

public int newControlTaintLV() {
    int idx = super.newLocal(Type.getType("Ledu/columbia/cs/psl/phosphor/struct/EnqueuedTaint;"));
    if (ctrlTagStartLbl == null) {
        ctrlTagStartLbl = new Label();
        super.visitLabel(ctrlTagStartLbl);
    }
    LocalVariableNode newLVN = new LocalVariableNode("phosphorJumpControlTag" + jumpIdx, "Ledu/columbia/cs/psl/phosphor/struct/EnqueuedTaint;", null, new LabelNode(ctrlTagStartLbl), new LabelNode(end), idx);
    createdLVs.add(newLVN);
    // System.out.println("Create taint tag at " + idx);
    analyzer.locals.add(idx, "edu/columbia/cs/psl/phosphor/struct/EnqueuedTaint");
    jumpIdx++;
    return idx;
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) Label(org.objectweb.asm.Label) LocalVariableNode(org.objectweb.asm.tree.LocalVariableNode)

Example 60 with LabelNode

use of org.objectweb.asm.tree.LabelNode in project evosuite by EvoSuite.

the class ReplaceComparisonOperator method apply.

/* (non-Javadoc)
	 * @see org.evosuite.cfg.instrumentation.MutationOperator#apply(org.objectweb.asm.tree.MethodNode, java.lang.String, java.lang.String, org.evosuite.cfg.BytecodeInstruction)
	 */
/**
 * {@inheritDoc}
 */
@Override
public List<Mutation> apply(MethodNode mn, String className, String methodName, BytecodeInstruction instruction, Frame frame) {
    JumpInsnNode node = (JumpInsnNode) instruction.getASMNode();
    List<Mutation> mutations = new LinkedList<Mutation>();
    LabelNode target = node.label;
    boolean isBoolean = frame.getStack(frame.getStackSize() - 1) == BooleanValueInterpreter.BOOLEAN_VALUE;
    for (Integer op : getOperators(node.getOpcode(), isBoolean)) {
        logger.debug("Adding replacement " + op);
        if (op >= 0) {
            // insert mutation into bytecode with conditional
            JumpInsnNode mutation = new JumpInsnNode(op, target);
            // insert mutation into pool
            Mutation mutationObject = MutationPool.addMutation(className, methodName, NAME + " " + getOp(node.getOpcode()) + " -> " + getOp(op), instruction, mutation, getInfectionDistance(node.getOpcode(), op));
            mutations.add(mutationObject);
        } else {
            // Replace relational operator with TRUE/FALSE
            InsnList mutation = new InsnList();
            if (opcodesInt.contains(node.getOpcode()))
                mutation.add(new InsnNode(Opcodes.POP));
            else
                mutation.add(new InsnNode(Opcodes.POP2));
            if (op == TRUE) {
                mutation.add(new LdcInsnNode(1));
            } else {
                mutation.add(new LdcInsnNode(0));
            }
            mutation.add(new JumpInsnNode(Opcodes.IFNE, target));
            Mutation mutationObject = MutationPool.addMutation(className, methodName, NAME + " " + getOp(node.getOpcode()) + " -> " + op, instruction, mutation, getInfectionDistance(node.getOpcode(), op));
            mutations.add(mutationObject);
        }
    }
    return mutations;
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) Mutation(org.evosuite.coverage.mutation.Mutation) InsnList(org.objectweb.asm.tree.InsnList) LinkedList(java.util.LinkedList)

Aggregations

LabelNode (org.objectweb.asm.tree.LabelNode)89 JumpInsnNode (org.objectweb.asm.tree.JumpInsnNode)37 AbstractInsnNode (org.objectweb.asm.tree.AbstractInsnNode)32 Label (org.objectweb.asm.Label)28 MethodInsnNode (org.objectweb.asm.tree.MethodInsnNode)23 InsnList (org.objectweb.asm.tree.InsnList)22 VarInsnNode (org.objectweb.asm.tree.VarInsnNode)21 InsnNode (org.objectweb.asm.tree.InsnNode)20 MethodNode (org.objectweb.asm.tree.MethodNode)19 LdcInsnNode (org.objectweb.asm.tree.LdcInsnNode)17 FieldInsnNode (org.objectweb.asm.tree.FieldInsnNode)16 TypeInsnNode (org.objectweb.asm.tree.TypeInsnNode)15 ClassNode (org.objectweb.asm.tree.ClassNode)14 ClassReader (org.objectweb.asm.ClassReader)12 LineNumberNode (org.objectweb.asm.tree.LineNumberNode)10 Type (org.objectweb.asm.Type)8 LocalVariableNode (org.objectweb.asm.tree.LocalVariableNode)8 LinkedList (java.util.LinkedList)6 ArrayList (java.util.ArrayList)5 LookupSwitchInsnNode (org.objectweb.asm.tree.LookupSwitchInsnNode)5