VS 安装CodeRunner插件
菜单→添加配置→lunch.json中设置如下:
program填入要调试的文件
{
"version": "0.2.0",
"configurations": [
{
"name": "gdb renderPng",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/renderPng",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
]
}
如果需要sudo权限调试修改如下:
{
"version": "0.2.0",
"configurations": [
{
"name": "gdb renderPng",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/renderPng",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath":"/home/pozhu/Desktop/sudo_gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
]
}
新建脚本sudo_gdb
sudo /usr/bin/gdb $@
chmod 777 sudo_gdb
路径填在字段miDebuggerPath
调试快捷键
继续 / 暂停 F5
跳过 F10
跳入 F11
跳出 Shift+F11
重启 Ctrl+Shift+F5
停止 Shift+F5
添加终端任务:
菜单→终端→添加任务→新建tasks.json
内容如下: