DTrace 使用 ustack() 丢失 Java 帧。在 Joyent SmartOS 基础架构容器上运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38413802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DTrace missing Java frames with ustack(). Running on Joyent SmartOS infrastructure container
提问by Gamlor
I cannot get any Java stack with dtrace in a Joyent SmartOS instance.
我无法在 Joyent SmartOS 实例中使用 dtrace 获取任何 Java 堆栈。
I tried the java:15.1.1
image and a plain SmartOS 'base64' image, where I installed openjdk 8.
我尝试了java:15.1.1
图像和普通的 SmartOS 'base64' 图像,我在其中安装了 openjdk 8。
I most basic example: cat Loop.java
我最基础的例子: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
I added the libdtrace_forceload.so
as recommended.
我添加了libdtrace_forceload.so
作为推荐。
export LD_AUDIT_64=/usr/lib/dtrace/64/libdtrace_forceload.so
It is a 64 bit JVM:
它是一个 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)
When I run dtrace, and use jstack, I get the C-stacks. However, the JAVA frames are the raw addresses, quite useless:
当我运行 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*
I do see hotspot probes are available:
我确实看到有可用的热点探针:
[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
Question: Is there a way to list ustack helpers and if they are loaded? Any way to get the Java stack?
问题:有没有办法列出 ustack helper 以及它们是否已加载?有没有办法获得Java堆栈?
采纳答案by Joshua M. Clulow
In your example with untranslated Java stack frames, you appear to be using the ustack()
action. In order to get translatedframes, I believe you ought to be using the jstack()
action instead.
在您使用未翻译的 Java 堆栈帧的示例中,您似乎正在使用该ustack()
操作。为了获得翻译的帧,我相信您应该改用jstack()
动作。