-
Notifications
You must be signed in to change notification settings - Fork 795
Added delve 'call' support #101
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
Added delve 'call' support #101
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@ekulabuhov - Thank you for the PR! I am so excited about this feature. Can you please sign the CLA so we can start the review process? |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
This PR (HEAD: 27d736c) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/240200 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be Please don’t reply on this GitHub thread. Visit golang.org/cl/240200. |
This PR (HEAD: 49b2904) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/240200 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: 261bea2) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/240200 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: c321337) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/240200 to see it. Tip: You can toggle comments from me using the |
Message from Hyang-Ah Hana Kim: Patch Set 4: (2 comments) Eugene, thanks for the contribution! Eli, can you please take a look? Please don’t reply on this GitHub thread. Visit golang.org/cl/240200. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! A request for documentation first.
Also, a question: did you try this with both API versions for Delve?
// #2326: Set the fully qualified name for variable mapping | ||
variable.fullyQualifiedName = variable.name; | ||
response.body = this.convertDebugVariableToProtocolVariable(variable); | ||
const re = new RegExp(/\w+(?=\(.*\))/, 'g'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a detailed comment here (or above the evaluateRequest
method) explaining this contract: what exactly we're looking for in the eval request to interpret as a 'call', and how it's treated. A reader writing a test for this should be able to read the comment and understand how to craft test DAP messages that would trigger this behavior, what its limitations and corner cases are, etc.
@eliben @ekulabuhov Can we move this forward? |
@ekulabuhov I created a cl based on your change. FYI Sorry that it would've been ideal if I could push the commit to this branch and the gerritbot could handle this without me creating a separate cl. I filed a feature request here for gerritbot improvement. golang/go#40906 |
Delve supports function calls. Even though it is still experimental and can be applied only to a limited set of functions, this is a useful feature, many vscode-go users long for. Unlike other javascript/typescript debuggers, delve treats function calls specially and requires different call paths than usual expression evaluation. That is because Go is a compiled, runtime-managed GC language, calling a function safely from debugger is complex. DAP and VS Code UI does not distinguish function calls and other expression evaluation either, so we have to implement this in the same `evaluateRequest` context. We use a heuristic to guess which route (call or expression evaluation) we need to take based on evaluateRequest's request. The set of expressions delve supports includes some of the builtin function calls like `len`, `cap`. We also expect some grammar changes due to the ongoing effort for Go2 experiment. In order to cope with this uncertainty, this change requires users to specify their intention using the 'call' keyword. Any expression that starts with 'call' and contains function-call-like strings, will cause the evaluateRequest to take the path for the `call` command. And, DAP and VSCode assumes all expressions return only one result, but in Go, function call can return multiple values. In this CL, we work around this sementic difference by wrapping all the return values in one wrapper result that has all return values as children. Users can expand each value. While we are here, this CL also adds a logic to handle the interface type value. Previously, it was captured by the default case that does not show the underlying type and value. Interface types behave differently depending on the underlying data type and value (e.g. nil error https://golang.org/doc/faq#nil_error) so showing the underlying type/value upfront helps debugging much easier. In particular, the 'error' type is commonly used as the last return value of a function call and the program control flow changes depending on whether the error is nil. So, here we surface the underlying type and, if the underlying type is invalid and the addr is 0 (nil error), present the result as 'nil <error>'. This allows users to recognize the 'nil' error value without extra value expansion. Any error with an underlying type will be presented as `<error(someUnderlyingType)>` and require the value expansion. I see we can further improve this display value handling and try to follow delve's data presentation as much as possible but that is a bigger change and is beyond the scope of this CL. This is based on github.com//pull/101 Fixes #100 Co-authored-by: Eugene Kulabuhov <[email protected]> Change-Id: I4e1e876ab1582b17fa2c7bf0b911f31ec348b484 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/249377 Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Polina Sokolova <[email protected]>
I just submitted https://go-review.googlesource.com/c/vscode-go/+/249377 that started based on @ekulabuhov's PR. |
Updates #100