无法将 HSDIS 与 OpenJDK 11 一起使用

Unable to use HSDIS with OpenJDK 11

所以我正在尝试 build/use hsdis with openJDK-11。如果我尝试使用 binutils 构建它,我会收到以下错误:

hsdis.c:316:32: error: incompatible type for argument 1 of ‘disassembler'
app_data->dfn = disassembler(native_bfd);

hsdis.c:316:19: error: too few arguments to function ‘disassembler’
app_data->dfn = disassembler(native_bfd);

我尝试使用 binutils 2.29、2.30、2.31 和 2.32 构建它。所有这些都出现了同样的错误。

如果我从 JDK-8 中取出一个预构建的二进制文件并将其放入我的 JDK 构建文件夹中,netbeans 拒绝承认它存在于该文件夹中。我在 netbeans 中设置了 OpenJDK 并生成了一个 slowdebug 构建。我尝试 运行 逐步查看正在搜索 hsdis 的确切位置,令我惊讶的是它确实在我放置文件的文件夹中查找,但它仍然说没有这样的文件或目录。对我来说那个文件夹是

home/ubuntu/jdk11u-dev/build/linux-x86_64-normal-server-slowdebug/images/jdk/lib/server

我正在使用 VMWare 和 运行 Ubuntu 18.04。有什么想法吗?

I have tried building it with binutils 2.29, 2.30, 2.31 and 2.32. Got same error with all of them.

您拥有的源代码版本不适用于 binutils 2.29+。 jdk/jdk 有一个补丁可以纠正这个问题。请参阅:https://bugs.openjdk.java.net/browse/JDK-8191006 其中建议对 hsdis.c 进行以下修复:

diff --git a/src/share/tools/hsdis/hsdis.c b/src/share/tools/hsdis/hsdis.c
index 3d038f1..88122fb 100644
--- a/src/share/tools/hsdis/hsdis.c
+++ b/src/share/tools/hsdis/hsdis.c
@@ -30,6 +30,7 @@
 #include <config.h> /* required by bfd.h */
 #include <libiberty.h>
 #include <bfd.h>
+#include <bfdver.h>
 #include <dis-asm.h>
 #include <inttypes.h>
 #include <string.h>
@@ -312,7 +313,13 @@ static void setup_app_data(struct hsdis_app_data* app_data,

  /* Finish linking together the various callback blocks. */
  app_data->dinfo.application_data = (void*) app_data;
- app_data->dfn = disassembler(native_bfd);
+ app_data->dfn = disassembler(
+#if BFD_VERSION >= 229000000
+ bfd_get_arch(native_bfd),
+ bfd_big_endian(native_bfd),
+ bfd_get_mach(native_bfd),
+#endif
+ native_bfd);
  app_data->dinfo.print_address_func = hsdis_print_address_func;
  app_data->dinfo.read_memory_func = hsdis_read_memory_func;