Skip to content

Commit 8cb80c0

Browse files
knightburtonyichoi
authored andcommitted
Specify different string for active and inactive breakpoint hit (#36)
IoT.js-Debug-DCO-1.0-Signed-off-by: Imre Kiss [email protected]
1 parent f8dee7a commit 8cb80c0

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/IotjsDebugger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ class IotjsDebugSession extends DebugSession {
122122
this._args = args;
123123
this._debugLog = args.debugLog || false;
124124

125-
const onBreakpointHit = () => {
125+
const onBreakpointHit = (breakpointRef, stopType) => {
126126
this.log('onBreakpointHit');
127-
this.sendEvent(new StoppedEvent('breakpoint', IotjsDebugSession.THREAD_ID));
127+
this.sendEvent(new StoppedEvent(stopType, IotjsDebugSession.THREAD_ID));
128128
};
129129

130130
const onExceptionHit = (data: JerryMessageExceptionHit) => {

src/JerryProtocolHandler.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface ParserStackFrame {
4444

4545
export interface JerryDebugProtocolDelegate {
4646
onBacktrace?(backtrace: Array<Breakpoint>): void;
47-
onBreakpointHit?(message: JerryMessageBreakpointHit): void;
47+
onBreakpointHit?(message: JerryMessageBreakpointHit, stopType: string): void;
4848
onExceptionHit?(message: JerryMessageExceptionHit): void;
4949
onEvalResult?(subType: number, result: string): void;
5050
onError?(code: number, message: string): void;
@@ -98,6 +98,10 @@ interface ParsedSource {
9898
source?: string;
9999
}
100100

101+
interface StopTypeMap {
102+
[type: number]: string;
103+
}
104+
101105
class PendingRequest {
102106
public data: Uint8Array;
103107
public promise: Promise<any>;
@@ -153,6 +157,8 @@ export class JerryDebugProtocolHandler {
153157
private log: LoggerFunction;
154158
private requestQueue: PendingRequest[];
155159
private currentRequest: PendingRequest;
160+
private stopTypeMap: StopTypeMap;
161+
private lastStopType: number;
156162

157163
constructor(delegate: JerryDebugProtocolDelegate, log?: LoggerFunction) {
158164
this.delegate = delegate;
@@ -189,6 +195,15 @@ export class JerryDebugProtocolHandler {
189195

190196
this.requestQueue = [];
191197
this.currentRequest = null;
198+
199+
this.stopTypeMap = {
200+
[SP.CLIENT.JERRY_DEBUGGER_NEXT]: 'step',
201+
[SP.CLIENT.JERRY_DEBUGGER_STEP]: 'step-in',
202+
[SP.CLIENT.JERRY_DEBUGGER_FINISH]: 'step-out',
203+
[SP.CLIENT.JERRY_DEBUGGER_CONTINUE]: 'continue',
204+
[SP.CLIENT.JERRY_DEBUGGER_STOP]: 'pause',
205+
};
206+
this.lastStopType = null;
192207
}
193208

194209
// FIXME: this lets test suite run for now
@@ -213,6 +228,8 @@ export class JerryDebugProtocolHandler {
213228
if (this.lastBreakpointHit) {
214229
return Promise.reject(new Error('attempted pause while at breakpoint'));
215230
}
231+
232+
this.lastStopType = SP.CLIENT.JERRY_DEBUGGER_STOP;
216233
return this.sendSimpleRequest(encodeMessage(this.byteConfig, 'B', [SP.CLIENT.JERRY_DEBUGGER_STOP]));
217234
}
218235

@@ -516,8 +533,12 @@ export class JerryDebugProtocolHandler {
516533
}
517534

518535
if (this.delegate.onBreakpointHit) {
519-
this.delegate.onBreakpointHit(breakpointRef);
536+
const stopTypeText = this.stopTypeMap[this.lastStopType] || 'entry';
537+
const stopType = `${breakpoint.activeIndex === -1 ? 'inactive ' : ''}breakpoint (${stopTypeText})`;
538+
this.delegate.onBreakpointHit(breakpointRef, stopType);
520539
}
540+
541+
this.lastStopType = null;
521542
}
522543

523544
public onBacktrace(data: Uint8Array): Breakpoint[] {
@@ -721,6 +742,7 @@ export class JerryDebugProtocolHandler {
721742
}
722743

723744
this.lastBreakpointHit = undefined;
745+
this.lastStopType = code;
724746
const result = this.sendSimpleRequest(encodeMessage(this.byteConfig, 'B', [code]));
725747

726748
if (this.delegate.onResume) {

0 commit comments

Comments
 (0)