Class 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 transform method gets called each time the JVM loads a class.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static SimpleLog debug_ppt_omit
      Debug information about ppt-omit and ppt-select.
      protected static SimpleLog debug_transform
      Debug information about which classes and/or methods are transformed and why.
      InstructionFactory instFactory
      InstructionFactory for a class.
      • Fields inherited from class StackMapUtils

        debugInstrument, firstLocalIndex, initialLocalsCount, initialTypeList, liveRangeEnd, liveRangeOperandSize, liveRangeStart, liveRangeType, needStackMap, numberActiveLocals, pool, runningOffset, smta, stackMapTable, stackTypes
    • Constructor Summary

      Constructors 
      Constructor Description
      Instrument()
      Create an instrumenter.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dump_code_attributes​(MethodGen mgen)
      Logs a method's attributes.
      static boolean shouldIgnore​(@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
    • 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 in Runtime.ppt_omit_pattern and Runtime.ppt_select_pattern. This method is used by both Chicory and Dyncomp.
        Parameters:
        className - class name to be checked
        methodName - method name to be checked
        pptName - ppt name to be checked
        Returns:
        true if the item should be filtered out
      • dump_code_attributes

        public void dump_code_attributes​(MethodGen mgen)
        Logs a method's attributes.
        Parameters:
        mgen - describes the given method