feat(debugger): memory view for a paused JVM (#2648)

Adds a Memory tab to the Debug tool window for JVM sessions: loaded classes with instance counts and shallow sizes (with deltas between refreshes), read over the HotSpot attach listener (`GC.class_histogram`), falling back to counting reachable objects through the debugger on JDKs that cannot answer while suspended. While paused, a class's instances, an instance's fields and its referrers are listed through a JDWP link (the Kotlin adapter's path, and a jdtls bundle `java/jvm-inspect` for java-debug). Debug launches started by the IDE get `-XX:+StartAttachListener` unless the user's VM options decide otherwise (not on Windows).

New crates: ide-jdwp, ide-jvm-attach, ide-jvm-inspect. The bundled jar rebuilds byte-for-byte from build.py against the pinned JDT LS plugins.

Co-authored-by: ntbang0901 <121003585+ntbang0901@users.noreply.github.com>
This commit is contained in:
ntbang0901
2026-11-11 17:10:21 +08:00
committed by GitHub
parent 0ff3f188de
commit a3d1e57f3e
125 changed files with 16949 additions and 307 deletions
+8
View File
@@ -129,6 +129,14 @@ export function joinJavaArgs(args: readonly string[]): string {
/** JDWP agent options: listen on a free local port and wait for the debugger. */
export const JDWP_AGENT = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=127.0.0.1:0";
/** Makes a HotSpot JVM open its attach socket at start-up; the memory view finds the debuggee through it. */
export const ATTACH_LISTENER = "-XX:+StartAttachListener";
/** True when VM options already decide about the attach mechanism, so the IDE must not override them. */
export function optsOutOfAttach(text: string): boolean {
return /StartAttachListener|DisableAttachMechanism/.test(text);
}
/** The port of `Listening for transport dt_socket at address: 5005` (JDWP's start-up line). */
export function jdwpListeningPort(line: string): number | null {
const m = /Listening for transport dt_socket at address:\s*(?:[\w.[\]:-]*:)?(\d+)\s*$/.exec(line.trim());