Open Forum > What's New

dbgcon - Script BASIC remote debugger

(1/1)

support:
A few years ago I made some bug fixes to Peter's Verhas's experimental sdbg remote Script BASIC debugger. I wrote my own console client in SB which works great. I plan on using some of Dave Zimmer's enhancements to his VB/COM IDE/Debugger preprocessor project to view array contents and trace the call stack. The remote socket based Script BASIC debugger works with both local desktop scripts and remote sbhttpd proxy server web applications.

dbgcon.sb

--- Code: Script BASIC ---' ScriptBasic Remote Console Debugger cmdln = TRIM(COMMAND())IF cmdln = "" THEN  PRINT "Usage: dbgcon [prog2debug]\n"  ENDEND IFexitcode = EXECUTE("/usr/bin/scriba -i sdbg " & cmdln,-1,PID)OPEN "127.0.0.1:6647" FOR SOCKET AS #1WHILE NOT EOF(1)  LINE INPUT #1, dbgs  IF dbgs = ".\n" THEN    PRINT "-> "    LINE INPUT dbgc    IF LCASE(CHOMP(dbgc)) = "h" THENPRINT """h helps step one lineS step one line, do not step into functions or subso step until getting out of the current function  (if you stepped into but changed your mind)? var  print the value of a variableu step one level up in the stackd step one level down in the stack (for variable printing)D step down in the stack to current execution depthG list all global variablesL list all local variablesl [n-m] list the source linesr [n] run to line nR [n] run to line n but do not stop in recursive function callb [n] set breakpoint on the line n or the current lineB [n-m] remove breakpoints from linesq quit the program"""    END IF     PRINT #1, dbgc    IF CHOMP(dbgc) = "q" THEN GOTO Done  ELSE    dbgcmd = CHOMP(dbgs)' l - List Source      IF INSTR(dbgcmd,"Break-Point: ")<>undef THEN      p = INSTR(dbgcmd,"Break-Point: ")      IF MID(dbgcmd,p+13,1) = "0" THEN        PRINT " "      ELSE        PRINT "*"      END IF      GOTO IT    END IF    IF INSTR(dbgcmd,"Line-Number: ")<>undef THEN      p = INSTR(dbgcmd,"Line-Number: ")      PRINT FORMAT("%~[0000] ~",VAL(MID(dbgcmd,p+13)))      online = TRUE      GOTO IT    END IF    IF INSTR(dbgcmd,"Line: ")<>undef THEN      p = INSTR(dbgcmd,"Line: ")      IF online THEN        PRINT MID(dbgcmd,p+6),"\n"      ELSE        PRINT MID(dbgcmd,p),"\n"      END IF              online = FALSE      GOTO IT    END IF    IF INSTR(dbgcmd,"Global-Variable")<>undef THEN      p = INSTR(dbgcmd,"Global-Variable")      PRINT "G-Var" & MID(dbgcmd,p+15) & "\n"      GOTO IT    END IF' Unprocessed out   PRINT dbgs  END IFIT:WEND Done:PRINT #1,"q"CLOSE(1)PRINT "Debug session closed.\n"END 
testarray.sb

--- Code: Script BASIC ---' Long / Double / Stringi = 1d = .99s = "JRS"' Indices arraya[0,0] = 0a[0,1] = 123a[0,2] = 1.23a[0,3] = "One,Two,Three"a[1,10] = "Zero"a[1,11] = 321a[1,12] = 32.1a[1,13] = "Three,Two,One"' Asscociative arrayb{"One"} = 1b{"Two"} = .2b{"Three"} = "*3*"' Mix asscociative & indices arrayc{"JRS"}[1] = 1c{"JRS"}[2] = .2c{"JRS"}[3] = "*3*"PRINT "Done\n" 
Output

jrs@laptop:~/sb/sb22/sbt$ scriba dbgcon.sb testarray.sb
Application: ScriptBasic Remote Debugger - Linux
Version: 1.0
Source-File-Count: 1
Source-File: testarray.sb
Line: 2
-> b15
Message: done
Line: 2
-> l1-
 [0001] ' Long / Double / String
 [0002] i = 1
 [0003] d = .99
 [0004] s = "JRS"
 [0005] ' Indices array
 [0006] a[0,0] = 0
 [0007] a[0,1] = 123
 [0008] a[0,2] = 1.23
 [0009] a[0,3] = "One,Two,Three"
 [0010] a[1,10] = "Zero"
 [0011] a[1,11] = 321
 [0012] a[1,12] = 32.1
 [0013] a[1,13] = "Three,Two,One"
 [0014] ' Asscociative array
*[0015] b{"One"} = 1
 [0016] b{"Two"} = .2
 [0017] b{"Three"} = "*3*"
 [0018] ' Mix asscociative & indices array
 [0019] c{"JRS"}[1] = 1
 [0020] c{"JRS"}[2] = .2
 [0021] c{"JRS"}[3] = "*3*"
 [0022] PRINT "Done\n"
Line: 2
-> r
Line: 15
-> r22
Line: 22
-> G
G-Var-Name: VT=0 @ 0x014BBD18 VN=main::i
G-Var-Value: 1
G-Var-Name: VT=1 @ 0x014C9258 VN=main::d
G-Var-Value: 0.990000
G-Var-Name: VT=2 @ 0x014C92B8 VN=main::s
G-Var-Value: "JRS"
G-Var-Name: VT=3 @ 0x014C9378 LB=0 : UB=1 VN=main::a
G-Var-Value: 
LB=0 : UB=3 VN=[0]
[0] VT=3 @ 0x014C9468 
[0] VT=0 @ 0x014C9558 0
[1] VT=0 @ 0x014C96D8 123
[2] VT=1 @ 0x014C9898 1.230000
[3] VT=2 @ 0x014BC0A8 "One,Two,Three"
LB=10 : UB=13 VN=[1]
[1] VT=3 @ 0x014BC1C8 
[10] VT=2 @ 0x014BC228 "Zero"
[11] VT=0 @ 0x014BC3A8 321
[12] VT=1 @ 0x014BC568 32.100000
[13] VT=2 @ 0x014BC6D8 "Three,Two,One"
G-Var-Name: VT=3 @ 0x014BC798 LB=0 : UB=5 VN=main::b
G-Var-Value: 
[0] VT=2 @ 0x014BC7F8 "One"
[1] VT=0 @ 0x014BC8B8 1
[2] VT=2 @ 0x014BC968 "Two"
[3] VT=1 @ 0x014BCA28 0.200000
[4] VT=2 @ 0x014BCAE8 "Three"
[5] VT=2 @ 0x014BCB48 "*3*"
G-Var-Name: VT=3 @ 0x014BCBA8 LB=0 : UB=1 VN=main::c
G-Var-Value: 
[0] VT=2 @ 0x014BCC08 "JRS"
LB=1 : UB=3 VN=[1]
[1] VT=3 @ 0x014BCCC8 
[1] VT=0 @ 0x014BCD88 1
[2] VT=1 @ 0x014BCEA8 0.200000
[3] VT=2 @ 0x014BD5C8 "*3*"
Line: 22
-> ?s
Value: "JRS"
Line: 22
-> ?b
Value: 
[0] VT=2 @ 0x014BC7F8 "One"
[1] VT=0 @ 0x014BC8B8 1
[2] VT=2 @ 0x014BC968 "Two"
[3] VT=1 @ 0x014BCA28 0.200000
[4] VT=2 @ 0x014BCAE8 "Three"
[5] VT=2 @ 0x014BCB48 "*3*"
Line: 22
-> r
Done
Debug session closed.
jrs@laptop:~/sb/sb22/sbt$

Navigation

[0] Message Index

Go to full version