Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-lldb hangs when printing non-trivial type #115632

Open
qrnch-jan opened this issue Sep 7, 2023 · 1 comment
Open

rust-lldb hangs when printing non-trivial type #115632

qrnch-jan opened this issue Sep 7, 2023 · 1 comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-debugging Working group: Bad Rust debugging experiences

Comments

@qrnch-jan
Copy link

Someone mentioned that rust-lldb has issues printing nested types. To test this I wrote the following testcase:

#[derive(Debug)]
struct Deep {
  s: String
}

#[derive(Debug)]
enum Something {
  Variant(Deep)
}

#[derive(Debug)]
struct Shallow {
  s: String,
  val: usize,
  ch: char,
  something: Something
}

fn main() {
  let d = Deep {
    s: String::from("g00")
  };
  let something = Something::Variant(d);
  let o = Shallow {
    s: String::from("w00"),
    val: 42,
    ch: 'q',
    something
  };
  let a = 7;
  let b = 11;
  let c = a * b;
  println!("{c}");
  println!("{:?}", o);
}

I built a debug version of this and ran rust-lldb on it:

$ rust-lldb ~/tmp/bld/cargo/debug/playground

I set a breakpoint on main, step until a is set and print it:

(lldb) breakpoint set --name main
Breakpoint 1: 2 locations.
(lldb) run
Process 6366 launched: '/Users/jan/tmp/bld/cargo/debug/playground' (x86_64)
Process 6366 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
    frame #0: 0x0000000100003960 playground`main
playground`main:
->  0x100003960 <+0>: pushq  %rbp
    0x100003961 <+1>: movq   %rsp, %rbp
    0x100003964 <+4>: movq   %rsi, %rdx
    0x100003967 <+7>: movslq %edi, %rsi
Target 0: (playground) stopped.
(lldb) cont
Process 6366 resuming
Process 6366 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x000000010000349b playground`playground::main::hf49c7f512596a7cd at main.rs:30:7
   27  	    ch: 'q',
   28  	    something
   29  	  };
-> 30  	  let a = 7;
   31  	  let b = 11;
   32  	  let c = a * b;
   33  	  println!("{c}");
Target 0: (playground) stopped.
(lldb) n
Process 6366 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x00000001000034a5 playground`playground::main::hf49c7f512596a7cd at main.rs:31:7
   28  	    something
   29  	  };
   30  	  let a = 7;
-> 31  	  let b = 11;
   32  	  let c = a * b;
   33  	  println!("{c}");
   34  	  println!("{:?}", o);
Target 0: (playground) stopped.
(lldb) print a
(int) $0 = 7

If I print o:

(lldb) print o

.. lldb seemingly hangs. I have to mash Ctrl+C until it stops.

If I restart rust-lldb and instead set a breakpoint inside main I get a different result.

(lldb) breakpoint set --file main.rs --line 31
Breakpoint 1: where = playground`playground::main::hf49c7f512596a7cd + 21 at main.rs:31:7, address = 0x00000001000034a5
(lldb) run
Process 6323 launched: '/Users/jan/tmp/bld/cargo/debug/playground' (x86_64)
Process 6323 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001000034a5 playground`playground::main::hf49c7f512596a7cd at main.rs:31:7
   28  	    something
   29  	  };
   30  	  let a = 7;
-> 31  	  let b = 11;
   32  	  let c = a * b;
   33  	  println!("{c}");
   34  	  println!("{:?}", o);
Target 0: (playground) stopped.
(lldb) print a
(int) $0 = 7
(lldb) print o
(playground::Shallow) $1 = {
  s = "" {
    vec = size=0
  }
  val = 4294967296
  ch = U+0x00000050 U'P'
  something =
}
(lldb) 

(Output of o indeed looks broken, but that's a separate issue).

Versions

$ rust-lldb --version
lldb-1403.0.17.67
Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
$ rustc --version
rustc 1.72.0 (5680fa18f 2023-08-23)

Running on x64.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 7, 2023
@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-debugging Working group: Bad Rust debugging experiences and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 9, 2023
@dev-ardi
Copy link
Contributor

cc: vadimcn/codelldb#994

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-debugging Working group: Bad Rust debugging experiences
Projects
None yet
Development

No branches or pull requests

4 participants