我使用的是 Visual Studio Code 1.84.2。 出于一个奇怪的原因,为什么我设置断点,构建,然后调试,我注意到我的断点被清除,并且出现以下错误:
Module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained.
这是我的launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Debug Current File",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "C/C++: Compile Current File",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe", // Specify the output file with .exe extension
"-lws2_32"
],
"options": {
"cwd": "${fileDirname}" // Set the working directory
},
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared"
}
}
]
}
如果它也有帮助,我的c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compilerPath": "C:/msys64/mingw64/bin/gcc.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"browse": {
"path": ["${workspaceFolder}"],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
我已经看到了这个线程:VSCode debugger not Stop at Breakpoint (with -g编译)。不过,我使用的是最新的 Visual Studio 代码。我不明白为什么我的调试器没有在断点处停止。
为什么你不在终端中使用 lldb ?