/** Instrument the specified method to replace mapped calls. */ public void instrument_method(Method m, MethodGen mg) { // Loop through each instruction, making substitutions InstructionList il = mg.getInstructionList(); for (InstructionHandle ih = il.getStart(); ih != null; ) { if (debug_instrument_inst.enabled()) { debug_instrument_inst.log("instrumenting instruction %s%n", ih); // ih.getInstruction().toString(pool.getConstantPool())); } InstructionList new_il = null; // Remember the next instruction to process InstructionHandle next_ih = ih.getNext(); // Get the translation for this instruction (if any) new_il = xform_inst(mg, ih.getInstruction()); if (debug_instrument_inst.enabled()) debug_instrument_inst.log(" new inst: %s%n", new_il); // If this instruction was modified, replace it with the new // instruction list. If this instruction was the target of any // jumps or line numbers , replace them with the first // instruction in the new list replace_instructions(il, ih, new_il); ih = next_ih; } }
/** * Long output format: * * <p><position in byte code> <name of opcode> "["<opcode number>"]" * "("<length of instruction>")" "<"<target instruction>">" "@"<branch target * offset> * * @param verbose long/short format switch * @return mnemonic for instruction */ public String toString(boolean verbose) { String s = super.toString(verbose); String t = "null"; if (verbose) { if (target != null) { if (target.getInstruction() == this) t = "<points to itself>"; else if (target.getInstruction() == null) t = "<null instruction!!!?>"; else t = target.getInstruction().toString(false); // Avoid circles } } else { if (target != null) { index = getTargetOffset(); t = "" + (index + position); } } return s + " -> " + t; }