1 # Debugging vs Code plugin and the Language Server
3 Install [LLDB](https://lldb.llvm.org/) and the [LLDB Extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb).
5 Checkout rust rust-analyzer and open it in vscode.
8 $ git clone https://github.com/rust-analyzer/rust-analyzer.git --depth 1
13 - To attach to the `lsp server` in linux you'll have to run:
15 `echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope`
17 This enables ptrace on non forked processes
19 - Ensure the dependencies for the extension are installed, run the `npm: install - editors/code` task in vscode.
21 - Launch the `Debug Extension`, this will build the extension and the `lsp server`.
23 - A new instance of vscode with `[Extension Development Host]` in the title.
25 Don't worry about disabling `rls` all other extensions will be disabled but this one.
27 - In the new vscode instance open a rust project, and navigate to a rust file
29 - In the original vscode start an additional debug session (the three periods in the launch) and select `Debug Lsp Server`.
31 - A list of running processes should appear select the `ra_lsp_server` from this repo.
33 - Navigate to `crates/ra_lsp_server/src/main_loop.rs` and add a breakpoint to the `on_task` function.
35 - Go back to the `[Extension Development Host]` instance and hover over a rust variable and your breakpoint should hit.
39 ![demonstration of debugging](https://user-images.githubusercontent.com/1711539/51384036-254fab80-1b2c-11e9-824d-95f9a6e9cf4f.gif)
43 ### Can't find the `ra_lsp_server` process
45 It could be a case of just jumping the gun.
47 The `ra_lsp_server` is only started once the `onLanguage:rust` activation.
49 Make sure you open a rust file in the `[Extension Development Host]` and try again.
51 ### Can't connect to `ra_lsp_server`
53 Make sure you have run `echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope`.
55 By default this should reset back to 1 everytime you log in.
57 ### Breakpoints are never being hit
59 Check your version of `lldb` if it's version 6 and lower use the `classic` adapter type.
60 It's `lldb.adapterType` in settings file.
62 If you're running `lldb` version 7 change the lldb adapter type to `bundled` or `native`.