Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Extension/src/Debugger/attachToProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export class RemoteAttachPicker {

const pipeCmd: string = `"${pipeProgram}" ${argList}`;

processes = await this.getRemoteOSAndProcesses(pipeCmd);
// If unspecified quoteArgs defaults to true.
const quoteArgs: boolean = pipeTransport.quoteArgs ?? true;

processes = await this.getRemoteOSAndProcesses(pipeCmd, quoteArgs);
} else if (!pipeTransport && useExtendedRemote) {
if (!miDebuggerPath || !miDebuggerServerAddress) {
throw new Error(localize("debugger.path.and.server.address.required", "{0} in debug configuration requires {1} and {2}", "useExtendedRemote", "miDebuggerPath", "miDebuggerServerAddress"));
Expand All @@ -106,7 +109,7 @@ export class RemoteAttachPicker {
}

// Creates a string to run on the host machine which will execute a shell script on the remote machine to retrieve OS and processes
private getRemoteProcessCommand(): string {
private getRemoteProcessCommand(quoteArgs: boolean): string {
let innerQuote: string = `'`;
let outerQuote: string = `"`;
let parameterBegin: string = `$(`;
Expand All @@ -127,6 +130,12 @@ export class RemoteAttachPicker {
innerQuote = `"`;
outerQuote = `'`;
}

// If the pipeTransport settings indicate "quoteArgs": "false", we need to skip the outer quotes.
if (!quoteArgs) {
outerQuote = ``;
}

// Also use a full path on Linux, so that we can use transports that need a full path such as 'machinectl' to connect to nspawn containers.
if (os.platform() === "linux") {
shPrefix = `/bin/`;
Expand All @@ -138,9 +147,9 @@ export class RemoteAttachPicker {
`then ${PsProcessParser.psDarwinCommand}; fi${innerQuote}${outerQuote}`;
}

private async getRemoteOSAndProcesses(pipeCmd: string): Promise<AttachItem[]> {
private async getRemoteOSAndProcesses(pipeCmd: string, quoteArgs: boolean): Promise<AttachItem[]> {
// Do not add any quoting in execCommand.
const execCommand: string = `${pipeCmd} ${this.getRemoteProcessCommand()}`;
const execCommand: string = `${pipeCmd} ${this.getRemoteProcessCommand(quoteArgs)}`;

const output: string = await util.execChildProcess(execCommand, undefined, this._channel);
// OS will be on first line
Expand Down