changeset 23352:3848113e3e6b

Update hsdis binaries
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 19 Apr 2016 23:28:22 -0700
parents 1c62a8bac25a
children 55877421f72a
files mx.jvmci/mx_jvmci.py src/share/tools/hsdis/Makefile src/share/tools/hsdis/hsdis.c
diffstat 3 files changed, 75 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/mx.jvmci/mx_jvmci.py	Tue Apr 19 21:36:49 2016 -0700
+++ b/mx.jvmci/mx_jvmci.py	Tue Apr 19 23:28:22 2016 -0700
@@ -546,7 +546,11 @@
 
             # Install a copy of the disassembler library
             try:
-                hsdis([], copyToDir=vmLibDirInJdk(jdkDir))
+                hsdis_args = []
+                syntax = mx.get_env('HSDIS_SYNTAX')
+                if syntax:
+                    hsdis_args = [syntax]
+                hsdis(hsdis_args, copyToDir=vmLibDirInJdk(jdkDir))
             except SystemExit:
                 pass
     else:
@@ -1451,36 +1455,39 @@
 
     This is needed to support HotSpot's assembly dumping features.
     By default it downloads the Intel syntax version, use the 'att' argument to install AT&T syntax."""
-    flavor = 'intel'
-    if 'att' in args:
-        flavor = 'att'
-    if mx.get_arch() == "sparcv9":
-        flavor = "sparcv9"
-        osSuffix = mx.get_os() + '-'
-    else:
-        osSuffix = ''
-    lib = mx.add_lib_suffix('hsdis-' + osSuffix + mx.get_arch())
-    path = join(_suite.get_output_root(), lib)
+    flavor = None
+    if mx.get_arch() == "amd64":
+        flavor = 'intel'
+        if 'att' in args:
+            flavor = 'att'
+
+    libpattern = mx.add_lib_suffix('hsdis-' + mx.get_arch() + '-' + mx.get_os() + '-%s')
 
     sha1s = {
-        'att/hsdis-amd64.dll' : 'bcbd535a9568b5075ab41e96205e26a2bac64f72',
-        'att/hsdis-amd64.so' : '58919ba085d4ef7a513f25bae75e7e54ee73c049',
-        'intel/hsdis-amd64.dll' : '6a388372cdd5fe905c1a26ced614334e405d1f30',
-        'intel/hsdis-amd64.so' : '844ed9ffed64fe9599638f29a8450c50140e3192',
-        'intel/hsdis-amd64.dylib' : 'fdb13ef0d7d23d93dacaae9c98837bea0d4fc5a2',
-        'sparcv9/hsdis-solaris-sparcv9.so': '970640a9af0bd63641f9063c11275b371a59ee60',
-        'sparcv9/hsdis-linux-sparcv9.so': '0c375986d727651dee1819308fbbc0de4927d5d9',
+        'att/hsdis-amd64-windows-%s.dll' : 'bcbd535a9568b5075ab41e96205e26a2bac64f72',
+        'att/hsdis-amd64-linux-%s.so' : '36a0b8e30fc370727920cc089f104bfb9cd508a0',
+        'att/hsdis-amd64-darwin-%s.dylib' : 'c1865e9a58ca773fdc1c5eea0a4dfda213420ffb',
+        'intel/hsdis-amd64-windows-%s.dll' : '6a388372cdd5fe905c1a26ced614334e405d1f30',
+        'intel/hsdis-amd64-linux-%s.so' : '0d031013db9a80d6c88330c42c983fbfa7053193',
+        'intel/hsdis-amd64-darwin-%s.dylib' : '67f6d23cbebd8998450a88b5bef362171f66f11a',
+        'hsdis-sparcv9-solaris-%s.so': '970640a9af0bd63641f9063c11275b371a59ee60',
+        'hsdis-sparcv9-linux-%s.so': '0c375986d727651dee1819308fbbc0de4927d5d9',
     }
 
-    flavoredLib = flavor + "/" + lib
+    if flavor:
+        flavoredLib = flavor + "/" + libpattern
+    else:
+        flavoredLib = libpattern
     if flavoredLib not in sha1s:
-        mx.logv("hsdis not supported on this plattform or architecture")
+        mx.warn("hsdis with flavor '{}' not supported on this plattform or architecture".format(flavor))
         return
 
+    sha1 = sha1s[flavoredLib]
+    lib = flavoredLib % (sha1)
+    path = join(_suite.get_output_root(), lib)
     if not exists(path):
-        sha1 = sha1s[flavoredLib]
         sha1path = path + '.sha1'
-        mx.download_file_with_sha1('hsdis', path, ['https://lafo.ssw.uni-linz.ac.at/pub/hsdis/' + flavoredLib], sha1, sha1path, True, True, sources=False)
+        mx.download_file_with_sha1('hsdis', path, ['https://lafo.ssw.uni-linz.ac.at/pub/hsdis/' + lib], sha1, sha1path, True, True, sources=False)
     if copyToDir is not None and exists(copyToDir):
         destFileName = mx.add_lib_suffix('hsdis-' + mx.get_arch())
         shutil.copy(path, copyToDir + os.sep + destFileName)
--- a/src/share/tools/hsdis/Makefile	Tue Apr 19 21:36:49 2016 -0700
+++ b/src/share/tools/hsdis/Makefile	Tue Apr 19 23:28:22 2016 -0700
@@ -142,6 +142,10 @@
 endif	# Linux
 endif	# SunOS
 
+ifneq ($(ATT_SYNTAX),)
+CFLAGS += -DATT_SYNTAX
+endif
+
 LIBARCH		= $(ARCH)
 ifdef		LP64
 LIBARCH64/sparc	= sparcv9
@@ -163,10 +167,15 @@
 endif
 
 CPPFLAGS	+= -I$(BINUTILSDIR)/include -I$(BINUTILSDIR)/bfd -I$(TARGET_DIR)/bfd
-CPPFLAGS	+= -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\"
+CPPFLAGS	+= -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\" -DBINUTILS="\"$(BINUTILS)\""
 
 TARGET_DIR	= build/$(OS)-$(JDKARCH)
-TARGET		= $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
+TARGET_LIBRARY  = hsdis-$(LIBARCH)$(LIB_EXT)
+ifeq ($(ALT_TARGET_DIR),)
+TARGET		= $(TARGET_DIR)/$(TARGET_LIBRARY)
+else
+TARGET		= $(ALT_TARGET_DIR)/$(TARGET_LIBRARY)
+endif
 
 SOURCE		= hsdis.c
 
@@ -203,5 +212,12 @@
 $(TARGET_DIR):
 	[ -d $@ ] || mkdir -p $@
 
+variants: att intel
+	make $(MAKEFLAGS) ALT_TARGET_DIR=intel 
+	make $(MAKEFLAGS) ALT_TARGET_DIR=att ATT_SYNTAX=1 all
+
+att intel:
+	mkdir $@
+
 clean:
 	rm -rf $(TARGET_DIR)
--- a/src/share/tools/hsdis/hsdis.c	Tue Apr 19 21:36:49 2016 -0700
+++ b/src/share/tools/hsdis/hsdis.c	Tue Apr 19 23:28:22 2016 -0700
@@ -70,6 +70,19 @@
   char insn_options[256];
 };
 
+#if defined(LIBARCH_i386) || defined(LIBARCH_amd64)
+#ifdef ATT_SYNTAX
+#define PLATFORM_OPTIONS "att"
+#else
+#define PLATFORM_OPTIONS "intel"
+#endif
+#else
+#define PLATFORM_OPTIONS ""
+#endif
+static const char* platform_options = PLATFORM_OPTIONS;
+
+const char* hsdis_version_string = "built from " BINUTILS " with disassembler options \"" PLATFORM_OPTIONS "\" on " __DATE__ " at " __TIME__;
+
 static void* decode(struct hsdis_app_data* app_data, const char* options);
 
 #define DECL_APP_DATA(dinfo) \
@@ -125,7 +138,7 @@
                     event_callback_t  event_callback_arg,  void* event_stream_arg,
                     printf_callback_t printf_callback_arg, void* printf_stream_arg,
                     const char* options) {
-  decode_instructions_virtual((uintptr_t)start_pv,
+  return decode_instructions_virtual((uintptr_t)start_pv,
                              (uintptr_t)end_pv,
                              (unsigned char*)start_pv,
                              (uintptr_t)end_pv - (uintptr_t)start_pv,
@@ -150,6 +163,8 @@
 
     (*event_callback)(event_stream, "insns", (void*)start);
 
+    (*event_callback)(event_stream, "options='%s'",
+                      (void*) app_data->insn_options);
     (*event_callback)(event_stream, "mach name='%s'",
                       (void*) app_data->arch_info->printable_name);
     if (app_data->dinfo.bytes_per_line != 0) {
@@ -205,6 +220,7 @@
 
   const char* type = "unknown";
   switch (itype) {
+  case dis_noninsn:
   case dis_nonbranch:   type = NULL;         break;
   case dis_branch:      type = "branch";     break;
   case dis_condbranch:  type = "condbranch"; break;
@@ -285,9 +301,14 @@
   */
   set_optional_callbacks(app_data);
 
+  memset(app_data->insn_options, 0, sizeof(app_data->insn_options));
+  if (platform_options != NULL) {
+    parse_caller_options(app_data, platform_options);
+  }
   /* Look into caller_options for anything interesting. */
-  if (caller_options != NULL)
+  if (caller_options != NULL) {
     parse_caller_options(app_data, caller_options);
+  }
 
   /* Discover which architecture we are going to disassemble. */
   app_data->arch_name = &app_data->mach_option[0];
@@ -385,6 +406,11 @@
   char* iop_base = app_data->insn_options;
   char* iop_limit = iop_base + sizeof(app_data->insn_options) - 1;
   char* iop = iop_base;
+
+  // Move to the end of any options already in the buffer
+  while (*iop != '\0' && iop < iop_limit) {
+    iop++;
+  }
   const char* p;
   for (p = caller_options; p != NULL; ) {
     const char* q = strchr(p, ',');