comparison src/share/vm/compiler/disassembler.cpp @ 3794:3e23978ea0c3

7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes Summary: do explicit lookup emulating old LD_LIBRARY_PATH search Reviewed-by: kvn, jrose
author never
date Wed, 06 Jul 2011 18:15:21 -0700
parents 167b70ff3abc
children 5a98bf7d847b b31471cdc53e 8c5333c80cfd
comparison
equal deleted inserted replaced
3793:fe240d87c6ec 3794:3e23978ea0c3
76 // Try to load it. 76 // Try to load it.
77 char ebuf[1024]; 77 char ebuf[1024];
78 char buf[JVM_MAXPATHLEN]; 78 char buf[JVM_MAXPATHLEN];
79 os::jvm_path(buf, sizeof(buf)); 79 os::jvm_path(buf, sizeof(buf));
80 int jvm_offset = -1; 80 int jvm_offset = -1;
81 int lib_offset = -1;
81 { 82 {
82 // Match "jvm[^/]*" in jvm_path. 83 // Match "jvm[^/]*" in jvm_path.
83 const char* base = buf; 84 const char* base = buf;
84 const char* p = strrchr(buf, '/'); 85 const char* p = strrchr(buf, '/');
86 if (p != NULL) lib_offset = p - base + 1;
85 p = strstr(p ? p : base, "jvm"); 87 p = strstr(p ? p : base, "jvm");
86 if (p != NULL) jvm_offset = p - base; 88 if (p != NULL) jvm_offset = p - base;
87 } 89 }
90 // Find the disassembler shared library.
91 // Search for several paths derived from libjvm, in this order:
92 // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so (for compatibility)
93 // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
94 // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
95 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
88 if (jvm_offset >= 0) { 96 if (jvm_offset >= 0) {
89 // Find the disassembler next to libjvm.so. 97 // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
90 strcpy(&buf[jvm_offset], hsdis_library_name); 98 strcpy(&buf[jvm_offset], hsdis_library_name);
91 strcat(&buf[jvm_offset], os::dll_file_extension()); 99 strcat(&buf[jvm_offset], os::dll_file_extension());
92 _library = os::dll_load(buf, ebuf, sizeof ebuf); 100 _library = os::dll_load(buf, ebuf, sizeof ebuf);
101 if (_library == NULL) {
102 // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
103 strcpy(&buf[lib_offset], hsdis_library_name);
104 strcat(&buf[lib_offset], os::dll_file_extension());
105 _library = os::dll_load(buf, ebuf, sizeof ebuf);
106 }
107 if (_library == NULL) {
108 // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
109 buf[lib_offset - 1] = '\0';
110 const char* p = strrchr(buf, '/');
111 if (p != NULL) {
112 lib_offset = p - buf + 1;
113 strcpy(&buf[lib_offset], hsdis_library_name);
114 strcat(&buf[lib_offset], os::dll_file_extension());
115 _library = os::dll_load(buf, ebuf, sizeof ebuf);
116 }
117 }
93 } 118 }
94 if (_library == NULL) { 119 if (_library == NULL) {
95 // Try a free-floating lookup. 120 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
96 strcpy(&buf[0], hsdis_library_name); 121 strcpy(&buf[0], hsdis_library_name);
97 strcat(&buf[0], os::dll_file_extension()); 122 strcat(&buf[0], os::dll_file_extension());
98 _library = os::dll_load(buf, ebuf, sizeof ebuf); 123 _library = os::dll_load(buf, ebuf, sizeof ebuf);
99 } 124 }
100 if (_library != NULL) { 125 if (_library != NULL) {
247 if (arg != NULL) { 272 if (arg != NULL) {
248 print_address(arg); 273 print_address(arg);
249 return arg; 274 return arg;
250 } 275 }
251 } else if (match(event, "mach")) { 276 } else if (match(event, "mach")) {
252 output()->print_cr("[Disassembling for mach='%s']", arg); 277 static char buffer[32] = { 0, };
278 if (strcmp(buffer, (const char*)arg) != 0 ||
279 strlen((const char*)arg) > sizeof(buffer) - 1) {
280 // Only print this when the mach changes
281 strncpy(buffer, (const char*)arg, sizeof(buffer) - 1);
282 output()->print_cr("[Disassembling for mach='%s']", arg);
283 }
253 } else if (match(event, "format bytes-per-line")) { 284 } else if (match(event, "format bytes-per-line")) {
254 _bytes_per_line = (int) (intptr_t) arg; 285 _bytes_per_line = (int) (intptr_t) arg;
255 } else { 286 } else {
256 // ignore unrecognized markup 287 // ignore unrecognized markup
257 } 288 }