08 ตุลาคม 2565

Debug Rust program on vscode (Visual Studio Code)

 Debug Rust program on vscode (Visual Studio Code)

  • Create new rust project by running cargo new hello
  • Open hello folder using vscode
  • Install vscode CodeLLDB extension
  • Make sure your .vscode/launch.json file will be like this (you can copy this JSON file)

{
// 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'",
"cargo": {
"args": [
"build",
"--bin=hello",
"--package=hello"
],
"filter": {
"name": "hello",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'hello'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=hello",
"--package=hello"
],
"filter": {
"name": "hello",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

  • Set breakpoint and click debug Debug executable 'hello'


ไม่มีความคิดเห็น:

แสดงความคิดเห็น

บทความยอดนิยม (ล่าสุด)

บทความยอดนิยม (All Time)