-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: some local variables are missing from DWARF #18247
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
cc: @hyangah |
I believe the simple explanation is we emit DWARF records for parameters (including result parameters) and for user-declared local variables that are allocated stack frame space. |
Ah, thanks. So variable that are constant, are allocated to registers, are CSE'd, or escape to the heap will be missing from the debug view. |
Oh, if a variable But I believe your other cases are correct: registerized and CSE'd variables are not mentioned in the DWARF output. If it would help, I think we can easily emit records to at least declare that those variables exist in the source (e.g., so debuggers looking up an identifier don't mistakenly find a shadowed global variable instead). We're just not currently setup to track location any more fine-grained than a simple stack frame offset, so we can't emit DW_AT_location for them. |
Furthermore, if a variable is allocated a stack slot but is registerized at a particular PC, the DWARF information will only refer to the stack slot, so you can get a stale (or uninitialized?) value. Fixing that is probably part of fixing debug info for fully registerized variables. But now that the DWARF is being emitted by the compiler instead of the linker, there's at least a hope of doing this. |
I've also noticed that at some points in program execution, running |
@bcmills I can't think of any significant recent DWARF changes that would have that effect. |
Would it be preferable that instead of emitting DWARF entries for the pseudo-variable |
Yes, definitely. :) |
Update: as of go1.21.5, there is now an entry for
|
For function
f
, gc emits debug information about the formal parameter x and the local variable i, but not the local variable s. In this instance I imagine the reason is that s is effectively constant, but still it would improve the debug view if such variables were included. And in other programs, many other locals that are truly variable are omitted too.(Is there a simple explanation for how the compiler currently decides which variables get a DW_TAG_variable record?)
The text was updated successfully, but these errors were encountered: