如何确定OpenJDK是否安装了调试符号 [英] How to Determine Whether OpenJDK Installed with Debugging Symbols

查看:258
本文介绍了如何确定OpenJDK是否安装了调试符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为RedHat Linux Server 8+中的体系结构安装了相同的主要/次要版本的openjdk-developenjdk-devel-debuginfo.我想确保OpenJDK运行时具有用于调试的符号.安装后,我执行以下操作:

I installed openjdk-devel and openjdk-devel-debuginfo of the same major/minor version for an architecture in RedHat Linux Server 8+. I would like to make sure that the OpenJDK runtime has symbols for debugging. After installation, I ran the followings:

[root@localhost bin]# objdump --syms /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/jre/bin/java

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/jre/bin/java:     file format elf64-x86-64

SYMBOL TABLE:
0000000000000270 l    d  .interp    0000000000000000              .interp
0000000000000290 l    d  .note.gnu.property 0000000000000000              .note.gnu.property
00000000000002b0 l    d  .note.ABI-tag  0000000000000000              .note.ABI-tag
00000000000002d0 l    d  .note.gnu.build-id 0000000000000000              .note.gnu.build-id
00000000000002f8 l    d  .hash  0000000000000000              .hash
0000000000000348 l    d  .gnu.hash  0000000000000000              .gnu.hash
0000000000000370 l    d  .dynsym    0000000000000000              .dynsym
....
....
....

[root@localhost etc]# file /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/jre/bin/java: 
ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=613871d1514ba05fa2914c22c10f1dfe01d3d2e8, not stripped


[root@localhost bin]# objdump --syms /usr/lib/debug/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/bin/java-1.8.0.242.b08-0.el8_1.x86_64.debug

/usr/lib/debug/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/bin/java-1.8.0.242.b08-0.el8_1.x86_64.debug:     file format elf64-x86-64

SYMBOL TABLE:
no symbols

[root@localhost bin]# file /usr/lib/debug/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/bin/java-1.8.0.242.b08-0.el8_1.x86_64.debug
/usr/lib/debug/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/bin/java-1.8.0.242.b08-0.el8_1.x86_64.debug: 
ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter \004, for GNU/Linux 3.2.0, BuildID[sha1]=613871d1514ba05fa2914c22c10f1dfe01d3d2e8, with debug_info, not stripped

如上所述,我看到javaobjdump打印出了某种符号表,但是我读过,在输出中也应该寻找.debug*,这在我中没有看到. SYMBOL TABLE部分的其余部分(为简洁起见,在上面的输出中省略了几十行).

As the above suggests, I see the objdump for java prints out some sort of symbol table, but I had read that one should also look for .debug* in the output, which I'm not seeing in the remaining of SYMBOL TABLE section (a few dozens of lines omitted from above output for brevity).

我看到file表示with debug_info,但是我需要确认Java安装中确实包含符号.

I see the file for /usr/lib/debug/..../java...debug says with debug_info, but I need confirmation that the Java installation does have symbols.

推荐答案

java可执行文件只是简单启动器 .您在那里找不到JVM符号.

java executable is just a simple launcher. You won't find JVM symbols there.

要查看JVM是否具有调试符号,请改为检查libjvm.so:

To see if JVM has debug symbols, check libjvm.so instead:

nm /usr/lib/jvm/jre/lib/amd64/server/libjvm.so


我的最终目标是在服务器旁边加载一个malloc探查器, 尝试跟踪本机内存分配.在这种情况下,如果 追溯到JVM,我需要知道正在调用哪个方法.

My ultimate goal is to load a malloc profiler alongside my server and try to trace the native memory allocations. In this case, if the calls are traced back to JVM, I need to know which method is getting called.

好吧,如果您是从这个问题开始的,那么您就不会陷入

Well, if you'd started with this question, you wouldn't have fallen into XY problem trap.

即使使用JVM调试符号,本机内存分析器(例如jemalloc)也无法显示Java方法.他们根本不知道如何解散Java堆栈,因此跟踪可能会在一些随机的十六进制地址处中断,例如这个问题.

Even with JVM debug symbols, native memory profilers (e.g. jemalloc) cannot show Java methods. They simply don't know how to unwind Java stack, so the traces will likely break at some random hex addresses, like in this question.

我建议尝试 async-profiler 来配置mallocmprotectmmap调用.该工具可以显示混合的Java +本机堆栈跟踪. 这是使用async-profiler来分析本机分配的示例. 该视频还演示了异步配置文件可以帮助查找本机内存泄漏.

I'd suggest to try async-profiler to profile malloc, mprotect and mmap calls. This tool can show mixed Java+native stack traces. Here is an example of using async-profiler to profile native allocations. This video also demonstrates how async-profiler can help in finding native memory leaks.

这篇关于如何确定OpenJDK是否安装了调试符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆