VSCode CMake 调试断点不停

Root Cause

需要 Debug Build 才可以调试

Action

需要在 tasks.json 中的 cmake 任务添加 "-DCMAKE_BUILD_TYPE=Debug" 参数

launch.json

{
    "version": "0.2.0",
    "configurations": [
       {
          "name": "launch after cmake build",
          "type": "cppdbg",
          "request": "launch",
          "program": "${fileDirname}/build/play",
          "args": [],
          "stopAtEntry": false,
          "cwd": "${workspaceFolder}",
          "environment": [],
          "externalConsole": false,
          "MIMode": "gdb",
          "preLaunchTask": "CMake Build",
          "miDebuggerPath": "/usr/bin/gdb"
       }
    ]
 }

tasks.json

{
   "options": {
      "cwd": "${workspaceFolder}/build"
   },
   "tasks": [
      {
         "label": "cmake",
         "command":"cmake",
         "args": ["-DCMAKE_BUILD_TYPE=Debug", ".."]
      },
      {
         "label": "make",
         "command":"make",
      },
      {
         "label": "CMake Build",
         "dependsOn":[
            "cmake",
            "make"
         ],
      }
   ],
   "version": "2.0.0"
}

Reference: https://blog.csdn.net/weixin_43878193/article/details/103656526

posted @ 2021-03-13 09:41  Zijian/TENG  阅读(2841)  评论(0编辑  收藏  举报