美文网首页
CPP vscode ubuntu环境调试

CPP vscode ubuntu环境调试

作者: heliping_peter | 来源:发表于2023-02-14 08:50 被阅读0次

需要提前安装好gdb
cmake版本低于3.7.2,不能自动支持debug,vscode的现象就是断点不会停住。
需要指定cmake的版本>3.7.2

sudo apt-get install build-essential gdb

task配置

{
    "version": "2.0.0",
    "tasks": [
      {
        "type": "shell",
        "label": "task1",
        "command": "bash ./build.sh",
        "args": [],
        "options": {
          
        },
        "problemMatcher": ["$gcc"],
        "group": {
          "kind": "build",
          "isDefault": true
        },
        "detail": "Task generated by Debugger."
      }
    ]
  }

launch.json


{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
      {
          "name": "(gdb) Launch",
          "type": "cppdbg",
          "request": "launch",
          "program": "${workspaceFolder}/server", //只改这里
          "args": [],
          "stopAtEntry": false,
          "cwd": "${workspaceFolder}",
          "environment": [],
          "externalConsole": false,
          "MIMode": "gdb",
          "setupCommands": [
              {
                  "description": "Enable pretty-printing for gdb",
                  "text": "-enable-pretty-printing",
                  "ignoreFailures": true
              }
          ],
          "preLaunchTask": "task1" //可以新增一条
      }
  ]
}

相关文章

网友评论

      本文标题:CPP vscode ubuntu环境调试

      本文链接:https://www.haomeiwen.com/subject/raqekdtx.html