jhsdb
Debug Java processes and core dumps
TLDR
Print stack and locks information of a Java process
Open a core dump in interactive debug mode
Start a remote debug server
Connect to a process in interactive debug mode
SYNOPSIS
jhsdb [-V] [-d <path>] [-X] <tool> [<tool-options>]
PARAMETERS
-V
Print version information and exit.
-d <path>
Path to JDK/JRE containing libjvm.so for SA (default: runtime JRE).
-X
Execute without confirmation prompts before exit.
clhsdb
Interactive command-line HotSpot debugger with commands like 'threads', 'heap'.
jmap
Heap viewer/dumper: --heap, --histo, --core <file>, --pid <pid>.
jstack
Thread dump generator: --pid <pid>, --core <file> --exe <jvm>.
jcmd
Diagnostic commands via SA (limited subset).
DESCRIPTION
jhsdb launches the Serviceability Agent (SA) for debugging HotSpot JVMs. It supports analysis of live processes or core dumps, providing access to heap, threads, stacks, and internals without a full debugger.
Ideal for production diagnostics like memory leaks or deadlocks, SA bypasses JVM attachment restrictions. Traditional tools like jmap and jstack invoke jhsdb internally in JDK 8+.
Key uses: generate heap dumps (jhsdb jmap --heap --pid <pid>), thread stacks (jhsdb jstack --pid <pid>), or interactive debugging (jhsdb clhsdb). For cores: jhsdb jmap --core <core> --exe <jvm>.
Requires matching JDK libs; works on Linux, Windows, macOS. Enables commands like 'threads', 'histogram', 'inspect' in clhsdb mode. Enhances Java observability beyond jcmd.
CAVEATS
Needs exact JVM binary/libjvm match for cores; full debug JDK recommended. Core dumps must capture JVM libs (use gcore). Incompatible with some compressed GCs without adjustments. Not for OpenJ9/other JVMs.
CORE DUMP EXAMPLE
jhsdb clhsdb <core-file> <jvm-executable>
Launches interactive debugger on core.
LIVE HEAP SUMMARY
jhsdb jmap --heap --pid <pid>
Prints non-interactive heap overview.
HISTORY
Introduced in OpenJDK/JDK 8 (2014) to unify SA access, evolving from JDK 5's debug agent. Standardized core/live JVM analysis amid rising cloud diagnostics needs.


