ScriptBasic

Extension Modules => Extension Modules => DBG => Topic started by: Support on December 08, 2012, 11:14:00 PM

Title: SDBG (Remote Socket Debugger)
Post by: Support on December 08, 2012, 11:14:00 PM
The debugger support for ScriptBasic has been pretty much Windows centric with the original DBG internal preprocessor debugger. It was dependent on the Windows console screen API which left Linux without a debugger. One of Peter Verhas's last projects was a socket version of DBG and using a GUI client written in C++. (still a Windows solution) The socket debugger allowed remote debugging of the ScriptBasic multi-threaded web server. I didn't get around to testing the new debugger internal preprocessor until a couple years after Peter moved on.

I recently fixed a couple bugs with SDBG and wrote a console mode client for it in ScriptBasic under Linux. (which will also work in Windows) Here is a list of debugging features which mirror the old DBG debugger which documentation exists on this board.



Note:



I will be releasing both Windows32 and Ubuntu64 versions of the SDBG remote ScriptBasic debugger. I will also setup a CGI or SBHTTPD server example page that you can debug with the included DBGCON(.exe) standalone debugger. (source withheld until final release)
Title: Re: SDBG (Remote Socket Debugger)
Post by: Support on December 12, 2012, 09:45:00 AM
Just an update on this.

I found the SDBG version of the debugger has a couple minor issues I still need to fix at the preprocessor shared object level. The remote client is done but needs to be tested on more complex scripts.

I'm having to deal with a series of critical family issues at the moment so I'm only working on this when I need a distraction. I'm not in any big hurry to get the 2.2 release out. I want all the enhancements since Peter's 2.1 release to be included in the next release. (IUP, Mini-XML/SBXML, SQLite3, Tom's new core language math functions, ...)



Title: Re: SDBG (Remote Socket Debugger)
Post by: Support on December 15, 2012, 11:18:54 AM
Peter Verhas was kind enough to help solve my G global variable display issue. I still have a bit of cleanup to do but hope to release a beta for Linux and Windows this weekend.

Note: Displaying array element values with the ? or G will not be available in this release. (not implemented in the original code) A temporary workaround is to PRINT the array elements your interested in to the console from the debugged running program.

Code: [Select]
USE sdbg
a = 1
b = "ScriptBasic"
PRINT a,"\n"
PRINT b,"\n"

Console 1
jrs@laptop:~/sb/test$ scriba dbgcontest.sb
1
ScriptBasic
jrs@laptop:~/sb/test$

Console 2
jrs@laptop:~/sb/test$ scriba dbgcon.sb
Application: ScriptBasic Remote Debug Console
Version: 1.0
Source-File-Count: 1
Source-File: dbgcontest.sb
Current-Line: 1
-> s
Current-Line: 2
-> s
Current-Line: 3
-> G
Global-Variable-Name: main::a
Global-Variable-Value: 1
Global-Variable-Name: main::b
Global-Variable-Value: "ScriptBasic"
Current-Line: 3
-> l -
 [0001] a = 1
 [0002] b = "ScriptBasic"
 [0003] PRINT a,"\n"
 [0004] PRINT b,"\n"
Current-Line: 3
-> s
Current-Line: 4
-> s
Debug session closed.
jrs@laptop:~/sb/test$
Title: Re: SDBG (Remote Socket Debugger)
Post by: Support on December 16, 2012, 07:00:46 PM
If you have the Ubuntu 64 version of ScriptBasic installed on your system, I have attached a beta version of the remote debugger to try. Comments welcome!

Place the sdbg.so in your SB modules directory and sdbg.bas in your SB include directory. The dbgcon.sb is the debugger client and the dbgcontest.sb is the test program being debugged. Start the test program in one console and the debugger client in another. I'll try and get a CGI test page going as an example of debugging a SB CGI program remotely.

Console 1
Code: [Select]
jrs@laptop:~/sb/test$ scriba dbgcontest.sb
1
ScriptBasic
jrs@laptop:~/sb/test$

Console 2
Code: [Select]
jrs@laptop:~/sb/test$ scriba dbgcon.sb
Application: ScriptBasic Remote Debugger
Version: 1.0
Source-File-Count: 1
Source-File: dbgcontest.sb
Current-Line: 2
-> l -
 [0001] REM DBGLISTEN 127.0.0.1:6666
 [0002] a = 1
 [0003] b = "ScriptBasic"
 [0004] PRINT a,"\n"
 [0005] PRINT b,"\n"
Current-Line: 2
-> s
Current-Line: 3
-> s
Current-Line: 4
-> G
Global-Variable-Name: main::a
Global-Variable-Value: 1
Global-Variable-Name: main::b
Global-Variable-Value: "ScriptBasic"
Current-Line: 4
-> ?a
Value: 1
Current-Line: 4
-> ?b
Value: "ScriptBasic"
Current-Line: 4
-> r
Debug session closed.
jrs@laptop:~/sb/test$

Note: The REM DGBLISTEN IP:PORT allows changing the default IP and port used by the debugger shared object. (currently hardcoded in dbgcon.sb)
Title: Re: SDBG (Remote Socket Debugger)
Post by: Support on December 20, 2012, 05:48:14 PM
I added to the dbgcon (client remote debugger) the ability to pass the IP and port if not using the default.

Code: [Select]
' ScriptBasic Remote Console Debugger

cmdln = TRIM(COMMAND())
IF cmdln = "" THEN
  ' Default IP:Port
  OPEN "127.0.0.1:6647" FOR SOCKET AS #1
ELSE
  OPEN cmdln FOR SOCKET AS #1
END IF

WHILE NOT EOF(1)
  LINE INPUT #1, dbgs
  IF dbgs = ".\r\n" THEN
    PRINT "-> "
    LINE INPUT dbgc
    PRINT #1, dbgc
    IF CHOMP(dbgc) = "q" THEN GOTO Done
  ELSE
    dbgcmd = CHOMP(dbgs)
' l - List Source   
    IF LEFT(dbgcmd,13) = "Break-Point: " THEN
      IF MID(dbgcmd,14,1) = "0" THEN
        PRINT " "
      ELSE
        PRINT "*"
      END IF
      GOTO IT
    END IF
    IF LEFT(dbgcmd,13) = "Line-Number: " THEN
      PRINT FORMAT("%~[0000] ~",VAL(MID(dbgcmd,14)))
      GOTO IT
    END IF
    IF LEFT(dbgcmd,6) = "Line: " THEN
      PRINT MID(dbgcmd,7),"\n"
      GOTO IT
    END IF
' Unprocessed out
    PRINT dbgs
  END IF
IT:
WEND

Done:
PRINT #1,"q\n"
PRINT "Debug session closed.\n"

jrs@laptop:~/sb/test$ scriba dbgcon.sb 127.0.0.1:6666
Application: ScriptBasic Remote Debugger
Version: 1.0
Source-File-Count: 1
Source-File: dbgcontest.sb
Current-Line: 2
-> l -
 [0001] REM DBGLISTEN 127.0.0.1:6666
 [0002] a = 1
 [0003] b = "ScriptBasic"
 [0004] PRINT a,"\n"
 [0005] PRINT b,"\n"
Current-Line: 2
->