Skip to content
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
Open

cmd/link: include declared constants in DWARF #14517

aclements opened this issue Feb 26, 2016 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Debugging
Milestone

Comments

@aclements
Copy link
Member

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
Copy link
Member Author

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

@gopherbot
Copy link

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
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
Copy link

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
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>
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Debugging
Projects
None yet
Development

No branches or pull requests

3 participants