在使用gdb调试C的VS代码中会忽略断点



我试图调试C代码,但我的断点被忽略了。我的系统是Windows 10。VS代码版本为1.38。

这是我的launch.json条目:

{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "C:/Users/NCH-Lap10/Desktop/aaa.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:/TDM-GCC-64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
},

如果有任何提示,我将不胜感激。我能提供更多信息吗?

在这里我共享我的配置文件,只需将它们添加到.vscode文件夹下,并按照下面给出的名称命名这些文件。

c_cpp_preties.json

{
"configurations":[
{
"name":"Win32",
"includePath":[
"${workspaceFolder}/**",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/trl"
],
"defines":[
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath":"C:\MinGW\bin\gcc.exe",
"cStandard":"c11",
"cppStandard":"c++17",
"intelliSenseMode":"clang-x64"
}
],
"version":4
}

launch.json

{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Compile C File"
}
]
}

tasks.json

{
"version": "2.0.0",
"tasks": [
{
"label": "Compile C File",
"command": "gcc",
"type": "shell",
"args": [
"-g",
"${file}",
"-o",
"${workspaceRoot}\a.exe"
],
"problemMatcher": [
"$tsc"
],
"presentation": {
"reveal": "always"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

为了使用上述配置,您至少需要有launch.jsontasks.json

尝试重建代码

  1. 使用代码激活选项卡
  2. 按Ctrl+Shift+B
  3. 按F5键开始调试

相关内容

  • 没有找到相关文章

最新更新