eranif / codelite

A multi purpose IDE specialized in C/C++/Rust/Python/PHP and Node.js. Written in C++
https://codelite.org
GNU General Public License v2.0
2.09k stars 448 forks source link

[Bug]: unable to expand vectors in "Debugger/Locals" for Rust #3307

Open Dreamoochy opened 5 months ago

Dreamoochy commented 5 months ago

What happened?

When debugging rust programs, vector varables can't be expanded in the Debugger/Locals to view their content. Also vector items can't be viewed in the Debugger/Watches.

Version

Other

Operating system

Windows 11

Steps to reproduce

1. Create the following rust program

fn main() {
    let a: [i32; 2] = [15, 16];

    for i in 0..a.len() {
        println!("a[{i}] = {}", a[i]);
    }

    let v: Vec<i32> = vec!(1, 10);

    for i in 0..v.len() {
        println!("v[{i}] = {}", v[i]);
    }
}

2. Start debugging
3. After creating `a` variable it is accessible in the Debugger/Locals panel and can be expanded showing the array items. Also each item (e.g. a[0]) can be viewed in the Debugger/Watches
4. After creating `v` variable it is accessible in the Debugger/Locals panel, but can't be expanded to view vector items. Also its items (e.g. v[0]) can't be viewed in the Debugger/Watches

P.S. Rust (cargo/rustc/rust-analyzer) v1.71.0

Relevant log output

No response

eranif commented 5 months ago

can you post a screenshot? which debugger are you using?

eranif commented 5 months ago

I tried various debuggers in CodeLite and that one that actually worked well for me was: gdb It did not work out of the box :( A small fix did the trick for me:

Note: I am using MSYS2 environment under windows, but this should be same for other OSs as well.

From the terminal, I typed this:

readlink -f $(rustc --print=sysroot)/lib/rustlib/etc

This should produce a path for you, for example, for me this was the output:

C:/msys64/clang64/lib/rustlib/etc

This is the location where the gdb python pretty printers for Rust are placed.

In CodeLite, right click on the top folder, open the workspace settings and click on the Debug tab, under the "Startup commands" set this:

python
import sys
sys.path.insert(0, 'C:/msys64/clang64/lib/rustlib/etc')
import gdb_load_rust_pretty_printers
end

(replace C:/msys64/clang64/lib/rustlib/etc with the output you got from the previous command)

Debugging should we working now

rust-gdb

Dreamoochy commented 5 months ago

Thank you. It seems there're some related issues.

  1. In CodeLite dir there is a subdir \gdb_printers which contains \rustlib\etc with the python scripts. So CodeLite distro already has rust-related scripts. With this scripts vectors can't be expanded.
  2. I copied the same scripts from my rust installation to the CodeLite datadir (--datadir command-line param). After that I was able to expand vectors, but in the inconvenient form: image And there's still no possibility to view vector items in Debugger/Watches
  3. On each start this folder (\gdb_printers) is copied to the CodeLite datadir overwriting existing files.

I use GNU gdb (GDB for MinGW-W64 x86_64, built by Brecht Sanders, r5) 14.1 which is a part of winlibs personal build version gcc-13.2.0-mingw-w64ucrt-11.0.1-r5 (https://winlibs.com/, https://github.com/brechtsanders/winlibs_mingw/)

I will wait for the Rust 1.76 to see if it's the matter of version incompatibility.

Dreamoochy commented 5 months ago

As it seems, with Rust v1.76 vectors are expanded correctly in Debugger/Locals, but it is still unable to view vector items in Debugger/Watches.