Add RA_WAIT_DBG and docs

This commit is contained in:
vsrs 2021-01-25 16:38:58 +03:00
parent 3f0e34e08e
commit 185cd736a6
3 changed files with 10 additions and 1 deletions

View file

@ -57,6 +57,7 @@ FLAGS:
ENVIRONMENTAL VARIABLES: ENVIRONMENTAL VARIABLES:
RA_LOG Set log filter in env_logger format RA_LOG Set log filter in env_logger format
RA_PROFILE Enable hierarchical profiler RA_PROFILE Enable hierarchical profiler
RA_WAIT_DBG If set acts like a --wait-dbg flag
COMMANDS: COMMANDS:

View file

@ -29,7 +29,7 @@ fn main() {
fn try_main() -> Result<()> { fn try_main() -> Result<()> {
let args = args::Args::parse()?; let args = args::Args::parse()?;
if args.wait_dbg { if args.wait_dbg || env::var("RA_WAIT_DBG").is_ok() {
#[allow(unused_mut)] #[allow(unused_mut)]
let mut d = 4; let mut d = 4;
while d == 4 { while d == 4 {

View file

@ -57,6 +57,14 @@ To apply changes to an already running debug process, press <kbd>Ctrl+Shift+P</k
- Go back to the `[Extension Development Host]` instance and hover over a Rust variable and your breakpoint should hit. - Go back to the `[Extension Development Host]` instance and hover over a Rust variable and your breakpoint should hit.
If you need to debug the server from the very beginning, including its initialization code, you can use the `--wait-dbg` command line argument or `RA_WAIT_DBG` environment variable. The server will spin at the beginning of the `try_main` function (see `crates\rust-analyzer\src\bin\main.rs`)
```rust
let mut d = 4;
while d == 4 { // set a breakpoint here and change the value
d = 4;
}
```
## Demo ## Demo
- [Debugging TypeScript VScode extension](https://www.youtube.com/watch?v=T-hvpK6s4wM). - [Debugging TypeScript VScode extension](https://www.youtube.com/watch?v=T-hvpK6s4wM).