Description
Code
I tried this code:
fn main() {
let var_a = 1;
let var_b = 2; // <- stop here
let var_c = 3;
}
Then run this with rust-gdb:
> b test.rs:3
> r
> info locals
for rust 1.70 output is correct:
var_a = 1
for rust 1.71 output contains uninitialized variable:
var_b = 0
var_a = 1
Lets see whats changed in dwarf, i dump'd 1.70 and 1.71 versions and check difference.
First for 1.70, lexical block of var_b:
< 4><0x00000063> DW_TAG_lexical_block
DW_AT_low_pc 0x00071010
DW_AT_high_pc <offset-from-lowpc> 8 <highpc: 0x00071018>
And line number info for line 3:
0x00071008 [ 3,17] NS
So it's ok, pc of lexical block for var_b greater then pc of line 3 start, and debugger doesnt show var_b.
Now for 1.71. Lexical block of var_b:
< 4><0x00000063> DW_TAG_lexical_block
DW_AT_low_pc 0x0006dd28
DW_AT_high_pc <offset-from-lowpc> 16 <highpc: 0x0006dd38>
And line number info for line 3:
0x0006dd28 [ 3, 9] NS
In dwarf generated by rustc 1.71 pc of var_b lexical block are equal to pc of line 3, that's why we see an uninitialized variable.
Version it worked on
Rust 1.70
Version with regression
rustc 1.71.0 (8ede3aa 2023-07-12)
binary: rustc
commit-hash: 8ede3aa
commit-date: 2023-07-12
host: x86_64-unknown-linux-gnu
release: 1.71.0
LLVM version: 16.0.5