VSCode - Add Configuration后launch.json为空的解决办法
今天需要使用VSCode debug一个程序,点击菜单栏的“Run”-"Add Configuration" 选项,准备生成一个默认的launch.json文件,结果出来的json文件是这个样子的:
以前不是可以自动生成 launch.json 的么?
没办法,只能手动点击上图的“Add Configuratioin”按钮,手动添加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.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
}
]
}
]
}
有几个地方需要手动修改下:
-
program
: 就是要运行的程序名字,打开tasks.json
, 复制生成的程序名字即可: -
miDebuggerPath
: 就是gdb调试器的路径,这里修改成:E:\\msys64\\mingw64\\bin\\gdb.exe
就是gdb调试器所在的路径; -
添加一个
preLaunchTask
项,拷贝tasks.json中的label项:
复制到launch.json
的preLaunchTask
项中:
最终修改后的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",
"preLaunchTask": "C/C++: g++.exe 生成活动文件",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "E:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
不明白为什么要把这个功能改成现在这样。。。
标签:exe,launch,VSCode,text,gdb,json,Add From: https://www.cnblogs.com/yongdaimi/p/16836992.html