source: trunk/src/scripttools/debugging/scripts/commands/condition.qs

Last change on this file was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 1.5 KB
Line 
1name = "condition";
2
3group = "breakpoints";
4
5shortDescription = "Specify breakpoint condition";
6
7longDescription = "condition <breakpoint-id> <expression> : Specify that the breakpoint with the given id should only be triggered if the given expression evaluates to true.";
8
9argumentTypes = [ "breakpoint-id", "script" ];
10
11seeAlso = [ "ignore" ];
12
13function 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
38function 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}
Note: See TracBrowser for help on using the repository browser.