-
Notifications
You must be signed in to change notification settings - Fork 728
Fix RemoteProcessPicker #1373
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
Fix RemoteProcessPicker #1373
Conversation
Also moved list process command to be written to a temp file and redirected to the pipeProgram.
src/features/processPicker.ts
Outdated
| pipeCmdList.push(pipeProgram); | ||
| pipeCmdList = pipeCmdList.concat(pipeArgs); | ||
|
|
||
| const scriptShellCmdList: string[] = ["bash", "-s"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bash [](start = 51, length = 4)
I am not sure it really matters much for .NET, but should we use 'sh' instead of 'bash' to make it easier to port code between this extension and C++?
src/features/processPicker.ts
Outdated
| pipeCmdList.push(pipeProgram); | ||
| pipeCmdList = pipeCmdList.concat(pipeArgs); | ||
|
|
||
| const scriptShellCmdList: string[] = ["bash", "-s"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scriptShellCmdList [](start = 18, length = 18)
Maybe I am remembering wrong, but I think we are doing something different here than what vsdbg-ui does.
In vsdbg-ui, if quoteArgs is enabled the command line would be something like:
/mypipePath/myPipe -myPipeArg "/vsdbg/vsdbg --interpreter=vscode"
Here, it looks like we will wind up using:
/mypipePath/myPipe -myPipeArg /vsdbg/vsdbg --interpreter=vscode
And we would only quote an argument if one of the individual arguments contained a space.
I think instead you want:
let scriptShellCmd : string = "bash -s";
if (quoteArgs) {
scriptShellCmd = `"${scriptShellCmd}"`;
}
src/features/processPicker.ts
Outdated
| let pipeCmd: string = `"${pipeProgram}" ${argList}`; | ||
| let pipeCmdList: string[] = []; | ||
| pipeCmdList.push(pipeProgram); | ||
| pipeCmdList = pipeCmdList.concat(pipeArgs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipeArgs [](start = 45, length = 8)
We need code to look for ${debuggerCommand}
src/features/processPicker.ts
Outdated
|
|
||
| // Create a temp file to redirect commands to the pipeProgram to solve quoting issues. | ||
| const tempFile = tmp.fileSync(); | ||
| fs.write(tempFile.fd, command); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a temp file with this, should we should stick this in a file in our extension?
Fixing syntax since = is for equality in sh. Also tested with Mac -> Linux w/ ZSH
src/features/processPicker.ts
Outdated
|
|
||
| return execChildProcessAndOutputErrorToChannel(`${pipeCmd} < ${tempFile.name}`, null, RemoteAttachPicker._channel).then(output => { | ||
| // Remove temp file since the uname and ps commands have been executed. | ||
| tempFile.removeCallback(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempFile [](start = 12, length = 8)
If we keep this, make sure to add a catch handler to clean it up in the case of failure as well.
gregg-miskelly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
|
|
||
| pipeCmdList = pipeCmdList.concat(scriptShellCmdList); | ||
|
|
||
| let pipeCmd: string = quoteArgs ? this.createArgumentList(pipeCmdList) : pipeCmdList.join(' '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I modify createArgumentList to only insert quotes if it has a space in the string?
| @@ -0,0 +1 @@ | |||
| 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 No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we don't need to have this as one big line, would it make sense to separate this out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there will be issues with \r\n vs \n if its separated on different lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably right. Oh line endings...
|
RE: Should I modify createArgumentList to only insert quotes if it has a space in the string? |
| @@ -0,0 +1 @@ | |||
| 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 No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a .gitattributes on this to make sure that it keeps Unix line endings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can 'Won't fix" this one since the script is a single line.
src/features/processPicker.ts
Outdated
| pipeCmdList.push(pipeProgram); | ||
|
|
||
| // Remove debuggerCommand for remoteProcessPicker | ||
| pipeCmdList = pipeCmdList.concat(pipeArgs.filter(arg => arg !== "${debuggerCommand}")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work, as ${debuggerCommand} might be only part of one of the args, and because we want to preserve the order.
gregg-miskelly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise I think you have it.
src/features/processPicker.ts
Outdated
| if (pipeArgs.filter(arg => arg === "${debuggerCommand}").length > 0) { | ||
| for (let arg of pipeArgs) | ||
| { | ||
| if (arg === "${debuggerCommand}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be:
while (arg.indexOf("${debuggerCommand}") >= 0) {
arg = arg.replace("${debuggerCommand}", scriptShellCmd);
}
src/features/processPicker.ts
Outdated
| pipeCmdList.push(pipeProgram); | ||
|
|
||
| pipeCmdList.push(scriptShellCmd); | ||
| if (pipeArgs.filter(arg => arg === "${debuggerCommand}").length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace: arg === "${debuggerCommand}"
With: arg.indexOf("${debuggerCommand}") >= 0
src/features/processPicker.ts
Outdated
|
|
||
| const debuggerCommandString: string = "${debuggerCommand}"; | ||
|
|
||
| if (pipeArgs.indexOf(debuggerCommandString) > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>= not >
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And don't you still need your filter like you did before?
gregg-miskelly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Allowing quoteArgs to handle the pipeProgram and pipeArgs quotes.
Moving the uname and ps command into a temp file so it can be redirected into the pipeProgram so the current shell does not mangle the command string.
Tested:
Windows -> Linux
Windows -> Docker Linux
Windows -> Mac
Mac -> Linux