Skip to content

Commit

Permalink
require async mode for pausing before exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke-zhang-04 committed Nov 12, 2024
1 parent eef8427 commit f611a68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/desktop/GDBTargetDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class GDBTargetDebugSession extends GDBDebugSession {

if (this.targetType === 'remote') {
// Need to pause first, then disconnect and exit
await this.pauseIfNeeded();
await this.pauseIfNeeded(true);
await this.gdb.sendCommand('disconnect');
}

Expand Down
7 changes: 5 additions & 2 deletions src/gdb/GDBDebugSessionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,12 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {
/**
* Sends a pause command to GDBBackend, and resolves when the debugger is
* actually paused. The paused thread ID is saved to `this.waitPausedThreadId`.
*
* @param requireAsync - require gdb to be in async mode to pause
*/
protected async pauseIfNeeded(): Promise<void> {
this.waitPausedNeeded = this.isRunning;
protected async pauseIfNeeded(requireAsync = false): Promise<void> {
this.waitPausedNeeded =
this.isRunning && (!requireAsync || this.gdb.getAsyncMode());

if (this.waitPausedNeeded) {
const waitPromise = new Promise<void>((resolve) => {
Expand Down
2 changes: 1 addition & 1 deletion src/web/GDBTargetDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export class GDBTargetDebugSession extends GDBDebugSession {
try {
if (this.targetType === 'remote') {
// Need to pause first, then disconnect and exit
await this.pauseIfNeeded();
await this.pauseIfNeeded(true);
await this.gdb.sendCommand('disconnect');
}

Expand Down

0 comments on commit f611a68

Please sign in to comment.