性能问答>如何从core文件里打印java 异常的栈轨迹?>
2回复
2年前

如何从core文件里打印java 异常的栈轨迹?



有一个用 C++ 编写的程序,是以 JNI 来启动 JVM 并运行 Java 代码。

现在程序崩溃并生成一个core 文件

但是当我通过 `gdb <my_program> 将core 与 gdb 连接时,只显示顶部的两个frame,其他frame是 “??”

(gdb) bt
#0  0x00007f635bf98596 in __memmove_avx_unaligned () from /var/lib/jenkins/Projects/libc.so.6
#1  0x00007f634aa1d142 in Unsafe_CopyMemory0 () from /RELEASE/BIN/Linux/_jre/lib/server/libjvm.so
#2  0x00007f63285c20a4 in ?? ()
#3  0x00000000000014ea in ?? ()
#4  0x00000000b5330948 in ?? ()
#5  0x0000000000000000 in ?? ()

一开始觉得那些“??”是 java 异常的栈轨迹,尝试打印了一下jstack <my_program> <core>,但错误如下

Error: More than one non-option argument
Cannot connect to the core dump or remote debug server. Use jhsdb jstack instead

于是再次试了jhsdb jstack --exe <my_pogram> --core <core>,但得到以下错误

Error attaching to core file: Can't attach to the core file
sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the core file
        at jdk.hotspot.agent/sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach0(Native Method)
        at jdk.hotspot.agent/sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:282)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:674)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:612)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:338)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:305)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:157)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:191)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.JStack.runWithArgs(JStack.java:90)
        at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJSTACK(SALauncher.java:297)
        at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:533)

各位大佬们,这些"??"是什么?怎么打印这些“??”

729 阅读
请先登录,查看2条精彩评论吧
快去登录吧,你将获得
  • 浏览更多精彩评论
  • 和开发者讨论交流,共同进步