Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for data breakpoints #134

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theHamsta
Copy link
Contributor

@theHamsta theHamsta commented Mar 31, 2021

First draft for data breakpoints. Program execution will stop when the specified variable/expression is modified. Since in the video it its not 100% obvious why the program has stopped, I added some message after capturing the screencast.

databreakpoint.mp4

They can persist over sessions. Java debug adapter only supports data breakpoints for value contained in some kind of container (a class or object) not free standing stack variables like a loop counter i nor more general expressions.

lua/dap.lua Outdated Show resolved Hide resolved
lua/dap.lua Outdated

function M.listeners.after.event_terminated.databreakpoints()
for key, bp in pairs(data_bp_info) do
if not bp.canPersist then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not only check whether they can persist, but also save from which debug adapter they where generated. We can only reuse them with the same debug adapter.

@theHamsta theHamsta force-pushed the data-breakpoints branch 9 times, most recently from 4b42ba5 to 6cfe8ac Compare March 31, 2021 13:58

if variable then
local parent
for _, p in pairs(state.line_to_variable) do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will only work when the parent is also display in this variable buffer. So if the breakpoint is set on any of the non-root elements. A depth search on current_frame.variables might be more precise.

@theHamsta theHamsta force-pushed the data-breakpoints branch 6 times, most recently from 09fd9b8 to 916a790 Compare March 31, 2021 16:51
lua/dap.lua Outdated
end


function M.toggle_data_breakpoint(resolve_expression_fn, condition, hit_condition)
Copy link
Contributor Author

@theHamsta theHamsta Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DAP protocol allows data breakpoints to be an arbitrary expression. But I don't use an adapter that supports this to test.

@theHamsta theHamsta force-pushed the data-breakpoints branch 2 times, most recently from 9b19f0f to 1073b74 Compare April 7, 2021 13:29
@mfussenegger
Copy link
Owner

Sorry for not getting back to this earlier, I wanted to wrap up some of the other stuff I was working on first.

Quite a bit has changed in the module structures so it looks like this PR would have to be adjusted. Are you still up for that?

@theHamsta
Copy link
Contributor Author

theHamsta commented May 7, 2021

I guess this could be split into multiple PRs. If you want you can take the methods for Session and the set data point to the new variables widget. I saw there is also a presentation hint that suggests whether a variable would support a data breakpoint.

I may have time for this next week.

@theHamsta theHamsta marked this pull request as draft July 16, 2021 22:58
mfussenegger added a commit that referenced this pull request Dec 2, 2021
Early WIP, picking up #134
but implemented on top of widget & entity

- [ ] Refine user API
- [ ] Variable render should indicate if there is an active data breakpoint
- [ ] Handle persistence (Do they go into dap.breakpoints, new module, or are part of the session)
- [ ] What goes into entity and what into session
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.

None yet

2 participants