Appearance
vscode debug
新建.vscode文件夹,然后添加以下文件,make成功后,按F5即可进入 debug 。
launch.json
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": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/kernel/kernel",
"cwd": "${workspaceFolder}",
"miDebuggerPath": "/usr/local/bin/gdb",
"miDebuggerServerAddress": "localhost:25501",
"MIMode": "gdb",
"stopAtEntry": true,
"preLaunchTask": "start-all",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
]
}
]
}tasks.json
json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "fix_gdbinit",
"type": "shell",
"command": "sed -i '' -e '/^target remote/d' ${workspaceFolder}/.gdbinit.tmpl-riscv"
},
{
"label": "qemu-gdb",
"type": "shell",
"command": "make qemu-gdb",
// 关键:告诉 VS Code 这是一个后台常驻任务
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "^\\s*$"
},
"background": {
"activeOnStart": true,
"beginsPattern": "qemu-system-riscv64",
"endsPattern": "Now run 'gdb'"
}
},
"presentation": {
"reveal": "always",
"panel": "shared"
}
},
{
"label": "start-all",
"dependsOn": [
"fix_gdbinit",
"qemu-gdb"
]
}
]
}