已添加-g编译选项,VSCode调试器仍无法在断点处停止
VSCode调试C/C++断点失效问题
使用Visual Studio Code 1.84.2版本调试C/C++代码时,设置断点后执行编译并启动调试,断点会被自动清除,同时弹出错误提示:
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,仍未找到断点失效的原因。
内容的提问来源于stack exchange,提问作者user2494337
相关产品推荐
相关产品推荐

