summaryrefslogtreecommitdiffstats
path: root/src/scripttools/debugging/scripts/commands/enable.qs
blob: 6468d0a1f4dba2d610db608cd82d9f9c30ed4b0c (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
53
54
55
56
name = "enable";

group = "breakpoints";

shortDescription = "Enable breakpoint(s)";

longDescription = "enable <breakpoint-id> : Enable the breakpoint with the given id.";

seeAlso = [ "disable" ];

function execute() {
    if (arguments.length == 0) {
        // enable all breakpoints
        state = 1;
        scheduleGetBreakpoints();
    } else {
        var id = parseInt(arguments[0]);
        if (isNaN(id)) {
            message("Breakpoint id expected.");
            return;
        }
        scheduleGetBreakpointData(id);
        breakpointId = id;
        state = 3;
    }
};

function handleResponse(resp) {
    if (state == 1) {
        var breakpoints = resp.result;
        if (breakpoints == undefined)
            return;
        for (var id in breakpoints) {
            var data = breakpoints[id];
            if (!data.enabled) {
                data.enabled = true;
                scheduleSetBreakpointData(id, data);
            }
        }
        state = 2;
    } else if (state == 2) {
        state = 0;
    } else if (state == 3) {
        var data = resp.result;
        if (data == undefined) {
            message("No breakpoint number " + breakpointId + ".");
            return;
        } else if (!data.enabled) {
            data.enabled = true;
            scheduleSetBreakpointData(breakpointId, data);
            state = 4;
        }
    } else if (state == 4) {
        state = 0;
    }
}