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