Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support DAP's "restart" request #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/mockDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ export class MockDebugSession extends LoggingDebugSession {
response.body.supportTerminateDebuggee = true;
response.body.supportsFunctionBreakpoints = true;

response.body.supportsRestartRequest = false;

this.sendResponse(response);

// since this debug adapter can accept configuration requests like 'setBreakpoint' at any time,
Expand Down Expand Up @@ -269,6 +271,15 @@ export class MockDebugSession extends LoggingDebugSession {
}
}

protected async restartRequest(response: DebugProtocol.RestartResponse, args0: DebugProtocol.RestartArguments, request?: DebugProtocol.Request | undefined) {

if (args0.arguments) {
const args = <ILaunchRequestArguments> args0.arguments;
await this._runtime.restart(args.program, !!args.stopOnEntry, !args.noDebug);
}
this.sendResponse(response);
}

protected setFunctionBreakPointsRequest(response: DebugProtocol.SetFunctionBreakpointsResponse, args: DebugProtocol.SetFunctionBreakpointsArguments, request?: DebugProtocol.Request): void {
this.sendResponse(response);
}
Expand Down
19 changes: 19 additions & 0 deletions src/mockRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,25 @@ export class MockRuntime extends EventEmitter {
}
}

public async restart(program: string, stopOnEntry: boolean, debug: boolean): Promise<void> {

this.currentLine = 0;
this.currentColumn = undefined;

if (debug) {
await this.verifyBreakpoints(this._sourceFile);

if (stopOnEntry) {
this.findNextStatement(false, 'stopOnEntry');
} else {
// we just start to run until we hit a breakpoint, an exception, or the end of the program
this.continue(false);
}
} else {
this.continue(false);
}
}

/**
* Continue execution to the end/beginning.
*/
Expand Down