> [!danger] > 2022-11-05時点で[[Rust for Visual Studio Code]]は非推奨になっている。[[rust-analyzer (VSCode)]]を使う場合は[[VSCodeでRustのデバッグ]]を参照。 [[VSCode Extension]]の[[CodeLLDB]]をインストールしていない場合はインストールする。 `main.rs`を開き、デバッガ画面から`launch.json`を作成する。 ![[Pasted image 20210831184907.png]] ![[Pasted image 20210831184931.png]] `launch.json`が自動生成されるので軽く整形する。 ```json:.vscode/launch.json { "version": "0.2.0", "configurations": [ { "type": "lldb", "request": "launch", "name": "Debug executable 'rust-sandbox'", "cargo": { "args": ["build", "--bin=rust-sandbox", "--package=rust-sandbox"], "filter": { "name": "rust-sandbox", "kind": "bin" } }, "args": [], "cwd": "${workspaceFolder}" }, { "type": "lldb", "request": "launch", "name": "Debug unit tests in executable 'rust-sandbox'", "cargo": { "args": [ "test", "--no-run", "--bin=rust-sandbox", "--package=rust-sandbox" ], "filter": { "name": "rust-sandbox", "kind": "bin" } }, "args": [], "cwd": "${workspaceFolder}" } ] } ``` ブレイクポイントを設置してデバッグ実行すると停止する。 ![[Pasted image 20210831185402.png]]