From 3541297e224374471f2e91dba2f66609664e3ad6 Mon Sep 17 00:00:00 2001 From: Robin Chalmet Date: Fri, 18 Apr 2025 14:58:55 +0200 Subject: [PATCH] Increase gdb exit timeout to allow clean exit. Else the target could remain halted. --- package-lock.json | 4 ++-- package.json | 2 +- src/backend/mi2/mi2.ts | 6 +++--- src/gdb.ts | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index f8d20d29..b2cb5cf1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cortex-debug", - "version": "1.12.1-pre5", + "version": "1.12.2-hotfix", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cortex-debug", - "version": "1.12.1-pre5", + "version": "1.12.2-hotfix", "license": "MIT", "dependencies": { "@vscode/extension-telemetry": "^0.4.7", diff --git a/package.json b/package.json index b3832f18..7384543e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.12.1", + "version": "1.12.2-hotfix", "preview": false, "activationEvents": [ "onDebugResolve:cortex-debug", diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts index addfdfe6..d68b36cf 100644 --- a/src/backend/mi2/mi2.ts +++ b/src/backend/mi2/mi2.ts @@ -454,7 +454,7 @@ export class MI2 extends EventEmitter implements IBackend { // Disconnect first. Not doing so and exiting will cause an unwanted detach if the // program is in paused state try { - startKillTimeout(500); + startKillTimeout(10000); await new Promise((res) => setTimeout(res, 100)); // For some people delay was needed. Doesn't hurt I guess await this.sendCommand('target-disconnect'); // Yes, this can fail } @@ -467,8 +467,8 @@ export class MI2 extends EventEmitter implements IBackend { ServerConsoleLog(`target-disconnect failed with exception: ${e}. Proceeding to gdb-exit` + e, this.pid); } - startKillTimeout(350); // Reset timer for a smaller timeout - await new Promise((res) => setTimeout(res, 250)); // For some people delay was needed. Doesn't hurt I guess + startKillTimeout(10000); // Reset timer + await new Promise((res) => setTimeout(res, 9500)); // Allow time for gdb to exit cleanly on its own if (this.exited) { // This occurs sometimes after a successful disconnect. ServerConsoleLog('gdb already exited before an exit was requested', this.pid); diff --git a/src/gdb.ts b/src/gdb.ts index 514fdfe7..039c33dc 100755 --- a/src/gdb.ts +++ b/src/gdb.ts @@ -1394,7 +1394,8 @@ export class GDBDebugSession extends LoggingDebugSession { private waitForServerExitAndRespond(response: DebugProtocol.DisconnectResponse) { if (!this.server.isExternal()) { - let nTimes = 60; + const intervalMs = 10; + let nTimes = 1200; // interval_ms * nTimes should be larger than max clean exit time. let to = setInterval(() => { if ((nTimes === 0) || this.quit) { // We waited long enough so try to nuke the server and send VSCode a response @@ -1407,7 +1408,7 @@ export class GDBDebugSession extends LoggingDebugSession { } else { nTimes--; } - }, 10); + }, intervalMs); this.server.once('exit', () => { if (to) { clearInterval(to);