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/link: include declared constants in DWARF #14517

Open
aclements opened this Issue Feb 26, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@aclements
Member

aclements commented Feb 26, 2016

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

@aclements aclements added this to the Unplanned milestone Feb 26, 2016

@aclements

This comment has been minimized.

Member

aclements commented Jul 10, 2017

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.

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

@hyangah hyangah added the Debugging label Jul 18, 2017

@gopherbot

This comment has been minimized.

gopherbot commented Sep 3, 2017

Change https://golang.org/cl/61019 mentions this issue: cmd/compile,cmd/link: export int global consts to DWARF

gopherbot pushed a commit that referenced this issue Sep 22, 2017

cmd/compile,cmd/link: export int global consts to DWARF
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>
@gopherbot

This comment has been minimized.

gopherbot commented Oct 9, 2017

Change https://golang.org/cl/69270 mentions this issue: cmd/compile: add ideal int constants to dwarf

gopherbot pushed a commit that referenced this issue Oct 9, 2017

cmd/compile: add ideal int constants to dwarf
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