Author Topic: SB π  (Read 7562 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #165 on: April 17, 2019, 09:02:24 AM »
AIR,

I was able to connect with SDBG if I started the debugger in another terminal session. I'm wondering if the current SDBG being compiled is Peter's old Windows GUI version rather then my modified version for a console debugger under Linux. (and Windows)


pi@raspberrypi:~/sbrpi $ scriba dbgcon.sb
Application: sbdbg 1.0
Version: 1.0
Source-File-Count: 1
Source-File: testarray.sb
Line: 1
Line: 1
.
l 1-

.
r
Debug session closed.
pi@raspberrypi:~/sbrpi $



Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #166 on: April 17, 2019, 10:33:38 AM »
It looks like the SDBG extension module is Peter's old Windows GUI based version.

I found my old code and I'm going to try and compile that and see where I get.


Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #167 on: April 17, 2019, 01:11:57 PM »
I was able to get it working again. It doesn't seem to have the array variable display stuff I did so I may not have the latest version of it. At least it works.


jrs@jrs-laptop:~/sb/examples/test$ scriba dbgcon2.sb dbgcontest.sb
Application: ScriptBasic Remote Debugger
Version: 1.0
Source-File-Count: 1
Source-File: dbgcontest.sb
Current-Line: 1
-> h
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
Current-Line: 1
-> l 1-
 [0001] a = 1
 [0002] b = "ScriptBasic"
 [0003] PRINT a,"\n"
 [0004] PRINT b,"\n"
Current-Line: 1
-> s
Current-Line: 2
-> ? a
Value: 1
Current-Line: 2
-> b 4
Message: done
Current-Line: 2
-> r
1
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
-> r
ScriptBasic
Debug session closed.
jrs@jrs-laptop:~/sb/examples/test$


Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #168 on: April 17, 2019, 02:08:33 PM »
I finally got it running on the RPi Zero/


Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB π
« Reply #169 on: April 17, 2019, 03:44:46 PM »
If you were trying to run it in the same terminal, that could explain why it wouldn't respond.

BTW, installing the firewall might require you to open other ports that you might need when using scriba/sbhttpd.  All UFW does is allow you to specify which ports are accessible, it doesn't "enable" the port itself.  That's dependent on whichever program is communicating on those ports.

I use UFW/PF on my servers (for obvious reasons) but I rarely use them on my personal desktop class systems.

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #170 on: April 17, 2019, 03:56:55 PM »
I got it to work in the same terminal session with the EXECUTE but I get an OPEN error sometimes. If run it again it works. Maybe that won't happen if I start the program being debugged with SDBG in another terminal session. Now that I have SBT working, I might try running SDBG in a thread rather than use EXECUTE.

Just remark out the EXECUTE logic in dbgcon.sb and you can try the second session route.

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #171 on: April 17, 2019, 04:23:35 PM »
I don't get the OPEN error between runs if I run the debugger pre-processor (scriba -i sdbg dbgcontest.sb) in one session and (scriba dbgcon.sb) in anther terminal session. Works everytime.

Remove / REM the following code to run the debugger in two terminal sessions.

Code: Script BASIC
  1. cmdln = TRIM(COMMAND())                                
  2. IF cmdln = "" THEN                                      
  3.   PRINT "Usage: dbgcon [prog2debug]\n"                  
  4.   END                                                  
  5. END IF                                                  
  6. pidid = SYSTEM("/usr/local/bin/scriba -i sdbg " & cmdln)
  7.  

Session 1: scriba -i sdbg dbgcontest.sb

Session 2: scriba dbgcon.sb

« Last Edit: April 17, 2019, 04:37:09 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB π
« Reply #172 on: April 17, 2019, 04:49:16 PM »
I got it to work in the same terminal session with the EXECUTE but I get an OPEN error sometimes. If run it again it works. Maybe that won't happen if I start the program being debugged with SDBG in another terminal session. Now that I have SBT working, I might try running SDBG in a thread rather than use EXECUTE.

Just remark out the EXECUTE logic in dbgcon.sb and you can try the second session route.

I think EXECUTE doesn't block/wait, so maybe putting a SLEEP in there to give the process a chance to fully spin up might help.  You might have to do that even if you run it in a thread.

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #173 on: April 17, 2019, 04:53:47 PM »
Good point!

This makes everything simple and you don't have to edit/recompile your basic.conf file to get this to work.

dbgcontest.sb
Code: Script BASIC
  1. USE sdbg
  2. a = 1
  3. b = "ScriptBasic"
  4. PRINT a,"\n"
  5. PRINT b,"\n"
  6.  

Console 1
scriba dbgcontest.sb

Console 2
scriba dbgcon.sb

The benefit of using two consoles is that the output of the program is done in Console 1 which doesn't step on dbgcon.sb debugger session.

« Last Edit: April 17, 2019, 05:58:07 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #174 on: April 17, 2019, 06:20:38 PM »
I really need to find the version I spent so much time on that displays arrays and local variables if an array.

The workaround for this version is to add PRINT array variabe as a debug helper.
« Last Edit: April 17, 2019, 06:25:15 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #175 on: April 17, 2019, 07:08:33 PM »
I'm going to install sbhttpd on the ScripBasic.org site and have 2 version of the echo script. One normal and one with USE sdbg so SB users can see what debugging a web application is like remotely.

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #176 on: April 17, 2019, 09:14:24 PM »
This what its supose to look ike for arrays with the sdbg debugger I did.

https://www.scriptbasic.org/forum/index.php/topic,336.0.html

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #177 on: April 18, 2019, 10:05:21 AM »
I found my SDBG that displays arrays on my laptop of three generations back. I only have one other laptop older that I haven't turned on in years was my last resort. Glad I didn't have to go there.

I attached a copy of SDBG (runtime) for the Raspberry Pi Zero which runs on all the RPi boards.


jrs@jrs-laptop:~/sb/examples/test$ scriba dbgcon.sb
Application: ScriptBasic Remote Debugger
Version: 1.0
Source-File-Count: 1
Source-File: testarray.sb
Current-Line: 1
-> l 1-
 [0001] i = 1
 [0002] d = .99
 [0003] s = "JRS"
 [0004] a[0,0] = 0
 [0005] a[0,1] = 123
 [0006] a[0,2] = 1.23
 [0007] a[0,3] = "One,Two,Three"
 [0008] a[1,0] = "Zero"
 [0009] a[1,1] = 321
 [0010] a[1,2] = 32.1
 [0011] a[1,3] = "Three,Two,One"
 [0012] PRINT "Done\n"
Current-Line: 1
-> b12
Message: done
Current-Line: 1
-> r
Current-Line: 12
-> ?a
Value: 
LB=0 : UB=3 VN=[0]
[0] VT=3 @ 0xF50EA908 
[0] VT=0 @ 0xF50EA9C8 0
[1] VT=0 @ 0xF50EAB48 123
[2] VT=1 @ 0xF50EACC8 1.230000
[3] VT=2 @ 0xF50F7418 "One,Two,Three"
LB=0 : UB=3 VN=[1]
[1] VT=3 @ 0xF50F7538 
[0] VT=2 @ 0xF50F7598 "Zero"
[1] VT=0 @ 0xF50F7718 321
[2] VT=1 @ 0xF50F7898 32.100000
[3] VT=2 @ 0xF50F34B8 "Three,Two,One"
Current-Line: 12
-> G
Global-Variable-Name: main::i
Global-Variable-Value: 1
Global-Variable-Name: main::d
Global-Variable-Value: 0.990000
Global-Variable-Name: main::s
Global-Variable-Value: "JRS"
Global-Variable-Name: main::a
Global-Variable-Value: 
LB=0 : UB=3 VN=[0]
[0] VT=3 @ 0xF50EA908 
[0] VT=0 @ 0xF50EA9C8 0
[1] VT=0 @ 0xF50EAB48 123
[2] VT=1 @ 0xF50EACC8 1.230000
[3] VT=2 @ 0xF50F7418 "One,Two,Three"
LB=0 : UB=3 VN=[1]
[1] VT=3 @ 0xF50F7538 
[0] VT=2 @ 0xF50F7598 "Zero"
[1] VT=0 @ 0xF50F7718 321
[2] VT=1 @ 0xF50F7898 32.100000
[3] VT=2 @ 0xF50F34B8 "Three,Two,One"
Current-Line: 12
-> s
Debug session closed.
jrs@jrs-laptop:~/sb/examples/test$


I've attached the source to the SBDG extension module which I would like to replace what is currently in the sandbox.
« Last Edit: April 18, 2019, 12:18:00 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB π
« Reply #178 on: April 18, 2019, 01:52:05 PM »
I was thinking of adding two new related debugger commands.

t = Trace On. The source code line text would display after the current line number display.

T = Trace Off. Work like it does now.

Trace Off would be the default startup mode.

I was also thinking of adding a few ESC sequences (or use the ncurses ext. module) to add color to the debugger output.

Your thoughts?
« Last Edit: April 18, 2019, 01:59:15 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB π
« Reply #179 on: April 18, 2019, 03:59:54 PM »
I've attached the source to the SBDG extension module which I would like to replace what is currently in the sandbox.

Go for it, just push a commit to the cleanup branch.