Added signal handlers to kill gdb server.

Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
jbicker 2020-01-23 14:42:58 +01:00 committed by Miro Spönemann
parent 2855026cec
commit 40ddd3714b

View File

@ -50,14 +50,32 @@ const STATIC_HANDLES_FINISH = 0x01FFFF;
export class CmsisDebugSession extends GDBDebugSession { export class CmsisDebugSession extends GDBDebugSession {
protected gdbServer = new OpenocdServer(); protected readonly gdbServer = new OpenocdServer();
protected portScanner = new PortScanner(); protected readonly portScanner = new PortScanner();
protected symbolTable!: SymbolTable; protected symbolTable!: SymbolTable;
protected globalHandle!: number; protected globalHandle!: number;
protected varMgr: VarManager; protected varMgr: VarManager;
constructor() { constructor() {
super(); super();
this.addProcessListeners();
}
protected addProcessListeners(): void {
process.on('exit', () => {
if (this.gdbServer.isRunning) {
this.gdbServer.kill();
}
});
const signalHandler = () => {
if (this.gdbServer.isRunning) {
this.gdbServer.kill();
}
process.exit();
}
process.on('SIGINT', signalHandler);
process.on('SIGTERM', signalHandler);
process.on('SIGHUP', signalHandler);
} }
protected createBackend(): GDBBackend { protected createBackend(): GDBBackend {
@ -258,11 +276,6 @@ export class CmsisDebugSession extends GDBDebugSession {
this.progressEvent(0, 'Starting Debugger'); this.progressEvent(0, 'Starting Debugger');
this.sendEvent(new OutputEvent(`Starting debugger: ${JSON.stringify(args)}`)); this.sendEvent(new OutputEvent(`Starting debugger: ${JSON.stringify(args)}`));
await this.gdbServer.spawn(args); await this.gdbServer.spawn(args);
process.on('exit', () => {
if (this.gdbServer.isRunning) {
this.gdbServer.kill();
}
});
await this.spawn(args); await this.spawn(args);
this.checkServerErrors(gdbServerErrors); this.checkServerErrors(gdbServerErrors);