vscode debug的方式

在.vscode文件夹下建立launch.json

例子1:调试python

来自
https://github.com/chunleili/tiPBD/tree/amg

{
    "version": "0.2.0",
    "configurations": [
            {
            "name": "hpbd 5 5",
            "type": "python",
            "request": "launch",
            "program": "engine/volumetric/arap_multigrid.py",
            "console": "integratedTerminal",
            "args": ["--fine_iterations", "5",
                     "--coarse_iterations", "5",
                     "--solver_type", "Jacobian",
                     "--multigrid_type", "HPBD"
                    ]
        },
    ]
}

逐行解释:
name是显示在侧边栏的名字,例如
vscode debug的方式_第1张图片

program是要调试的程序

console是console打开的类型,分为内部(vscode内)和外部(额外弹出个终端模拟器)

args是调试传入参数,注意对应于命令行的每个空格都要单独分一个词。

例子2:调试c++

参考
https://github.com/chunleili/fast_mass_spring

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(msvc) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            // Resolved by CMake Tools:
            "program": "${workspaceFolder}/fast_mass_spring/main.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}/fast_mass_spring",
            "environment": [
                {
                    "name": "PATH",
                    "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
                }
            ],
            "console": "externalTerminal"
        }
    ]
}

这里额外增加了几个

cwd是设定当前目录
stopAtEntry是是否在程序第一句暂停
environment是设定环境变量,这里将${command:cmake.getLaunchTargetDirectory}追加到PATH最后

GUI的使用

如图,
vscode debug的方式_第2张图片

你可能感兴趣的:(vscode,ide,编辑器)