Author Topic: SDBG (Remote Socket Debugger)  (Read 30142 times)

Support

  • Administrator
  • *****
  • Posts: 19
    • View Profile
SDBG (Remote Socket Debugger)
« 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.

  • h help
  • s step one line, or just press return on the 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


Note:

  • This is not an IDE but a console mode remote debugger.
  • You can only display the executing scripts source, not change it.
  • You can view the state of global and local variables but not alter them.
  • If you set up the SB conf file for SDBG, you only need to insert USE SDBG in your source to use the debugger console with it. (no matter where the program is actually running)


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)
« Last Edit: December 09, 2012, 11:55:56 AM by support »

Support

  • Administrator
  • *****
  • Posts: 19
    • View Profile
Re: SDBG (Remote Socket Debugger)
« Reply #1 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, ...)




Support

  • Administrator
  • *****
  • Posts: 19
    • View Profile
Re: SDBG (Remote Socket Debugger)
« Reply #2 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$
« Last Edit: December 15, 2012, 04:33:34 PM by support »

Support

  • Administrator
  • *****
  • Posts: 19
    • View Profile
Re: SDBG (Remote Socket Debugger)
« Reply #3 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)
« Last Edit: December 16, 2012, 09:46:55 PM by support »

Support

  • Administrator
  • *****
  • Posts: 19
    • View Profile
Re: SDBG (Remote Socket Debugger)
« Reply #4 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
->