Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dap: handle SetVariable requests (go-delve#2440)
* dap: handle SetVariable requests The handler invokes debugger.SetVariableInScope, except for string type variables. For which, we rely on the `call` command. Moved the call expression handling logic to the new `doCall` function, so it can be reused by the SetVariable requenst handler. With this PR, every successful SetVariable request triggers a StoppedEvent - that's a hack to reset the variablesHandle map internally and notify the client of this change. It will be nice if we can just update cached data corresponding to the updated variable. But I cannot find an easy and safe way to achieve this yet. Also fixed a small bug in the call expression evaluation - Previously, dlv dap returned an error "Unable to evaluate expression: call stopped" if the call expression is for variable assignment. (e.g. "call animal = "rabbit"). * dap: address comments from aarzilli resetHandlesForStop & sendStoppedEvent unconditionally after call command is left as a TODO - This is an existing code path (just refactored) and an preexisting bug. Fixing it here requires updates in TestEvaluateCallRequest and I prefer addressing it in a separate cl. Disabled call injection testing on arm64. Separated TestSetVariable into two, one that doesn't involve call injection and another that may involve call injection. Fixed variableByName by removing unnecessary recursion. * dap: address polina's comments - removed the hard reset for every variable set - added tests for various variable types - added tests that involves interrupted function calls. (breakpoint/panic) And, - changed to utilize EvalVariableInScope to access the variable instead of searching the children by name. - changed to utilize evaluate requests when verifying whether the variable is changed as expected in testing. Since now we avoid resetting the variable handles after variable reset, either we need to trigger scope changes explicitly, or stop depending on the variables request. * dap: address comments - Discuss the problem around the current doCall implementation and the implication. - Refine the description on how VS Code handles after setVariable and evaluate request (there could be followup scopes/evaluate requests). - Use the explicit line numbers for breakpoints in the SetVariable tests. - Do not use errors.Is - we could've used golang.org/x/xerrors polyfill but that's an additional dependency, and we will remove this check once tests that depend on old behavior are fixed. * dap: remove errTerminated and adjust the test * dap: evaluate in the outer frame, instead of advancing to the next bp
- Loading branch information