Skip to content

Commit

Permalink
Ensure 'interrupt' and 'disconnect' signals are sent before '-gdb-exi…
Browse files Browse the repository at this point in the history
…t' (eclipse-cdt-cloud#338)

Signed-off-by: Luke Zhang <[email protected]>
  • Loading branch information
Luke-zhang-mchp authored Nov 8, 2024
1 parent 44fda62 commit afa6d13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions src/desktop/GDBTargetDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,15 @@ export class GDBTargetDebugSession extends GDBDebugSession {

if (this.targetType === 'remote') {
if (this.gdb.getAsyncMode() && this.isRunning) {
// See #295 - this use of "then" is to try to slightly delay the
// See #295 - this use of "await" 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.sendCommand('interrupt');
}

await this.gdb.sendCommand('disconnect');
}

await this.gdb.sendGDBExit();
Expand Down
10 changes: 4 additions & 6 deletions src/web/GDBTargetDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,15 @@ export class GDBTargetDebugSession extends GDBDebugSession {
try {
if (this.targetType === 'remote') {
if (this.gdb.getAsyncMode() && this.isRunning) {
// See #295 - this use of "then" is to try to slightly delay the
// See #295 - this use of "await" 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.sendCommand('interrupt');
}

await this.gdb.sendCommand('disconnect');
}

await this.gdb.sendGDBExit();
Expand Down

0 comments on commit afa6d13

Please sign in to comment.