On Sun, 3 Jan 2021 14:31:44 GMT, Yasumasa Suenaga <[email protected]> wrote:

> `livenmethods` CLHSDB command could not find hsdis library even though it 
> deployed to `$JAVA_HOME/lib/server/`.
> 
> sun.jvm.hotspot.debugger.DebuggerException: 
> /usr/local/jdk-15.0.1/lib/amd64/hsdis-amd64.so: cannot open shared object 
> file: No such file or directory
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.asm.Disassembler.load_library(Native Method)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.asm.Disassembler.<init>(Disassembler.java:95)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.asm.Disassembler.decode(Disassembler.java:52)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.asm.Disassembler.decode(Disassembler.java:43)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.genHTML(HTMLGenerator.java:1435)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor$45.doit(CommandProcessor.java:1651)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:2051)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:2021)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.run(CommandProcessor.java:1901)
>         at jdk.hotspot.agent/sun.jvm.hotspot.CLHSDB.run(CLHSDB.java:99)
>         at jdk.hotspot.agent/sun.jvm.hotspot.CLHSDB.main(CLHSDB.java:40)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runCLHSDB(SALauncher.java:280)
>         at 
> jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:483)
> 
> JDK directory layout has been changed since JDK 9, however `livenmethods` 
> hasn't followed it yet.

Changes requested by cjplummer (Reviewer).

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/Disassembler.java line 
80:

> 78:          }
> 79: 
> 80:          String jvmPattern = "^(lib)?jvm\\" + ext + "$";

A comment before this section would be useful. Something like "Find the full 
path to libjvm.so (jvm.dll and libjvm.dylib on Windows and OSX)."

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/Disassembler.java line 
90:

> 88:                           .findAny()
> 89:                           .get();
> 90:          String arch = targetSysProps.getProperty("os.arch");

Newline before this line.

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/Disassembler.java line 
67:

> 65:       // Lazily load hsdis
> 66:       if (decode_function == 0) {
> 67:          // 1. <home>/lib/<vm>/libhsdis-<arch>.so

Before this comment add a comment stating "Search for hsdis library in the 
following 4 locations:"

src/jdk.hotspot.agent/share/native/libsaproc/sadis.c line 150:

> 148:   hsdis_handle = dlopen(libname, RTLD_LAZY | RTLD_GLOBAL);
> 149:   if (hsdis_handle == NULL) {
> 150:     hsdis_handle = dlopen(libname, RTLD_LAZY | RTLD_GLOBAL);

If the first dlopen fails, then you are just repeating it. Same for the windows 
code just above this. I think the second attempt is no longer needed since you 
are now dealing with a libname that you know exists due to the changes in 
Disassembler.java.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1920

Reply via email to