I want to print the result of a calling a function of a std::path::Path instance.
I'm using Rust 1.43 and GDB 9.1
main.rs
use std::path::Path;
fn main() {
let path = Path::new("/home/sweet/home");
println!("The path: {}", path.display());
}
When I try to debug it with rust-gdb I get this:
$ rust-gdb target/debug/poc-gdb-pathbuf
...
>>> start
>>> n
>>> print path
$1 = (*mut std::path::Path) 0x55555557c000
>>> print &path
$2 = (*mut *mut std::path::Path) 0x7fffffffe0c0
>>> print *path
$3 = std::path::Path {
inner: std::ffi::os_str::OsStr {
inner: std::sys_common::os_str_bytes::Slice {
inner: 0x55555557c000
}
}
}
>>> print *path.is_absolute()
Could not find function named 'std::path::Path::is_absolute'
>>> print path.is_absolute()
Could not find function named 'std::path::Path::is_absolute'
>>> print path.display()
Function 'std::path::Path::display' takes no arguments
>>> print *path.display()
Function 'std::path::Path::display' takes no arguments
As you can see I cannot manage to call a single Path instance function correctly, either it tells me the function doesn't exists (it does) or that it takes no arguments (I haven't passed any).
I have no problems with a simple, minimal struct function call, here's an example that works.
main.rs
struct Something {
x: u8
}
impl Something {
pub fn new(x: u8) -> Self {
Something { x }
}
pub fn show(&self) -> u8 {
return self.x
}
}
fn main() {
let something = Something::new(10);
something.show();
}
The rust-gdb session:
$ rust-gdb target/debug/poc-gdb-something
...
>>> start
>>> n
>>> print something
$1 = poc_gdb_pathbuf::Something {
x: 10
}
>>> print something.show()
$2 = 10
I suspect it may be something about the Path instance being a pointer but dereferencing it doesn't help...
Why the Path calls doesn't work? What am I missing?