Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some symbols in pipeArgs aren't substituted before being passed to ${command:pickRemoteProcess} #5103

Closed
Helloimbob opened this issue Mar 12, 2020 · 8 comments

Comments

@Helloimbob
Copy link
Contributor

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)

@Helloimbob
Copy link
Contributor Author

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 ?

@Helloimbob Helloimbob changed the title Symbols in pipeArgs aren't substituted before being passed to ${command:pickRemoteProcess} Some symbols in pipeArgs aren't substituted before being passed to ${command:pickRemoteProcess} Mar 12, 2020
@WardenGnaw
Copy link
Member

${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: microsoft/vscode#87450

@Helloimbob
Copy link
Contributor Author

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.

@WardenGnaw
Copy link
Member

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.

@Helloimbob
Copy link
Contributor Author

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 ?

@WardenGnaw
Copy link
Member

WardenGnaw commented Mar 17, 2020

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?

@Helloimbob
Copy link
Contributor Author

Looks like someone has already opened an issue

@WardenGnaw
Copy link
Member

@Helloimbob Thank you for your time investigating this issue.

Lets readdress this once microsoft/vscode#89758 is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants