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

Tuple field names in debuginfo are prefixed with __. #106009

Open
jswrenn opened this issue Dec 21, 2022 · 2 comments
Open

Tuple field names in debuginfo are prefixed with __. #106009

jswrenn opened this issue Dec 21, 2022 · 2 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jswrenn
Copy link
Member

jswrenn commented Dec 21, 2022

The DWARF debugging information entries for tuple field names (and for the field names of tuple-like structs and variants) are prefixed with __. For instance, Option's Some variant is recorded as having a field named __0, rather than 0.

I think this is a little unfortunate. Tuple indices behave quite like field names in Rust, insofar that they're accessed with . and that you can instantiate tuple-like structs and variants as if they are records; e.g.:

Some { 0: true };

It's odd, then, that these fields would not appear in a debugger as they would in Rust.

My own stake in this is deflect, allows you to get fields by name from structs and variants. Users reflecting on tuple-like structs and variants must know to prefix their queries with __, and the pretty-printer and serializers provided by deflect cannot generally strip away the __ from field names.

@notriddle notriddle added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Dec 21, 2022
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@tromey
Copy link
Contributor

tromey commented Apr 13, 2023

I'd imagine this approach was desirable before gdb had direct support for Rust. Back then you'd have to debug in C++ mode and that wouldn't understand x.0 as referring to a field.

Nowadays, gdb knows about the __ convention. It would be pretty simple to add support for numeric field names (for Rust) in gdb, but it would be nice to have some warning before a change is made; and on the other hand I probably wouldn't bother modifying gdb unless I knew Rust was planning to change.

@tromey
Copy link
Contributor

tromey commented Mar 17, 2025

Nowadays, gdb knows about the __ convention. It would be pretty simple to add support for numeric field names (for Rust) in gdb, but it would be nice to have some warning before a change is made; and on the other hand I probably wouldn't bother modifying gdb unless I knew Rust was planning to change.

FTR, gccrs emits tuple fields without the underscores, so I've submitted a gdb patch for that: https://sourceware.org/pipermail/gdb-patches/2025-March/216383.html. This should be in gdb 17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants