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

Fix show a list local processes, if remote connection failed (useExtendedRemote) #12623

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion Extension/src/Debugger/attachToProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,18 @@ export class RemoteAttachPicker {
const args: string[] = [`-ex "target extended-remote ${miDebuggerServerAddress}"`, '-ex "info os processes"', '-batch'];
let processListOutput: util.ProcessReturnType = await util.spawnChildProcess(miDebuggerPath, args);
// The device may not be responsive for a while during the restart after image deploy. Retry 5 times.
for (let i: number = 0; i < 5 && !processListOutput.succeeded; i++) {
for (let i: number = 0; i < 5 && !processListOutput.succeeded && processListOutput.outputError.length === 0; i++) {
processListOutput = await util.spawnChildProcess(miDebuggerPath, args);
}

if (!processListOutput.succeeded) {
throw new Error(localize('failed.to.make.gdb.connection', 'Failed to make GDB connection: "{0}".', processListOutput.output));
}

if (processListOutput.outputError.length !== 0) {
throw new Error(localize('failed.to.make.gdb.connection', 'Failed to make GDB connection: "{0}".', processListOutput.outputError));
sean-mcmanus marked this conversation as resolved.
Show resolved Hide resolved
}

const processes: AttachItem[] = this.parseProcessesFromInfoOsProcesses(processListOutput.output);
if (!processes || processes.length === 0) {
throw new Error(localize('failed.to.parse.processes', 'Failed to parse processes: "{0}".', processListOutput.output));
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/SSH/sshCommandRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export function runInteractiveSshTerminalCommand(args: ITerminalCommandArgs): Pr

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

const failed = (error?: any) => {
Expand Down
5 changes: 3 additions & 2 deletions Extension/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ export interface ProcessReturnType {
succeeded: boolean;
exitCode?: number | NodeJS.Signals;
output: string;
outputError: string;
}

export async function spawnChildProcess(program: string, args: string[] = [], continueOn?: string, skipLogging?: boolean, cancellationToken?: vscode.CancellationToken): Promise<ProcessReturnType> {
Expand All @@ -766,7 +767,7 @@ export async function spawnChildProcess(program: string, args: string[] = [], co
const programOutput: ProcessOutput = await spawnChildProcessImpl(program, args, continueOn, skipLogging, cancellationToken);
const exitCode: number | NodeJS.Signals | undefined = programOutput.exitCode;
if (programOutput.exitCode) {
return { succeeded: false, exitCode, output: programOutput.stderr || programOutput.stdout || localize('process.exited', 'Process exited with code {0}', exitCode) };
return { succeeded: false, exitCode, outputError: programOutput.stderr, output: programOutput.stderr || programOutput.stdout || localize('process.exited', 'Process exited with code {0}', exitCode) };
} else {
let stdout: string;
if (programOutput.stdout.length) {
Expand All @@ -775,7 +776,7 @@ export async function spawnChildProcess(program: string, args: string[] = [], co
} else {
stdout = localize('process.succeeded', 'Process executed successfully.');
}
return { succeeded: true, exitCode, output: stdout };
return { succeeded: true, exitCode, outputError: programOutput.stderr, output: stdout };
sean-mcmanus marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading