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: variable read should not be optimized when using -gcflags="all=-N -l" #29977
Comments
This looks like it's a consequence of the fact that we haven't separated out required rewrites from optional rewrites in the There are only a few required rewrite rules; they shouldn't be hard to split out. There's even a comment in the code:
|
@randall77 I do have a question for you. Why is it that when swapping the lines 22 and 23 then this doesn't happen? And, perhaps the bigger question, why doesn't this optimization apply to line 23 in the original code as well? I would expect the behavior to be consistently applied for function calls, but it seems it's not? Is it related to the parameter type that the function expects? |
This is the difference between:
and
In the former, a simple rewrite rule can follow the flow of "5" to the argument slot of
This is because |
using go version go1.15.3 linux/amd64 this bug still exists and prevents assignments to variables in delve. |
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?
dlv debug blah.go
curl -i http://localhost:8080/
set returnStatus = 404
in delve then resume the applicationWhat did you expect to see?
The debugger should be able to change the value of the function parameter before the call happens.
What did you see instead?
The debugger was unable to change the value and the old value was used.
My expectation is that if I compile the application using
-gcflags="all=-N -l"
such optimization is removed and I can do what I need to do with my program to debug it.I also noticed that if I swap lines 22 and 23 and keep the breakpoint on line 22 then the result is the expected one. So the optimization applied here is not consistently applied either (should I open a separate bug for it?).
According to @aarzilli in the original issue, go-delve/delve#1473 (comment):
that line compiles to:
the instruction of interest is 0x75094b which sets one of the function arguments directly to the constant 0xc8 (200). The compiler noticed that the value of the variable is constant and optimized the read away.
The text was updated successfully, but these errors were encountered: