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

group = "stack";

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

longDescription = "";

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

function execute() {
    scheduleGetContextCount();
    state = 1;
}

function handleResponse(resp) {
    if (state == 1) {
        var count = resp.result;
        var idx = getCurrentFrameIndex() + 1;
        if (idx == count) {
            warning("Already at top (outermost) frame.");
            return;
        }
        setCurrentFrameIndex(idx);
        scheduleGetContextInfo(idx);
        state = 2;
    } else if (state == 2) {
        var info = resp.result;
        setCurrentScriptId(info.scriptId);
        setCurrentLineNumber(info.lineNumber);
        scheduleGetBacktrace();
        state = 3;
    } else if (state == 3) {
        var backtrace = resp.result;
        message("#" + getCurrentFrameIndex() + "  " + backtrace[getCurrentFrameIndex()]);
    }
}