From 6761db59ff0d75e8e584ca921a682e423376d338 Mon Sep 17 00:00:00 2001 From: AE1020 <68134252+AE1020@users.noreply.github.com> Date: Wed, 12 Oct 2022 13:04:49 -0400 Subject: [PATCH 1/3] 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). --- src/compiler-debugging.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/compiler-debugging.md b/src/compiler-debugging.md index 35458b55c..f602b7b15 100644 --- a/src/compiler-debugging.md +++ b/src/compiler-debugging.md @@ -307,3 +307,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/x86_64-unknown-linux-gnu/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 From 37ad7a10f7ef00484980a7f8cea4b1a0afcaf35f Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 15 Feb 2023 11:29:05 -0300 Subject: [PATCH 2/3] Update src/compiler-debugging.md Co-authored-by: jyn --- src/compiler-debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler-debugging.md b/src/compiler-debugging.md index f602b7b15..9d5657457 100644 --- a/src/compiler-debugging.md +++ b/src/compiler-debugging.md @@ -312,7 +312,7 @@ error: aborting due to previous error ## 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 +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 19245e401060cd2ff4e69b2ff794a65291738127 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 15 Feb 2023 11:29:13 -0300 Subject: [PATCH 3/3] Update src/compiler-debugging.md Co-authored-by: jyn --- src/compiler-debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler-debugging.md b/src/compiler-debugging.md index 9d5657457..ea7fb35df 100644 --- a/src/compiler-debugging.md +++ b/src/compiler-debugging.md @@ -328,7 +328,7 @@ from the directory where it is built (does not have to be "installed"): "request": "launch", "name": "Launch", "args": [], // array of string command-line arguments to pass to compiler - "program": "${workspaceFolder}/build/x86_64-unknown-linux-gnu/stage1/bin/rustc", + "program": "${workspaceFolder}/build/TARGET/stage1/bin/rustc", "windows": { // applicable if using windows "program": "${workspaceFolder}/build/x86_64-pc-windows-msvc/stage1/bin/rustc.exe" },