Debug in vscode can't show the slice value

I want to see the slice value in the debug window of vscode. however, it only gave me an address of a referenced vector variable. It's very inconvenient to debug, how can I solve this problem. How you guys debug in vscode?

[update] I have committed this issue to

Which debugger extension are you using? To show slice values you need to load the rust pretty printer for lldb or gdb. How you do this depends on the debugger extension. For terminal usage, the rust-gdb and rust-lldb wrapper scripts load it for you.

1 Like

Thanks, I use CodeLLDB Extension. How can I integrate this extension with pretty printer?

I just tried rust-lldb on the terminal and the pretty printer doesn't seem to work this way either.

It's an absolute nightmare for a beginner. I tried rust-lldb, too. When I use the 'print' command, there is only an address with some unimportant information. Does rust-gdb will work fine? (I have not installed gdb, lldb was installed by default in OS X bigsur)

Nope, doesn't work with rust-gdb either.

Um..., that's a really tricky problem. Use "println!" to debug every function is a little bit disgusting.

On my Linux system with gdb 9.2, pretty-printing works with rust-gdb:

Breakpoint 1, dbg::main () at src/
3	    let n = v.len();
(gdb) p v
$1 = Vec(size=3) = {1, 2, 3}

However, it is not working in lldb 10.0.0 with rust-lldb:

Process 21765 stopped
* thread #1, name = 'dbg', stop reason = breakpoint 1.1
    frame #0: 0x000055555555961b dbg`dbg::main::h3c5bf25b2d123525 at
   1   	fn main() {
   2   	    let v = vec![1,2,3];
-> 3   	    let n = v.len();
   4   	    dbg!(n);
   5   	}
(lldb) p v
(alloc::vec::Vec<int>) $0 = {
  buf = {
    ptr = {
      pointer = 0x000055555559b9d0
      _marker = {}
    cap = 3
    alloc = {}
  len = 3

It could be a bug in OS X.

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.