(51条消息) 【工具】VScode设置断点调试(以cpp为例)_vdcode运行断点 cpp_沙diao网友的博客-CSDN博客
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) 启动", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/a.out",//gdb目标的路径 "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}",//当前工作目录 "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "g++"//前置任务 对应tasks.json的label } ] }
tasks.json内容
{ // 有关 tasks.json 格式的文档,请参见 // https://go.microsoft.com/fwlink/?LinkId=733558 "version": "2.0.0", "tasks": [ { "type": "shell", "label": "g++",//对应launch的preLaunchTask "command": "/usr/bin/g++",//执行的命令 "args": [ "-g", "${file}", "-o", "a.out"//生成的可执行文件名称 对应launch.json的program ], "options": { "cwd": "${workspaceFolder}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true } } ] }