Hotspot Disassembler (Hsdis)

Building hsdis on Ubuntu and macOS
🪦 End of Life. This note is no longer maintained, and is scheduled for deletion.

Newer versions of the JDK do not include binaries for the HotSpot Disassembler. This is required if you're looking to make use of some JMH profilers, such as the Linux perfasm profiler, or just want to review the assembly generated for a given Java application using -XX:+PrintAssembly or jitwatch. These instructions have been tested with the OpenJDK 17 GA release on Ubuntu 20.04 and macOS Monterey on Intel CPUs.

Initial Prep

The initial prep varies by operating system

Ubuntu 20.04

First, ensure you have build essential tools installed.

sudo apt update
sudo apt install build-essential

macOS Monterey on Intel CPUs

First, ensure you have xcode command line tools installed.

sudo xcode-select --install

If you don't already have wget installed, this can be installed with Homebrew:

brew install wget

Building hsdis

Next, clone the JDK repo:

git clone git@github.com:openjdk/jdk.git

Next, move into the JDK source folder, and then checkout the JDK 17-ga tag:

cd jdk
git checkout jdk-17-ga

Next, move into the hsdis folder:

cd src/utils/hsdis

Next, get a copy of the GNU binutils from gnu.org:

wget https://ftp.gnu.org/gnu/binutils/binutils-2.35.tar.gz
tar xvf binutils-2.35.tar.gz

Finally, build hsdis:

make BINUTILS=binutils-2.35 ARCH=amd64

The remaining steps are going to vary by operating system. If you're making use of something like SDK Man, ensure that the correct JDK is set to current - given we're building hsdis for JDK 16, it'd need to be OpenJDK 16 (or equivalent from Azul etc.).

Installing hsdis to your JDK

Ubuntu 20.04

sudo cp build/linux-amd64/hsdis-amd64.so $JAVA_HOME/lib/server

macOS Monterey on Intel CPUs

sudo cp build/macosx-amd64/hsdis-amd64.dylib $JAVA_HOME/lib/server

References

OpenJDK Wiki: HotSpot PrintAssembly.

Change log

  • Added 10 March 2021
  • Updated 16 March 2021 for JDK 16
  • Updated 11 December 2021 for JDK 17; clarify this is for Intel CPUs on macOS only
Metadata
🌳
reading time
2 min read
published
2021-03-10
last updated
2021-12-11
importance
low
review policy
continuous
Topics
Hardware
--- Views

© 2009-2023 Shaun Laurens. All Rights Reserved.