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 IsStmt flag not set for line although it is executed #45680
Comments
CC @thanm |
I can reproduce this problem in 1.16 and on tip. The problem seems to be happening in the expand_calls phase. Looking at the SSA for main.main, prior to expand_calls we have:
with IsStmt flag set on the deref prior to the call (call itself does not have flag set). In expand_calls, the Deref is rewritten to a Move, and in the process the IsStmt flag is explicitly turned off (https://go.googlesource.com/go/+/f12cf7694f491a13bb39741d183034a917a994b3/src/cmd/compile/internal/ssa/expand_calls.go#634). SSA after expand calls looks like
Note v14 above -- before it had "IstStmt" and now it does not (which makes sense given line 634). Resulting final assembly for Go 1.16 is:
which explains why we can't set a breakpoint on line 19. On tip things are also unhappy, however in a slightly different and interesting way (worse in fact): At the trim phase we have:
which is more or less what was happening in 1.16 modulo reg abi (e.g. the IsStmt marker on the Deref has been lost), but then the final assembly looks like:
Note the IsStmt + line 20 on the MOVQ at 00003. This is a good deal more unhappy than what we had in 1.16. I think the weird position in the MOVQ is being introduced by this code, first and then Requesting help from @dr2chase , author of expand_calls and also the firstPos code in ssagen/ssa.go lines 6602/6679. |
I wonder if it might make sense to have expand_calls make use of f.cachedLineStarts (similar to what's done in rewrite and deadcode). |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
It was working on 1.14.9 but not after that
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
for some sample code I tried to read the dwarf information however in below specific code the line number information is wrong
I get dwarf line info using
objdump --dwarf=decodedline hello2
What did you expect to see?
Line 19 is desirable
What did you see instead?
Line 19 is desirable
So it is not possible to put a breakpoint on line 19 for instance on debuggers
Speculation
The strange thing about this bug is that if you change the source code to be like this:
or this
the line number information is right.
So passing struct which has array elements or
complex64
to a function which does twofmt.Println
call make the line number information for the calling line, wrongThe text was updated successfully, but these errors were encountered: