跳至主要內容
在 VSCode 中调试 Google Test

本文介绍如何在 VSCode 下配置 Google Test 的断点调试环境,包括 launch.json 和 tasks.json 的标准写法,以及调试流程说明。

1. 配置 launch.json

.vscode/launch.json 中添加如下内容:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug GTest (Auto)",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",
            "preLaunchTask": "cmake: build"
        }
    ]
}

KSJ小于 1 分钟C++gtestvscodedebugcmake