Skip to content

Commit 65a6e79

Browse files
Yuyuporobertsipka
authored andcommitted
Add restart function (#23)
IoT.js-VSCode-DCO-1.0-Signed-off-by: Daniella Barsony [email protected]
1 parent 0db29f0 commit 65a6e79

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

src/IotjsDebugger.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class IotjsDebugSession extends DebugSession {
7979
response.body.supportsFunctionBreakpoints = true;
8080
response.body.supportsEvaluateForHovers = false;
8181
response.body.supportsStepBack = false;
82-
response.body.supportsRestartRequest = false;
82+
response.body.supportsRestartRequest = true;
8383
response.body.supportsDelayedStackTraceLoading = true;
8484

8585
this._sourceSendingOptions = <SourceSendingOptions>{
@@ -237,9 +237,14 @@ class IotjsDebugSession extends DebugSession {
237237
}
238238

239239
protected restartRequest(response: DebugProtocol.RestartResponse, args: DebugProtocol.RestartArguments): void {
240-
this.log('restartRequest: Not implemented yet', LOG_LEVEL.SESSION);
241-
242-
this.sendResponse(response);
240+
this.log('restartRequest', LOG_LEVEL.SESSION);
241+
try {
242+
this._protocolhandler.restart();
243+
this.sendResponse(response);
244+
} catch (error) {
245+
this.log(error.message, LOG_LEVEL.ERROR);
246+
this.sendErrorResponse(response, 0, (<Error>error).message);
247+
}
243248
}
244249

245250
protected continueRequest(response: DebugProtocol.ContinueResponse, args: DebugProtocol.ContinueArguments): void {

src/JerryProtocolHandler.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ export class JerryDebugProtocolHandler {
244244
return this.resumeExec(SP.CLIENT.JERRY_DEBUGGER_CONTINUE);
245245
}
246246

247+
public restart(): Promise<any> {
248+
const array = stringToCesu8(SP.EVAL_SUBTYPE.JERRY_DEBUGGER_EVAL_ABORT + '\'r353t\'', 1 + 4, this.byteConfig);
249+
array[0] = SP.CLIENT.JERRY_DEBUGGER_EVAL;
250+
251+
return this.sendRequest(array);
252+
}
253+
247254
public getPossibleBreakpoints(scriptId: number, startLine: number, endLine?: number): Array<Breakpoint> {
248255
const array = [];
249256
const lineList = this.lineLists[scriptId];

src/test/JerryProtocolHandler.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,4 +873,30 @@ suite('JerryProtocolHandler', () => {
873873
assert(debugClient.send.withArgs(array));
874874
});
875875
});
876+
877+
suite('restart()', () => {
878+
test('sends the correct message', () => {
879+
const { handler, debugClient } = setupHaltedProtocolHandler();
880+
const defConfig = {
881+
cpointerSize: 2,
882+
littleEndian: false,
883+
};
884+
handler.restart();
885+
let array = stringToCesu8(SP.EVAL_SUBTYPE.JERRY_DEBUGGER_EVAL_ABORT + '\'r353t\'', 1 + 4, defConfig);
886+
array[0] = SP.CLIENT.JERRY_DEBUGGER_EVAL;
887+
assert(debugClient.send.withArgs(array));
888+
});
889+
890+
test('sends the correct message2', () => {
891+
const { handler, debugClient } = setupHaltedProtocolHandler();
892+
const altConfig = {
893+
cpointerSize: 4,
894+
littleEndian: false,
895+
};
896+
handler.restart();
897+
let array = stringToCesu8(SP.EVAL_SUBTYPE.JERRY_DEBUGGER_EVAL_ABORT + '\'r353t\'', 1 + 4, altConfig);
898+
array[0] = SP.CLIENT.JERRY_DEBUGGER_EVAL;
899+
assert(debugClient.send.withArgs(array));
900+
});
901+
});
876902
});

0 commit comments

Comments
 (0)