-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: Go generates wrong .debug_loc in dwarf #49133
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
Comments
Thanks for reporting this. Do you know if it's a go1.17 regression? (i.e., does go1.16 do the right thing?) |
maybe related? #47354 |
I tried go1.15 and go1.16, the location info in both version seems okay. |
I retested this morning, and it looks like this is now working properly on tip. In GDB I get:
There have been several CL's submitted recently to fix DWARF problems: CL 362244, CL 362618, and CL 362244, most likely one of them took care of the problem. Closing out this issue, please comment if needed. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Step 1
I wrote a simple program: https://play.golang.org/p/KQIOD26fmo7
Step 2
I built program with default flags and used gdb to run, tried to inspect the arguments when
strings.Replace
was about to be called:What did you expect to see?
I expected to see the correct value of variable
n
: 1.What did you see instead?
However I got
4285733
.Some other facts that may help
I confirmed that gdb located variable
n
using dwarf debug info, and details are as followed:Let's look at .debug_info first, and here's info concerned:
We can see the variable
n
at location0xe2c
, so here's what I got from .debug_loc:Because DW_OP_fbreg is calculated based on CFA, so let's turn to .debug_frame:
So these information has told us,
n
is located at$rsp+8+48
, and that's exactly where gdb tried to find the variable value:However it doesn't seem working.
I also tried delve debugger instead of gdb, and it turned out dlv generated .debug_loc precisely:
I extracted related infomation as followed:
This time variable
n
is located at $r9, and that is right.Then I get back to the normal binary (from
go build .
), found out then
variable is actually also located at $r9, that's to say go compiler generated the wrong .debug_loc info in dwarf.The text was updated successfully, but these errors were encountered: