Skip to content

debuginfo: DWARF encoding of space-optimized enums not correct for fat pointers #19339

Closed
@michaelwoerister

Description

@michaelwoerister

Debuginfo for adt::RawNullablePointer (and probably also adt::StructWrappedNullablePointer) enums is not correct if the pointer that doubles as discriminant is a fat pointer.

Steps to reproduce:

(1) Compile the following program with -g

fn main() {
    let x = Some("abc");
    ::std::io::println(x.unwrap());
}

(2) Print the value of x in LLDB with pretty printers enabled:

Michaels-Mac-mini:option-fat-pointer mw$ rust-lldb ./main
Executing commands in '/tmp/rust-lldb-commands.66chQx'.
(lldb)  command script import "/Users/mw/rust/x86_64-apple-darwin/stage1/lib/rustlib/etc/lldb_rust_formatters.py"
(lldb)  type summary add --no-value --python-function lldb_rust_formatters.print_val -x ".*" --category Rust
(lldb)  type category enable Rust
Current executable set to './main' (x86_64).
(lldb) b 4
Breakpoint 1: where = main`main::main + 88 at main.rs:4, address = 0x0000000100001878
(lldb) r
Process 26375 launched: './main' (x86_64)
Process 26375 stopped
* thread #1: tid = 0x202ad, 0x0000000100001878 main`main::main + 88 at main.rs:4, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100001878 main`main::main + 88 at main.rs:4
   1    
   2    fn main() {
   3        let x = Some("abc");
-> 4        ::std::io::println(x.unwrap());
   5    }
(lldb) p x
(core::option::Option<&str>) $0 = None
(lldb) 

This should print Some(0x12345678) instead of None.

Maybe it's just the LLDB pretty printer that needs to be adapted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions