rust-lang / lldb

No longer used, use https://github.com/rust-lang/llvm-project instead
Other
14 stars 6 forks source link

impl Struct functions are not found #26

Open jeremysalwen opened 5 years ago

jeremysalwen commented 5 years ago

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6193616cd6aa584793bcb730269a6eac

fn main() {
    let foo = Foo {x: 5};
    foo.print();
    println!("Hello, world!");
}

struct Foo {
    x :i32
}

impl Foo {
    fn print(&self) {
        println!("hello {}", self.x)
    }
}
#[test]
fn test_foo() {
    println!("Hello test");
    let _foo = Foo {x: 5};
    panic!();
}
$ rust-lldb target/debug/deps/exampledgb-0f6ba88c6ac57fe3
(lldb) command script import "/home/jeremysalwen/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/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
(lldb) target create "target/debug/deps/exampledgb-0f6ba88c6ac57fe3"
Current executable set to 'target/debug/deps/exampledgb-0f6ba88c6ac57fe3' (x86_64).
(lldb) b main.rs:20
Breakpoint 1: where = exampledgb-0f6ba88c6ac57fe3`exampledgb::test_foo::h6982aa095a01d5c4 + 72 at main.rs:20, address = 0x0000000000011a28
(lldb) run
Process 196886 launched: '/home/jeremysalwen/fun/exampledgb/target/debug/deps/exampledgb-0f6ba88c6ac57fe3' (x86_64)

running 1 test
Process 196886 stopped
* thread #2, name = 'test_foo', stop reason = breakpoint 1.1
    frame #0: exampledgb-0f6ba88c6ac57fe3`exampledgb::test_foo::h6982aa095a01d5c4 at main.rs:20
   17   fn test_foo() {
   18       println!("Hello test");
   19       let _foo = Foo {x: 5};
-> 20       panic!();
   21   }
(lldb) p _foo.print()
error: no member named 'print' in 'exampledgb::Foo'
(lldb) 
tromey commented 5 years ago

error: no member named 'print' in 'exampledgb::Foo'

I wonder whether you are using the rust-enabled lldb. In mine I get:

(lldb) print foo.print()
error: no field named print

That is, different error message.

tromey commented 5 years ago

It seems I just forgot to implement this properly in the parser.