Vscode-cpptools: Program arguments in launch.json are not being passed when using gdbserver

Created on 18 Jan 2019  路  1Comment  路  Source: microsoft/vscode-cpptools

Type: Debugger

  • OS and Version: linux
  • VS Code Version: 1.30.1
  • C/C++ Extension Version 0.20.1:
  1. build an app on one machine in c/c++, copy it over to a remote machine so it can be debugged there
  2. on the remote machine run 'gdbserver {app}
  3. on the local machine use this launch.json:
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "C++ Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceRoot}/myapp
      "miDebuggerServerAddress": "myremotehost",
      "runtimeArgs": [
        "--hello"
      ],
      "args": [
        "--hello"
      ],
      "stopAtEntry": false,
      "cwd": "${workspaceRoot}",
      "environment": [],
      "externalConsole": true,
      "linux": {
        "MIMode": "gdb"
      },
      "osx": {
        "MIMode": "gdb"
      },
      "windows": {
        "MIMode": "gdb"
      }
    }
  ]
}
  1. put a breakpoint in main(argc, argv). The argc variable will be 1 (the app path). It should be 2, the second one should be '--hello' due to "args" in the json file (i'm not sure if it was supposed to be "runtimeArgs" so i added "--hello" in there as well just in case.
by design debugger

Most helpful comment

@edwinchenloo This is expected behavior. We don't pass args because gdbserver's command line is where those arguments would come from.

In that scenario all you are doing is connecting to a remote debug session, not passing additional debug parameters.

Per gdbserver's man page, it says the usage for the command is:

gdbserver comm prog [args...]

To use the server, you log on to the target system, and run the gdbserver program.  You must tell it (a) how to
       communicate with GDB, (b) the name of your program, and (c) its arguments.  The general syntax is:

               target> gdbserver <comm> <program> [<args> ...]

So the args need to be configured on the gdbserver command.

>All comments

@edwinchenloo This is expected behavior. We don't pass args because gdbserver's command line is where those arguments would come from.

In that scenario all you are doing is connecting to a remote debug session, not passing additional debug parameters.

Per gdbserver's man page, it says the usage for the command is:

gdbserver comm prog [args...]

To use the server, you log on to the target system, and run the gdbserver program.  You must tell it (a) how to
       communicate with GDB, (b) the name of your program, and (c) its arguments.  The general syntax is:

               target> gdbserver <comm> <program> [<args> ...]

So the args need to be configured on the gdbserver command.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arl picture arl  路  3Comments

SkyRiderMike picture SkyRiderMike  路  3Comments

jrieken picture jrieken  路  3Comments

jyavenard picture jyavenard  路  3Comments

ecbrodie picture ecbrodie  路  3Comments