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

incorrect DW_AT_location for static #32574

Open
tromey opened this issue Mar 29, 2016 · 3 comments
Open

incorrect DW_AT_location for static #32574

tromey opened this issue Mar 29, 2016 · 3 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tromey
Copy link
Contributor

tromey commented Mar 29, 2016

I'm using rust from the Fedora COPR:

bapiya. rustc --version
rustc 1.7.0 (a5d1e7a59 2016-02-29)

Consider this program:

pub static AA: i32 = 5;

fn main() {
}

I compile with -g and then examine the DWARF using readelf. I see:

 <2><2f>: Abbrev Number: 3 (DW_TAG_variable)
    <30>   DW_AT_name        : (indirect string, offset: 0x48): AA
    <34>   DW_AT_type        : <0x62>
    <38>   DW_AT_decl_file   : 1
    <39>   DW_AT_decl_line   : 1
    <3a>   DW_AT_location    : 9 byte block: 3 0 0 0 0 0 0 0 0  (DW_OP_addr: 0)
    <44>   DW_AT_linkage_name: (indirect string, offset: 0x4f): _ZN2b12AAE

Now, this variable is not actually emitted. There's no ELF symbol for it. Given this, it seems strange to emit DW_AT_linkage_name and DW_AT_location, especially considering that the latter is incorrect.

@sanxiyn sanxiyn added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Mar 29, 2016
@michaelwoerister
Copy link
Member

Interesting. We are probably setting the static's linkage to private but don't take care of removing debuginfo for it and LLVM doesn't either.

@Mark-Simulacrum
Copy link
Member

#33172 has good reproduction instructions.

@wesleywiser
Copy link
Member

Visited in wg-debugging's triage meeting. This still repros in 2022 but since it's just a matter of including more info than necessary, we don't believe this is breaking any debuggers so marking as P-low.

bors bot added a commit to probe-rs/probe-rs that referenced this issue Sep 20, 2022
1232: Stack overflow when expanding "static" section in probe-rs-debugger r=Yatekii a=noppej

There was an error in the logic that prevented cetain variable types from being loaded in a deferred/lazy way. This resulted in situations where recursively referenced types (as in a linked list) would loop forever trying to resolve all children of a structured variable.

Fixes #1231

Additional fixes: 
- This also fixes a new issue (exposed by testing of this PR). Recent changes in RUST have removed the intermediate `DW_AT_name` attribute for the `DW_AT_type` of the `data_ptr` child of `&str` variables, resulting in a failure to resolve those variable values during debug.
- A [RUST compiler issue](rust-lang/rust#32574) resulted in a reference to a variable being left behind in the debug info, even though the value has been optimized out. This PR updated the error message to be a bit more user friendly.




Co-authored-by: JackN <[email protected]>
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
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.) C-bug Category: This is a bug. P-low Low priority 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

6 participants