diff options
author | Veetaha <[email protected]> | 2020-02-16 20:58:17 +0000 |
---|---|---|
committer | Veetaha <[email protected]> | 2020-02-16 21:00:10 +0000 |
commit | 64112b0b61cd842f2186240374a89ae05a8d0bb9 (patch) | |
tree | 0578ad5b2a81e8126cb4f180f777023ef92a9946 /docs | |
parent | 43a41819cbb1d400c8787936e3d35b8b65c55a29 (diff) |
docs: update debugging.md with the freshest VSCode debugging information
Diffstat (limited to 'docs')
-rw-r--r-- | docs/dev/debugging.md | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/docs/dev/debugging.md b/docs/dev/debugging.md index f868e6998..5a942ba5d 100644 --- a/docs/dev/debugging.md +++ b/docs/dev/debugging.md | |||
@@ -1,34 +1,58 @@ | |||
1 | # Debugging vs Code plugin and the Language Server | 1 | # Debugging vs Code plugin and the Language Server |
2 | 2 | ||
3 | Install [LLDB](https://lldb.llvm.org/) and the [LLDB Extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb). | 3 | ## Prerequsities |
4 | 4 | ||
5 | Checkout rust rust-analyzer and open it in vscode. | 5 | - Install [LLDB](https://lldb.llvm.org/) and the [LLDB Extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) VSCode extensions. |
6 | - Open the root folder in VSCode. Here you can access the preconfigured debug setups. | ||
6 | 7 | ||
7 | ``` | 8 | <img height=150px src="https://user-images.githubusercontent.com/36276403/74611090-92ec5380-5101-11ea-8a41-598f51f3f3e3.png" alt="Debug options view"> |
8 | $ git clone https://github.com/rust-analyzer/rust-analyzer.git --depth 1 | 9 | |
9 | $ cd rust-analyzer | 10 | - Install all TypeScript dependencies |
10 | $ code . | 11 | ```bash |
11 | ``` | 12 | cd editors/code |
13 | npm i | ||
14 | ``` | ||
15 | |||
16 | ## Common knowledge | ||
17 | |||
18 | * All debug configurations open new `[Extension Development Host]` VSCode instance | ||
19 | where **only** your `rust-analyzer` extension is enabled. | ||
20 | * To activate the extension you need to open any Rust project folder in `[Extension Development Host]`. | ||
12 | 21 | ||
13 | - To attach to the `lsp server` in linux you'll have to run: | ||
14 | 22 | ||
15 | `echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope` | 23 | ## Debug TypeScript VSCode extension |
16 | 24 | ||
17 | This enables ptrace on non forked processes | 25 | - `Run Extension` - runs the extension with globally installed `ra_lsp_server` binary. |
26 | - `Run Extension (Dev Server)` - runs extension with binary from your locally built `target/debug/ra_lsp_server`. | ||
18 | 27 | ||
19 | - Ensure the dependencies for the extension are installed, run the `npm: install - editors/code` task in vscode. | 28 | TypeScript debugging is configured to watch your source edits and recompile. |
29 | To apply changes to already running debug process press <kbd>Ctrl+Shift+P</kbd> and run the following command in your `[Extension Development Host]` | ||
30 | |||
31 | ``` | ||
32 | > Developer: Reload Window | ||
33 | ``` | ||
34 | |||
35 | ## Debug Rust LSP server | ||
36 | |||
37 | - To attach to the `lsp server` in linux you'll have to run: | ||
20 | 38 | ||
21 | - Launch the `Debug Extension`, this will build the extension and the `lsp server`. | 39 | ``` |
40 | echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | ||
41 | ``` | ||
22 | 42 | ||
23 | - A new instance of vscode with `[Extension Development Host]` in the title. | 43 | This enables ptrace on non-forked processes |
24 | 44 | ||
25 | Don't worry about disabling `rls` all other extensions will be disabled but this one. | 45 | - Enable debug symbols in `Cargo.toml`: |
46 | ```toml | ||
47 | [profile.dev] | ||
48 | debug = 2 | ||
49 | ``` | ||
26 | 50 | ||
27 | - In the new vscode instance open a rust project, and navigate to a rust file | 51 | - Select `Run Extension (Dev Server)` to run your local built `target/debug/ra_lsp_server`. |
28 | 52 | ||
29 | - In the original vscode start an additional debug session (the three periods in the launch) and select `Debug Lsp Server`. | 53 | - In the original VSCode window once again select `Attach To Server` debug configuration. |
30 | 54 | ||
31 | - A list of running processes should appear select the `ra_lsp_server` from this repo. | 55 | - A list of running processes should appear. Select the `ra_lsp_server` from this repo. |
32 | 56 | ||
33 | - Navigate to `crates/ra_lsp_server/src/main_loop.rs` and add a breakpoint to the `on_task` function. | 57 | - Navigate to `crates/ra_lsp_server/src/main_loop.rs` and add a breakpoint to the `on_task` function. |
34 | 58 | ||
@@ -36,7 +60,8 @@ $ code . | |||
36 | 60 | ||
37 | ## Demo | 61 | ## Demo |
38 | 62 | ||
39 | ![demonstration of debugging](https://user-images.githubusercontent.com/1711539/51384036-254fab80-1b2c-11e9-824d-95f9a6e9cf4f.gif) | 63 | - [Debugging TypeScript VScode extension](https://www.youtube.com/watch?v=T-hvpK6s4wM). |
64 | - [Debugging Rust LSP server](https://www.youtube.com/watch?v=EaNb5rg4E0M). | ||
40 | 65 | ||
41 | ## Troubleshooting | 66 | ## Troubleshooting |
42 | 67 | ||