Search in sources :

Example 26 with LocalVariableNode

use of org.objectweb.asm.tree.LocalVariableNode 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 27 with LocalVariableNode

use of org.objectweb.asm.tree.LocalVariableNode 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 28 with LocalVariableNode

use of org.objectweb.asm.tree.LocalVariableNode 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 29 with LocalVariableNode

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

the class ReplaceVariable method getType.

private Type getType(MethodNode mn, AbstractInsnNode node) throws VariableNotFoundException {
    if (node instanceof VarInsnNode) {
        LocalVariableNode var = getLocal(mn, node, ((VarInsnNode) node).var);
        return Type.getType(var.desc);
    } else if (node instanceof FieldInsnNode) {
        return Type.getType(((FieldInsnNode) node).desc);
    } else if (node instanceof IincInsnNode) {
        IincInsnNode incNode = (IincInsnNode) node;
        LocalVariableNode var = getLocal(mn, node, incNode.var);
        return Type.getType(var.desc);
    } else {
        throw new RuntimeException("Unknown variable node: " + node);
    }
}
Also used : IincInsnNode(org.objectweb.asm.tree.IincInsnNode) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode) LocalVariableNode(org.objectweb.asm.tree.LocalVariableNode)

Example 30 with LocalVariableNode

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

the class ReplaceVariable method getLocal.

private LocalVariableNode getLocal(MethodNode mn, AbstractInsnNode node, int index) throws VariableNotFoundException {
    int currentId = mn.instructions.indexOf(node);
    for (Object v : mn.localVariables) {
        LocalVariableNode localVar = (LocalVariableNode) v;
        int startId = mn.instructions.indexOf(localVar.start);
        int endId = mn.instructions.indexOf(localVar.end);
        logger.info("Checking " + localVar.index + " in scope " + startId + " - " + endId);
        if (currentId >= startId && currentId <= endId && localVar.index == index)
            return localVar;
    }
    throw new VariableNotFoundException("Could not find local variable " + index + " at position " + currentId + ", have variables: " + mn.localVariables.size());
}
Also used : LocalVariableNode(org.objectweb.asm.tree.LocalVariableNode)

Aggregations

LocalVariableNode (org.objectweb.asm.tree.LocalVariableNode)41 Label (org.objectweb.asm.Label)11 MethodNode (org.objectweb.asm.tree.MethodNode)9 Type (org.objectweb.asm.Type)8 LabelNode (org.objectweb.asm.tree.LabelNode)8 VarInsnNode (org.objectweb.asm.tree.VarInsnNode)8 FieldInsnNode (org.objectweb.asm.tree.FieldInsnNode)6 IincInsnNode (org.objectweb.asm.tree.IincInsnNode)6 GeneratorAdapter (org.objectweb.asm.commons.GeneratorAdapter)5 AbstractInsnNode (org.objectweb.asm.tree.AbstractInsnNode)5 InsnList (org.objectweb.asm.tree.InsnList)5 MethodInsnNode (org.objectweb.asm.tree.MethodInsnNode)5 ClassNode (org.objectweb.asm.tree.ClassNode)4 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 FieldNode (org.objectweb.asm.tree.FieldNode)3 FrameNode (org.objectweb.asm.tree.FrameNode)3 TryCatchBlockNode (org.objectweb.asm.tree.TryCatchBlockNode)3 NeverNullArgAnalyzerAdapter (edu.columbia.cs.psl.phosphor.instrumenter.analyzer.NeverNullArgAnalyzerAdapter)2 ControlTaintTagStack (edu.columbia.cs.psl.phosphor.struct.ControlTaintTagStack)2