about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorAE1020 <68134252+AE1020@users.noreply.github.com>2023-02-15 09:31:02 -0500
committerGitHub <noreply@github.com>2023-02-15 11:31:02 -0300
commit240f076d804d8682994c49a92b5407ebbbe1fe3a (patch)
treea7d3d6e6ae477ff46efffec0ee52ca7ec86f2c5a /src/doc/rustc-dev-guide
parent4092a74d1f6881c27d8a93b2df7840007f9d256c (diff)
Add sample CodeLLDB launch.json (#1482)
* Add sample CodeLLDB launch.json

There is a section with [instructions for setting up source analyzer in VSCode](https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc), but
nothing for setting up debugging with CodeLLDB.  This adds a sample configuration
that may not be ideal, but appears to work for me.

To source highlight the snippet, uses JavaScript instead of JSON so that comments
do not show up as errors highlighted in red (VSCode allows comments).

* Update src/compiler-debugging.md

Co-authored-by: jyn <github@jyn.dev>

* Update src/compiler-debugging.md

Co-authored-by: jyn <github@jyn.dev>

---------

Co-authored-by: Santiago Pastorino <spastorino@gmail.com>
Co-authored-by: jyn <github@jyn.dev>
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/src/compiler-debugging.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/doc/rustc-dev-guide/src/compiler-debugging.md b/src/doc/rustc-dev-guide/src/compiler-debugging.md
index 6920904bbf3..76e900690b3 100644
--- a/src/doc/rustc-dev-guide/src/compiler-debugging.md
+++ b/src/doc/rustc-dev-guide/src/compiler-debugging.md
@@ -341,3 +341,37 @@ error: aborting due to previous error
 ```
 
 [`Layout`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/abi/struct.Layout.html
+
+
+## Configuring CodeLLDB for debugging `rustc`
+
+If you are using VSCode, and have edited your `config.toml` to request debugging
+level 1 or 2 for the parts of the code you're interested in, then you should be
+able to use the [CodeLLDB] extension in VSCode to debug it.
+
+Here is a sample `launch.json` file, being used to run a stage 1 compiler direct
+from the directory where it is built (does not have to be "installed"):
+
+```javascript
+// .vscode/launch.json
+{
+    "version": "0.2.0",
+    "configurations": [
+      {
+        "type": "lldb",
+        "request": "launch",
+        "name": "Launch",
+        "args": [],  // array of string command-line arguments to pass to compiler
+        "program": "${workspaceFolder}/build/TARGET/stage1/bin/rustc",
+        "windows": {  // applicable if using windows
+            "program": "${workspaceFolder}/build/x86_64-pc-windows-msvc/stage1/bin/rustc.exe"
+        },
+        "cwd": "${workspaceFolder}",  // current working directory at program start
+        "stopOnEntry": false,
+        "sourceLanguages": ["rust"]
+      }
+    ]
+  }
+```
+
+[CodeLLDB]: https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb