Added 'optimize for debug' option

This commit is contained in:
Miro Spönemann
2020-02-24 10:33:39 +01:00
parent 486f110c80
commit 0445700088
24 changed files with 2441 additions and 424 deletions

View File

@@ -13,6 +13,10 @@ export interface ArduinoLaunchRequestArguments extends DebugProtocol.LaunchReque
export class ArduinoDebugSession extends GDBDebugSession {
protected get arduinoBackend(): ArduinoGDBBackend {
return this.gdb as ArduinoGDBBackend;
}
protected createBackend(): GDBBackend {
return new ArduinoGDBBackend();
}
@@ -38,4 +42,24 @@ export class ArduinoDebugSession extends GDBDebugSession {
}
}
protected async disconnectRequest(response: DebugProtocol.DisconnectResponse): Promise<void> {
try {
if (this.isRunning) {
// Need to pause first
const waitPromise = new Promise(resolve => this.waitPaused = resolve);
this.gdb.pause();
await waitPromise;
}
try {
await this.arduinoBackend.sendTargetDetach();
} catch (e) {
// Need to catch here as the command result being returned will never exist as it's detached
}
await this.gdb.sendGDBExit();
this.sendResponse(response);
} catch (err) {
this.sendErrorResponse(response, 1, err.message);
}
}
}

View File

@@ -6,7 +6,7 @@ import { ArduinoLaunchRequestArguments } from './arduino-debug-session';
export class ArduinoGDBBackend extends GDBBackend {
public spawn(requestArgs: ArduinoLaunchRequestArguments): Promise<void> {
spawn(requestArgs: ArduinoLaunchRequestArguments): Promise<void> {
if (!requestArgs.sketch) {
throw new Error('Missing argument: sketch');
}
@@ -28,14 +28,18 @@ export class ArduinoGDBBackend extends GDBBackend {
return this.parser.parse(proc.stdout);
}
public sendFileExecAndSymbols(): Promise<void> {
sendFileExecAndSymbols(): Promise<void> {
// The program file is already sent by `arduino-cli`
return Promise.resolve();
}
public pause(): boolean {
pause(): boolean {
this.sendCommand('-exec-interrupt');
return true;
}
sendTargetDetach(): Promise<void> {
return this.sendCommand('-target-detach');
}
}