Package daikon.chicory
Class Instrument
- Object
-
- StackMapUtils
-
- InstructionListUtils
-
- Instrument
-
- All Implemented Interfaces:
ClassFileTransformer
public class Instrument extends InstructionListUtils implements ClassFileTransformer
This class is responsible for modifying another class's bytecodes. Specifically, its main task is to add calls into the Chicory runtime at method entries and exits for instrumentation purposes. These added calls are sometimes referred to as "hooks".This class is loaded by ChicoryPremain at startup. It is a ClassFileTransformer which means that its
transformmethod gets called each time the JVM loads a class.
-
-
Field Summary
Fields Modifier and Type Field Description static SimpleLogdebug_ppt_omitDebug information about ppt-omit and ppt-select.protected static SimpleLogdebug_transformDebug information about which classes and/or methods are transformed and why.InstructionFactoryinstFactoryInstructionFactory for a class.
-
Constructor Summary
Constructors Constructor Description Instrument()Create an instrumenter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddump_code_attributes(MethodGen mgen)Logs a method's attributes.static booleanshouldIgnore(@BinaryName String className, String methodName, String pptName)Returns true if the given ppt should be ignored.byte @Nullable []transform(@Nullable ClassLoader loader, @InternalForm String className, @Nullable Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)Given a class, return a transformed version of the class that contains instrumentation code.-
Methods inherited from class InstructionListUtils
append_inst, build_il, calculateLiveLocalTypes, calculateLiveStackTypes, delete_instructions, insertAtMethodStart, insertBeforeHandle, replaceInstructions
-
Methods inherited from class StackMapUtils
addNewParameter, addString, adjust_code_for_locals_change, bcelCalcStackTypes, buildUninitializedNewMap, create_local_from_live_range, create_method_scope_local, createNewStackMapAttribute, findStackMapEqual, findStackMapIndexAfter, findStackMapIndexBefore, fixLocalVariableTable, gen_locals, gen_locals_from_byte_codes, gen_locals_from_byte_codes, generate_Type_from_StackMapType, generateStackMapTypeFromType, get_attribute_name, get_local_variable_type_table_attribute, getSize, getStackMapTable_attribute, is_local_variable_type_table, isStackMapTable, modifyStackMapsForSwitches, printStackMapTable, remove_local_variable_type_table, set_method_stackTypes, setCurrentStackMapTable, typeToClassGetName, update_full_frameStackMap_entries, updateStackMapOffset, updateUninitializedNewOffsets
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ClassFileTransformer
transform
-
-
-
-
Field Detail
-
debug_transform
protected static final SimpleLog debug_transform
Debug information about which classes and/or methods are transformed and why.
-
debug_ppt_omit
public static final SimpleLog debug_ppt_omit
Debug information about ppt-omit and ppt-select.
-
instFactory
public InstructionFactory instFactory
InstructionFactory for a class.
-
-
Constructor Detail
-
Instrument
public Instrument()
Create an instrumenter. Setup debug directories, if needed.
-
-
Method Detail
-
shouldIgnore
public static boolean shouldIgnore(@BinaryName String className, String methodName, String pptName)
Returns true if the given ppt should be ignored. Uses the patterns inRuntime.ppt_omit_patternandRuntime.ppt_select_pattern. This method is used by both Chicory and Dyncomp.- Parameters:
className- class name to be checkedmethodName- method name to be checkedpptName- ppt name to be checked- Returns:
- true if the item should be filtered out
-
transform
public byte @Nullable [] transform(@Nullable ClassLoader loader, @InternalForm String className, @Nullable Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
Given a class, return a transformed version of the class that contains instrumentation code. Because Chicory is invoked as a javaagent, the transform method is called by the Java runtime each time a new class is loaded. A return value of null leaves the byte codes unchanged.- Specified by:
transformin interfaceClassFileTransformer- Throws:
IllegalClassFormatException
-
dump_code_attributes
public void dump_code_attributes(MethodGen mgen)
Logs a method's attributes.- Parameters:
mgen- describes the given method
-
-