views:

573

answers:

3

My Leopard system has dtrace built in. I also have Java 6 installed, using the Apple-provided installer:

$ java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode)

Nevertheless, dtrace shows no hotspot probes when listing probes:

$ sudo dtrace -l | grep spot
$

Can anybody tell me how to enable dtrace probes for Java (supposedly they ship with Java 6) in Leopard?

A: 

Are you sure this applies to the Apple JVM as well? While the DTrace hooks are mentioned in the document about JDK 6, you can also find on Non-standard Java HotSpot VM Options (emphasis added):

-XX:-ExtendedDTraceProbes Enable performance-impacting dtrace probes.
(Introduced in 6. Relevant to Solaris only.)

Not a good sign if this is platform specific. AFAIK Apple builds its own custom-made JVM.

ShiDoiSi
Good point. Looks indeed like only Sun's JDK supports dtrace. OpenJDK has support planned but not yet implemented it seems. Probably the same holds for Apple's implementation.
+1  A: 

I'm running Snow Leopard with Java 1.6, and I can see the hotspot probes:

...

43223 hotspot_jni3644   libclient.dylib                   jni_AllocObject AllocObject-entry
43224 hotspot_jni3644   libclient.dylib                   jni_AllocObject AllocObject-return
43225 hotspot_jni3644   libclient.dylib           jni_AttachCurrentThread AttachCurrentThread-entry
43226 hotspot_jni3644   libclient.dylib           jni_AttachCurrentThread AttachCurrentThread-return
43227 hotspot_jni3644   libclient.dylib   jni_AttachCurrentThreadAsDaemon AttachCurrentThreadAsDaemon-entry
43228 hotspot_jni3644   libclient.dylib   jni_AttachCurrentThreadAsDaemon AttachCurrentThreadAsDaemon-return
43229 hotspot_jni3644   libclient.dylib             jni_CallBooleanMethod CallBooleanMethod-entry
43230 hotspot_jni3644   libclient.dylib             jni_CallBooleanMethod CallBooleanMethod-return

...

Alex Brown
Hmm, interesting. I am running the same configurations but for me the probes do not show up. What command line did you use? Also "sudo dtrace -l | grep spot" ?
'sudo dtrace -l | grep hotspot' does it.
Noah Campbell
+4  A: 

" Hmm, interesting. I am running the same configurations but for me the probes do not show up. What command line did you use? Also "sudo dtrace -l | grep spot" ? "

  • Just one cross check. You should have a running java application at the time when you issue "sudo dtrace -l | grep spot". Only then the probes will be listed.
Ramsundar Kandasamy
No, I did not have Java running. Indeed it is working now. Thanks!
The probes are named like `hotspot_jni5867`, meaning that the process id is included in the probe name. The probes are dynamically created when a process is started.
Thorbjørn Ravn Andersen