List of usage examples for org.objectweb.asm.util TraceMethodVisitor TraceMethodVisitor
TraceMethodVisitor
From source file:cl.inria.stiq.instrumenter.BCIUtils.java
License:Open Source License
private static void printFrames(MethodNode aNode, Frame[] aFrames) { int bcIndex = 1; for (int i = 0; i < aFrames.length; i++) { Frame theFrame = aFrames[i]; AbstractInsnNode theInsn = aNode.instructions.get(i); switch (theInsn.getType()) { case AbstractInsnNode.INSN: case AbstractInsnNode.INT_INSN: case AbstractInsnNode.VAR_INSN: case AbstractInsnNode.TYPE_INSN: case AbstractInsnNode.FIELD_INSN: case AbstractInsnNode.METHOD_INSN: case AbstractInsnNode.JUMP_INSN: case AbstractInsnNode.LDC_INSN: case AbstractInsnNode.IINC_INSN: case AbstractInsnNode.TABLESWITCH_INSN: case AbstractInsnNode.LOOKUPSWITCH_INSN: case AbstractInsnNode.MULTIANEWARRAY_INSN: TraceMethodVisitor theTraceVisitor = new TraceMethodVisitor(); theInsn.accept(theTraceVisitor); StringWriter theWriter = new StringWriter(); theTraceVisitor.print(new PrintWriter(theWriter)); String theTraced = theWriter.toString().replace("\n", ""); System.out.println(bcIndex + "\t" + frameString(theFrame) + " |\t" + theTraced); bcIndex++;// ww w . j ava2s. c o m break; case AbstractInsnNode.FRAME: case AbstractInsnNode.LINE: case AbstractInsnNode.LABEL: break; } } }
From source file:com.googlecode.dex2jar.v3.V3MethodAdapter.java
License:Apache License
protected void debug_dump(MethodNode methodNode) { TraceMethodVisitor tmv = new TraceMethodVisitor(); methodNode.instructions.accept(tmv); StringBuilder sb = new StringBuilder(); int i = 0;/* w ww.j a v a 2 s .com*/ for (Object o : tmv.text) { sb.append(i++).append(o); } System.out.println(sb); }
From source file:pku.sei.checkedcoverage.tracer.instrumentation.Transformer.java
License:Creative Commons License
public static void printMethod(PrintStream out, MethodNode method) { final TraceMethodVisitor mv = new TraceMethodVisitor(); out.println(method.name + method.desc); for (int j = 0; j < method.instructions.size(); ++j) { method.instructions.get(j).accept(mv); final StringBuffer s = new StringBuffer(); while (s.length() < method.maxStack + method.maxLocals + 1) { s.append(' '); }/*ww w . j av a 2 s . c o m*/ out.print(Integer.toString(j + 100000).substring(1)); out.print(" " + s + " : " + mv.text.get(j)); } for (int j = 0; j < method.tryCatchBlocks.size(); ++j) { ((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv); out.print(" " + mv.text.get(method.instructions.size() + j)); } out.println(" MAXSTACK " + method.maxStack); out.println(" MAXLOCALS " + method.maxLocals); out.println(); }
From source file:pku.sei.checkedcoverage.tracer.instrumentation.Transformer.java
License:Creative Commons License
private static void printMethod(final Analyzer a, final PrintStream out, final MethodNode method) { final Frame[] frames = a.getFrames(); final TraceMethodVisitor mv = new TraceMethodVisitor(); out.println(method.name + method.desc); for (int j = 0; j < method.instructions.size(); ++j) { method.instructions.get(j).accept(mv); final StringBuffer s = new StringBuffer(); final Frame f = frames[j]; if (f == null) { s.append('?'); } else {/* w w w. jav a 2 s . co m*/ for (int k = 0; k < f.getLocals(); ++k) { s.append(getShortName(f.getLocal(k).toString())).append(' '); } s.append(" : "); for (int k = 0; k < f.getStackSize(); ++k) { s.append(getShortName(f.getStack(k).toString())).append(' '); } } while (s.length() < method.maxStack + method.maxLocals + 1) { s.append(' '); } out.print(Integer.toString(j + 100000).substring(1)); out.print(" " + s + " : " + mv.text.get(j)); } for (int j = 0; j < method.tryCatchBlocks.size(); ++j) { ((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv); out.print(" " + mv.text.get(method.instructions.size() + j)); } out.println(" MAXSTACK " + method.maxStack); out.println(" MAXLOCALS " + method.maxLocals); out.println(); }