-
Notifications
You must be signed in to change notification settings - Fork 963
Description
Hi, i am a newbie of btrace.
I have written a script(Calls.java) to profile our app as follow:
import com.sun.btrace.AnyType;
import com.sun.btrace.annotations.;
import static com.sun.btrace.BTraceUtils.;
import com.sun.btrace.Profiler;
/**
-
- This script demonstrates the possibility to intercept
-
- method calls that are about to be executed from the body of
-
- a certain method. This is achieved by using the {@linkplain Kind#CALL}
-
* location value. -
*/
@btrace public class Calls {
@Property
private static Profiler swingProfiler = Profiling.newProfiler();
@OnMethod(clazz="/com\\.handwin\\.game\\.controller\\..*/", method="/.*/")
public static void entry(@ProbeMethodName(fqn=true) String probeMethod) { // all calls to the methods with signature "()"
//print(str(self) + " in " + probeMethod + ": ");
println("entry " + probeMethod);
Profiling.recordEntry(swingProfiler, probeMethod);
}
@OnMethod(clazz="/com\\.handwin\\.game\\.controller\\..*/", method="/.*/", location=@Location(value=Kind.RETURN))
public static void exit(@ProbeMethodName(fqn=true) String probeMethod, @Duration long duration) { // all calls to the methods with signature "()"
println("exit " + probeMethod);
Profiling.recordExit(swingProfiler, probeMethod, duration);
}
@onerror
public static void onError(Throwable t) {
print("btrace throw: ");
println(t);
}
@OnTimer(10000)
public static void timer() {
Profiling.printSnapshot("Swing performance profile", swingProfiler);
}
}
The script works well in verbose mode( export JAVA_HOME=/opt/jdk8 && ./bin/btrace -v 22967 Calls.java):
[faceshow@ip-10-1-40-222 btrace]$ export JAVA_HOME=/opt/jdk8 && ./bin/btrace -v 22967 Calls.java
DEBUG: assuming default port 2020
DEBUG: assuming default classpath '.'
DEBUG: compiling Calls.java
DEBUG: compiled Calls.java
DEBUG: attaching to 22967
DEBUG: checking port availability: 2020
DEBUG: attached to 22967
DEBUG: loading /opt/faceshow/btrace/build/btrace-agent.jar
DEBUG: agent args: port=2020,statsd=,debug=true,bootClassPath=.,systemClassPath=/opt/jdk8/jre/../lib/tools.jar,probeDescPath=.
DEBUG: loaded /opt/faceshow/btrace/build/btrace-agent.jar
DEBUG: registering shutdown hook
DEBUG: registering signal handler for SIGINT
DEBUG: submitting the BTrace program
DEBUG: opening socket to 2020
DEBUG: setting up client settings
DEBUG: sending instrument command
DEBUG: entering into command loop
DEBUG: received com.sun.btrace.comm.RenameCommand@43bd930a
DEBUG: received com.sun.btrace.comm.OkayCommand@33723e30
DEBUG: received com.sun.btrace.comm.RetransformationStartNotification@64f6106c
DEBUG: received com.sun.btrace.comm.OkayCommand@553a3d88
DEBUG: received com.sun.btrace.comm.MessageCommand@543c6f6d
entry public final java.util.Map com.handwin.game.controller.GameController$$EnhancerBySpringCGLIB$$c0ce67f0#getGames(javax.servlet.http.HttpServletRequest)
DEBUG: received com.sun.btrace.comm.MessageCommand@13eb8acf
entry public java.lang.Object com.handwin.game.controller.GameController$$FastClassBySpringCGLIB$$e44b30f2#invoke(int, java.lang.Object, java.lang.Object[])
DEBUG: received com.sun.btrace.comm.MessageCommand@51c8530f
entry public java.util.Map com.handwin.game.controller.GameController#getGames(javax.servlet.http.HttpServletRequest)
DEBUG: received com.sun.btrace.comm.MessageCommand@7403c468
entry private boolean com.handwin.game.controller.GameController#shouldBuy(javax.servlet.http.HttpServletRequest)
DEBUG: received com.sun.btrace.comm.MessageCommand@43738a82
entry private int com.handwin.game.controller.GameController#compareVersion(java.lang.String, java.lang.String)
DEBUG: received com.sun.btrace.comm.MessageCommand@c81cdd1
exit private int com.handwin.game.controller.GameController#compareVersion(java.lang.String, java.lang.String)
DEBUG: received com.sun.btrace.comm.MessageCommand@1fc2b765
exit private boolean com.handwin.game.controller.GameController#shouldBuy(javax.servlet.http.HttpServletRequest)
DEBUG: received com.sun.btrace.comm.MessageCommand@75881071
entry private boolean com.handwin.game.controller.GameController#shouldGetPlayerNum(javax.servlet.http.HttpServletRequest)
DEBUG: received com.sun.btrace.comm.MessageCommand@2a70a3d8
exit private boolean com.handwin.game.controller.GameController#shouldGetPlayerNum(javax.servlet.http.HttpServletRequest)
DEBUG: received com.sun.btrace.comm.MessageCommand@289d1c02
entry private void com.handwin.game.controller.GameController#lambda$getGames$0(com.handwin.game.entity.User, int, com.handwin.game.entity.vo.game.GameVo)
DEBUG: received com.sun.btrace.comm.MessageCommand@22eeefeb
exit private void com.handwin.game.controller.GameController#lambda$getGames$0(com.handwin.game.entity.User, int, com.handwin.game.entity.vo.game.GameVo)
DEBUG: received com.sun.btrace.comm.MessageCommand@17d0685f
entry private void com.handwin.game.controller.GameController#lambda$getGames$0(com.handwin.game.entity.User, int, com.handwin.game.entity.vo.game.GameVo)
DEBUG: received com.sun.btrace.comm.MessageCommand@3891771e
But if i remove -v, there is no output.
Could you guys shed light on me?