дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 11:15:40 +02:00
fix(debugger): Debug JVM scripts and Maven server goals through a JDWP agent (#185)
java-debug runs inside jdtls and is reached through its debugServer port, but configurations that aren't Application / Spring Boot and select java-debug (a Shell Script running `catalina.bat run`, say) fell through to the generic launch template, and the adapter launcher tried to start com.microsoft.java.debug.plugin.jar as a process: on Windows that failed with os error 193, elsewhere with a misleading "debug adapter not found". - Shell script / program configurations with java-debug start with a suspended JDWP agent injected through JAVA_TOOL_OPTIONS and attach once the JVM prints its port, so `catalina.bat run` / `catalina.sh run` can be debugged. - Maven goals that run the app in Maven's JVM (tomcat7:run, jetty:run(-war), exec:java, or any Maven config with java-debug) are debugged through MAVEN_OPTS. - Gradle tasks that start no JVM say why they can't be debugged; `debug.startConfig` with a single debuggable config goes through the run debug flow. - .jar adapters are never spawned as processes, and Windows adapter lookup only accepts PATHEXT files (so npm-installed adapters pick the .cmd shim instead of the POSIX one); the PATHEXT expansion moves to ide_core::process::executable_names, shared with ide-run. Not run on Windows; the Windows resolution is covered by tests with an injected platform. Fixes #179 Claude-Session: https://claude.ai/code/session_01Dq6jQQn8ZhRfkkyj3PRutA
Цей коміт міститься в:
1 джерело
1f9be73174
коміт
75e7d582d4
9 files changed
+216
-37
No files matched your search
@@ -261,6 +261,48 @@ describe("debugging build tool configurations", () => {
|
||||
expect(jdwpLaunch(cfg({ id: "p", kind: "maven", args: ["package"] }))).toBeNull();
|
||||
expect(jdwpLaunch(cfg({ id: "n", kind: "npm", args: ["test"] }))).toBeNull();
|
||||
});
|
||||
|
||||
const AGENT = /-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=127\.0\.0\.1:0$/;
|
||||
|
||||
it.each([
|
||||
["tomcat7:run"],
|
||||
["org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run"],
|
||||
["jetty:run"],
|
||||
["jetty:run-war"],
|
||||
["exec:java"],
|
||||
])("debugs Maven's own JVM for the in-process goal %s", (goal) => {
|
||||
const out = jdwpLaunch(cfg({ id: "m", kind: "maven", args: ["clean", goal], env: { MAVEN_OPTS: "-Xmx1g" } }))!;
|
||||
expect(out.args).toEqual(["clean", goal]);
|
||||
expect(out.env.MAVEN_OPTS).toMatch(/^-Xmx1g -agentlib:jdwp=/);
|
||||
expect(out.env.MAVEN_OPTS).toMatch(AGENT);
|
||||
});
|
||||
|
||||
it("keeps plain Maven builds out of the debugger unless set to the Java debugger", () => {
|
||||
expect(jdwpLaunch(cfg({ id: "p", kind: "maven", args: ["exec:exec"] }))).toBeNull();
|
||||
const chosen = jdwpLaunch(cfg({ id: "p", kind: "maven", args: ["package"], debugAdapter: "java-debug" }))!;
|
||||
expect(chosen.env.MAVEN_OPTS).toMatch(AGENT);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["shell", "C:\\apache-tomcat-9.0.98\\bin\\catalina.bat", ["run"]],
|
||||
["shell", "/opt/tomcat9/bin/catalina.sh", ["run"]],
|
||||
["program", "java", ["-jar", "app.war"]],
|
||||
])("starts a %s configuration set to the Java debugger with an agent in JAVA_TOOL_OPTIONS", (kind, command, args) => {
|
||||
const rc = cfg({ id: "tomcat9", kind, command, args, debugAdapter: "java-debug" });
|
||||
const out = jdwpLaunch(rc)!;
|
||||
expect(out.command).toBe(command);
|
||||
expect(out.args).toEqual(args);
|
||||
expect(out.env.JAVA_TOOL_OPTIONS).toMatch(AGENT);
|
||||
const merged = jdwpLaunch({ ...rc, env: { JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8" } })!;
|
||||
expect(merged.env.JAVA_TOOL_OPTIONS).toMatch(/^-Dfile\.encoding=UTF-8 -agentlib:jdwp=/);
|
||||
});
|
||||
|
||||
it("leaves Application configurations and other debuggers alone", () => {
|
||||
for (const kind of ["application", "spring-boot"])
|
||||
expect(jdwpLaunch(cfg({ id: "a", kind, command: "java", debugAdapter: "java-debug" }))).toBeNull();
|
||||
expect(jdwpLaunch(cfg({ id: "s", kind: "shell", command: "./run.sh", debugAdapter: "debugpy" }))).toBeNull();
|
||||
expect(jdwpLaunch(cfg({ id: "g", kind: "gradle", args: ["build"], debugAdapter: "java-debug" }))).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("JUnit XML reports", () => {
|
||||
|
||||
Reference in new issue
Заблокувати користувача