diff src/share/tools/hsdis/hsdis.c @ 23352:3848113e3e6b

Update hsdis binaries
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 19 Apr 2016 23:28:22 -0700
parents 52b4284cb496
children
line wrap: on
line diff
--- 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, ',');