AnsweredAssumed Answered

Teaser: NSA 2.00 ready soon with a built-in debugger

Question asked by carstein.seeberg on Nov 23, 2010
Latest reply on Nov 29, 2010 by carstein.seeberg

Hi fellow script developers !

 

We had some pretty cold days with snow the last weekend, so I thought it was a great day to do some unplanned development work :smileywink:  I felt the need for implementing a debugger for NSA making it easier to locate and fix problems during script development.  So I came up with a command-line like solution, very much like gdb/dbx for C.  Anyway, I have a transcript of a session below. 

 

Hope you enjoy the functionality as much as I did developing it...

 

You can even tell NSA to print each line of executed code, which is quite helpful when trying to uncover em bugs... 

 

What do y'all think ?

Carstein

 

 

C:\Program Files\NimBUS\sdk\nsa
$ nsa -D scripts\test.lua
====== NSA 2.00 DEBUGGER STARTING ======= nsa>? Available Commands:    r|run                               execute script.    c|cont                              continue execution.    n|next                              next statement, step over functions.    s|step                              step into functions.    e|exit                              exit NSA.    q|quit                              quit debugging, and reload script.    l|list [num_lines]                  list num_lines of script sourcecode.    p|print [variable|*]                print all or named variables.    b|break [file:]lineno|funct.        set breakpoint.    t|bt|backtrace                      show stacktrace.    B|Breakpoints                       list breakpoints    clear [file:]lineno|funct.          clear spesified breakpoint.    where                               print current line.     set <token> <value>        coverage true                   print each executed linenumber.    set <named variable> <value>        sets the named variable to value.     info <token>        break                           list breakpoints.        version                         show version.  nsa>b 27 Breakpoint added at scripts\test.lua:27 nsa>r At breakpoint scripts\test.lua:27 nsa>l     23 : end     24 :     25 : a=1+2     26 : a=a+b ==> 27 : s="case was here"     28 :     29 : b = iif (a>3,b*2,a+b+b)     30 :     31 : x(123)     32 : s=s..tostring(a)     33 : nsa>p a = 3.000000 [number] b = 0.000000 [number] s = carstein [string] t =  [table] pd =  [userdata] nsa>set b 1234 nsa>p a = 3.000000 [number] b = 1234.000000 [number] s = carstein [string] t =  [table] pd =  [userdata] nsa>n nsa>where Current line is scripts\test.lua:29 nsa>l     25 : a=1+2     26 : a=a+b     27 : s="case was here"     28 : ==> 29 : b = iif (a>3,b*2,a+b+b)     30 :     31 : x(123)     32 : s=s..tostring(a)     33 :     34 : exit(0)     35 : --[[ nsa>p b b = 1234.000000 [number] nsa>n nsa>p b b = 2471.000000 [number] nsa>s Entering function 'x' scripts\test.lua:18 nsa>p abc = 123.000000 [number] nsa>n nsa>l     14 :    return 1     15 : end     16 :     17 : function x(abc) ==> 18 :    local b=b+1     19 :    printf("%s",tostring(abc))     20 :    y(b,22)     21 :    b=b*2     22 :    return b     23 : end     24 : nsa>n nsa>p abc = 123.000000 [number] b = 2472.000000 [number] nsa>n 123 nsa>n y: 2472, 22 nsa>p abc = 123.000000 [number] b = 2472.000000 [number] nsa>l     17 : function x(abc)     18 :    local b=b+1     19 :    printf("%s",tostring(abc))     20 :    y(b,22) ==> 21 :    b=b*2     22 :    return b     23 : end     24 :     25 : a=1+2     26 : a=a+b     27 : s="case was here" nsa>n Script completed, reloading.... nsa>

Outcomes