Vscode-cpptools: Some symbols in pipeArgs aren't substituted before being passed to ${command:pickRemoteProcess}

Created on 12 Mar 2020  路  8Comments  路  Source: microsoft/vscode-cpptools

Type: Debugger

Describe the bug
OS and Version: Linux (RHEL 7.6)
VS Code Version: 1.43.0
C/C++ Extension Version: 0.27.0-insiders
Other extensions you installed (and if the issue persists after disabling them): It does

  • When using ${command:pickRemoteProcess} and also a symbol to be substituted in pipeTransport.pipeArgs (i.e. "pipeArgs": ["top@${input:serverName}"]) the symbols in pipeArgs aren't substituted before being passed to the pickRemoteProcess command.

To Reproduce
Please include a code sample and launch.json configuration.
Example launch.json:

{
            "name": "debug_Binary",
            "type": "cppdbg",
            "request": "attach",
            "program": "${workspaceRoot}/debug64/bin/debug_Binary",
            "processId": "${command:pickRemoteProcess}",
            "MIMode": "gdb",
            "pipeTransport": {
                "pipeCwd": "/usr/bin",
                "pipeProgram": "/usr/bin/ssh",
                "pipeArgs": ["top@${input:serverName}"],
                "debuggerPath": "/usr/bin/gdb"
            },
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },

    "inputs": [
        {
            "type": "promptString",
            "id": "serverName",
            "description": "Server to connect to"
        }
    ]

Steps to reproduce the behavior:

  1. Configure pipeArgs to use any form of variable substitution
  2. Run the debugging task
  3. Error occurs
ssh: Could not resolve hostname : Name or service not known
Command failed: "/usr/bin/ssh" "top@${input:serverName}" '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"'

Additional context
If applicable, please include logging by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your launch.json

The pipeArgs is substituted if ${command:pickRemoteProcess} is not used (i.e. with explicit process ID configuration)

Feature Request debugger

All 8 comments

FWIW the substitution will work with the remoteProcessPicker for ${config: } variables, it seems to be a specific issue with ${input: }

Could this be because input type isn't resolved in the resolveVariables function from src/common.ts ?

${input:...} is resolved by VS Code.

This used to be an issue for VS Code to provide us a way to replace those. But they recently created an hook resolveDebugConfigurationWithSubstitutedVariables to use.

See: https://github.com/microsoft/vscode/issues/87450

I've tried to look at adding this myself, but I've found an issue - it seems as though the ${command:pickRemoteProcess} is resolved during the resolveDebugConfiguration call, so the ${input:...} is always passed unresolved.

Since resolveDebugConfigurationWithSubstitutedVariables is called after resolveDebugConfiguration I don't think there is a way to get ${input:...} to work with it right now.

I think if we get rid of resolveDebugConfiguration in the extension and only have resolveDebugConfigurationWithSubstitutedVariables, ${command:*} will be resolved only in resolveDebugConfigurationWithSubstitutedVariables

If resolveDebugConfiguration does not exist, it will never be called.

I've now tried this with just resolveDebugConfigurationWithSubstitutedVariables defined, and it gets a slight improvement - the input prompt pops up but then in the config object passed to ShowAttachEntries() the variable is still not resolved:

image

Other variable types which aren't ${input:*} are resolved by this point though. Could this be a bug with VSCode and resolveDebugConfigurationWithSubstitutedVariables ?

Yeah, this would be an issue with the VS Code extension. In microsoft/vscode#87450, they mentioned it was either provide an API to resolve variables or create a new API for resolvingDebug configuraitons and they went with the latter. This means that we have no way to resolve ${input:...} at this point.

Can you file an issue that not all variables are being substituted in resolveDebugConfigurationWithSubstitutedVariables?

Looks like someone has already opened an issue

@Helloimbob Thank you for your time investigating this issue.

Lets readdress this once https://github.com/microsoft/vscode/issues/89758 is resolved.

Was this page helpful?
0 / 5 - 0 ratings