1

我无法在 Joyent SmartOS 实例中使用 dtrace 获得任何 Java 堆栈。

我尝试了该java:15.1.1图像和一个普通的 SmartOS 'base64' 图像,我在其中安装了 openjdk 8。

我最基本的例子:cat Loop.java

[root@7e8c2a25-c852-4967-b60c-7b4fbd9a1de5 /demo]# cat Loop.java 
class Loop {

    public static void main(String[] args) throws InterruptedException {
        while (true) {
                System.out.println("Sleepy");
                Thread.sleep(2000);
        }
    }
}
[root@7e8c2a25-c852-4967-b60c-7b4fbd9a1de5 /demo]# javac Loop.java 
[root@7e8c2a25-c852-4967-b60c-7b4fbd9a1de5 /demo]# java Loop

libdtrace_forceload.so按照推荐添加了。

export LD_AUDIT_64=/usr/lib/dtrace/64/libdtrace_forceload.so

它是一个 64 位 JVM:

[root@7e8c2a25-c852-4967-b60c-7b4fbd9a1de5 /demo]# java -version
openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-pkgsrc_2015_05_29_19_05-b00)
OpenJDK 64-Bit Server VM (build 24.76-b04, mixed mode)

当我运行 dtrace 并使用 jstack 时,我得到了 C 堆栈。但是,JAVA 帧是原始地址,毫无用处:

[root@7e8c2a25-c852-4967-b60c-7b4fbd9a1de5 ~]# pgrep -fn "java Loop"
32597
[root@7e8c2a25-c852-4967-b60c-7b4fbd9a1de5 ~]# dtrace -n 'syscall:::entry/pid == 32597/ { @num[ustack(20)] = count(); }'
dtrace: description 'syscall:::entry' matched 237 probes
^C


              libc.so.1`__write+0xa
              libjvm.so`_ZN2os5writeEiPKvj+0x128
              libjvm.so`JVM_Write+0x34
              libjava.so`writeBytes+0x1b5
              libjava.so`Java_java_io_FileOutputStream_writeBytes+0x1f
              0xffffbf7ffa612d98
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa606058
              0xffffbf7ffa6004e7
              libjvm.so`_ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread+0x31d

*snip*

我确实看到热点探针可用:

[root@7e8c2a25-c852-4967-b60c-7b4fbd9a1de5 ~]# dtrace -l | grep hotspot | more
 6103 hotspot32597         libjvm.so     _ZN17VM_GenCollectFull4doitEv gc-begin
 6104 hotspot32597         libjvm.so _ZN15VM_GC_Operation13notify_gc_endEv gc-end
 6105 hotspot32597         libjvm.so _ZN26VM_GenCollectForAllocation4doitEv gc-end
 6106 hotspot32597         libjvm.so _ZN35VM_GenCollectForPermanentAllocation4doitEv gc-end
 6107 hotspot32597         libjvm.so     _ZN17VM_GenCollectFull4doitEv gc-end
 6132 hotspot32597         libjvm.so _ZN13instanceKlass15initialize_implE19instanceKlassHandleP6Thread class-initialization-end
 6133 hotspot32597         libjvm.so _ZN13instanceKlass15initialize_implE19instanceKlassHandleP6Thread class-initialization-erroneous
 6441 hotspot_jni32597         libjvm.so                jni_DeleteLocalRef DeleteLocalRef-entry
 6442 hotspot_jni32597         libjvm.so                jni_DeleteLocalRef DeleteLocalRef-return
 6443 hotspot_jni32597         libjvm.so           jni_DeleteWeakGlobalRef DeleteWeakGlobalRef-entry
 6444 hotspot_jni32597         libjvm.so           jni_DeleteWeakGlobalRef DeleteWeakGlobalRef-return
 6445 hotspot_jni32597         libjvm.so                 jni_DestroyJavaVM DestroyJavaVM-entry
 6446 hotspot_jni32597         libjvm.so                 jni_DestroyJavaVM DestroyJavaVM-return

问题:有没有办法列出 ustack 助手以及它们是否已加载?有什么方法可以获取 Java 堆栈?

4

1 回答 1

3

在您使用未翻译的 Java 堆栈帧的示例中,您似乎正在使用该ustack()操作。为了获得翻译帧,我相信你应该改用jstack()动作。

于 2016-07-17T20:34:56.890 回答