-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
service,terminal,cmd/dlv: automatically guessing substitute-path config #3781
Conversation
15b7904
to
d41a9b9
Compare
cc @hyangah I've been wanting to remove the legacy mode of vscode-go adapter and I was wondering if something like this would work. How it worksClient side it runs What the extension would have to doThe extension, before connecting to dlv, would have to run locally Thoughts? Would this work? |
Thank you so much! A couple of questions:
In case of the remote debugging, the debugged target executable is available only on the remote host. Shouldn't
|
The idea is that
The idea is that
I initially did this and then backed off of it. There is no guarantee that the standard library that was used to build the executable is the same one that's available locally, so we shouldn't blindly map it. We could be smarter about it, but in practice it is rare that the user will step into the standard library (I think) so it's probably fine to leave it unmapped. |
Thanks. I will give it a try and test it.
I'd say there is also no guarantee that the user code used to build the executable is not exactly the same as the one available locally strictly speaking. I hope users of remote debugging to ensure both systems use the identical versions. (Or can we have a warning based on the Go build info?) |
Yes, we have a warning for this. Vscode-go doesn't but that's a UI problem.
Sure, let us know. |
I think we need to handle stdlib locations unfortunately.
I agree that it's not perfect if local/remote go versions don't match. We can track this issue - how to notify users of this version skew - separately, independent of this PR. There is one more issue. In the specific example I tested (https://github.com/hyangah/go-docker-alpine-remote-debug), the main package is
I will send the copy of the binary built in case it's helpful for investigation. |
94e462d
to
5829ae6
Compare
Added the GOROOT mapping and fixed the example. The example did not work because there the main module contains a single package (main). |
5829ae6
to
a5ef8b3
Compare
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.
LGTM
@hyangah can you approve as well? After your +1 I will merge.
Thanks (and sorry for all this delay). One more question: what is the meaning of "ImportPathOfMainPackage"? Running Looking into the code, I wonder if we should use |
a5ef8b3
to
f17d687
Compare
It's the import path of the package named 'main'. I added it because of https://github.com/hyangah/go-docker-alpine-remote-debug where without it we wouldn't know how to map the files in the main module.
I hadn't considered that a module could contain multiple packages named main. I have changed the code to account for that. For now I'm just discarding this information when there are multiple main packages. This would only affect a module that contains at least two main packages and zero non-main packages, I think this is unlikely and we can ignore it.
To do that we need to know the path of the main package, right? I don't think VSCode-go necessarily knows that. |
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! LGTM.
BTW, I wonder if golang.org/x/tools/go/packages can be useful when adding support for other build systems like bazel (with GOPACKAGESDRIVER) in the future.
service/dap/types.go
Outdated
// GuessSubstitutePath is used to automatically guess SubstitutePath if it | ||
// is not specified explicitly. It should be copied from the output of | ||
// 'dlv substitute-path-guess-helper'. | ||
GuessSubstitutePath *api.GuessSubstitutePathIn |
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.
(optional) to be consistent with other fields style, it may be json:"guessSubstitutePath,omitempty"
.
I'm ok with keeping the json encoding of api.GuessSubstitutePathIn
fields as they are though because that's an output of dlv substitute-path-guess-helper
output.
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.
Done.
@@ -0,0 +1,39 @@ | |||
## dlv substitute-path-guess-helper | |||
|
|||
|
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.
since this is a public page :-) I think it's worth mention that this is an internal utility to support DAP's remote debugging guess substitute path.
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.
Actually, I don't think that page should exist at all, since it's an hidden command. I've removed it. Thanks.
8d668bf
to
90f3e33
Compare
Is this something that has actually been implemented (a GOPACKAGESDRIVER for bazel) or is it planned? |
9f2978e
to
cceb973
Compare
Add command, API calls and launch.json option to automatically guess substitute-path configuration.
cceb973
to
40e93ce
Compare
I think https://pkg.go.dev/github.com/bazelbuild/rules_go/go/tools/gopackagesdriver is one of the open-source bazel GOPACKAGESDRIVER. Google internally also has a similar one. But, how complete, reliable they are currently (e.g. does 'module' info make sense and get populated...) needs research. |
Add command, API calls and launch.json option to automatically guess
substitute-path configuration.