I am trying to profile a Java application using DTrace on macOS Sierra 10.12. I am using JDK8:
โ> ~ java -version java version "1.8.0_102" Java(TM) SE Runtime Environment (build 1.8.0_102-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode) โ> ~ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home
My ultimate goal is to trace all the entries and outputs of the Java method for specific packages.
DTrace Probes on the HotSpot VM and Mac OS X Port using HotSpot DTrace Probes seem to suggest that this should actually be supported on macOS. However, even when my Java application is running, there are no hotspot probes available and jstack() crashes:
โ> ~ pgrep java 24564 โ> ~ sudo dtrace -ln 'hotspot*:::' dtrace: system integrity protection is on, some features will not be available ID PROVIDER MODULE FUNCTION NAME dtrace: failed to match hotspot*:::: No probe matches description โ> ~ sudo dtrace -n 'syscall::read:entry /execname == "java"/ { jstack(); }' dtrace: system integrity protection is on, some features will not be available dtrace: description 'syscall::read:entry ' matched 1 probe dtrace: error on enabled probe ID 1 (ID 153: syscall::read:entry): invalid address (0xe2e3275e) in action
Providing the path to libjvm.dylib with the libjvm.dylib command dtrace not help:
โ> ~ ll "$JAVA_HOME/jre/lib/server/" total 31616 -rw-rw-r-- 1 root wheel 1.4K Jun 22 15:02 Xusage.txt -rwxrwxr-x 1 root wheel 15K Jun 22 15:01 libjsig.dylib -rwxrwxr-x 1 root wheel 15M Jun 22 15:02 libjvm.dylib โ> ~ sudo dtrace -L "$JAVA_HOME/jre/lib/server/" -ln 'hotspot*:::' dtrace: system integrity protection is on, some features will not be available ID PROVIDER MODULE FUNCTION NAME dtrace: failed to match hotspot*:::: No probe matches description
So what am I missing? How to profile a Java application using DTrace tools?
source share