Skip to content

DWARF does not emit DW_TAG_label #140407

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

Open
ratmice opened this issue Apr 28, 2025 · 3 comments
Open

DWARF does not emit DW_TAG_label #140407

ratmice opened this issue Apr 28, 2025 · 3 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ratmice
Copy link
Contributor

ratmice commented Apr 28, 2025

In the following rust code it would be nice if this emitted a DW_TAG_label

fn foo() {
    'rs_label: {
        break 'rs_label;
    }
}

In the equivalent C code,

int main() {
  c_label:
    return 0;
}

This will emit a DW_TAG_label

 <2><55>: Abbrev Number: 3 (DW_TAG_label)
    <56>   DW_AT_name        : (indirect string, offset: 0): c_label

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (cb31a009e 2025-04-27)
rustc 1.86.0 (05f9846f8 2025-03-31)
@ratmice ratmice added the C-bug Category: This is a bug. label Apr 28, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 28, 2025
@moxian
Copy link
Contributor

moxian commented Apr 28, 2025

The label information does not exist in the MIR presently AFAICT, so adding that would probably be the first step
@rustbot label: -C-bug +C-enhancement +T-compiler +A-debuginfo +A-MIR

@rustbot rustbot added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. labels Apr 28, 2025
@bjorn3
Copy link
Member

bjorn3 commented Apr 29, 2025

What would be the benefit of emitting this? Adding unnecessary things to the debuginfo still increases the size of the debuginfo and it already is way too big.

@ratmice
Copy link
Contributor Author

ratmice commented Apr 29, 2025

It allows you to set breakpoints on labels, in the c example you can break main:c_label in gdb,
the gdb linespec processor would need fixing to deal the with quote in rust labels, but it is probably reasonable to escape it.

Edit:
In that sense it allows you to avoid specifying line numbers for stable breakpoints: instead of break main.rs:3 or whatever.

There is another way to do this, using https://crates.io/crates/probe and specifying a breakpoint on a probe.
But that only works in userspace on platforms that support probes.

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 29, 2025
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.) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

5 participants