microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Apply pipeTransport.quoteArgs to pickRemoteProcess command #6702

Open DaanDeMeyer opened 3 years ago

DaanDeMeyer commented 3 years ago

Type: Debugger

Describe the bug

When running the pickRemoteProcess command via pipeTransport, quoteArgs is not applied to pipeArgs and the args are quoted regardless of the value of quoteArgs.

To Reproduce

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cppdbg",
            "program": "/usr/lib/systemd/systemd-resolved",
            "processId": "${command:pickRemoteProcess}",
            "request": "attach",
            "name": "Attach",
            "pipeTransport": {
                "pipeCwd": "${workspaceFolder}",
                "pipeProgram": "mkosi",
                "pipeArgs": [
                    "ssh"
                ],
                "debuggerPath": "/usr/bin/gdb",
                "quoteArgs": false
            }
        }
    ]
}

Produces in the error log:

Command failed: "mkosi" "ssh" 'sh -c "uname && if [ $(uname) = \"Linux\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Darwin\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi"'

We can see "ssh" is quoted even though quoteArgs is set to false.

sean-mcmanus commented 3 years ago

FYI, @WardenGnaw might be OOF till January.

WardenGnaw commented 3 years ago

@DaanDeMeyer Are you expecting the command to be:

"mkosi" ssh 'sh -c "uname && if [ $(uname) = \"Linux\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Darwin\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi"'

At the moment, we only use quoteArgs for the debug adapter.

This would require a change in this code path to check for quoteArgs.

DaanDeMeyer commented 3 years ago

Yes, that's what I was expecting. My error turned out to be caused by something else but I figure this might be useful to have nonetheless.