Package org.jboss.byteman.agent.adapter
Class RuleTriggerMethodAdapter
java.lang.Object
org.objectweb.asm.MethodVisitor
org.jboss.byteman.agent.adapter.RuleMethodAdapter
org.jboss.byteman.agent.adapter.RuleGeneratorAdapter
org.jboss.byteman.agent.adapter.RuleTriggerMethodAdapter
- Direct Known Subclasses:
EntryTriggerAdapter.EntryTriggerMethodAdapter,ExceptionExitTriggerAdapter.ExceptionExitTriggerMethodAdapter,ExitTriggerAdapter.ExitTriggerMethodAdapter,FieldAccessTriggerAdapter.FieldAccessTriggerMethodAdapter,IndexParamAccessTriggerAdapter.IndexParamAccessTriggerMethodAdapter,InvokeTriggerAdapter.InvokeTriggerMethodAdapter,LineTriggerAdapter.LineTriggerMethodAdapter,NewArrayTriggerAdapter.NewArrayTriggerMethodAdapter,NewTriggerAdapter.NewTriggerMethodAdapter,SynchronizeTriggerAdapter.SynchronizeTriggerMethodAdapter,ThrowTriggerAdapter.ThrowTriggerMethodAdapter,VariableAccessTriggerAdapter.VariableAccessTriggerMethodAdapter
class which provides base functionality extended by all the location-specific method trigger adapters
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
RuleMethodAdapter.LocalVar -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]private org.objectweb.asm.Type[]private booleanprivate booleanprivate booleanprivate CFGprotected String[]private org.objectweb.asm.Typeprivate RuleScriptprivate org.objectweb.asm.Typeprivate StringFields inherited from class org.jboss.byteman.agent.adapter.RuleGeneratorAdapter
ADD, AND, DIV, EQ, GE, GT, LE, LT, MUL, NE, NEG, OR, REM, SHL, SHR, SUB, USHR, XORFields inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
access, descriptor, localVarsByName, name, rule, transformContextFields inherited from class org.objectweb.asm.MethodVisitor
api, mv -
Constructor Summary
ConstructorsConstructorDescriptionRuleTriggerMethodAdapter(org.objectweb.asm.MethodVisitor mv, TransformContext transformContext, int access, String name, String descriptor, String signature, String[] exceptions) -
Method Summary
Modifier and TypeMethodDescriptionprivate Bindingprivate booleandoArgLoad(int saveSlot) stack an argument array containing all the values which need to be bound to parameters or local variables in the rule or a null pointer if no bindings are required.private voidplant code to copy back any updated values from the argument array to the relevant local variable slotsprivate intprivate intorg.objectweb.asm.Type[]method overridden by AT INVOKE method adapter allowing types for the invoked method owner, parameters and return value to be identified.protected Stringmethod overridden by AT NEW method trigger adapter allowing String value for NEWCLASS binding to be retrieved., this default version should never get invokedorg.objectweb.asm.Typemethod overridden by AT INVOKE method adapter allowing the type of the $! binding to be identified.protected booleanreturn true if the current block is a handler which catches a byteman exception thrown by the byteman runtimeprotected booleanreturn true if the current block is in a trigger block injected by Bytemanprotected voidinject the rule trigger codeprotected booleanreturn true if the current block is handler which catches a thrown exception within the scope of a monitor enter in order to be able exit the monitor and rethrow the exceptionprivate voidvoidvoidvisitEnd()voidvisitFieldInsn(int opcode, String owner, String name, String desc) voidvisitIincInsn(int var, int increment) voidvisitInsn(int opcode) voidvisitIntInsn(int opcode, int operand) voidvisitInvokeDynamicInsn(String name, String desc, org.objectweb.asm.Handle bsm, Object... bsmArgs) voidvisitJumpInsn(int opcode, org.objectweb.asm.Label label) voidvisitLabel(org.objectweb.asm.Label label) voidvisitLdcInsn(Object cst) voidvisitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels) voidvisitMaxs(int maxStack, int maxLocals) ensure we allow enough room for any extra locals on the stackvoidvisitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) voidvisitMultiANewArrayInsn(String desc, int dims) voidvisitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels) voidvisitTriggerEnd(org.objectweb.asm.Label label) voidvisitTriggerStart(org.objectweb.asm.Label label) voidvisitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, String type) voidvisitTypeInsn(int opcode, String desc) voidvisitVarInsn(int opcode, int var) override this so we can see track which local var slots are in use and avoid overwriting themMethods inherited from class org.jboss.byteman.agent.adapter.RuleGeneratorAdapter
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, loadThis, mark, mark, math, monitorEnter, monitorExit, newArray, newInstance, newLabel, newLocal, not, pop, pop2, popLocal, push, push, push, push, push, push, push, push, putField, putStatic, ret, returnValue, storeArg, storeLocal, swap, swap, tableSwitch, tableSwitch, throwException, throwException, unbox, visitFrameMethods inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
getTriggerClassName, lookup, visitLocalVariableMethods inherited from class org.objectweb.asm.MethodVisitor
getDelegate, visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitInsnAnnotation, visitLineNumber, visitLocalVariableAnnotation, visitMethodInsn, visitParameter, visitParameterAnnotation, visitTryCatchAnnotation, visitTypeAnnotation
-
Field Details
-
ruleScript
-
signature
-
exceptions
-
argumentTypes
private org.objectweb.asm.Type[] argumentTypes -
saveValueType
private org.objectweb.asm.Type saveValueType -
argLocalIndices
private int[] argLocalIndices -
callArrayBindings
-
bindReturnOrThrowableValue
private boolean bindReturnOrThrowableValue -
bindInvokeParams
private boolean bindInvokeParams -
bindingIndicesSet
private boolean bindingIndicesSet -
returnBindingType
private org.objectweb.asm.Type returnBindingType -
cfg
-
-
Constructor Details
-
RuleTriggerMethodAdapter
RuleTriggerMethodAdapter(org.objectweb.asm.MethodVisitor mv, TransformContext transformContext, int access, String name, String descriptor, String signature, String[] exceptions)
-
-
Method Details
-
getInvokedTypes
public org.objectweb.asm.Type[] getInvokedTypes()method overridden by AT INVOKE method adapter allowing types for the invoked method owner, parameters and return value to be identified. this default version should never get invoked- Returns:
- an array containing the types of the invoked method owner, parameters and return value
-
getNewClassName
method overridden by AT NEW method trigger adapter allowing String value for NEWCLASS binding to be retrieved., this default version should never get invoked- Returns:
- String value for NEWCLASS binding
-
getReturnBindingType
public org.objectweb.asm.Type getReturnBindingType()method overridden by AT INVOKE method adapter allowing the type of the $! binding to be identified. this default version should only get invoked for an AT EXIT rule where it returns the trigger method return type. the overridden version should only get invoked for an AFTER INVOKE rule where it returns the invoked method return type- Returns:
- the appropriate return type
-
setBindingIndices
private void setBindingIndices() -
alias
-
doReturnOrThrowSave
private int doReturnOrThrowSave() -
doInvokeBindingsSave
private int doInvokeBindingsSave() -
doArgLoad
private boolean doArgLoad(int saveSlot) stack an argument array containing all the values which need to be bound to parameters or local variables in the rule or a null pointer if no bindings are required. this method also inserts a copy of the array below the initial two top entries if any of the bindings can potentially be updated by the rule, allowing the updated values to be written back on return from the call to the rule engine.- Parameters:
saveSlot- a local variable slot containing either the return value which the trigger method is about to return or the Throwable the method is about to throw. this is only valid if, respectively, the rule location is AT EXIT/AFTER INVOKE or AT THROW and the rule body contains a reference to the return value ($!) or throwable value ($@).- Returns:
- true if the rule may update the argument array and hence if a copy of the array has been inserted below the initial two top entries otherwise false.
-
doArgUpdate
private void doArgUpdate()plant code to copy back any updated values from the argument array to the relevant local variable slots -
inBytemanHandler
protected boolean inBytemanHandler()return true if the current block is a handler which catches a byteman exception thrown by the byteman runtime- Returns:
- true if the current block is a handler false if not
-
inBytemanTrigger
protected boolean inBytemanTrigger()return true if the current block is in a trigger block injected by Byteman- Returns:
- true if the current block is in a trigger block false if not
-
inRethrowHandler
protected boolean inRethrowHandler()return true if the current block is handler which catches a thrown exception within the scope of a monitor enter in order to be able exit the monitor and rethrow the exception- Returns:
- true if the current block is in a rethrow handler false if not
-
getMethodName
-
visitCode
public void visitCode()- Overrides:
visitCodein classorg.objectweb.asm.MethodVisitor
-
visitInsn
public void visitInsn(int opcode) - Overrides:
visitInsnin classorg.objectweb.asm.MethodVisitor
-
visitIincInsn
public void visitIincInsn(int var, int increment) - Overrides:
visitIincInsnin classorg.objectweb.asm.MethodVisitor
-
visitIntInsn
public void visitIntInsn(int opcode, int operand) - Overrides:
visitIntInsnin classorg.objectweb.asm.MethodVisitor
-
visitLdcInsn
- Overrides:
visitLdcInsnin classorg.objectweb.asm.MethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int var) Description copied from class:RuleGeneratorAdapteroverride this so we can see track which local var slots are in use and avoid overwriting them- Overrides:
visitVarInsnin classRuleGeneratorAdapter- Parameters:
opcode- the bytecode operationvar- local variable index
-
visitTypeInsn
- Overrides:
visitTypeInsnin classorg.objectweb.asm.MethodVisitor
-
visitFieldInsn
- Overrides:
visitFieldInsnin classorg.objectweb.asm.MethodVisitor
-
visitMethodInsn
- Overrides:
visitMethodInsnin classorg.objectweb.asm.MethodVisitor
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(String name, String desc, org.objectweb.asm.Handle bsm, Object... bsmArgs) - Overrides:
visitInvokeDynamicInsnin classorg.objectweb.asm.MethodVisitor
-
visitJumpInsn
public void visitJumpInsn(int opcode, org.objectweb.asm.Label label) - Overrides:
visitJumpInsnin classorg.objectweb.asm.MethodVisitor
-
visitLabel
public void visitLabel(org.objectweb.asm.Label label) - Overrides:
visitLabelin classorg.objectweb.asm.MethodVisitor
-
visitTriggerStart
public void visitTriggerStart(org.objectweb.asm.Label label) -
visitTriggerEnd
public void visitTriggerEnd(org.objectweb.asm.Label label) -
visitTableSwitchInsn
public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels) - Overrides:
visitTableSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitLookupSwitchInsn
public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels) - Overrides:
visitLookupSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitMultiANewArrayInsn
- Overrides:
visitMultiANewArrayInsnin classorg.objectweb.asm.MethodVisitor
-
visitTryCatchBlock
public void visitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, String type) - Overrides:
visitTryCatchBlockin classorg.objectweb.asm.MethodVisitor
-
visitMaxs
public void visitMaxs(int maxStack, int maxLocals) Description copied from class:RuleGeneratorAdapterensure we allow enough room for any extra locals on the stack- Overrides:
visitMaxsin classRuleGeneratorAdapter- Parameters:
maxStack- the maximum stack depthmaxLocals- the maximum local count
-
visitEnd
public void visitEnd()- Overrides:
visitEndin classorg.objectweb.asm.MethodVisitor
-
injectTriggerPoint
protected void injectTriggerPoint()inject the rule trigger code
-