Skip to content

feat(dap): data breakpoints - #1782

Merged
angelozerr merged 1 commit into
redhat-developer:mainfrom
lagergren:feat/dap-data-breakpoints
Oct 28, 2026
Merged

angelozerr merged 1 commit into
redhat-developer:mainfrom
lagergren:feat/dap-data-breakpoints

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

A DAP server can stop the program when a value changes, rather than at a line, when it advertises supportsDataBreakpoints. The client first asks which data a variable is (dataBreakpointInfo), by its name and the variablesReference of its container, or by an expression and a frame. The answer has a dataId, a description, the access types offered and whether the data stays the same in a later session (canPersist), or no dataId and a description of why it can't be watched. The client then sends all its data breakpoints (setDataBreakpoints) each time one of them changes. A stop at one is a stopped event with the reason data breakpoint and hitBreakpointIds. VS Code offers this as Break on Value Change in its Variables view. LSP4IJ never sent either request and had no breakpoint type for them, and DAPSupport.md listed both as unsupported.

The change

  • Break on Value Change (DAP.BreakOnValueChange) is in the context menu of the Variables and Watches views (XDebugger.ValueGroup). It is shown only for a DAP value whose DAP server advertises supportsDataBreakpoints.
    • It asks that DAP server dataBreakpointInfo with the variablesReference of the value's container and the value's name. A watch has no container, so it sends its expression and the frame.
    • When the answer has no dataId, the debug tool window shows the description as the reason, and nothing is added.
    • It finds the selected DAP value with XDebuggerTreeBackendOnlyActionBase.getSelectedValue (IntelliJ 2025.3 and later), called by reflection, and otherwise with XDebuggerTreeActionBase.getSelectedValue. With the split debugger of IntelliJ 2026.1 and later, the views' tree holds frontend proxies of the values (FrontendXNamedValue), not the DAP values, so the older lookup never finds a DAPValue there. XDebuggerTreeBackendOnlyActionBase is @ApiStatus.Experimental; is reflection on it acceptable to you, or would you rather handle the split debugger another way?
  • A DAP Data Breakpoint (dap-data-breakpoint, DAPDataBreakpointType) is added otherwise. It isn't a line's breakpoint.
    • Its properties (DAPDataBreakpointProperties) hold the dataId and the description, which is its text in the Breakpoints dialog. They also hold the access type (write if offered, else the first one offered), canPersist, and the id of the DAP server configuration. The DAP server which gave the dataId is kept too, but not saved.
    • It has the Condition, Suspend and logging options of a line breakpoint, and a hit condition, which its properties panel edits.
  • DAPDataBreakpointHandler sends the enabled data breakpoints with setDataBreakpoints. DebugAdapterDescriptor.createDataBreakpointHandler creates it, as it creates the other breakpoint handlers.
    • Each DAP server gets all of its own data breakpoints: those whose dataId it gave. They are sent when the session starts, and again whenever one is added, changed or removed, only to a DAP server that advertises supportsDataBreakpoints. Removing the last one sends an empty request.
    • As for function breakpoints, the answer shows each one verified, or invalid with the DAP server's message. The answer to an older request is ignored, and breakpoint events with the reason changed update them by id.
    • The presentation of a breakpoint that isn't a line's, which the function breakpoint handler set, moves to BreakpointHandlerBase for both.
  • Stops. A stopped event's hitBreakpointIds reach a data breakpoint through DAPDebugProcess.findBreakpointById, so the stop goes through breakpointReached, as a line breakpoint's does. The stopped event's description, such as Counter.count changed from 0 to 2, is shown as an information hint where the program stopped. The error hint display of an exception stop shows it too.
  • Data that can't persist. A dataId whose canPersist is false or absent is valid only in its session.
    • Its breakpoint is removed when that session ends, as IntelliJ removes a temporary breakpoint. So it isn't saved in workspace.xml, isn't sent to a later session, and is gone from the Breakpoints dialog.
    • It is also removed before the project is saved on close (DAPProjectLifecycleListener). One left over by an IDE that stopped mid-session is removed when the next DAP session registers it.
    • A persistable one is kept, unbound, and sent to the later sessions of the same DAP server configuration.
  • Docs. DAPSupport.md marks DataBreakpointInfo and SetDataBreakpoints supported, with supportsDataBreakpoints and DataBreakpoint, and the user guide gets a "Data breakpoints" section.

Test

  • New DAPBreakOnValueChangeSessionTest (2) runs a debug session, attached to a DAP server in the test's process, which stops with a local counter whose field is count:
    • Break on Value Change on the DAPValue of count, as the Variables view gets it, is offered. It asks dataBreakpointInfo with the variablesReference of counter, the name and the frame id, and sends setDataBreakpoints with the dataId. The breakpoint, which can't persist, is gone once the session stops.
    • Against a DAP server without supportsDataBreakpoints, the action is hidden.
    • It fails when the action finds no DAP value, and when the session's end removes nothing.
  • New DAPDataBreakpointHandlerTest (12), with real IntelliJ data breakpoints and proxy IDebugProtocolServers:
    • a DAP server without supportsDataBreakpoints gets nothing;
    • the dataBreakpointInfo arguments, for a variable and for a watch, and a refusal adds nothing;
    • the access type is write if offered, and the data ids, access types, conditions and hit conditions are sent;
    • each change sends all of a DAP server's breakpoints, and each DAP server gets only those of its own data;
    • verified and invalid answers, and a failed request shows the breakpoints invalid;
    • non-persistable breakpoints are removed at the session's end, at the project's close and when left over.
  • New DAPDataBreakpointPropertiesTest (3): the properties survive a save and load without the DAP server, the panel changes the hit condition, and a breakpoint without a description shows its data id.
  • New DAPClientDataBreakpointTest (2) and DAPClientDataBreakpointHintTest (2): a stop reaches the data breakpoint its hitBreakpointIds name, a stop that names none is not a breakpoint stop, and the stop's description is shown where the program stopped, and nothing for another stop.
  • New DAPBreakOnValueChangeActionTest (3): the action is in the Variables and Watches menu, and is hidden when nothing is selected or the value is another debugger's.
  • Not covered by these tests: the split debugger's lookup, since the tests run on IntelliJ 2024.2, which has none. main doesn't compile against 2025.3 (WillRenameFilesMoveHandler, WillRenameFilesRefactoringHelper), so the tests couldn't run there. The native check below covers it.

./gradlew check: 894 tests, 3 skipped. The only failures are the 7 that main has on macOS too (LSPIJUtils_applyWorkspaceEdit_*Test and CommandExecutorTest). The rest of check (Kover, JaCoCo) passes.

Native check

IntelliJ IDEA 2026.2.3 with the Ecstasy (XVM) debug adapter, and a plugin built from this branch:

  • The program stopped before two calls that each add to a counter's field count. Break on Value Change, chosen on count in the Variables view, added a data breakpoint shown as Counter.count, verified.
  • With the line breakpoint removed, each of the two changes stopped the program on the line after it, in the method that made the change.
  • Resume ran the program to its exit, and the breakpoint, which the adapter doesn't let persist, was gone once the session ended.

Line breakpoints, steps, function breakpoints and Reset Frame also still worked with a build of this branch.

LSP4IJ never sent 'dataBreakpointInfo' or 'setDataBreakpoints' and had
no breakpoint type for them, so the data breakpoints of a DAP server,
which stop the program when a value changes, could not be used from
IntelliJ.

- "Break on Value Change" (DAP.BreakOnValueChange), in the context menu
  of the Variables and Watches views (XDebugger.ValueGroup), is shown
  for a DAP value whose DAP server advertises supportsDataBreakpoints.
  It asks that DAP server 'dataBreakpointInfo' with the variablesReference
  of the value's container and the value's name; a watch, which has no
  container, sends its expression and the frame. When the answer has no
  dataId, the debug tool window shows the description the DAP server
  gives as the reason, and nothing is added.
- The action finds the selected DAP value with
  XDebuggerTreeBackendOnlyActionBase.getSelectedValue (IntelliJ 2025.3
  and later, through Java reflection), and otherwise with
  XDebuggerTreeActionBase.getSelectedValue: with the split debugger of
  IntelliJ 2026.1 and later, the views' tree holds frontend proxies of
  the values (FrontendXNamedValue), not the DAP values, so the action
  was never shown there.
- Otherwise a "DAP Data Breakpoint" (dap-data-breakpoint) is added. Its
  properties hold the dataId, the description, which is its text in the
  Breakpoints dialog, the access type (write if offered, else the first
  one offered), canPersist, the id of the DAP server configuration, and,
  not saved, the DAP server which gave the dataId. It has the Condition,
  Suspend and logging options of a line breakpoint, and a hit condition
  which its properties panel edits.
- DAPDataBreakpointHandler sends the enabled data breakpoints of each
  DAP server, all of them, with 'setDataBreakpoints' when the session
  starts and whenever one is added, changed or removed, to each DAP
  server of the session which advertises supportsDataBreakpoints; the
  removal of the last one sends an empty request. As for function
  breakpoints, the answer shows each verified, or invalid with the DAP
  server's message, the answer to an older request is ignored, and
  'breakpoint' changed events update them by id. A stop names its data
  breakpoint by hitBreakpointIds, through findBreakpointById, and the
  stopped event's description, such as "Counter.count changed from 0
  to 2", is shown where the program stopped, as an information hint.
- A dataId whose canPersist is false or absent is valid only in its
  session: its breakpoint is removed when that session ends, as IntelliJ
  removes a temporary breakpoint, so it is not saved in workspace.xml,
  not sent to a later session, and gone from the Breakpoints dialog.
  It is also removed before the project is saved on close, and one left
  over by an IDE which stopped mid-session is removed when the next DAP
  session registers it. A persistable one is kept, unbound, and sent to
  the later sessions of the same DAP server configuration.
- The presentation of a non-line breakpoint, which the function
  breakpoints set, moves to BreakpointHandlerBase for both. The error
  hint display of an exception stop shows the data breakpoint hint too.
- DAPSupport.md marks DataBreakpointInfo and SetDataBreakpoints
  supported, with supportsDataBreakpoints and DataBreakpoint, and the
  user guide describes data breakpoints.

Tests: DAPDataBreakpointHandlerTest, DAPDataBreakpointPropertiesTest,
DAPClientDataBreakpointTest, DAPClientDataBreakpointHintTest and
DAPBreakOnValueChangeActionTest, with proxy DAP servers: the
dataBreakpointInfo arguments, a refusal adding nothing, replace-all on
add and removal, each DAP server getting its own data, verified and
invalid answers, a stop matched by hitBreakpointIds, the stop hint, and
non-persistable breakpoints removed at session end, at project close
and when left over, and not in the saved breakpoint state.
DAPBreakOnValueChangeSessionTest runs a debug session attached to a DAP
server in the test's process, stopped with a local 'counter' whose field
is 'count'. Break on Value Change on the DAPValue of 'count', as the
Variables view gets it, is offered, asks dataBreakpointInfo with the
variablesReference of 'counter', the name and the frame id, and sends
setDataBreakpoints with the dataId; the breakpoint, which can't persist,
is gone once the session stops. Against a DAP server without
supportsDataBreakpoints, the action is hidden. The session test fails
when the action finds no DAP value, and when the session's end removes
nothing.

Validation, from the JUnit XML: the tests of
'com.redhat.devtools.lsp4ij.dap.*': 175, no failures or skips, 24 of
them new. ./gradlew check: 894 tests, 7 failures, 3 skips; the 7 are the
ones upstream main already fails on macOS (the applyWorkspaceEdit Go,
TypeScript, Scala and Zig tests and
CommandExecutorTest.testExecuteCommandWithValidTextEdit), and the skips
are inline completion tests. ./gradlew check -x test passes.

Native check, in IntelliJ IDEA 2026.2.3 with the Ecstasy (XVM) debug
adapter: Break on Value Change, chosen on a counter's field in the
Variables view, adds a data breakpoint shown as Counter.count and
verified; each of the program's changes to the field stops it on the
line after the change, and the breakpoint, which the adapter does not
let persist, is gone once the session ends.

Limits: the tests run on IntelliJ 2024.2, the project's platform, which
has no split debugger; the lookup through
XDebuggerTreeBackendOnlyActionBase was checked natively in 2026.2.3
only. main does not compile against 2025.3 (WillRenameFilesMoveHandler,
WillRenameFilesRefactoringHelper), so the tests could not run there. A
data breakpoint added while its session runs, but whose DAP server is a
child session which ends earlier, stays until the parent session ends.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

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: 99f257a2-e0a7-4c72-8d8f-d59f6df01838
Commits

Reviewing files that changed from the base of the PR and between 0d3c64d and bf392a0.

Files selected for processing: 22
  • docs/dap/DAPSupport.md
  • docs/dap/UserGuide.md
  • src/main/java/com/redhat/devtools/lsp4ij/dap/DAPDebugProcess.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/DAPProjectLifecycleListener.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/BreakpointHandlerBase.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPDataBreakpointHandler.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPDataBreakpointProperties.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPDataBreakpointPropertiesPanel.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPDataBreakpointType.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPFunctionBreakpointHandler.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPBreakOnValueChangeAction.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValue.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/descriptors/DebugAdapterDescriptor.java
  • src/main/resources/META-INF/plugin.xml
  • src/main/resources/messages/DAPBundle.properties
  • src/test/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPDataBreakpointHandlerTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPDataBreakpointPropertiesTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/DAPClientDataBreakpointHintTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/DAPClientDataBreakpointTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPBreakOnValueChangeActionTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPBreakOnValueChangeSessionTest.java
Files with no reviewable changes: 1
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPFunctionBreakpointHandler.java

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

📝 Summary

Summary by CodeRabbit

  • New Features
    • Added data breakpoints for supported debug adapters. Set breakpoints on variable values from the Variables and Watches views, with conditions and hit conditions.
    • Data breakpoints can stop on value changes, show verification status and change details, and persist across sessions when the adapter supports persistence.
  • Documentation
    • Added guidance on setting, configuring, and managing data breakpoints.

This change adds DAP data-breakpoint support, including breakpoint creation and session cleanup, a “Break on Value Change” action, debugger stop hints, and documentation.

Changes: Data Breakpoint Support

Layer / File(s) Summary
Breakpoint model and presentation
src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/*, src/main/resources/META-INF/plugin.xml, src/main/resources/messages/DAPBundle.properties
Adds data-breakpoint properties, type, hit-condition panel, and presentation helpers. Registers the breakpoint type and adds related messages.
Server requests and session lifecycle
src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPDataBreakpointHandler.java, src/main/java/com/redhat/devtools/lsp4ij/dap/DAPDebugProcess.java, src/main/java/com/redhat/devtools/lsp4ij/dap/DAPProjectLifecycleListener.java, src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java, src/main/java/com/redhat/devtools/lsp4ij/dap/descriptors/DebugAdapterDescriptor.java, src/test/java/com/redhat/devtools/lsp4ij/dap/breakpoints/*, src/test/java/com/redhat/devtools/lsp4ij/dap/client/DAPClientDataBreakpointTest.java
The handler requests data-breakpoint information, sends each adapter its associated breakpoints, and updates verification status. Session and project cleanup removes non-persistent breakpoints and unbinds persistent ones. Tests cover request routing, responses, and cleanup.
Value action and stop hints
src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/*, src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java, src/main/resources/META-INF/plugin.xml, docs/dap/*, src/test/java/com/redhat/devtools/lsp4ij/dap/client/*, src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/*
Adds the “Break on Value Change” action for supported DAP values and displays a data-breakpoint stop description when present. Documentation and tests cover the action, stop hints, and breakpoint support.

Priority: Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ValueAction as DAPBreakOnValueChangeAction
  participant BreakpointHandler as DAPDataBreakpointHandler
  participant DebugAdapter as IDebugProtocolServer
  ValueAction->>BreakpointHandler: addDataBreakpoint(arguments)
  BreakpointHandler->>DebugAdapter: dataBreakpointInfo(arguments)
  DebugAdapter-->>BreakpointHandler: data ID, access types, persistence
  BreakpointHandler->>DebugAdapter: setDataBreakpoints(arguments)
  DebugAdapter-->>BreakpointHandler: breakpoint IDs and verification
Loading

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to bf392

No actionable merge-blocking issue is established by the available evidence. Merge after the normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 23.03% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the DAP data-breakpoint feature, implementation scope, tests, and known limitations.
Title check Passed The title concisely identifies the main change: adding DAP data breakpoints.
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: Docstring Coverage

Explanation

Docstring coverage is 23.03% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 178 functions across 17 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.65350% with 113 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.96%. Comparing base (0d3c64d) to head (bf392a0).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...p4ij/dap/breakpoints/DAPDataBreakpointHandler.java 75.17% 23 Missing and 13 partials ⚠️
...m/redhat/devtools/lsp4ij/dap/client/DAPClient.java 47.05% 18 Missing ⚠️
.../lsp4ij/dap/breakpoints/DAPDataBreakpointType.java 38.46% 15 Missing and 1 partial ⚠️
.../client/variables/DAPBreakOnValueChangeAction.java 52.94% 13 Missing and 3 partials ⚠️
...j/dap/breakpoints/DAPDataBreakpointProperties.java 76.19% 10 Missing ⚠️
.../lsp4ij/dap/breakpoints/BreakpointHandlerBase.java 52.63% 5 Missing and 4 partials ⚠️
.../breakpoints/DAPDataBreakpointPropertiesPanel.java 76.47% 4 Missing ⚠️
...om/redhat/devtools/lsp4ij/dap/DAPDebugProcess.java 57.14% 3 Missing ⚠️
...vtools/lsp4ij/dap/DAPProjectLifecycleListener.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1782      +/-   ##
==========================================
+ Coverage   33.70%   35.96%   +2.25%     
==========================================
  Files         770      775       +5     
  Lines       29145    29452     +307     
  Branches     5851     4477    -1374     
==========================================
+ Hits         9823    10591     +768     
+ Misses      17598    16993     -605     
- Partials     1724     1868     +144     

☔ 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.

@angelozerr angelozerr added enhancement New feature or request dap Debugging Adapter Protocol labels Oct 28, 2026
@angelozerr angelozerr added this to the 0.21.1 milestone Oct 28, 2026
@angelozerr angelozerr moved this to In Progress in Java Tooling Oct 28, 2026
@angelozerr
angelozerr merged commit c7955a1 into redhat-developer:main Oct 28, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Java Tooling Oct 28, 2026
@angelozerr

Copy link
Copy Markdown
Contributor

Thanks @lagergren !

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

Labels

dap Debugging Adapter Protocol enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants