Skip to content

Commit c1cef41

Browse files
committed
Add support for conditional breakpoints. Fixed: #22
1 parent 31322ed commit c1cef41

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"request": "launch",
88
"program": "${workspaceRoot}/out/webkit/webKitDebug.js",
99
"runtimeArgs": ["--nolazy"],
10-
"stopOnEntry": true,
10+
"stopOnEntry": false,
1111
"args": [ "--server=4712" ],
1212
"sourceMaps": true,
1313
"outDir": null,

nativescript/android/androidDebugConnection.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export class AndroidDebugConnection implements ns.INSDebugConnection {
442442
this._socket.close();
443443
}
444444

445-
public debugger_setBreakpointByUrl(url: string, lineNumber: number, columnNumber: number): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse> {
445+
public debugger_setBreakpointByUrl(url: string, lineNumber: number, columnNumber: number, condition?: string): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse> {
446446
//throw new Error("Not implemented");
447447
//return this.sendMessage('Debugger.setBreakpointByUrl', <WebKitProtocol.Debugger.SetBreakpointByUrlParams>{ url, lineNumber, columnNumber });
448448

@@ -451,7 +451,8 @@ export class AndroidDebugConnection implements ns.INSDebugConnection {
451451
type: 'script',
452452
target: that.inspectorUrlToV8Name(url),
453453
line: lineNumber,
454-
column: columnNumber
454+
column: columnNumber,
455+
condition: condition
455456
};
456457

457458
return this.request("setbreakpoint", requestParams)

nativescript/nativescript.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface INSDebugConnection {
1111

1212
close(): void;
1313

14-
debugger_setBreakpointByUrl(url: string, lineNumber: number, columnNumber: number): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse>
14+
debugger_setBreakpointByUrl(url: string, lineNumber: number, columnNumber: number, condition?: string): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse>
1515

1616
debugger_removeBreakpoint(breakpointId: string): Promise<WebKitProtocol.Response>
1717

webkit/webKitConnection.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ export class WebKitConnection implements ns.INSDebugConnection {
171171
}
172172

173173
public debugger_setBreakpoint(location: WebKitProtocol.Debugger.Location, condition?: string): Promise<WebKitProtocol.Debugger.SetBreakpointResponse> {
174-
return this.sendMessage('Debugger.setBreakpoint', <WebKitProtocol.Debugger.SetBreakpointParams>{ location, condition });
174+
return this.sendMessage('Debugger.setBreakpoint', <WebKitProtocol.Debugger.SetBreakpointParams>{ location, options: { condition: condition }});
175175
}
176176

177-
public debugger_setBreakpointByUrl(url: string, lineNumber: number, columnNumber: number): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse> {
178-
return this.sendMessage('Debugger.setBreakpointByUrl', <WebKitProtocol.Debugger.SetBreakpointByUrlParams>{ url, lineNumber, columnNumber: 0 /* a columnNumber different from 0 confuses the debugger */ });
177+
public debugger_setBreakpointByUrl(url: string, lineNumber: number, columnNumber: number, condition?: string): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse> {
178+
return this.sendMessage('Debugger.setBreakpointByUrl', <WebKitProtocol.Debugger.SetBreakpointByUrlParams>{ url: url, lineNumber: lineNumber, columnNumber: 0 /* a columnNumber different from 0 confuses the debugger */, options: { condition: condition }});
179179
}
180180

181181
public debugger_removeBreakpoint(breakpointId: string): Promise<WebKitProtocol.Response> {

webkit/webKitDebugAdapter.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ export class WebKitDebugAdapter implements IDebugAdapter {
354354
// DebugProtocol sends all current breakpoints for the script. Clear all scripts for the breakpoint then add all of them
355355
const setBreakpointsPFailOnError = this._setBreakpointsRequestQ
356356
.then(() => this._clearAllBreakpoints(targetScriptUrl))
357-
.then(() => this._addBreakpoints(targetScriptUrl, args.lines, args.cols))
357+
.then(() => this._addBreakpoints(targetScriptUrl, args))
358358
.then(responses => ({ breakpoints: this._webkitBreakpointResponsesToODPBreakpoints(targetScriptUrl, responses, args.lines) }));
359359

360360
const inDebug = typeof (<any>global).v8debug === 'object';
@@ -386,10 +386,10 @@ export class WebKitDebugAdapter implements IDebugAdapter {
386386
});
387387
}
388388

389-
private _addBreakpoints(url: string, lines: number[], cols?: number[]): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse[]> {
389+
private _addBreakpoints(url: string, breakpoints: ISetBreakpointsArgs): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse[]> {
390390
// Call setBreakpoint for all breakpoints in the script simultaneously
391-
const responsePs = lines
392-
.map((lineNumber, i) => this._webKitConnection.debugger_setBreakpointByUrl(url, lineNumber, cols ? cols[i] : 0));
391+
const responsePs = breakpoints.breakpoints
392+
.map((b, i) => this._webKitConnection.debugger_setBreakpointByUrl(url, breakpoints.lines[i], breakpoints.cols ? breakpoints.cols[i] : 0, b.condition));
393393

394394
// Join all setBreakpoint requests to a single promise
395395
return Promise.all(responsePs);

webkit/webKitProtocol.d.ts

+21-8
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,37 @@ declare namespace WebKitProtocol {
6565
columnNumber?: number;
6666
}
6767

68-
interface SetBreakpointParams {
69-
location: Location;
68+
interface BreakpointAction {
69+
type: string; /* "log", "evaluate", "sound" or "probe" */
70+
data?: string;
71+
id?: number;
72+
}
73+
74+
interface BreakpointOptions {
7075
condition?: string;
76+
actions?: BreakpointAction[];
77+
autoContinue?: boolean;
78+
ignoreCount?: number;
7179
}
7280

73-
interface SetBreakpointResponse extends Response {
74-
result: {
75-
breakpointId: BreakpointId;
76-
actualLocation: Location;
77-
};
81+
interface SetBreakpointParams {
82+
location: Location;
83+
options: BreakpointOptions;
7884
}
7985

8086
interface SetBreakpointByUrlParams {
8187
url?: string;
8288
urlRegex?: string;
8389
lineNumber: number;
8490
columnNumber: number;
85-
condition?: string;
91+
options: BreakpointOptions;
92+
}
93+
94+
interface SetBreakpointResponse extends Response {
95+
result: {
96+
breakpointId: BreakpointId;
97+
actualLocation: Location;
98+
};
8699
}
87100

88101
interface SetBreakpointByUrlResponse extends Response {

0 commit comments

Comments
 (0)