-
Notifications
You must be signed in to change notification settings - Fork 770
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
debug: issues displaying dereferenced pointer value in the Variable pane #112
Comments
cc @polinasok A similar issue was discussed recently in #567 but, there users expressed interest in easier inspection of the dereferenced values. My personal preference is to present the type, pointer value, and dereferenced values (if available) rather than switching to I agree the name-less |
@hyangah The current behavior is consistent with what happens with dlv cli:
This is also consistent with other compound types that have fields, items or elements, such as arrays, maps, interfaces. Those also show type, not value, at the top and an option to expand into the child elements that build up the value. A pointer is more than just the raw address because it has an underlying type. And without the type, you can't tell the difference between different kinds of pointers just from the numeric address, but you can tell the difference between ints and floats and such from just the value. Scalar types are inherently different, so they don't have to be consistent. But a case can be made that including extra type information into scalars can be useful as well because then you can differentiate between primitive and user-defined types as well as different flavors of ints or floats. Would it at all be helpful to print ints as "int(5)" vs "myInt(5)" vs "int32(5)"? @willfaught |
Interesting, good to know!
True, but you can't tell the difference between an
Agreed that "int(5)" vs "myInt(5)" vs "int32(5)" would be more helpful. Perhaps the pointer syntax could be changed from
The Go spec defines pointer types with:
So perhaps "value" is best. |
This would require adjusting how all other types are displayed as they all use angular brackets to differentiate types from values visually. |
Change https://golang.org/cl/252979 mentions this issue: |
We are working on a new version of the adapter (please see dlv-dap.md). It inlines values in place of just the type, so you don't even need to expand to view the data in many cases. I believe this addresses some of the issues described here. |
it's weird that vscode doesn't have a UI to see types and addresses. I guess the javascript bias is still strong. There's another way to go here: add the type to the variable name instead of the value, so you have |
There is type field in dap Variable, but it is intended to go into hover for each var. No address field though. Types being too long is the unfortunate reality and has come up before in other contexts, so I would be hesitant to add that to the variable names. Interestingly, it would be consistent with what .NET does: Although in the past they had the type at the end of the value, which is also an option and would be more compatible with long types: I will add some c++ snapshots for inspiration tomorrow. |
I think the hover for looking up type is sufficient for now. We can revisit if we hear more from the users. One possibility would be to have a |
Personally, I like C++'s way. Furthermore, if we can move most the type info into the hover, and take it out of the inlined value presentation, that will be consistent and help reducing the cruft caused by the type info. Still type is long, but visible only when people hover over. IMO most likely, people know the types of the variables they are investigating and filling the screenspace with the type info isn't great. |
How are pointer values (not the values they reference) inspected now? Do I understand correctly that now for var p, q *int
// ...
for p != q {
// ...
} When the Locals show
we know what the code will do, whereas for
who knows what will happen? It depends on the pointer values themselves, not the values they reference. I suggest we omit the types entirely like C++. The type info is in the source code that you're (presumably) looking at as you step through it. It's helpful for debug info to be as concise and readable as possible. Just use the most concise form of the underlying type: |
From @willfaught in microsoft/vscode-go#2176:
The dereferenced pointer value is labeled with a single colon, which might be a bug. See the b variable below:
The debugger presentation of the pointer type seems incompatible with the other integral types (variables i and x in the example above).
int(0)
is displayed asi: 0
,X(34)
(where X istype X int
) is displayed asx: 34
, but(*int)(0xc0000160f8)
is displayed asp: <*int>(0xc0000160f8)
. Maybe it makes sense to display it as justp: 0xc0000160f8
and let the user infer the type from the code like for the other variable types (and the presence of the drill down menu)?Please see microsoft/vscode-go#2176 for more discussion on this
The text was updated successfully, but these errors were encountered: