VScode debug传入参数与环境变量


需求

使用VScode自带debug工具调试c++代码,希望传入指定参数与环境变量。

实现

./vscode/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": "/home/.../target/bin/our_app",
            "args": ["-d","1","-v","-o"],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [
                { "name": "APP_ROOT", "value": "/home/.../target" },
                { "name": "LD_LIBRARY_PATH", "value": "/home/.../target/3rdparty/lib:"}
            ],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

参考

Configure launch.json for C/C++ debugging in Visual Studio Code


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM