I was noticing that values printed in the debugger often seem to be uninitialized when stepping past a line that initializes them. It appears that the DWARF line tables are advancing the line number one instruction too early. For example, with this go code
I looked at gc's assembly output, and it shows the same issue, so this isn't a problem with the dwarf generation. Also I can't seem to reproduce it if I use --gcflags "-N -l" to disable optimization, so it may not be worth digging in to.
It's not an off-by-one. The instruction you identified is the spill of a variable to memory. Spills don't really have a "correct" line number. They can be arbitrarily delayed, too, so certainly line 24 could end and parts of line 25 could continue to execute before the spill happened. In this sense the current line number reporting is probably better. Anyway, it's a very hard problem.