Tracing simple program on Windows

  3 posts   Feedicon  
Replies: 2 - Last Post: July 15, 2009 18:25
by: Rahul.Joshi
showing 1 - 3 of 3
 
Posted: July 12, 2009 03:20 by Rahul.Joshi
Hi,

I wrote a simple program to see BTrace in action on Windows with JDK 1.6.0_14.

Here's the program to be traced:


public class DoCurrentTimeMillis {

public static void main(String[] args) {
while (true) {
System.out.println("Hello World at " + System.currentTimeMillis());
}
}
}


Here's the BTrace script (CurrentTimeMillis.java):


import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;

@BTrace
public class CurrentTimeMillis {

@OnMethod(clazz="java.lang.System", method="currentTimeMillis")
public static void onCurrentTimeMillisReturn() {
println("The System.currentTimeMillis() is called!");
}
}


On running the DoCurrentTimeMillis.java program first, then BTrace as follows, I get the following:

C:\tools\btracedemo\exercises\ex0> btrace.bat 5528 CurrentTimeMillis.java
DEBUG: btrace debug mode is set
DEBUG: btrace unsafe mode is set
DEBUG: dumpClasses flag is set
DEBUG: dumpDir is .
DEBUG: assuming default port 2020
DEBUG: assuming default classpath '.'
DEBUG: compiling CurrentTimeMillis.java
DEBUG: compiled CurrentTimeMillis.java
DEBUG: attaching to 5528
DEBUG: attached to 5528
DEBUG: loading C:\tools\btrace-bin\build\btrace-agent.jar
DEBUG: agent args: port=2020,debug=true,unsafe=true,dumpClasses=true,dumpDir=.,systemClassPath=C:\Progra~1\Java\jdk1.6.0_14\lib\tools.jar,probeDescPat
h=.
DEBUG: loaded C:\tools\btrace-bin\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: sending instrument command
DEBUG: entering into command loop
DEBUG: received com.sun.btrace.comm.OkayCommand@10e3293


So, the result is that there is no output printed. Also tried location = @Location(Kind.RETURN)

I also tried using the VisualVM BTrace plugin but still no output.

Note that I enabled debuggin in btrace/btrace.bat

Thanks,
Rahul

 
Posted: July 13, 2009 15:05 by sundararajana
Hi Rahul, System.currentTimeMillis() is a native method. BTrace currently does not support tracing native methods. But, it may be feasible to support tracing native methods using native method prefixing support of java.lang.instrument.
(http://java.sun.com/javase/6/docs/api/java/lang/instrument/Instrumentation.html#isNativeMethodPrefixSupported%28%29). I think this is a good candidate for an RFE with BTrace.
 
Posted: July 15, 2009 18:25 by Rahul.Joshi
Thanks Sundararajan.
Replies: 2 - Last Post: July 15, 2009 18:25
by: Rahul.Joshi
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close