In the previous article we explored a couple of strategies to debug the OpenJDK JVM bytecodes interpreter. I will now present a procedure to debug JIT compiled code.
There are some JVM arguments useful to get information about JIT compiled methods:
|
-Xcomp -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -XX:PrintAssemblyOptions=hsdis-print-bytes -XX:+LogCompilation -XX:LogFile=/tmp/java_compilation_log.log |
Note: +PrintAssembly argument can be used to disassemble compiled code but requires a plugin library called hsdis in some JDK releases such as 8. In hotspot/src/share/tools/hsdis directory you will find the plugin code. To build it, open a command line and run:
|
export BINUTILS=<path-to-binutils> && touch $BINUTILS/bfd/doc/bfd.info && make all64 |
Once built, copy build/linux-amd64/hsdis-amd64.so library to jre/lib/amd64 and jre/lib/amd64/server directories.
Continue reading “How to debug JIT compiled methods in OpenJDK JVM?”