-
Notifications
You must be signed in to change notification settings - Fork 963
Description
Greetings!
I think I figured out a way to trace all object allocations, unfortunately I'm not sure the results are entirely correct : there are several stack overflows reported. I tried playing with -Xss and -XX:ThreadStackSize to see if I could get rid of them, but it wont.
@OnMethod(clazz="+java.lang.Object",
method="<init>")
public static void onNewThing(@Self Object o,
@ProbeClassName String pcn) {
if (!enabled)
return;
Class objectClass = Reflective.classOf(o);
String objectClassString = Reflective.name(objectClass);
if (Strings.compareTo(pcn, objectClassString) == 0) {
print(pcn);
print('\t');
println(Strings.str(sizeof(o)));
}
}The full script is at https://gist.github.com/mrzor/4486f49eced97bba18fb32557090cd53
(The pcn to objectClassString comparison hack is to avoid printing several lines for the same Object, when I'm only interested in the XXX part of XXX extends YYY extends Object)
I believe the stack overflows are happening during instrumentation - when I run btracer with the -d debug flag, they happen in the middle of it.
Exception: java.lang.StackOverflowError thrown from the UncaughtExceptionHandler in thread "Thread-3"
Exception: java.lang.StackOverflowError thrown from the UncaughtExceptionHandler in thread "BTrace FileClient Flusher"
Without surprise, the output is truncated, and I have no certainty as to whether or not all classes were instrumented.
Any help appreciated :)