-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/compile: DWARF Incorrect slice len #48405
Comments
Please compile with |
Thanks that worked for delve but actually we are working on different debugger project in IBM zOS and this issue pops up. Is there any reason that normal build creates this issue? |
|
My guess is the length gets spilled to a stack location, which is where Delve thinks the value lives. I'm not sure what the state of our dwarf info is for optimized code. Do we emit dwarf entries for things that live in registers? |
@randall77 we do emit DWARF entries for things that live in registers, so in theory a correct debug location should be possible even if different parts of the slice are in registers/mem. With that said, getting the locations right 100% of the time is a difficult problem. I'll take a closer look at the code+DWARF and see if I can see anything useful. |
I looked at the variable locations being emitted for "cards". They are pretty clearly damaged/incorrect, but it is hard to see exactly what the root cause is. The DWARF variable DIE looks like
and the location list is
From looking at the locations above it is clear that the location-tracking code has detected that the variable is partially in memory/registers at various points in the procedure, but it is clearly getting the location wrong for the epilog. The code before the return looks like
So the correct location should be rdx/rsi/rdi, but that is obviously not happening. I'll add this to my collection of things to look at for future improvements, time permitting. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No, this issue appeared after 1.14.9
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Consider below source code:
Now, compile the code and run debugger on final exe. set breakpoint on line 12 of
newDeck
function and then try to see the local variable:What did you expect to see?
the slice length is 16 and I expect to see this after running
locals
commad:cards = main.deck len: 16, cap: 16, [...]
What did you see instead?
cards = main.deck len: 15, cap: 16, [...]
There is also an interesting behavior here. If you try to print the length of that slice the debugger shows the length correctly:
The text was updated successfully, but these errors were encountered: