blob: 9bf6ae2728d71226c54dd044d4d59c0f228658e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
name = "condition";
group = "breakpoints";
shortDescription = "Specify breakpoint condition";
longDescription = "condition <breakpoint-id> <expression> : Specify that the breakpoint with the given id should only be triggered if the given expression evaluates to true.";
argumentTypes = [ "breakpoint-id", "script" ];
seeAlso = [ "ignore" ];
function execute() {
if (arguments.length == 0) {
message("Missing arguments (breakpoint number and condition).");
return;
}
var arg = arguments[0];
var spaceIndex = arg.indexOf(' ');
if (spaceIndex == -1)
spaceIndex = arg.length;
var id = parseInt(arg.slice(0, spaceIndex));
if (isNaN(id)) {
message("First argument must be a number (breakpoint id).");
return;
}
var cond = arg.slice(spaceIndex+1);
if ((cond.length != 0) && !checkSyntax(cond)) {
message("The condition has a syntax error.");
return;
}
scheduleGetBreakpointData(id);
breakpointId = id;
condition = cond;
state = 1;
}
function handleResponse(resp) {
if (state == 1) {
var data = resp.result;
if (data == undefined) {
message("No breakpoint number " + breakpointId + ".");
return;
}
data.condition = condition;
scheduleSetBreakpointData(breakpointId, data);
state = 2;
} else if (state == 2) {
if (condition.length == 0)
message("Breakpoint " + breakpointId + " now unconditional.");
}
}
|