Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I inspect local variables or use the watch window with Rust code using VSCode and LLDB?

I am trying to debug a Rust application using VSCode, but I am unable to inspect any local variables or use the watch window (see attached).

All breakpoints work fine, I just cannot view any variables, etc.

  • VSCode v1.19.1
  • Linux Elementary (latest)
  • LLDB Debugger 0.7.3

The LLDB is what is shown in VSCODE plugin, but when I do lldb --version from the terminal it says: lldb version 3.8.0 ( revision ).

I get no errors when starting lldb from the terminal. All breakpoints are hit while debugging, I just cannot see any of the variable values.

For the sake of completeness, I verified python scripting support as a Prerequisite listed on: https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb

**

python-lldb-3.8 is already the newest version

**

No local or watch

like image 490
schmoopy Avatar asked Jan 02 '18 21:01

schmoopy


People also ask

How do I run a rust program in VS Code?

Install the rust-analyzer extension# You can find and install the rust-analyzer extension from within VS Code via the Extensions view (Ctrl+Shift+X) and searching for 'rust-analyzer'. You should install the Release Version.

How do I run a json file in VS Code?

In Visual Studio Code, use shortcut Ctrl + Shift + P to open the Command Palette and type Open launch. json . And it will open the launch.

How do you debug using breakpoints in Visual Studio Code?

Set breakpoints in source code To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.


1 Answers

The correct solution was to install LLDB 3.9. I can now inspect local variables, use the watch window, and see values via tooltips.

Here are the steps:

  1. Install LLVM 3.9. I found the accepted answer in this SE post to be the easiest way.
  2. Update Python LLDB to this version as per the vscode-lldb wiki. For example, I ran sudo apt-get install python-lldb-3.9
    1. Since LLVM now is invoked as llvm-3.9 (instead of just llvm) then VSCode may not recognize it and complain that LLVM is not installed or supported. My solution (yours may vary) was to remove then reinstall the VSCode extensions "LLDB Debugger 0.7.3" and "Native Debug 0.21.2"

Once this was done and VSCode was restarted, I started to debug with F5 then VSCode gave me an alert that a different LLDB was found (3.9) and asked to update to new executable - say yes and you should be good to go.

Results:

debugging session

like image 93
schmoopy Avatar answered Oct 27 '22 16:10

schmoopy