src/share/vm/compiler/disassembler.cpp

changeset 2991
3e23978ea0c3
parent 2895
167b70ff3abc
child 4093
5a98bf7d847b
child 4107
b31471cdc53e
     1.1 --- a/src/share/vm/compiler/disassembler.cpp	Wed Jul 06 09:27:54 2011 -0700
     1.2 +++ b/src/share/vm/compiler/disassembler.cpp	Wed Jul 06 18:15:21 2011 -0700
     1.3 @@ -78,21 +78,46 @@
     1.4    char buf[JVM_MAXPATHLEN];
     1.5    os::jvm_path(buf, sizeof(buf));
     1.6    int jvm_offset = -1;
     1.7 +  int lib_offset = -1;
     1.8    {
     1.9      // Match "jvm[^/]*" in jvm_path.
    1.10      const char* base = buf;
    1.11      const char* p = strrchr(buf, '/');
    1.12 +    if (p != NULL) lib_offset = p - base + 1;
    1.13      p = strstr(p ? p : base, "jvm");
    1.14      if (p != NULL)  jvm_offset = p - base;
    1.15    }
    1.16 +  // Find the disassembler shared library.
    1.17 +  // Search for several paths derived from libjvm, in this order:
    1.18 +  // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so  (for compatibility)
    1.19 +  // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
    1.20 +  // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
    1.21 +  // 4. hsdis-<arch>.so  (using LD_LIBRARY_PATH)
    1.22    if (jvm_offset >= 0) {
    1.23 -    // Find the disassembler next to libjvm.so.
    1.24 +    // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
    1.25      strcpy(&buf[jvm_offset], hsdis_library_name);
    1.26      strcat(&buf[jvm_offset], os::dll_file_extension());
    1.27      _library = os::dll_load(buf, ebuf, sizeof ebuf);
    1.28 +    if (_library == NULL) {
    1.29 +      // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
    1.30 +      strcpy(&buf[lib_offset], hsdis_library_name);
    1.31 +      strcat(&buf[lib_offset], os::dll_file_extension());
    1.32 +      _library = os::dll_load(buf, ebuf, sizeof ebuf);
    1.33 +    }
    1.34 +    if (_library == NULL) {
    1.35 +      // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
    1.36 +      buf[lib_offset - 1] = '\0';
    1.37 +      const char* p = strrchr(buf, '/');
    1.38 +      if (p != NULL) {
    1.39 +        lib_offset = p - buf + 1;
    1.40 +        strcpy(&buf[lib_offset], hsdis_library_name);
    1.41 +        strcat(&buf[lib_offset], os::dll_file_extension());
    1.42 +        _library = os::dll_load(buf, ebuf, sizeof ebuf);
    1.43 +      }
    1.44 +    }
    1.45    }
    1.46    if (_library == NULL) {
    1.47 -    // Try a free-floating lookup.
    1.48 +    // 4. hsdis-<arch>.so  (using LD_LIBRARY_PATH)
    1.49      strcpy(&buf[0], hsdis_library_name);
    1.50      strcat(&buf[0], os::dll_file_extension());
    1.51      _library = os::dll_load(buf, ebuf, sizeof ebuf);
    1.52 @@ -249,7 +274,13 @@
    1.53        return arg;
    1.54      }
    1.55    } else if (match(event, "mach")) {
    1.56 -   output()->print_cr("[Disassembling for mach='%s']", arg);
    1.57 +    static char buffer[32] = { 0, };
    1.58 +    if (strcmp(buffer, (const char*)arg) != 0 ||
    1.59 +        strlen((const char*)arg) > sizeof(buffer) - 1) {
    1.60 +      // Only print this when the mach changes
    1.61 +      strncpy(buffer, (const char*)arg, sizeof(buffer) - 1);
    1.62 +      output()->print_cr("[Disassembling for mach='%s']", arg);
    1.63 +    }
    1.64    } else if (match(event, "format bytes-per-line")) {
    1.65      _bytes_per_line = (int) (intptr_t) arg;
    1.66    } else {

mercurial