8224672: (lib)hsdis-<arch>.so search incorrect after JDK-8213084
authorlucy
Tue, 28 May 2019 09:41:20 +0200
changeset 55051 fb9758536458
parent 55050 feba48c5dfb4
child 55052 05a408cbd945
8224672: (lib)hsdis-<arch>.so search incorrect after JDK-8213084 Reviewed-by: kvn, shade
src/hotspot/share/compiler/disassembler.cpp
--- a/src/hotspot/share/compiler/disassembler.cpp	Tue May 28 12:01:52 2019 +0530
+++ b/src/hotspot/share/compiler/disassembler.cpp	Tue May 28 09:41:20 2019 +0200
@@ -774,13 +774,14 @@
     // Match "[lib]jvm[^/]*" in jvm_path.
     const char* base = buf;
     const char* p = strrchr(buf, *os::file_separator());
+    if (p != NULL) lib_offset = p - base + 1; // this points to the first char after separator
 #ifdef _WIN32
     p = strstr(p ? p : base, "jvm");
+    if (p != NULL) jvm_offset = p - base;     // this points to 'j' in jvm.
 #else
     p = strstr(p ? p : base, "libjvm");
+    if (p != NULL) jvm_offset = p - base + 3; // this points to 'j' in libjvm.
 #endif
-    if (p != NULL) lib_offset = p - base + 1;
-    if (p != NULL) jvm_offset = p - base;
   }
 #endif
 
@@ -794,11 +795,13 @@
     // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
     strcpy(&buf[jvm_offset], hsdis_library_name);
     strcat(&buf[jvm_offset], os::dll_file_extension());
+    if (Verbose) st->print_cr("Trying to load: %s", buf);
     _library = os::dll_load(buf, ebuf, sizeof ebuf);
     if (_library == NULL && lib_offset >= 0) {
       // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
       strcpy(&buf[lib_offset], hsdis_library_name);
       strcat(&buf[lib_offset], os::dll_file_extension());
+      if (Verbose) st->print_cr("Trying to load: %s", buf);
       _library = os::dll_load(buf, ebuf, sizeof ebuf);
     }
     if (_library == NULL && lib_offset > 0) {
@@ -809,6 +812,7 @@
         lib_offset = p - buf + 1;
         strcpy(&buf[lib_offset], hsdis_library_name);
         strcat(&buf[lib_offset], os::dll_file_extension());
+        if (Verbose) st->print_cr("Trying to load: %s", buf);
         _library = os::dll_load(buf, ebuf, sizeof ebuf);
       }
     }
@@ -817,6 +821,7 @@
     // 4. hsdis-<arch>.so  (using LD_LIBRARY_PATH)
     strcpy(&buf[0], hsdis_library_name);
     strcat(&buf[0], os::dll_file_extension());
+    if (Verbose) st->print_cr("Trying to load: %s via LD_LIBRARY_PATH or equivalent", buf);
     _library = os::dll_load(buf, ebuf, sizeof ebuf);
   }