用 vscode debug 服务器上 C++ 代码无法进入断点问题记录

遇到的一个问题是,为了方便的 dubug C++ 代码,下午配置了环境,但遇到了无法进入断点的问题,问题解决,一定要记录一下:

  • 连接到远程服务器,这步省略

  • 配置 lauch.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_test", //自行取名字
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/beibei/slam/slambook/ch2/a.out", // 可执行文件
            "args": [],
            "stopAtEntry": true,
            "cwd": "/home/beibei/slam/slambook/ch2/", // program 的上一级目录
            "environment": [],
            "externalConsole": false, // 这块是 false 还是 true 我这边都可以
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb", // 如果不是使用服务器,可以本地下载 mingw 将本地其路径  C:\\MinGW\\bin\\gdb  扔到这        
        }
    ]
}



//此注释给我自己看,免得忘记,,,将 beibei, 修改为公司服务器的账号名,此处为不引起异议做了修改

  • 配置 settings.json 
{
    "debug.allowBreakpointsEverywhere": true,
    "C_Cpp.intelliSenseEngine": "Disabled" 
}

   

    - 配置 tasks.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

你可能感兴趣的:(slam,vscode,c++,ide,服务器)