Skip to content

Commit 49d987d

Browse files
authored
Fix show a list local processes, if remote connection failed (useExtendedRemote) (#12623)
* Fix show a list local processes, if remote connection failed (useExtendedRemote)
1 parent c81120e commit 49d987d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Extension/src/Debugger/attachToProcess.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,18 @@ export class RemoteAttachPicker {
187187
const args: string[] = [`-ex "target extended-remote ${miDebuggerServerAddress}"`, '-ex "info os processes"', '-batch'];
188188
let processListOutput: util.ProcessReturnType = await util.spawnChildProcess(miDebuggerPath, args);
189189
// The device may not be responsive for a while during the restart after image deploy. Retry 5 times.
190-
for (let i: number = 0; i < 5 && !processListOutput.succeeded; i++) {
190+
for (let i: number = 0; i < 5 && !processListOutput.succeeded && processListOutput.outputError.length === 0; i++) {
191191
processListOutput = await util.spawnChildProcess(miDebuggerPath, args);
192192
}
193193

194194
if (!processListOutput.succeeded) {
195195
throw new Error(localize('failed.to.make.gdb.connection', 'Failed to make GDB connection: "{0}".', processListOutput.output));
196196
}
197+
198+
if (processListOutput.outputError.length !== 0) {
199+
throw new Error(localize('failed.to.make.gdb.connection', 'Failed to make GDB connection: "{0}".', processListOutput.outputError));
200+
}
201+
197202
const processes: AttachItem[] = this.parseProcessesFromInfoOsProcesses(processListOutput.output);
198203
if (!processes || processes.length === 0) {
199204
throw new Error(localize('failed.to.parse.processes', 'Failed to parse processes: "{0}".', processListOutput.output));

Extension/src/SSH/sshCommandRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export function runInteractiveSshTerminalCommand(args: ITerminalCommandArgs): Pr
304304

305305
// When using showLoginTerminal, stdout include the passphrase prompt, etc. Try to get just the command output on the last line.
306306
const actualOutput: string | undefined = cancel ? '' : lastNonemptyLine(stdout);
307-
result.resolve({ succeeded: !exitCode, exitCode, output: actualOutput || '' });
307+
result.resolve({ succeeded: !exitCode, exitCode, outputError: '', output: actualOutput || '' });
308308
};
309309

310310
const failed = (error?: any) => {

Extension/src/common.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ export interface ProcessReturnType {
753753
succeeded: boolean;
754754
exitCode?: number | NodeJS.Signals;
755755
output: string;
756+
outputError: string;
756757
}
757758

758759
export async function spawnChildProcess(program: string, args: string[] = [], continueOn?: string, skipLogging?: boolean, cancellationToken?: vscode.CancellationToken): Promise<ProcessReturnType> {
@@ -766,7 +767,7 @@ export async function spawnChildProcess(program: string, args: string[] = [], co
766767
const programOutput: ProcessOutput = await spawnChildProcessImpl(program, args, continueOn, skipLogging, cancellationToken);
767768
const exitCode: number | NodeJS.Signals | undefined = programOutput.exitCode;
768769
if (programOutput.exitCode) {
769-
return { succeeded: false, exitCode, output: programOutput.stderr || programOutput.stdout || localize('process.exited', 'Process exited with code {0}', exitCode) };
770+
return { succeeded: false, exitCode, outputError: programOutput.stderr, output: programOutput.stderr || programOutput.stdout || localize('process.exited', 'Process exited with code {0}', exitCode) };
770771
} else {
771772
let stdout: string;
772773
if (programOutput.stdout.length) {
@@ -775,7 +776,7 @@ export async function spawnChildProcess(program: string, args: string[] = [], co
775776
} else {
776777
stdout = localize('process.succeeded', 'Process executed successfully.');
777778
}
778-
return { succeeded: true, exitCode, output: stdout };
779+
return { succeeded: true, exitCode, outputError: programOutput.stderr, output: stdout };
779780
}
780781
}
781782

0 commit comments

Comments
 (0)