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

group = "stack";

shortDescription = "Select and print a stack frame";

longDescription = "";

aliases = [ "f" ];

function execute() {
    if (arguments.length == 0)
        requestedFrameIndex = getCurrentFrameIndex();
    else
        requestedFrameIndex = parseInt(arguments[0]);
    scheduleGetContextInfo(requestedFrameIndex);
    state = 1;
};

function handleResponse(resp, id) {
    if (state == 1) {
        var info = resp.result;
        if (info == undefined) {
            message("Frame index out of range.");
            return;
        }
        setCurrentFrameIndex(requestedFrameIndex);
        setCurrentScriptId(info.scriptId);
        setCurrentLineNumber(info.lineNumber);
        scheduleGetBacktrace();
        state = 2;
    } else if (state == 2) {
        var backtrace = resp.result;
        message("#" + getCurrentFrameIndex() + "  " + backtrace[getCurrentFrameIndex()]);
    }
}