无法将HSDIS与OpenJDK 11一起使用

时间:2019-05-12 17:44:49

标签: java ubuntu java-11 jvm-hotspot

所以我正在尝试使用openJDK-11构建/使用hsdis。如果我尝试使用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的build文件夹中,netbeans将拒绝确认它存在于该文件夹中。我已经在netbeans中设置了OpenJDK并生成了slowdebug构建。我尝试逐步运行它以查看hsdis的确切搜索位置,令我惊讶的是它确实位于我放置文件的文件夹中,但是仍然没有显示该文件或目录。对我来说那个文件夹是

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

我正在使用VMWare并运行Ubuntu 18.04。有什么想法我可以做什么?

1 个答案:

答案 0 :(得分:1)

  

我尝试使用binutils 2.29、2.30、2.31和2.32构建它。他们都遇到了相同的错误。

您拥有的源版本不适用于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;