-
Notifications
You must be signed in to change notification settings - Fork 765
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
Debugger shows only 1 entry in a map whose keys are structs #1042
Comments
While supporting compound values, the adapter erroneously treats all keys as scalars, using their variable "values" as-is. However, the value of a compound variable is not actually its unique value, but just a type placeholder with an option to expand for more info. And since all keys have the same type, they all end up with the exact same value, so the map ends up with only one entry in the UI. From the log with
Related bug: #1085 |
This is how the new adapter in delve repo (go-delve/delve#1515) is handling this: go-delve/delve#2111 (comment) Update 01/12: changed from index to address in keys in go-delve/delve#2291 |
@polinasok Thank you for taking a look at this issue. Would it be possible to serialize the keys, e.g. by calling btw. how can I use that new adapter in delve repo? Listing all keys and values with unique indices would be a usable workaround for me 🙂 |
The debugger backend doesn't operate on Go types. It has its own way to track and annotate types and variables that allows to power debugging. Therefore we would not be able to just serialize the actual key. There are also limitations on the size of the string value that we load once (delve default is 64). If we serialize a nested struct, we will end up trying to fit into a single line something that would require multiple lines with dlv cli and multiple expansions with vscode UI. What you can do to serialize on your end is use The new adapter is experimental and work in progress. We are not actively advertising it yet as some key features are still missing, but we welcome any user testing if you want to check it out. As delve releases only once every several months, you need to get its latest revision on your own to try out the new adapter. You could launch |
The new adapter is still accessible using the nightly version of this extension. |
Summarizing earlier discussion. We will not be fixing this issue in the existing adapter. We have fixed this in the new adapter However, displaying the key as just type+address is not as informative as one would like. @Gelio could you please file a separate issue for this feature request? Would something like what dlv cli does suit you?
|
Closing this is understandable. Thanks for the summary. I actually don't really know how we could proceed here and what would be a useful fix for the improvement here. Displaying all the entries in the map sounds great, so IMO it should be good enough 🙂 The dlv cli output also looks reasonable, since it seems to serialize the keys (or am I missing something?). So, to sum up, do you want me to create a ticket essentially copying what you said in the comment above? |
That would be great. We don't need the details about fixing the 1-entry issue in that but, just the info about displaying variables in a user-friendly way. If your point of view matches what I wrote, feel free to copy things. If you have any additional insights, please let us know. Thank you! |
Thanks for the instructions 🙂 I've described the feature request in #1267 That forced me to explore the new adapter, which honestly, looks pretty dope 😄 Finally I'm able to see the contents of the struct keys 🎉 very cool Also, that was my first time using |
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gogopls -v version
to get version of Gopls if you are using the language server.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insidersgo env
to get the go development environment detailsShare the Go related settings you have added/edited
Describe the bug
When debugging the program, a map whose keys are structs displays only a single entry, even though the length shows there are many.
Code sample:
p
will only show 1 entryEven with
String
implemented forposition
, and changing the name toPosition
, the result is still the sameI would expect the debugger to list all entries in this case, possibly using
String
to serialize the map keys.Steps to reproduce the behavior:
fmt.Println
in the snippet abovep
. It will show only 1 entry, and length of 3Screenshots or recordings
Added in the description
The text was updated successfully, but these errors were encountered: