如何从 Java 调用本机 C 代码获取更多调试信息
我不是 Java 程序员,但我编写(并测试)了一个从 Java JNI/Swig 调用的 C 库。最近,当从 Java 调用时它会崩溃,而它曾经工作正常。我正在努力寻找有关崩溃的任何有意义的信息。 我得到一个 hs_err_pid153408.log 文件,其中包含大量(1100 行)无用的内容。
里面说生成了一个核心文件,但事实并非如此。那么有没有办法让Java保存核心文件,然后我可以用gdb查看?
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to //core.153408)
然后在该日志文件中,对 C 代码的唯一引用是:
# C [libc.so.6+0x19557c] __strlen_evex+0x1c
但这没有帮助。如何获得 C 代码的完整回溯,而不仅仅是 Java 代码?是的,我在调试选项打开的情况下进行编译。 谢谢
I'm no Java programmer but I wrote (and tested) a C library called from Java JNI/Swig. Lately it crashes when called from Java and it used to work fine. I'm struggling to find any meaningful info about the crashes.
I get a hs_err_pid153408.log file with tons (1100 lines) of useless content in it.
Inside it says a core file was generated, but that is not true. So is there a way to get Java to save a core file I can then look through with gdb ?
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to //core.153408)
Then in that log file the only reference to the C code is this:
# C [libc.so.6+0x19557c] __strlen_evex+0x1c
But that's no help. How can I get a complete backtrace of the C code, not just the Java ? Yes, I compile with debugging options ON.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的解决方案是调用 coredumpctl debug 来启动带有最新核心转储的 gdb(还有其他选项)。
就像@user253751所说,您可能必须增加
/etc/systemd/coredump.conf
中的转储大小Simplest solution is to invoke
coredumpctl debug
to launchgdb
with the latest core dump (there are other options).Like @user253751 said, you may have to increase the dump size in
/etc/systemd/coredump.conf