Printing single vector elements in gdb

After searching, the simpler solution seems to be:

p int_vec.buf.ptr.pointer.__0[0]

Now, another point. If you use rust-gdb, printing a Vec should look like:

$1 = Vec<i32>(len: 7, cap: 7) = {1, 2, 3, 4, 5, 6, 7}

And not all this unreadable stuff. The two most probable reason for that is that your version of gdb is too old, or that is was compiled without the python support. If you run info pretty-printer in gdb, it should include rust_pretty_printer_lookup_function.

1 Like