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

group = "stack";

shortDescription = "Select and print the stack frame below the current one";

longDescription = "";

seeAlso = [ "up", "frame" ];

function execute() {
    var idx = getCurrentFrameIndex();
    if (idx == 0) {
        warning("Already at bottom (innermost) frame.");
        return;
    }
    setCurrentFrameIndex(idx - 1);
    scheduleGetContextInfo(idx - 1);
    state = 1;
}

function handleResponse(resp, id) {
    if (state == 1) {
        var info = resp.result;
        setCurrentScriptId(info.scriptId);
        setCurrentLineNumber(info.lineNumber);
        scheduleGetBacktrace();
        state = 2;
    } else if (state == 2) {
        var backtrace = resp.result;
        message("#" + getCurrentFrameIndex() + "  " + backtrace[getCurrentFrameIndex()]);
    }
}