VScode配置makefile编译
Author:onceday date:2022年7月26日
1.修改终端任务配置(Terminal)
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build", //标签名,用于在调试里调用
"type": "shell", //类型,可选shell和process
"command": "make",//在命令行的命令
"args": [
"clean",//用于清楚编译中间件
],//命令参数
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$gcc" //错误抓取
}
]
}
此处重点配置label、command,args即可。
调试需要gcc编译-g选项的二进制文件,即携带调试信息。
2.修改调试启动文件(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": [
{
"name": "gdb_launch",
"type": "cppdbg",//类型固定
"request": "launch",
"program": "${workspaceFolder}/a.exe",//输入调式程序的执行路径
"args": [],//参数表
"stopAtEntry": false,//进函数暂停
"cwd": "${fileDirname}",//进入目录
"environment": [],
"externalConsole": false,//额外的控制台
"MIMode": "gdb",//调试的程序
"miDebuggerPath": "/path/to/gdb",//调试程序的路径
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "build",//加载前先执行编译任务
}
]
}
- 重要的是program,这个指定要调试的程序。
- 有些时候,gdb需要指定路径,即miDebuggerPath
3.可以使用gdb server远程调试作为替代方案。
版权声明:本文为Once_day原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。