Rust-gdb no prettify variables properly

Hello folks, I'm reading Debugging Rust apps with GDB. But when I going to (gdb) p *animals statement, the result are not the same.

Result in the article:

(gdb) p *animals
$2 = Vec(size=3) = {rust_gdb_example::Animal {kind: rust_gdb_example::AnimalType::Cat, name: "Chip", age: 4}, rust_gdb_example::Animal {kind: rust_gdb_example::AnimalType::Cat, name: "Nacho", age: 6}, rust_gdb_example::Animal {kind: rust_gdb_example::AnimalType::Dog, name: "Taco", age: 2}}

here is mine (debian bullseye, gdb version: Debian 10.1-1.7):

(gdb) p *animals
$2 = Vec(size=3) = {
  rust_gdb_example::Animal {kind: rust_gdb_example::AnimalType::Cat, name: alloc::string::String {vec: alloc::vec::Vec<u8> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: 0x5555555a3ad0, _marker: core::marker::PhantomData<u8>}, cap: 4, alloc: alloc::alloc::Global}, len: 4}}, age: 4}, 
  rust_gdb_example::Animal {kind: rust_gdb_example::AnimalType::Cat, name: alloc::string::String {vec: alloc::vec::Vec<u8> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: 0x5555555a3af0, _marker: core::marker::PhantomData<u8>}, cap: 5, alloc: alloc::alloc::Global}, len: 5}}, age: 6}, 
  rust_gdb_example::Animal {kind: rust_gdb_example::AnimalType::Dog, name: alloc::string::String {vec: alloc::vec::Vec<u8> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: 0x5555555a3b10, _marker: core::marker::PhantomData<u8>}, cap: 4, alloc: alloc::alloc::Global}, len: 4}}, age: 2}}

Look like name field not decode correctly.

I also try to use gdb 8.3 (compile by myself), but still not the same:

# start gdb by following command ...
RUST_GDB=/tmp/gdb-8.3/gdb/gdb rust-gdb ~/test/rust-gdb-example/target/debug/examples/basic

...

(gdb) p *animals
$2 = alloc::vec::Vec<rust_gdb_example::Animal> {buf: alloc::raw_vec::RawVec<rust_gdb_example::Animal, alloc::alloc::Global> {ptr: core::ptr::unique::Unique<rust_gdb_example::Animal> {pointer: 0x5555555a3480, _marker: core::marker::PhantomData<rust_gdb_example::Animal>}, cap: 3, alloc: alloc::alloc::Global}, len: 3}

This is the first time I'm playing with gdb. Any suggestions are very welcome. Thanks.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.