public final class ConcolicMethodAdapter
extends org.objectweb.asm.commons.GeneratorAdapter
Before each user ByteCode instruction, add a call to one of our static methods, that reflects the particular ByteCode. In a few cases noted below, we add our callback after the user ByteCode, instead of before.
| Modifier and Type | Method and Description |
|---|---|
void |
visitCode()
Before first ByteCode of the method/constructor
|
void |
visitFieldInsn(int opcode,
String owner,
String name,
String desc)
GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC
http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
|
void |
visitIincInsn(int i,
int value)
IINC
|
void |
visitInsn(int opcode)
Insert call to our method directly before the corresponding user
instruction
|
void |
visitIntInsn(int opcode,
int operand)
BIPUSH: push one byte from instruction stream to operand stack
SIPUSH: push two bytes from instruction stream to operand stack
NEWARRAY
|
void |
visitJumpInsn(int opcode,
org.objectweb.asm.Label label) |
void |
visitLabel(org.objectweb.asm.Label label)
Pseudo-instruction, inserted directly before the corresponding target
instruction.
|
void |
visitLdcInsn(Object constant)
LDC, (LDC_W) -- push category one constant from constant pool
LDC2_W -- push category two constant from constant pool
Insert call to our method after user ByteCode instruction, allows us to
use the result of LDC.
|
void |
visitLineNumber(int line,
org.objectweb.asm.Label start) |
void |
visitLookupSwitchInsn(org.objectweb.asm.Label dflt,
int[] keys,
org.objectweb.asm.Label[] labels)
LOOKUPSWITCH
|
void |
visitMaxs(int maxStack,
int maxLocals) |
void |
visitMethodInsn(int opcode,
String owner,
String name,
String desc)
Invoke a method/constructor/class initializer:
INVOKE_X -- signature and receiver (!) of invoked method
CALLER_STACK_PARAM -- last parameter
CALLER_STACK_PARAM -- next-to-last parameter
make call
CALL_RESULT
|
void |
visitMultiANewArrayInsn(String arrayTypeDesc,
int nrDimensions)
MULTIANEWARRAY
|
void |
visitTableSwitchInsn(int min,
int max,
org.objectweb.asm.Label dflt,
org.objectweb.asm.Label[] labels)
TABLESWITCH
|
void |
visitTryCatchBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label handler,
String type) |
void |
visitTypeInsn(int opcode,
String type)
CHECKCAST, INSTANCEOF, NEW, ANEWARRAY
|
void |
visitVarInsn(int opcode,
int var)
ILOAD, ISTORE, ILOAD_0, ILOAD_1, etc.
|
arrayLength, arrayLoad, arrayStore, box, cast, catchException, checkCast, dup, dup2, dup2X1, dup2X2, dupX1, dupX2, endMethod, getField, getLocalType, getStatic, goTo, ifCmp, ifICmp, ifNonNull, ifNull, ifZCmp, iinc, instanceOf, invokeConstructor, invokeDynamic, invokeInterface, invokeStatic, invokeVirtual, loadArg, loadArgArray, loadArgs, loadArgs, loadLocal, loadLocal, loadThis, mark, mark, math, monitorEnter, monitorExit, newArray, newInstance, newLabel, not, pop, pop2, push, push, push, push, push, push, push, push, putField, putStatic, ret, returnValue, setLocalType, storeArg, storeLocal, storeLocal, swap, swap, tableSwitch, tableSwitch, throwException, throwException, unbox, valueOfnewLocal, newLocalMapping, updateNewLocals, visitFrame, visitLocalVariable, visitLocalVariableAnnotationpublic void visitCode()
Issue one call per argument, excluding the "this" receiver for non-constructor instance methods. Work left to right, starting with receiver.
visitCode in class org.objectweb.asm.MethodVisitorpublic void visitInsn(int opcode)
visitInsn in class org.objectweb.asm.MethodVisitorpublic void visitJumpInsn(int opcode,
org.objectweb.asm.Label label)
visitJumpInsn in class org.objectweb.asm.MethodVisitorpublic void visitLineNumber(int line,
org.objectweb.asm.Label start)
visitLineNumber in class org.objectweb.asm.MethodVisitorpublic void visitLabel(org.objectweb.asm.Label label)
Our instrumentation code does not change the shape of the instrumented method's control flow graph. So hopefully we do not need to modify any label and trust that ASM will recompute the concrete offsets correctly for us.
visitLabel in class org.objectweb.asm.MethodVisitorpublic void visitIntInsn(int opcode,
int operand)
visitIntInsn in class org.objectweb.asm.MethodVisitorpublic void visitLdcInsn(Object constant)
visitLdcInsn in class org.objectweb.asm.MethodVisitor://java.sun.com/docs/books/jvms/second_edition/html/Instructions2
.doc8.html#ldc,
://java.sun.com/docs/books/jvms/second_edition/html/Instructions2
.doc8.html#ldc2_wpublic void visitVarInsn(int opcode,
int var)
These may follow a WIDE instruction.
visitVarInsn in class org.objectweb.asm.commons.LocalVariablesSorterpublic void visitFieldInsn(int opcode,
String owner,
String name,
String desc)
visitFieldInsn in class org.objectweb.asm.MethodVisitorpublic void visitMethodInsn(int opcode,
String owner,
String name,
String desc)
Add callback before any invocation. Besides all method calls (static,
instance, private, public, native, etc.) and all constructor calls, this
also works for the special case of the (implicit) super call that the
Java compiler adds to the beginning of each constructor:
"InvokeSpecial MySuperType
Although the Java compiler does not allow any statement before this super
call, we can still add a callback at the JVM level. It seems that the
Java compiler (and language) is overly restrictive here.
TODO: Pass receiver for more than two parameters.
http://java.sun.com/docs/books/jvms/second_edition/html/Concepts.doc.html
#16411
visitMethodInsn in class org.objectweb.asm.MethodVisitorpublic void visitIincInsn(int i,
int value)
Increment i-th local (int) variable by constant (int) value.
May follow a WIDE instruction.
visitIincInsn in class org.objectweb.asm.commons.LocalVariablesSorterpublic void visitMultiANewArrayInsn(String arrayTypeDesc, int nrDimensions)
boolean[] b1 = new boolean[1]; // NEWARRAY T_BOOLEAN Boolean[] B1 = new Boolean[1]; // ANEWARRAY java/lang/Boolean boolean[][] b2 = new boolean[1][2]; // MULTIANEWARRAY [[Z 2 Boolean[][] B2 = new Boolean[1][2]; // MULTIANEWARRAY [[Ljava/lang/Boolean; 2
visitMultiANewArrayInsn in class org.objectweb.asm.MethodVisitorpublic void visitTableSwitchInsn(int min,
int max,
org.objectweb.asm.Label dflt,
org.objectweb.asm.Label[] labels)
visitTableSwitchInsn in class org.objectweb.asm.MethodVisitorpublic void visitLookupSwitchInsn(org.objectweb.asm.Label dflt,
int[] keys,
org.objectweb.asm.Label[] labels)
TODO: Optimize this. Do we really need to create a new array every time we execute this switch statement?
visitLookupSwitchInsn in class org.objectweb.asm.MethodVisitorpublic void visitTypeInsn(int opcode,
String type)
visitTypeInsn in class org.objectweb.asm.MethodVisitorpublic void visitTryCatchBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label handler,
String type)
visitTryCatchBlock in class org.objectweb.asm.MethodVisitorpublic void visitMaxs(int maxStack,
int maxLocals)
visitMaxs in class org.objectweb.asm.commons.LocalVariablesSorterCopyright © 2010–2017 EvoSuite. All rights reserved.