-
Notifications
You must be signed in to change notification settings - Fork 575
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
Add Rust Formatters to Debugger (Vector, Map etc.) #2219
Add Rust Formatters to Debugger (Vector, Map etc.) #2219
Conversation
9ca4cb3
to
1b489de
Compare
@@ -63,7 +63,8 @@ jobs: | |||
- name: install utils macos | |||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos') | |||
run: | | |||
brew install swig cmake ninja libedit | |||
brew remove swig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to remove a pre-installed dependency from a GitHub image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, there isn't a better way. I think removing the existing version and reinstalling the version needed is a solid way.
@@ -111,7 +112,7 @@ jobs: | |||
-DLLVM_INCLUDE_TESTS:BOOL=OFF \ | |||
-DLLVM_ENABLE_BINDINGS:BOOL=OFF \ | |||
-DLLVM_ENABLE_LIBXML2:BOOL=ON \ | |||
-DLLDB_ENABLE_PYTHON:BOOL=OFF \ | |||
-DLLDB_ENABLE_PYTHON:BOOL=ON \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to include a full version of Python along with the LLDB download or what is the common way to deal with this dependency when shipping LLDB binaries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://lldb.llvm.org/resources/build.html IIUC, just need to enable |
If I do so and execute the resulting binary on a different machine. I get this:
I think I have to bundle Python with LLDB, so that version and the path are the same. |
How about using the default configuration? |
0ee3579
to
37207c7
Compare
9fdf8e3
to
728fa44
Compare
728fa44
to
c5de03c
Compare
-DLLVM_BUILD_BENCHMARKS:BOOL=OFF \ | ||
-DLLVM_BUILD_DOCS:BOOL=OFF \ | ||
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \ | ||
-DLLVM_BUILD_BENCHMARKS:BOOL=OFF -DLLVM_BUILD_DOCS:BOOL=OFF \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had better put -DLLVM_BUILD_DOCS:BOOL=OFF
on another line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
-DCMAKE_BUILD_TYPE:STRING="Release" \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | ||
-DLLVM_ENABLE_PROJECTS="clang;lldb" \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_ENABLE_PROJECTS="clang;lldb" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had better put -DLLVM_ENABLE_PROJECTS="clang;lldb"
on another line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
a8c2757
to
13f9de3
Compare
Hi, @MrSarius I think it's really cool to better format the container data structure in the debugger panel of VS Code. I wanted to give the new lldb a try, however, as a VS Code rookie I got stuck when writing launch.json. The only way I know how to use a customized lldb is to set |
- remove redundant flags - improve formatting
13f9de3
to
e319f72
Compare
Hey @TianlongLiang , |
LGTM |
This PR adds tests for #2219 by changing the `compilation_on_android_ubuntu.yml` workflow. The first run will take about two hours, since LLDB is built from scratch. Later, the build is cached and the whole job should not take more than three minutes. Core of the PR is an integration test that boots up vscode and lets it debug a test WASM file.
…2219) This PR adds LLDB formatters so that variables are human-readable when debugging Rust code in VS Code. This includes Tuple, Slice, String, Vector, Map, Enum etc. It also distributes a standalone Python version with LLDB. This solution enables high portability, so Ubuntu 20.04 and 22.04 can for example still be supported with the same build since glibc is statically linked in the Python build, also making it easier to support more operating systems in the future. Known Issues: Enum types are not displayed correctly. For more details, refer to: bytecodealliance#2219
This PR adds tests for bytecodealliance#2219 by changing the `compilation_on_android_ubuntu.yml` workflow. The first run will take about two hours, since LLDB is built from scratch. Later, the build is cached and the whole job should not take more than three minutes. Core of the PR is an integration test that boots up vscode and lets it debug a test WASM file.
This PR adds LLDB formatters so that variables are human-readable when debugging Rust code in VS Code. This includes Tuple, Slice, String, Vector, Map, Enum etc.
Python in LLDB
For performing more complex calculations on debugger variables (as required in this PR), LLDB uses Python. This requires building LLDB with Python support, but there are some hurdles to overcome.
LLDB links to the Python C ABI, which is not compatible between minor versions of Python. Although a stable Python ABI exists, LLDB does not stick to this subset. Means we have to ensure that the exact version of Python that we are using in our pipeline is available on the user's machine. Even if the version is correct, LLDB cannot link against Python from different distributions (e.g. homebrew and python.org).
Therefore I decided to distribute a stand-alone Python version with LLDB. This solution enables high portability. This way, Ubuntu 20.04 and 22.04 can for example still be supported with the same build since glibc is statically linked in the Python build, also making it easier to support more operating systems in the future.
This approach also seems to be the GOTO solution in comparable cases (e.g. XCode also uses LLDB and distributes it with a own Python build with each version).
Swig3 MacOs
Inside the MacOs pipeline I had to downgrade from swig4 to swig3 because swig4 causes the LLDB build to fail. Perhaps this can be removed at a later date.
Tests
This was tested on MacOs13-aarch64 and Ubuntu22.04-x86.
I've also written unit and integration tests for my implementation, however for anything related to the VS Code extension there haven't been any tests at all yet, I'll open another PR for that.
Known Issues
Enum types are not displayed correctly. For example, for optionals LLDB resolves this type:
core::option::Option<>
instead ofcore::option::Option<&str>...
(see screenshot). This must be an issue in the patched LLDB build, the formatters themselves work fine with native LLDB.I'm currently investigating this, but it should not be related to the changes from this PR.
Test changes
Click me
Build iwasm with source debugging feature.
Compile your rust file with debug symbols and no optimisation to avoid inlining.
Download the LLDB build (with python) for your platform from my pipeline and move it to the extension's resource folder.
Execute iwasm with debug engine enabled.
Open vs code in
${WAMR_ROOT}/test-tools/wamr-ide/VSCode-Extension
, go to the debug tab and launchLaunch Extension
. In this new window, the extension is now enabled.Set your breakpoints in vs code and launch the debugger with this
launch.json