772 { |
772 { |
773 // Match "libjvm" instead of "jvm" on *nix platforms. Creates better matches. |
773 // Match "libjvm" instead of "jvm" on *nix platforms. Creates better matches. |
774 // Match "[lib]jvm[^/]*" in jvm_path. |
774 // Match "[lib]jvm[^/]*" in jvm_path. |
775 const char* base = buf; |
775 const char* base = buf; |
776 const char* p = strrchr(buf, *os::file_separator()); |
776 const char* p = strrchr(buf, *os::file_separator()); |
|
777 if (p != NULL) lib_offset = p - base + 1; // this points to the first char after separator |
777 #ifdef _WIN32 |
778 #ifdef _WIN32 |
778 p = strstr(p ? p : base, "jvm"); |
779 p = strstr(p ? p : base, "jvm"); |
|
780 if (p != NULL) jvm_offset = p - base; // this points to 'j' in jvm. |
779 #else |
781 #else |
780 p = strstr(p ? p : base, "libjvm"); |
782 p = strstr(p ? p : base, "libjvm"); |
|
783 if (p != NULL) jvm_offset = p - base + 3; // this points to 'j' in libjvm. |
781 #endif |
784 #endif |
782 if (p != NULL) lib_offset = p - base + 1; |
|
783 if (p != NULL) jvm_offset = p - base; |
|
784 } |
785 } |
785 #endif |
786 #endif |
786 |
787 |
787 // Find the disassembler shared library. |
788 // Find the disassembler shared library. |
788 // Search for several paths derived from libjvm, in this order: |
789 // Search for several paths derived from libjvm, in this order: |
792 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH) |
793 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH) |
793 if (jvm_offset >= 0) { |
794 if (jvm_offset >= 0) { |
794 // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so |
795 // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so |
795 strcpy(&buf[jvm_offset], hsdis_library_name); |
796 strcpy(&buf[jvm_offset], hsdis_library_name); |
796 strcat(&buf[jvm_offset], os::dll_file_extension()); |
797 strcat(&buf[jvm_offset], os::dll_file_extension()); |
|
798 if (Verbose) st->print_cr("Trying to load: %s", buf); |
797 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
799 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
798 if (_library == NULL && lib_offset >= 0) { |
800 if (_library == NULL && lib_offset >= 0) { |
799 // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so |
801 // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so |
800 strcpy(&buf[lib_offset], hsdis_library_name); |
802 strcpy(&buf[lib_offset], hsdis_library_name); |
801 strcat(&buf[lib_offset], os::dll_file_extension()); |
803 strcat(&buf[lib_offset], os::dll_file_extension()); |
|
804 if (Verbose) st->print_cr("Trying to load: %s", buf); |
802 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
805 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
803 } |
806 } |
804 if (_library == NULL && lib_offset > 0) { |
807 if (_library == NULL && lib_offset > 0) { |
805 // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so |
808 // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so |
806 buf[lib_offset - 1] = '\0'; |
809 buf[lib_offset - 1] = '\0'; |
807 const char* p = strrchr(buf, *os::file_separator()); |
810 const char* p = strrchr(buf, *os::file_separator()); |
808 if (p != NULL) { |
811 if (p != NULL) { |
809 lib_offset = p - buf + 1; |
812 lib_offset = p - buf + 1; |
810 strcpy(&buf[lib_offset], hsdis_library_name); |
813 strcpy(&buf[lib_offset], hsdis_library_name); |
811 strcat(&buf[lib_offset], os::dll_file_extension()); |
814 strcat(&buf[lib_offset], os::dll_file_extension()); |
|
815 if (Verbose) st->print_cr("Trying to load: %s", buf); |
812 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
816 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
813 } |
817 } |
814 } |
818 } |
815 } |
819 } |
816 if (_library == NULL) { |
820 if (_library == NULL) { |
817 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH) |
821 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH) |
818 strcpy(&buf[0], hsdis_library_name); |
822 strcpy(&buf[0], hsdis_library_name); |
819 strcat(&buf[0], os::dll_file_extension()); |
823 strcat(&buf[0], os::dll_file_extension()); |
|
824 if (Verbose) st->print_cr("Trying to load: %s via LD_LIBRARY_PATH or equivalent", buf); |
820 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
825 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
821 } |
826 } |
822 |
827 |
823 // load the decoder function to use (new or old version). |
828 // load the decoder function to use (new or old version). |
824 if (_library != NULL) { |
829 if (_library != NULL) { |