7

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
  • 1
    same problem,I also have a question in stackoverflow.com/questions/60415097/… Commented Feb 26, 2020 at 13:42
  • 1
    Do you have a solution for it? I have been stuck in there for a while :( Commented Feb 26, 2020 at 13:43

2 Answers 2

3

That's cause the type of argv is char**. The debugger doesn't know if it's pointing at a single element or an array.

In VS you can use format specifiers. With gdb you should be able to use something like this in the Watch view:

(char*[6])argv

https://github.com/Microsoft/vscode-cpptools/issues/688#issuecomment-685956825

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.