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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM