So I am introducing myself to btrace but currently I am getting no output out of it. With this script :
package com.sun.btrace.samples;
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class AllLines {
@OnMethod(
clazz="/.*/",
location=@Location(value=Kind.LINE, line=-1)
)
public static void online(@ProbeClassName String pcn, @ProbeMethodName String pmn, int line) {
print(Strings.strcat(pcn, "."));
print(Strings.strcat(pmn, ":"));
println(line);
}
}
This come straight from the samples directory, just changed the "clazz="/.*/"," out of desperation to get something printed out. No luck.
The pid I am pointing btrace at is a simple java program I developped just for testing purpose which calls a certain method on a loop. I am running it through Eclipse.
Any ideas what i could be missing ? Thanks!
Update: Turned on debug mode to find out it is hanging at "debug: checking port availability: 2020 ". Any ideas ?
Are the classes you are trying to trace compiled with javac -g
or at least javac -g:lines
? You need to do that in order to be able to access the line number information in the bytecode.
Additionally - enabling line tracing for all methods of all classes is a really Bad Idea(tm). You will cause a huge number of class retransformations and reloadings and with a bit of bad luck you can shoot your application down (due to memory problems).