' ScriptBasic Remote Console Debugger
cmdln = TRIM(COMMAND())
IF cmdln = "" THEN
PRINT "Usage: dbgcon [prog2debug]\n"
END
END IF
exitcode = EXECUTE("/usr/bin/scriba -i sdbg " & cmdln,-1,PID)
OPEN "127.0.0.1:6647" FOR SOCKET AS #1
WHILE NOT EOF(1)
LINE INPUT #1, dbgs
IF dbgs = ".\n" THEN
PRINT "-> "
LINE INPUT dbgc
IF LCASE(CHOMP(dbgc)) = "h" THEN
PRINT """h help
s step one line
S step one line, do not step into functions or subs
o step until getting out of the current function
(if you stepped into but changed your mind)
? var print the value of a variable
u step one level up in the stack
d step one level down in the stack (for variable printing)
D step down in the stack to current execution depth
G list all global variables
L list all local variables
l [n-m] list the source lines
r [n] run to line n
R [n] run to line n but do not stop in recursive function call
b [n] set breakpoint on the line n or the current line
B [n-m] remove breakpoints from lines
q 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 IF
IT:
WEND
Done:
PRINT #1,"q"
CLOSE(1)
PRINT "Debug session closed.\n"
END