13
votes

I want to debug a C++ project in VSCode (on a Mac, using either GDB or LLDB). The program itself takes command line arguments like

./prog -input cf file_x.txt

This works fine when starting a debugging session in GDB on the command line.

In VSCode, I tried to adapt launch.json to read like this (only relevant lines shown):

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input cf",
               "path_to/file_x.txt"
            ]

With this, I get @"Unknown option: \"-input cf\"\r\n" in the output and the process is not debugged; alternatively, I tried only one argument like so:

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input cf path_to/file_x.txt"
            ]

resulting in the same message. Have I missed something important?

1

1 Answers

20
votes

Try it like this

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input",
              "cf",
              "path_to/file_x.txt"
            ]