7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
Do explicit lookup emulating old LD_LIBRARY_PATH search Reviewed-by: kvn, jrose
This commit is contained in:
parent
d23654d851
commit
d57ae98564
@ -75,8 +75,16 @@ will build the Win32 cross compiled version of hsdis based on 2.19.1.
|
|||||||
* Installing
|
* Installing
|
||||||
|
|
||||||
Products are named like build/$OS-$LIBARCH/hsdis-$LIBARCH.so. You can
|
Products are named like build/$OS-$LIBARCH/hsdis-$LIBARCH.so. You can
|
||||||
install them on your LD_LIBRARY_PATH, or inside of your JRE next to
|
install them on your LD_LIBRARY_PATH, or inside of your JRE/JDK. The
|
||||||
$LIBARCH/libjvm.so.
|
search path in the JVM is:
|
||||||
|
|
||||||
|
1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
|
||||||
|
2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
|
||||||
|
3. <home>/jre/lib/<arch>/hsdis-<arch>.so
|
||||||
|
4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
|
||||||
|
|
||||||
|
Note that there's a bug in hotspot versions prior to hs22 that causes
|
||||||
|
steps 2 and 3 to fail when used with JDK7.
|
||||||
|
|
||||||
Now test:
|
Now test:
|
||||||
|
|
||||||
|
@ -78,21 +78,46 @@ bool Disassembler::load_library() {
|
|||||||
char buf[JVM_MAXPATHLEN];
|
char buf[JVM_MAXPATHLEN];
|
||||||
os::jvm_path(buf, sizeof(buf));
|
os::jvm_path(buf, sizeof(buf));
|
||||||
int jvm_offset = -1;
|
int jvm_offset = -1;
|
||||||
|
int lib_offset = -1;
|
||||||
{
|
{
|
||||||
// Match "jvm[^/]*" in jvm_path.
|
// Match "jvm[^/]*" in jvm_path.
|
||||||
const char* base = buf;
|
const char* base = buf;
|
||||||
const char* p = strrchr(buf, '/');
|
const char* p = strrchr(buf, '/');
|
||||||
|
if (p != NULL) lib_offset = p - base + 1;
|
||||||
p = strstr(p ? p : base, "jvm");
|
p = strstr(p ? p : base, "jvm");
|
||||||
if (p != NULL) jvm_offset = p - base;
|
if (p != NULL) jvm_offset = p - base;
|
||||||
}
|
}
|
||||||
|
// Find the disassembler shared library.
|
||||||
|
// Search for several paths derived from libjvm, in this order:
|
||||||
|
// 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so (for compatibility)
|
||||||
|
// 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
|
||||||
|
// 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
|
||||||
|
// 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
|
||||||
if (jvm_offset >= 0) {
|
if (jvm_offset >= 0) {
|
||||||
// Find the disassembler next to libjvm.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());
|
||||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||||
|
if (_library == NULL) {
|
||||||
|
// 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
|
||||||
|
strcpy(&buf[lib_offset], hsdis_library_name);
|
||||||
|
strcat(&buf[lib_offset], os::dll_file_extension());
|
||||||
|
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||||
}
|
}
|
||||||
if (_library == NULL) {
|
if (_library == NULL) {
|
||||||
// Try a free-floating lookup.
|
// 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
|
||||||
|
buf[lib_offset - 1] = '\0';
|
||||||
|
const char* p = strrchr(buf, '/');
|
||||||
|
if (p != NULL) {
|
||||||
|
lib_offset = p - buf + 1;
|
||||||
|
strcpy(&buf[lib_offset], hsdis_library_name);
|
||||||
|
strcat(&buf[lib_offset], os::dll_file_extension());
|
||||||
|
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_library == NULL) {
|
||||||
|
// 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());
|
||||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||||
@ -249,7 +274,13 @@ address decode_env::handle_event(const char* event, address arg) {
|
|||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
} else if (match(event, "mach")) {
|
} else if (match(event, "mach")) {
|
||||||
|
static char buffer[32] = { 0, };
|
||||||
|
if (strcmp(buffer, (const char*)arg) != 0 ||
|
||||||
|
strlen((const char*)arg) > sizeof(buffer) - 1) {
|
||||||
|
// Only print this when the mach changes
|
||||||
|
strncpy(buffer, (const char*)arg, sizeof(buffer) - 1);
|
||||||
output()->print_cr("[Disassembling for mach='%s']", arg);
|
output()->print_cr("[Disassembling for mach='%s']", arg);
|
||||||
|
}
|
||||||
} else if (match(event, "format bytes-per-line")) {
|
} else if (match(event, "format bytes-per-line")) {
|
||||||
_bytes_per_line = (int) (intptr_t) arg;
|
_bytes_per_line = (int) (intptr_t) arg;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user