Skip to content

fix(dap): apply a capabilities event to what the configuration sent - #1979

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/apply-a-capabilities-event-to-what-was-sent
Nov 12, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/apply-a-capabilities-event-to-what-was-sent

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

A follow-up of #1974. Its description lists what it left out: some capabilities are read only once, during the configuration, so a capabilities event that changed them later had no effect yet.

Change

Once the configuration is done, a capabilities event now sends again what it changed, to the DAP server that sent it only:

  • Function and data breakpoints, when the event turns their support on or off. They go through the handler's synchronized send, with the new BreakpointHandlerBase.sendBreakpoints(server), which does nothing for a server the handler wasn't initialized for.
  • Exception breakpoint filters, when the filters (other than their default) or supportsExceptionFilterOptions change. The Exception Breakpoints panel shows them on the EDT, keeping the user's choices for the filters it already showed, and setExceptionBreakpoints sends the enabled ones.
  • Instruction breakpoints, when the event turns supportsDisassembleRequest on. The disassembly breakpoint handler is then initialized for that server, once.

Line breakpoints send their condition, hit condition and log message whatever the capabilities say, so they aren't sent again. Nothing is sent to a program that runs without debugging.

During the configuration, each step keeps the capabilities it sent with:

  • An event that arrives before a step changes what that step sends, since fix(dap): apply the capabilities event of a debug adapter #1974 made the steps read the current capabilities.
  • An event that arrives after a step, for example while the debug adapter handles configurationDone, is applied once the configuration is done.

So nothing is sent twice, and nothing is missed. A lock in DAPClient makes a step's read-and-send and an event take turns. Both run on LSP4J's reader thread anyway.

Questions

  1. A filter the adapter drops: the panel's refresh replaces the saved filter list, so the user's choice for that filter is lost. If the adapter offers the filter again, it comes back with its default; saved conditions are kept. Should the choices of dropped filters be kept?
  2. Support turned off: when function or data breakpoint support is turned off, should those breakpoints show as unverified, instead of keeping the verified icon that server gave them?
  3. A panel shared by sessions: the root and child sessions share the Exception Breakpoints panel. A child's event, like a child's configuration, replaces the panel's filters with the child's own. Is that intended?

How this was checked

  • DAPClientCapabilitiesEventTest (10 tests) runs end to end: a real DAPDebugProcess and DAPClient against a mock debug adapter over a socket. It covers:
    • an event that enables function breakpoints, data breakpoints, exception filter options, or disassembling;
    • an event that changes the exception filters;
    • only the session that sent the event getting its breakpoints again;
    • events before and after the configuration's steps;
    • an event that changes nothing relevant;
    • a program run without debugging.
  • The 7 tests that add behaviour fail without the change. The 3 that guard against duplicate or unwanted sends pass without it, so each was checked against a naive variant: re-sending on every event, comparing filters including default, or no check for a debug run. Each test catches its variant.
  • DAPBreakpointHandlerBaseTest.testTheBreakpointsAreSentAgainToAnInitializedDebugAdapterOnly covers the new method's guard.
  • DAP tests: 307 pass. Full suite: only the 7 local macOS failures that test: run the tests on macOS, and the installer registry test on its own #1978 fixes.

Since redhat-developer#1974, a 'capabilities' event changes the capabilities which
DAPClient reads, but what the configuration had sent with the earlier
ones stayed as it was until something else changed:

- function or data breakpoints, which an event enables, were sent only
  with the next change of the breakpoints;
- the exception breakpoint filters, and whether their conditions are
  sent as filter options, stayed those of the 'initialize' response;
- the instruction breakpoints were never sent to a DAP server which
  supports disassembling only after the configuration.

Once the configuration is done, an event now sends again, to the DAP
server which sent it only, what it changed:

- the function or the data breakpoints, when it turns their support on
  or off, through the synchronized send of their handler, with the new
  BreakpointHandlerBase.sendBreakpoints(server);
- the exception breakpoint filters, when the filters (but for their
  'default') or 'supportsExceptionFilterOptions' change: the "Exception
  Breakpoints" panel shows them on the EDT, with the user's choices for
  the filters which it showed already, and 'setExceptionBreakpoints'
  sends the enabled ones;
- the instruction breakpoints, when it turns 'supportsDisassembleRequest'
  on: the disassembly breakpoint handler is initialized for the DAP
  server, once.

Each step of the configuration keeps the capabilities which it sent
with. An event which arrives before a step changes what the step sends,
and one which arrives after it is applied once the configuration is
done, so that nothing is sent twice and nothing is missed. Line
breakpoints don't depend on the capabilities and are not sent again,
and nothing is sent to a program which runs without debugging.
@lagergren lagergren added this to the 0.30.0 milestone Nov 12, 2026
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Breakpoint settings now stay in sync when a debug adapter’s capabilities change, including support for function, data, and instruction breakpoints.
    • Exception filters and their options update when the adapter changes the available filters or supported options.
    • Breakpoint updates are sent only to initialized debug adapters.

DAPClient now records the capabilities used for breakpoint configuration and reconciles applicable requests after capability changes. BreakpointHandlerBase adds a method to resend breakpoints to an initialized debug adapter.

Changes: DAP capability synchronization

Layer / File(s) Summary
Breakpoint resend and source replacement
src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/BreakpointHandlerBase.java, src/test/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointHandlerBaseTest.java
BreakpointHandlerBase can resend breakpoints to an initialized server. Tests cover source-specific replacement, clearing, and resending behavior.
Capability snapshots and initialization
src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java
DAPClient records the capabilities used for initial function, data, and exception breakpoint requests. Instruction breakpoint initialization runs once when disassembly is supported.
Capability-change reconciliation
src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java, src/test/java/com/redhat/devtools/lsp4ij/dap/client/DAPClientCapabilitiesEventTest.java
After configuration, capability changes trigger applicable breakpoint and exception-filter updates. Tests cover capability changes, configuration timing, and session isolation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant DAPAdapter
  participant DAPClient
  participant BreakpointHandlerBase
  participant EDT
  DAPAdapter->>DAPClient: Send capability event
  DAPClient->>BreakpointHandlerBase: Resend supported breakpoints
  BreakpointHandlerBase->>DAPAdapter: Send breakpoint request
  DAPClient->>EDT: Schedule exception-filter update
  EDT->>DAPClient: Run filter update callback
  DAPClient->>DAPAdapter: Send exception filters
Loading

Suggested reviewers: angelozerr, muescha, hgschmie

Merge Risk: Minimal · up to e9c68

The change resends only the affected breakpoint settings when a debug adapter reports capability changes. The remaining gaps are narrow failure-recovery edge cases with a safe fallback. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(dap): apply a capabilities event to what the configuration sent" matches the main change. The PR makes DAP capabilities events resend affected breakpoint settings (function/data breakpo…
Description check Passed The description explains the change. It covers the follow-up to #1974, which breakpoint types are resent on a capabilities event, the timing rules during configuration, the lock, the tests added, and …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(dap): apply a capabilities event to what the configuration sent" matches the main change. The PR makes DAP capabilities events resend affected breakpoint settings (function/data breakpoints, exception filters, instruction breakpoints) after configuration, to the server that sent the event. The title is specific and concise, and it follows a conventional-commit style. It is 67 characters, within a reasonable length.

Full details: Description check

Explanation

The description explains the change. It covers the follow-up to #1974, which breakpoint types are resent on a capabilities event, the timing rules during configuration, the lock, the tests added, and open questions. It is directly related to the changeset.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2dfd3f54-86b5-4326-8410-1416b68ea1a0
Commits

Reviewing files that changed from the base of the PR and between 358015d and e9c6819.

Files selected for processing: 4

  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/BreakpointHandlerBase.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointHandlerBaseTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/DAPClientCapabilitiesEventTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.11688% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.73%. Comparing base (358015d) to head (e9c6819).

Files with missing lines Patch % Lines
...m/redhat/devtools/lsp4ij/dap/client/DAPClient.java 82.43% 10 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1979      +/-   ##
==========================================
+ Coverage   48.36%   48.73%   +0.36%     
==========================================
  Files         810      810              
  Lines       32612    32674      +62     
  Branches     5037     5045       +8     
==========================================
+ Hits        15774    15923     +149     
+ Misses      14326    14224     -102     
- Partials     2512     2527      +15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit 481052e into redhat-developer:main Nov 12, 2026
11 checks passed
lagergren added a commit to leotimus/lsp4ij that referenced this pull request Nov 12, 2026
Main has redhat-developer#1979 now, which sends the breakpoints again when a debug
adapter's capabilities change. DAPBreakpointHandlerBaseTest keeps the
tests of both, with redhat-developer#1979's handler() and server(requests) next to this
branch's handler(session) and server(verified, ...).
Sign up for free to 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.

1 participant