'How can arguments be passed to executable given for lldb in a VSCode launch.json file?

I want to debug this command in VSCode:

myExecutable -f arg1 -g arg2 -e arg3

Notice the executable takes 3 arguments. When running this executable in lldb we need to use "--" to pass the arguments to the executable:

lldb myExecutable -- -f arg1 -g arg2 -e arg3

I need to find out how to pass these 3 arguments to the executable given to lldb through the launch.json file for VSCode.

How the "args" JSON field should be properly defined for lldb to be able to debug the executable above with it?

{
"version": "0.2.0",
"configurations": [
    {
        "name": "(Launch) lldb",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [
            "-f arg1",
            "-g arg2",
            "-e arg3"
        ],
        "stopAtEntry": true,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "lldb",
        "miDebuggerPath": "/somepath/lldb-mi/build/src/lldb-mi"
    }
]

}

I am doing this in Linux Debian 11.



Solution 1:[1]

The issue above was due to spaces in the arguments. Here is the JSON snippet that works. Notice how the flag and the actual argument goes separately.

    "args": [
        "-f",
        "arg1",
        "-e"
        "arg2",
        "-g",
        "arg3"
    ],

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ivan Garcia