summaryrefslogtreecommitdiffstats
path: root/src/scripttools/debugging/scripts/commands/disable.qs
blob: 91bf44bb4d92c4fff5501d5e2b86d6ffb96c8a12 (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 = "disable";

group = "breakpoints";

shortDescription = "Disable breakpoint(s)";

longDescription = "disable <breakpoint-id> : Disables the breakpoint with the given id.";

seeAlso = [ "enable", "delete", "ignore" ];

function execute() {
    if (arguments.length == 0) {
        // disable 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 = false;
                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 = false;
            scheduleSetBreakpointData(breakpointId, data);
            state = 4;
        }
    } else if (state == 4) {
        state = 0;
    }
}