How to pass command-line arguments to debugger using VSCode?

Viewed 4310

I'm using VSCode on Linux and I've came up with a the following launch configuration in my attempt to fire the VSCode debugger, which, in turn, would rely on gdb:

{
    "version": "0.2.0",
    "configurations": [
    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": ["a", "b", "c", "d", "e"],
        "stopAtEntry": false,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "make project"
    }]

}

Here, using the args attribute I'd like to pass 5 arguments to the process I'm debugging, namely: "a", "b", "c", "d", "e".

However, when I run the debugger, the argc value is correctly set to 6, but the values themselves, stored by argv are not present.

enter image description here

2 Answers

The first argument is always the executable. This is expected behaviour.

Related