Rust debugger's question


#1

Hi I have rust-gdb and lldb installed in my linux OS, but I cannot successfully use them to debug rust program.

Here I list the details of the debug process, the rust-gdb is able to run, but failed to hit the correct break point, and the watched variables also not display;

And the lldb simply not runs, I think I should get a rust-lldb, but I can’t find it from the installed rust package, or on the net, could anybody tell me where I can get that rust-lldb?

rust-gdb:

…Rust/hello/target/debug> cargo build
…Rust/hello/target/debug> rust-gdb hello

Reading symbols from hello…done.
(gdb) l main.rs:main
1 fn main() {
2 let mut ia;
3 for i in 0…10 {
4 ia = i;
5 println!(“Hello{}!”, ia);
6 }
7 }
(gdb) b 3
Breakpoint 1 at 0x5ecb: …/Rust/hello/src/main.rs:3. (2 locations)
(gdb) b 4
Breakpoint 2 at 0x5f97: file …/Rust/hello/src/main.rs, line 4.
(gdb) run
Starting program: …/Rust/hello/target/debug/hello
Missing separate debuginfos, use: zypper install glibc-debuginfo-2.19-22.1.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib64/libthread_db.so.1”.

Breakpoint 1, hello::main ()
at /…/Rust/hello/src/main.rs:3
3 for i in 0…10 {
Missing separate debuginfos, use: zypper install libgcc_s1-debuginfo-5.3.1+r233831-6.1.x86_64
(gdb) c
Continuing.

Breakpoint 1, hello::main ()
at /…/Rust/hello/src/main.rs:3
3 for i in 0…10 {
(gdb) c
Continuing.

Breakpoint 2, hello::main ()
at /…/Rust/hello/src/main.rs:5
5 println!(“Hello{}!”, ia);
(gdb) watch ia
Hardware watchpoint 3: ia
(gdb) c
Continuing.
Hello0!

Breakpoint 1, hello::main ()
at /…/Rust/hello/src/main.rs:3
3 for i in 0…10 {
(gdb) c
Continuing.

Breakpoint 2, hello::main ()
at …/Rust/hello/src/main.rs:5
5 println!(“Hello{}!”, ia);


lldb:

…Rust/hello/target/debug> lldb hello
(lldb) target create "hello"
Current executable set to ‘hello’ (x86_64).
(lldb) l
1 fn main() {
2 let mut ia;
3 for i in 0…10 {
4 ia = i;
5 println!(“Hello{}!”, ia);
6 }
7 }
(lldb) run
// Nothing more display here


#2

What is your question?


#3

Hi vadimcn

Sorry I was in a hurry to post this question before my internet connection was cut off, hence missing a lot of things in describing the question itself.

I have edited this post to add more details about the question.

Thank you for your replies!


#4

I’ve just tried this using both current nightly as well as stable, and it worked as expected. Would be useful to know versions of everything you are using.

rust-lldb is a script that adds nicer formatting for Rust data types, otherwise it’d be the same lldb you have.


#5

Hi vadimcn

I tried both Rust beta and nightly, they behaved the same, I mean, the debugging outcomes.

The gdb version is: (GDB; openSUSE Leap 42.1) 7.11.1
The lldb is: lldb version 3.7.0 ( revision 246586 clang revision 246586 llvm revision 246586)

When I tried to debug in VS Code by using gdb, although the only breakpoint I added was in line 4, but the program paused at line 5, the breakpoint in line 4 was not hit.

When I moved the mouse to any breakpoint while it was debugging, it always feedback the message said “unverified breakpoint”.

And it printed a warning, which I am not sure will be the reason for this problem:

warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/Gene/ST/Studio/VSCode/Rust/hello/target/debug/hello.
Use `info auto-load python-scripts [REGEXP]’ to list them.

Thank you for you help!


#6

I’ve had the same problem several months ago. It’s because your lldb is outdated. All you need is a newer one.
See this: Rust-lldb not printing out local variables


#7

Thank you, Congee.

I have just downloaded and installed the latest lldb and llvm and everything related, but it still kept hanging there when I “run” the rust program under lldb. The command “list” is OK to display the source code, just can’t “run”, let alone the debugging.

I am using the openSUSE leap, I am considering an ubuntu or other OS may work, but not sure, because I can’t debug the rust program in Windows too.

By the way, do you know where I can get the rust-lldb? I think I may try that.


#8

Maybe you should try gdb 7.12.

http://phoronix.com/scan.php?page=news_item&px=GDB-7.12-Released


#9

rust-lldb is just a shell script wrapper, here it is:

The previous problem of lldb is that the older version of lldb just doesn’t list the source code. But now it seems you have a new problem. I suggest you report an issue.


#10

Thank you for all your guys’ replies, very appreciate for you help.

I have changed my OS from openSUSE to Fedora, it seems Fedora does not have this issue.

Not sure whether it’s a gcc version issue or not, since I have changed my OS before reading your replies.