debug: support data breakpoints (watchpoint)
Is your feature request related to a problem? Please describe. As gdb does, break at a watch point for when a variable value change. Delve support watch command, but I cant' execute this command in vscode.
Describe the solution you'd like (dlv) watch -rw b Watchpoint b set at 0x556188 (dlv) l
how to do this in vscode? I want to set a watchpoint break.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
I think should add two menu bars when right click global variables.
@gopherbot can you assign this issue to sb?
I guess the closest is data breakpoint. Delve DAP (the debug adapter behind the scene) is not supporting data breakpoints yet.
https://github.com/go-delve/delve/blob/a164b89df10aba455e0196222e51fa4b65e5746c/service/dap/server.go#L796-L799
Contribution to DAP (in the go-delve repo) is welcome.
@hyangah , thanks. Do you know when to support this feature?
Since we support rr, this will be a powerful and convinient feature.
This is not a feature that can be implemented by vscode-go, it must be implemented by the debugger, delve. However, it appears unlikely that it will be implemented. If you look at delve's DAP implementation, data breakpoints are explicitly not supported and the comment above that block says "Requests that we do not plan to support".
https://github.com/go-delve/delve/blob/52a73b0ecfc50ad1eb0bcd579e2213a8ca64f5a2/service/dap/server.go#L788-L806
This comment indicates that @aarzilli (one of the two maintainers of the debugger) does not think it is feasible to implement data breakpoints.
Since that comment was written we actually implemented watchpoints in delve, so now I think that data breakpoint (with limitations) could be implemented (maybe, I haven't looked at the spec)
dlv does support watchpoint, but it doesn't expose it to DAP, right?
I try to use --accept-multiclient, and connect it with vscode-go and dlv connect (which case watchpoint is available), the watchpoint of dlv command line client works, but it doesn't work well with vscode-go, it has bugs so breakpoints command doesn't show id of breakpoints(even breakpoints set from dlv command line client), making it hard to clear a breakpoint.
I still wonder whether exposing direct dlv command line client communication to the DAP DEBUG CONSOLE is a good idea, actually you can do it by --accept-multiclient. So we can use fuctions of dlv which not covered by dlv dap or DAP itself.
dlv does support watchpoint, but it doesn't expose it to DAP, right?
Correct. To change this, someone will need to read through the DAP specification to understand how DAP expects data breakpoints to behave, and then implement the SetDataBreakpointsRequest and DataBreakpointInfoRequest requests and add supportsDataBreakpoints to delve's DAP capabilities list.