8224672: (lib)hsdis-<arch>.so search incorrect after JDK-8213084

Reviewed-by: kvn, shade
This commit is contained in:
Lutz Schmidt 2019-05-28 09:41:20 +02:00
parent da85e43f56
commit 910fa9ad50

View File

@ -774,13 +774,14 @@ bool Disassembler::load_library(outputStream* st) {
// Match "[lib]jvm[^/]*" in jvm_path. // Match "[lib]jvm[^/]*" in jvm_path.
const char* base = buf; const char* base = buf;
const char* p = strrchr(buf, *os::file_separator()); 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 #ifdef _WIN32
p = strstr(p ? p : base, "jvm"); p = strstr(p ? p : base, "jvm");
if (p != NULL) jvm_offset = p - base; // this points to 'j' in jvm.
#else #else
p = strstr(p ? p : base, "libjvm"); p = strstr(p ? p : base, "libjvm");
if (p != NULL) jvm_offset = p - base + 3; // this points to 'j' in libjvm.
#endif #endif
if (p != NULL) lib_offset = p - base + 1;
if (p != NULL) jvm_offset = p - base;
} }
#endif #endif
@ -794,11 +795,13 @@ bool Disassembler::load_library(outputStream* st) {
// 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
strcpy(&buf[jvm_offset], hsdis_library_name); strcpy(&buf[jvm_offset], hsdis_library_name);
strcat(&buf[jvm_offset], os::dll_file_extension()); 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); _library = os::dll_load(buf, ebuf, sizeof ebuf);
if (_library == NULL && lib_offset >= 0) { if (_library == NULL && lib_offset >= 0) {
// 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
strcpy(&buf[lib_offset], hsdis_library_name); strcpy(&buf[lib_offset], hsdis_library_name);
strcat(&buf[lib_offset], os::dll_file_extension()); 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); _library = os::dll_load(buf, ebuf, sizeof ebuf);
} }
if (_library == NULL && lib_offset > 0) { if (_library == NULL && lib_offset > 0) {
@ -809,6 +812,7 @@ bool Disassembler::load_library(outputStream* st) {
lib_offset = p - buf + 1; lib_offset = p - buf + 1;
strcpy(&buf[lib_offset], hsdis_library_name); strcpy(&buf[lib_offset], hsdis_library_name);
strcat(&buf[lib_offset], os::dll_file_extension()); 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); _library = os::dll_load(buf, ebuf, sizeof ebuf);
} }
} }
@ -817,6 +821,7 @@ bool Disassembler::load_library(outputStream* st) {
// 4. hsdis-<arch>.so (using LD_LIBRARY_PATH) // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
strcpy(&buf[0], hsdis_library_name); strcpy(&buf[0], hsdis_library_name);
strcat(&buf[0], os::dll_file_extension()); 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); _library = os::dll_load(buf, ebuf, sizeof ebuf);
} }