You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已添加-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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 15:45:12