Skip to content

Commit

Permalink
Ensure 'interrupt' signal is fully sent before 'disconnect' (#292)
Browse files Browse the repository at this point in the history
While this change does not wait for the target to be paused
it slightly slows down how long after interrupt is sent that
disconnect is sent.

See also #295
  • Loading branch information
XingMicrochip authored Sep 19, 2023
1 parent 93a7ce9 commit 9d9a463
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/GDBTargetDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,18 @@ export class GDBTargetDebugSession extends GDBDebugSession {
this.serialPort.close();

if (this.targetType === 'remote') {
if (this.gdb.getAsyncMode() && this.isRunning)
this.gdb.sendCommand('interrupt');
await this.gdb.sendCommand('disconnect');
if (this.gdb.getAsyncMode() && this.isRunning) {
// See #295 - this use of "then" is to try to slightly delay the
// call to disconnect. A proper solution that waits for the
// interrupt to be successful is needed to avoid future
// "Cannot execute this command while the target is running"
// errors
this.gdb
.sendCommand('interrupt')
.then(() => this.gdb.sendCommand('disconnect'));
} else {
await this.gdb.sendCommand('disconnect');
}
}

await this.gdb.sendGDBExit();
Expand Down

0 comments on commit 9d9a463

Please sign in to comment.