aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/debugging.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dev/debugging.md')
-rw-r--r--docs/dev/debugging.md61
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
3Install [LLDB](https://lldb.llvm.org/) and the [LLDB Extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb). 3## Prerequsities
4 4
5Checkout 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
19where **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. 28TypeScript debugging is configured to watch your source edits and recompile.
29To 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