【发布时间】:2022-11-17 17:28:47
【问题描述】:
我正在尝试使用断点在 vscode 中调试我的 C,但调试器似乎每次运行它时都会跳过它们(断点的颜色从红色变为灰色)。我查看了这个question,这与我的问题基本相同。我尝试了那里的所有答案,但没有一个有效(没有一个被提问者设置为“答案”,因此我为什么再次问这个问题)。所以我的问题是,如何让 vscode 断点在 C 中工作?
Vscode 版本:Windows 10 上的 1.73.1
gdb 版本:12.1
启动.json
{
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file",
}
]
任务.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "make",
"args": [
"all"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
生成文件
dynamic_array: dynamic_array.c dynamic_array.h
gcc -c dynamic_array.c
test: test.c dynamic_array.h
gcc -c test.c
all: dynamic_array.o test.o
gcc -o test.exe dynamic_array.o test.o
clean:
del -f *.o & del -f *.exe & del -f *.out
【问题讨论】:
标签: debugging visual-studio-code gdb