util/src/scripttools/debugging/scripts/commands/up.qs
changeset 7 f7bc934e204c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
       
     1 name = "up";
       
     2 
       
     3 group = "stack";
       
     4 
       
     5 shortDescription = "Select and print the stack frame above the current one";
       
     6 
       
     7 longDescription = "";
       
     8 
       
     9 seeAlso = [ "down", "frame" ];
       
    10 
       
    11 function execute() {
       
    12     scheduleGetContextCount();
       
    13     state = 1;
       
    14 }
       
    15 
       
    16 function handleResponse(resp) {
       
    17     if (state == 1) {
       
    18         var count = resp.result;
       
    19         var idx = getCurrentFrameIndex() + 1;
       
    20         if (idx == count) {
       
    21             warning("Already at top (outermost) frame.");
       
    22             return;
       
    23         }
       
    24         setCurrentFrameIndex(idx);
       
    25         scheduleGetContextInfo(idx);
       
    26         state = 2;
       
    27     } else if (state == 2) {
       
    28         var info = resp.result;
       
    29         setCurrentScriptId(info.scriptId);
       
    30         setCurrentLineNumber(info.lineNumber);
       
    31         scheduleGetBacktrace();
       
    32         state = 3;
       
    33     } else if (state == 3) {
       
    34         var backtrace = resp.result;
       
    35         message("#" + getCurrentFrameIndex() + "  " + backtrace[getCurrentFrameIndex()]);
       
    36     }
       
    37 }