Permalink
Browse files

Fixed #54: Interrupted in tracing.

  • Loading branch information...
1 parent 5d2a4eb commit 4872157db67514a529d2623bb5b4ae331b92cd44 @zhongl zhongl committed Jun 20, 2012
@@ -40,7 +40,7 @@ public static void main(String[] args) throws Exception {
while (true) {
addOne(0);
- o.getClass().getMethod("m", String.class).invoke(o, "123");
+ o.getClass().getMethod("m", String.class).invoke(o, (String)null);
try {
Thread.sleep(500L);
} catch (Exception e) {
@@ -88,12 +88,12 @@ public void heartbeat(long now) {
println("Can't inspect " + accessor + " because there's no invocation on " + accessor.classSimpleName);
else
for (Object target : targets) printStat(target);
+ println();
}
private void printStat(Object target) {
try {
println(accessor + " " + accessor.getField(target) + " " + target + " " + target.getClass().getClassLoader());
- println();
} catch (Exception e) {
error(e);
}
@@ -24,6 +24,7 @@ import com.github.zhongl.housemd.misc.Reflections._
import java.util.Date
import collection.immutable.SortedSet
import com.github.zhongl.housemd.instrument.{Hook, Context}
+import org.objectweb.asm.Type
/**
* @author <a href="mailto:zhong.lunfu@gmail.com">zhongl<a>
@@ -105,7 +106,7 @@ class Trace(val inst: Instrumentation, out: PrintOut)
lazy val methodSign = "%1$s.%2$s(%3$s)".format(
simpleNameOf(context.className),
context.methodName,
- context.arguments.map(o => simpleNameOf(o.getClass)).mkString(", ")
+ Type.getArgumentTypes(context.descriptor).map(t => simpleNameOf(t.getClassName)).mkString(", ")
)
lazy val loader = if (context.loader == null) "BootClassLoader" else context.loader.toString
@@ -124,7 +125,7 @@ class Trace(val inst: Instrumentation, out: PrintOut)
this.context.className == context.className &&
this.context.methodName == context.methodName &&
this.context.arguments.size == context.arguments.size &&
- this.context.arguments.map(_.getClass) == context.arguments.map(_.getClass) &&
+ this.context.descriptor == context.descriptor &&
this.context.thisObject == context.thisObject
def reps(maxMethodSignLength: Int, maxClassLoaderLength: Int) =
@@ -36,6 +36,7 @@
public static final String VOID_RETURN = "voidReturn";
public static final String THIS = "this";
public static final String ARGUMENTS = "arguments";
+ public static final String DESCRIPTOR = "descriptor";
public static final String STACK = "stack";
public static final String STARTED = "started";
public static final String STOPPED = "stopped";
@@ -84,6 +85,7 @@ public static void onMethodBegin(String className, String methodName, String des
context.put(VOID_RETURN, isVoidReturn(descriptor));
context.put(THIS, thisObject);
context.put(ARGUMENTS, arguments);
+ context.put(DESCRIPTOR, descriptor);
context.put(STACK, currentStackTrace());
context.put(STARTED, System.currentTimeMillis());
context.put(THREAD, Thread.currentThread());
@@ -25,6 +25,7 @@ case class Context(
methodName: String,
loader: ClassLoader,
arguments: Array[AnyRef],
+ descriptor: String,
isVoidReturn: Boolean,
thisObject: AnyRef,
started: Long,
@@ -44,6 +45,7 @@ object Context {
map.get(Advice.METHOD).asInstanceOf[String],
map.get(Advice.CLASS_LOADER).asInstanceOf[ClassLoader],
map.get(Advice.ARGUMENTS).asInstanceOf[Array[AnyRef]],
+ map.get(Advice.DESCRIPTOR).asInstanceOf[String],
map.get(Advice.VOID_RETURN).asInstanceOf[Boolean],
map.get(Advice.THIS),
map.get(Advice.STARTED).asInstanceOf[Long],

0 comments on commit 4872157

Please sign in to comment.