我正在嘗試在 VS Code 中除錯 Rust 程式,但出現錯誤:
要除錯代碼,有必要創建一個launch.json
檔案,使用Run - Add configuration...
但是,檔案不正確,<your program>
正確的名稱應該在哪里。這是錯誤的做法。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/<your program>",
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
在這一點上,檔案是一個稀缺的投標。正確的做法是選擇不同的檔案夾,即專案的頂層hello_world
。該Cargo.toml
檔案可用。
現在,何時Run - Add configuration...
使用,并選擇了選項LLDB
-
該Cargo.toml
檔案可以拿起 -
然后該Cargo.toml
檔案用于正確構建launch.json
檔案 -
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'hello_world'",
"cargo": {
"args": [
"build",
"--bin=hello_world",
"--package=hello_world"
],
"filter": {
"name": "hello_world",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'hello_world'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=hello_world",
"--package=hello_world"
],
"filter": {
"name": "hello_world",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
現在,兩者Run - Start debugging
都Run - Run without Debugging
正常作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/512247.html