-
Notifications
You must be signed in to change notification settings - Fork 645
Migrate delve calls to v2 API #1555
Comments
I agree that its about time we did this. |
FWIW, I'm giving it a try here: master...lggomez:delve_v2, it's still a work in progress The diff between v1 and v2 seems to be mostly on the side of wrapper types (for both in/out params) and the inclusion of the LoadConfig type which gives us the customization options for #868, among others). These are obviously breaking changes but it looks a bit less painful than I thought originally With these changes, the debug mode blows up upon launch with the following errors: Do you have any tips on how to debug this? breakpoints on goDebug don't get bound and I find the verbose mode being not really helpful |
Some more info: This is the diff I get by logging the delve API calls from the extension Example code is the same as #1385 (comment) for the package v1:
v2:
The |
Sounds great. How will I know when it will support api v2? Thanks |
I've been swamped with work these last weeks so unfortunately I couldn't put any further effort into this. The WIP branch I have it this one: master...lggomez:delve_v2, but since the new apicalls aren't working I can't consider it PR ready yet. There's also the difficulty of debugging the debug adapter in a fast and reliable way A tentative roadmap would be the following:
If someone can give me a hand with the debugging part I can continue with this migration |
@lggomez I think your problem is that the argument to CreateBreakpoint isn't wrapped, which means no breakpoint gets created and when you call the continue Command the program executes completely. |
@aarzilli indeed, that was the problem. I just verified it so I will continue with the rest of a basic debug case during the following days. Thanks for the tip |
@ramya-rao-a I made progress to the point of having a working adapter. I conducted very basic tests but so far all of the basic commands seem to work I've some questions regarding the next steps to take
|
If you want to manually run the tests we do automatically for delve: https://github.com/derekparker/delve/blob/master/service/test/integration2_test.go look for things that call withTestClient2 and withTestProcess in this two files. Also https://github.com/derekparker/delve/blob/master/_fixtures/testvariables2.go. |
@lggomez Regarding your questions
|
@lggomez I've pushed a commit to make this backward compatible. Here is my intended plan
As I mentioned before, we would still need to take care of the scenario of remote debugging. Are you aware of any way the client can figure out what version of api is the headless server running on? |
@ramya-rao-a thanks for the help, this work is finally taking shape and the plan sounds good to me I'll start debugging tests tomorrow, on my work projects. Regarding remote debugging, I just found the api calls needed to achieve it: https://godoc.org/github.com/derekparker/delve/service/rpccommon. These should be common across v1 and v2 so the compat is already granted I added the check during launchRequest, upon successful connection to delve: bcb89e4 The api also supports changing the version served by the remote server, but I prefer failing fast instead of doing that as I deem it too aggressive to be a default behavior |
To use v2 apis add the below in your debug configuration:
Change the 64 to the say 300 to see longer strings and arrays when debugging |
This feature is now out in the latest update to the Go extension (0.6.81) |
Is there anyway to use v2 when debugging tests by clicking the "Debug test" in the IDE? It looks like there is a hard coded debug config in vscode-go. |
I believe that the debug tests command uses the currently selected debug configuration, so as long as you have v2 activated on that config with these settings you should be able to use it |
@lggomez As I mentioned in #1647 (comment), the codelens for "debug tests" uses hard coded configuration from https://github.com/Microsoft/vscode-go/blob/0.6.82/src/goRunTestCodelens.ts and doesn't read from the launch.json file. @giulianob What is your specific use case for using the v2 apis? Do you intend to configure any of the settings from #1555 (comment)? If yes, then feel free to log a feature request for the same. |
@ramya-rao-a my bad. We can add an option that, if set to true, will bypass that default launch cfg and use the currently selected one forcing (or validating) that it has mode === 'test' Can we use the configurationmanager from the native debugService to retrieve the launch cfg from the codelens provier? |
VS Code also lets you debug files with default config even when there is no launch.json file. To support that as well as the debug codelens, we will have to have a separate setting which mimics the
I don't see how that is possible though. The debug adapters from extensions are called by VS Code in a separate process that has no access to settings as far as I know. If you find anything different, do share. I was thinking of reading the settings in https://github.com/Microsoft/vscode-go/blob/master/src/goDebugConfiguration.ts. |
I've logged #1735 to track the pending item from the above discussion |
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 64000,
"maxArrayValues": 64000,
"maxStructFields": -1
} Debugging is very very slow now. It's unusable. |
@kzhui125 never tried such large limits but I can't say it's unexpected though, you'll have to settle down with a lower value We could measure which part has the major slowdown: delve, the rpc apicall itself or vs code |
Some debugging limitations/issues such as #868 can be solved by using the new delve API:
https://godoc.org/github.com/derekparker/delve/service/rpc2
As a reference, this is the version we're using right now:
https://godoc.org/github.com/derekparker/delve/service/rpc1
The following calls would have to be migrated:
The main challenge here is that the migration cannot be done partially (on a per call basis) since the delve server starts either in v1 or v2 mode, as stated here, and the signature changes will involve a partial rewrite of goDebug
The text was updated successfully, but these errors were encountered: