Skip to content

Commit 185cd73

Browse files
committed
Add RA_WAIT_DBG and docs
1 parent 3f0e34e commit 185cd73

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

crates/rust-analyzer/src/bin/args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ FLAGS:
5757
ENVIRONMENTAL VARIABLES:
5858
RA_LOG Set log filter in env_logger format
5959
RA_PROFILE Enable hierarchical profiler
60+
RA_WAIT_DBG If set acts like a --wait-dbg flag
6061
6162
COMMANDS:
6263

crates/rust-analyzer/src/bin/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929

3030
fn try_main() -> Result<()> {
3131
let args = args::Args::parse()?;
32-
if args.wait_dbg {
32+
if args.wait_dbg || env::var("RA_WAIT_DBG").is_ok() {
3333
#[allow(unused_mut)]
3434
let mut d = 4;
3535
while d == 4 {

docs/dev/debugging.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ To apply changes to an already running debug process, press <kbd>Ctrl+Shift+P</k
5757

5858
- Go back to the `[Extension Development Host]` instance and hover over a Rust variable and your breakpoint should hit.
5959

60+
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`)
61+
```rust
62+
let mut d = 4;
63+
while d == 4 { // set a breakpoint here and change the value
64+
d = 4;
65+
}
66+
```
67+
6068
## Demo
6169

6270
- [Debugging TypeScript VScode extension](https://www.youtube.com/watch?v=T-hvpK6s4wM).

0 commit comments

Comments
 (0)