DWARF doesn't describe use declarations

fc3f1ed
Opened by Tom Tromey at 2023-02-20 15:21:59

I wrote a small test program of use declarations:

pub mod mod_x {
    pub fn f() {
        use ::mod_y::g;

        g();
    }

    pub fn g() {
        println!("X");
    }
}

pub mod mod_y {
    pub fn g() {
        println!("Y");
    }
}

pub fn main() {
    mod_x::f();
}

Examining the DWARF, I don't see anything in the body of f that reflect the use declaration.

What this means is that when stopped in f in gdb, name lookup will not work properly -- call g() will call the wrong g.

use declarations can be represented with something like DW_TAG_imported_declaration or DW_TAG_imported_module.

  1. Visited during wg-debugging triage. We're not aware of any work to implement this since the issue was filed.

    Wesley Wiser at 2023-02-20 15:21:59