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