0

I have a setup in launch.json for vscode as follows:

{
    // 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 25.0_regeragpu",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/25.0_regeragpu/Blazer/MercuryImageComputer/KT/leaf/M31/BrightField/bin/LeafStandalone/Debug/12/LeafStandAlone.x86-64",
            "args": ["-noForcedPatches","${workspaceFolder}/virgo_algo_preq/JobDump/JobInfo_108"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}/25.0_regeragpu/Blazer/MercuryImageComputer/KT/leaf/M31/BrightField/bin/LeafStandalone/Debug/12",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

The purpose of this setup is to use GDB integration in vscode. In particular, I specified the following pair to ensure all environment variables set up in my bash session in terminal of vscode are inherited when debugging: "externalConsole": false. I also notice that there is a pair named environment in the configuration. It is my understanding that if a new bash session is started for debugging by vscode, then all environment variables should be specified in this environment pair. To try the option of starting a new bash when debug, I modified the configuration file:

{
    // 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 25.0_regeragpu",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/25.0_regeragpu/Blazer/MercuryImageComputer/KT/leaf/M31/BrightField/bin/LeafStandalone/Debug/12/LeafStandAlone.x86-64",
            "args": ["-noForcedPatches","${workspaceFolder}/virgo_algo_preq/JobDump/JobInfo_108"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}/25.0_regeragpu/Blazer/MercuryImageComputer/KT/leaf/M31/BrightField/bin/LeafStandalone/Debug/12",
            "environment": [{"CUDA_VISIBLE_DEVICES":"0,1,2,3","CUDA_DEVICE_ORDER":"PCI_BUS_ID"}],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

In particular, it can be seen that I specified the following pairs: "environment": [{"CUDA_VISIBLE_DEVICES":"0,1,2,3","CUDA_DEVICE_ORDER":"PCI_BUS_ID"}] and "externalConsole": true. Nevertheless, as I started debugging, the debugging tool of vscode prepared forever and never entered the real debugging session. How should I set up the environment variables if I want to debug in a new console in vscode?

1 Answer 1

0

Here is an example, you set the value in the environment block.

    {
// 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": "g++ - (GDB 9.2) Build and debug active file with RepoCodeInspection",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/bin/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [
            {
                "description": "same as commands below by using 'setenv ...",
                "info": "cant debug b/c of libBase/libRecipe now requiring dependency to boost for stacktrace dumps",
                "name": "LD_LIBRARY_PATH",
                "value": "/libs/:./"
            }
        ],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "logging": {
            "trace": false,
            "traceResponse": false
        },
        "preLaunchTask": "RepoCodeInspection",
        
    },
    {
        "name": "g++ - (GDB 9.2) Attach to a running process",
        "type": "cppdbg",
        "request": "attach",
        "processId":"${command:pickProcess}",
        "program": "${fileDirname}/bin/${fileBasenameNoExtension}",
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "logging": {
            "trace": false,
            "traceResponse": false
        },
        "preLaunchTask": "RepoCodeInspection",
       
    },
]

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.