cmd/link: include declared constants in DWARF #14517
Open
Comments
This is somewhat easier now that DWARF is being generated by the compiler. It would still require that we keep track of the constants, since currently they disappear pretty early in the process. This came up again in a discussion of how heap analysis from a core dump could get access to runtime constants. At the moment they just have to be hard-coded. /cc @khr @heschik |
Change https://golang.org/cl/61019 mentions this issue: |
gopherbot
pushed a commit
that referenced
this issue
Sep 22, 2017
Updates #14517 Change-Id: I23ef88e71c89da12dffcadf5562ea2d7557b62cf Reviewed-on: https://go-review.googlesource.com/61019 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Change https://golang.org/cl/69270 mentions this issue: |
gopherbot
pushed a commit
that referenced
this issue
Oct 9, 2017
The core dump reader would like a bunch of ideal int constants to be available in dwarf. Makes the go binary 0.9% bigger. Update #14517 Change-Id: I00cdfc7f53bcdc56fccba576c1d33010f03bdd95 Reviewed-on: https://go-review.googlesource.com/69270 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the DWARF information does not include constant symbols (such as
const x = 1
). This can make debugging more difficult, as constants available to the program are not available in the debugger. It also causes problems for debugging helpers. For example, our own runtime-gdb.py GDB helper hard-codes the G status constant values. This list gets out of date and means we can't cull now-unused G statuses.We should include constants in the DWARF information. DWARF has a DW_TAG_constant for exactly this. The DW_AT_const_value attribute can be a string or any constant form, including DW_FORM_sdata, which is encoded as a LEB128, so in principle it can store arbitrary precision integers (though I don't know how well this is supported in practice). It's not clear to me how to represent floating point constants, though I suspect we'd have to truncate them to 64-bit precision to get them to actually work (despite DWARF's dizzying array of numeric type encodings; scaled packed decimal anyone?).
Doing this would be difficult right now because the compiler would have to emit constants in a way the linker could consume to produce DWARF information. It would probably be relatively straightforward if we switched to producing DWARF directly in the compiler.
/cc @ribrdb @derekparker
The text was updated successfully, but these errors were encountered: