diff --git a/CHANGELOG.md b/CHANGELOG.md index ffc0b56d..f57f1669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ChangeLog +#V0.4.6 +* Bugfix: Issue #493 In the previous release, we were trying to end OpenOCD using a SIGINT first and then SIGTERM. The way VSCode works, this did not work in production releases. Reverting back to the previous method of just using SIGTERM. Unfortunately. Still looking for a better method to end OpenOCD. + #V0.4.5 * Support for resume/suspend after Launch/Attach. With new UI features added to VSCode, the Stop button (after `Launch`) can now also be used for a Disconnect using keyboard shortcuts. The reverse is true when using an `Attach` type session. But this requires co-operation from the gdb-server to comply. Certain versions of OpenOCD do comply, JLink always seems to resume (see issue $481). Provided the gdb-server cooperates, the expected behavior now when you end a debug session is: * `Stop` will leave the program in a halted state diff --git a/package.json b/package.json index a2fae3cb..8eefcec9 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.4.5", + "version": "0.4.6", "activationEvents": [ "onDebugResolve:cortex-debug" ], diff --git a/src/backend/server.ts b/src/backend/server.ts index 3f473c43..6aaa4692 100644 --- a/src/backend/server.ts +++ b/src/backend/server.ts @@ -1,10 +1,25 @@ import * as ChildProcess from 'child_process'; import * as os from 'os'; import * as net from 'net'; +import * as fs from 'fs'; import { EventEmitter } from 'events'; import { setTimeout } from 'timers'; -import { TcpPortScanner } from '../tcpportscanner'; +const tmpDirName = os.platform() === 'win32' ? process.env.TEMP || process.env.TMP || '.' : '/tmp'; +export function ServerConsoleLog(str: string) { + console.log(str); + try { + if (false) { + if (!str.endsWith('\n')) { + str += '\n'; + } + fs.appendFileSync(`${tmpDirName}/cortex-debug-server-exiting-${process.pid}`, str); + } + } + catch (e) { + console.log(e.toString()); + } +} export class GDBServer extends EventEmitter { private process: ChildProcess.ChildProcess; private outBuffer: string = ''; @@ -67,25 +82,17 @@ export class GDBServer extends EventEmitter { public exit(): void { if (this.process) { try { - // Some of gdb-servers want to recieve an Control-C equivalent first, so try that for - // a bit more graceful exit - console.log('GDBServer: requesting an exit with SIGINT'); - this.process.kill('SIGINT'); - setTimeout(() => { - if (this.process != null) { // Still not dead? - console.log('GDBServer: forcing an exit with kill()'); - this.process.kill(); - } - }, 100); + ServerConsoleLog('GDBServer: forcing an exit with kill()'); + this.process.kill(); } catch (e) { - console.log(`Tring to force and exit failed ${e}`); + ServerConsoleLog(`Tring to force and exit failed ${e}`); } } } private onExit(code, signal) { - console.log(`GDBServer: exited ${code} ${signal}`); + ServerConsoleLog(`GDBServer: exited ${code} ${signal}`); this.process = null; if (this.exitTimeout) { clearTimeout(this.exitTimeout);