Skip to content

Add suspend mode for source breakpoints - #610

Open
Thomas Mäder (tsmaeder) wants to merge 6 commits into
microsoft:mainfrom
tsmaeder:608_suspend_modes
Open

Add suspend mode for source breakpoints#610
Thomas Mäder (tsmaeder) wants to merge 6 commits into
microsoft:mainfrom
tsmaeder:608_suspend_modes

Conversation

@tsmaeder

@tsmaederThomas Mäder (tsmaeder) commented Oct 21, 2025

Copy link
Copy Markdown

Fixes#608

Note that this PR contains code for handling source breakpoints and exception breakpoints. But in fact, VS Code Java only properly handles source and instruction breakpoints. I've left the code in there, since it's not completely trivial and it should not affect the behavior if no suspend mode is sent when setting the exception breakpoints.

How to Test

  1. Set a breakpoint in a Java Program
  2. Start Debugging
  3. You now should be able to chose the suspend mode (thread or VM) in the breakpoints view and when editing the breakpoint condition.
  4. Make sure the breakpoint can suspend either all threads or only one thread depending on the mode
  5. Put your breakpoint in a for loop and when the breakpoint is hit, switch to the other suspend mode
  6. Resume the program (may need "resume all" from the context menu) and ensure the new suspend mode is honored the next time you hit the breakpoint.
  7. Make sure exception breakpoints behave as usual. There should be no UI to set the mode and exceptions should only suspend the thread the occur on.

@chagong

Copy link
Copy Markdown
Contributor

Thomas Mäder (@tsmaeder) I wrote a simple program to test it, but got error:

publicclassHelloWorld {
publicstaticvoidmain(String[] args) {
System.out.println("Starting application...");
Stringmessage = "Hello, World!";
System.out.println(message); // Set a breakpoint herefor (inti = 0; i < 3; i++) {
System.out.println("Count: " + i);
}
System.out.println("Application finished.");
}
}

Error:
No delegateCommandHandler for vscode.java.resolveMainMethod
image

Also please fix CI errors.

@tsmaeder

Copy link
Copy Markdown
Author

Changyong Gong (@chagong) how are you testing? I have a very similar program which works fine for me. Also, this PR does not contain changes that could cause a problem with the delegate command handler, IMO. Here's what I do:

  1. build a new jar with mvnw clean install
  2. copy the resulting jar to ..\vscode-java-debug\server
  3. Run the vscode-java-debug plugin from source
  4. Works fine for me 🤷

Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
@chagong

Copy link
Copy Markdown
Contributor

Thomas Mäder (@tsmaeder) probably the problem of my setup, it works after I relaunch vscode and F5. The PR is good to go after your fix the format errors.

Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
@tsmaeder

Thomas Mäder (tsmaeder) commented Nov 6, 2025

Copy link
Copy Markdown
Author

Changyong Gong (@chagong) running checkstyle:check locally spews out messages about <cr><lf> not being allowed for every file. However, that line ending is just an artifact of checking out the repo on Windows.

Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
@tsmaeder

Copy link
Copy Markdown
Author

Changyong Gong (@chagong) is there anything (beyond a rebase) that I could do to move this forward?

@chagong

Copy link
Copy Markdown
Contributor

Hi Thomas Mäder (@tsmaeder), can you check if the fix to microsoft/vscode-java-debug#722 has already supported the suspend policy setting?

@tsmaeder

Copy link
Copy Markdown
Author

Changyong Gong (@chagong) no, this PR allows to set the suspend mode per breakpoint, the other PR just introduces a global flag.

@chagong

Copy link
Copy Markdown
Contributor

Thomas Mäder (@tsmaeder) we make it a global flag because vscode doesn't have UI option to set breakpoint property. Are you doing this for cursor?

@tsmaeder

Copy link
Copy Markdown
Author

Thomas Mäder (@tsmaeder) we make it a global flag because vscode doesn't have UI option to set breakpoint property. Are you doing this for cursor?

Chagon VS Code does have UI for this, but you have to enable the modes in the debug adapter (what this PR does) in order to see it. See description.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support "Suspend VM" and "Suspend Thread" Breakpoint Modes

3 participants

@tsmaeder@chagong@wenytang-ms