Jump to content

Photo

Poll to see if improving stella debugging for bB is worth it


18 replies to this topic

Poll: bB debugging (9 member(s) have cast votes)

Do you use the stella debugger during bB development?

  1. Yes (7 votes [77.78%] - View)

    Percentage of vote: 77.78%

  2. No (2 votes [22.22%] - View)

    Percentage of vote: 22.22%

Would displaying bB labels in disassembly window be helpful?

  1. Yes (8 votes [88.89%] - View)

    Percentage of vote: 88.89%

  2. No (1 votes [11.11%] - View)

    Percentage of vote: 11.11%

Vote Guests cannot vote

#1 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • 715 posts
  • Location:Orlando, FL US

Posted Mon Mar 30, 2015 9:04 PM

I'm trying to gauge how much the stella debugging facilities are used by bB. If it's worth it, I will try to add out of the box support for resolving label addresses inside of the stella debugger for bB and VbB projects. This would make setting breakpoints and reading the disassembly easier.


Edited by ZackAttack, Mon Mar 30, 2015 9:06 PM.


#2 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,689 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Mon Mar 30, 2015 10:15 PM

So far I've only used the Stella debugger to make a batari Basic program stop if it goes over 262 and to look at the sound effects of classic games.

 

Is there more that I could be doing?



#3 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • Topic Starter
  • 715 posts
  • Location:Orlando, FL US

Posted Tue Mar 31, 2015 9:08 PM

So far I've only used the Stella debugger to make a batari Basic program stop if it goes over 262 and to look at the sound effects of classic games.

 

Is there more that I could be doing?

The stella debugger offers a lot of cool features to track down the hard to find bugs. You can set breakpoints for execution, writes, and reads at specific locations. You can inspect the current values of variables. It allows you to trace through each instruction as it's executed and will highlight the registers and memory locations that changed in red. When the proper lst and sym files are provided, stella will use friendly names instead of hex values to represent labels in the disassembly and memory sections. I modified my 2600bas.bat to create the files correctly for visual bB and was able to break on labels from the bas source file as well as see the variable names in the disassembly and memory label section. In the screen shot below you can easily see that the Velocity variable has a value of 1 and execution is at the .ChangeDirection label.

stella_debug.png

If anyone is interested in making a similar change to their 2600bas.bat file you can change the dasm line to this:

dasm "%~f1.asm" -I"%bB%"/includes -f3 -l"%~p1\bin\%~n1%~x1.lst" -s"%~p1\bin\%~n1%~x1.sym" -o"%~f1.bin" | bbfilter

For regular bB (non-visual) I think all you would need to do is fix the lst and sym file extensions on that same line.



#4 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • 1,879 posts
  • 10 PRINT CHR$(205.5+RND(1));
  • Location:St. Louis, Missouri USA

Posted Sun Apr 5, 2015 9:00 PM

I'm trying to gauge how much the stella debugging facilities are used by bB. If it's worth it, I will try to add out of the box support for resolving label addresses inside of the stella debugger for bB and VbB projects. This would make setting breakpoints and reading the disassembly easier.

 

I haven't really used the Stella debugger all that much to be honest. After reading your comments I think it would be a really nice addition that many people would find useful as long as it was well documented how to use it.  I've spent hours of time troubleshooting in the past simply wondering what in the heck value a bB variable currently had, and setting specific breakpoints would be incredibly useful.  I would certainly use any integrated Stella bB debugging facilities in future projects.



#5 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • Topic Starter
  • 715 posts
  • Location:Orlando, FL US

Posted Thu Apr 9, 2015 7:09 PM

 

I haven't really used the Stella debugger all that much to be honest. After reading your comments I think it would be a really nice addition that many people would find useful as long as it was well documented how to use it.  I've spent hours of time troubleshooting in the past simply wondering what in the heck value a bB variable currently had, and setting specific breakpoints would be incredibly useful.  I would certainly use any integrated Stella bB debugging facilities in future projects.

There aren't any bB debugging features in stella. However, the asm debugging tools are fairly applicable since the bB source is mapped to assembly. Did you try the the modification to 2600bas.bat to see if you could get the symbols to load properly?



#6 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • 1,879 posts
  • 10 PRINT CHR$(205.5+RND(1));
  • Location:St. Louis, Missouri USA

Posted Fri Apr 17, 2015 11:07 PM

There aren't any bB debugging features in stella. However, the asm debugging tools are fairly applicable since the bB source is mapped to assembly. Did you try the the modification to 2600bas.bat to see if you could get the symbols to load properly?

 

I actually haven't done that at this point.  I will certainly reference this thread and try it out on for my next project.   Thank you for sharing, I look forward to using your tips as a troubleshooting tool in the future. :) :thumbsup:



#7 Gemintronic ONLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 8,955 posts

Posted Sat Apr 18, 2015 10:31 AM

The most critical must have feature would be viewing of variable values in realtime.  Debugging with the score has always been HIGHLY imperfect.



#8 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • Topic Starter
  • 715 posts
  • Location:Orlando, FL US

Posted Sat Apr 18, 2015 3:05 PM

The most critical must have feature would be viewing of variable values in realtime.  Debugging with the score has always been HIGHLY imperfect.

That can already be achieved in the stella debugger once the symbol files are properly loaded. Just hit ` to enter the debugger and all 128 bytes of RAM are displayed in a table. I'm not sure if the variables a-z always get put in the same location. That may change depending on the banking type. The test program I looked at started with a at #D6.

 

@RT maybe you could refine this info and start a "Debugging with stella" section in your documentation.



#9 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,689 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Thu Jun 14, 2018 11:03 PM

If anyone is interested in making a similar change to their 2600bas.bat file you can change the dasm line to this:
 

dasm "%~f1.asm" -I"%bB%"/includes -f3 -l"%~p1\bin\%~n1%~x1.lst" -s"%~p1\bin\%~n1%~x1.sym" -o"%~f1.bin" | bbfilter

 
I put that in my 2600bas.bat file, but I don't see any variable names in Stella. I must be doing something wrong.



#10 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • Topic Starter
  • 715 posts
  • Location:Orlando, FL US

Posted Thu Jun 14, 2018 11:40 PM

 
I put that in my 2600bas.bat file, but I don't see any variable names in Stella. I must be doing something wrong.

 

It's been a while, but if I remember correctly bB and vbB put the bin files in different locations. One of the two moves the bin file into a \bin folder. -l"%~p1\bin\%~n1%~x1.lst" would handle the scenario where the .bin file was moved to the \bin folder. If that's not the case then there is no need to add \bin\ to the path and that can simply become -l"%~f1.lst" and -s"%~f1.sym".

 

The important thing is that the .sym, .lst, and .bin files are all in the same place once the build is complete. Then stella will find the lst and sym files needed for labels in the debugger.

 

See this post for more details about what the %~?1 is doing.

 

In summary, try this instead:

dasm "%~f1.asm" -I"%bB%"/includes -f3 -l"%~f1.lst" -s"%~f1.sym" -o"%~f1.bin" | bbfilter

Please let us know if that works. I don't have bB or vbB installed on this computer so I'm unable to verify at the moment.



#11 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,689 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Thu Jun 14, 2018 11:50 PM

I create a new folder for every project and when I compile for the first time, a bin folder is created and the .bin file goes in that folder. The other files you mentioned are outside of that folder and they end with "symbol.txt" and "list.txt".

 

Here is what I see after compiling a program using VbB:

 

i_like_pizza.png



#12 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • Topic Starter
  • 715 posts
  • Location:Orlando, FL US

Posted Fri Jun 15, 2018 7:08 AM

Did you try moving those files and changing the extension? You should be able to get the batch file to do it for you.

#13 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,689 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Fri Jun 15, 2018 11:39 AM

Did you try moving those files and changing the extension? You should be able to get the batch file to do it for you.

 
I don't know the magical symbols to use to get it to do it for me.



#14 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • Topic Starter
  • 715 posts
  • Location:Orlando, FL US

Posted Fri Jun 15, 2018 8:38 PM

 
I don't know the magical symbols to use to get it to do it for me.

 

I installed vbb and played around with this some. I believe this will do the right thing for both bb and vbb. To test this do the following:

 

  1. Open %bb% in file explorer. (win + r)
  2. Copy 2600bas.bat so you can revert the change if needed.
  3. Edit 2600bas.bat with notepad.
  4. Replace the file with the following and save it.
@echo off


if X"%bB%" == X goto nobb
preprocess <"%~f1" | 2600basic.exe -i "%bB%" > bB.asm
if errorlevel 1 goto bBerror
if X%2 == X-O goto optimize
postprocess -i "%bB%" > "%~f1.asm"
goto nooptimize
:optimize
postprocess -i "%bB%" | optimize >"%~f1.asm"
:nooptimize

IF /I "%SESSIONNAME%"=="console" (
echo Detected bB
dasm "%~f1.asm" -I"%bB%"/includes -f3 -l"%~f1.lst" -s"%~f1.sym" -o"%~f1.bin" | bbfilter
) ELSE (
echo Detected vbB
mkdir "%~p1\bin"
dasm "%~f1.asm" -I"%bB%"/includes -f3 -l"%~p1\bin\%~n1%~x1.lst" -s"%~p1\bin\%~n1%~x1.sym" -o"%~f1.bin" | bbfilter
)

goto end

:nobb
echo bB environment variable not set.

:bBerror
echo Compilation failed.

:end



#15 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,689 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Fri Jun 15, 2018 9:27 PM

Thanks. I skipped step 1 and opened my "bB.1.1d.reveng40" folder the regular way, then followed the other steps. I can now see my variable aliases under the Stella disassembly tab.

 

When I click inside of the grid above the disassembly tab and move around using the arrow keys, I can see my variable aliases and their current values (among other things).

 

 

 

The next step is to learn how to do the things you mentioned before:

 

"You can set breakpoints for execution, writes, and reads at specific locations."

 

How do we do that?

 

 

 

This part seems to be talking about the grid I mentioned above:

 

"You can inspect the current values of variables. It allows you to trace through each instruction as it's executed and will highlight the registers and memory locations that changed in red."

 

When I click on the Frame +1 button or Ctrl + F, various spots in the grid turn red. I can click on those spots and some of them are my variable aliases. As I move from frame to frame, I can see the current values of my variables, like you mentioned.



#16 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • Topic Starter
  • 715 posts
  • Location:Orlando, FL US

Posted Fri Jun 15, 2018 10:09 PM

"You can set breakpoints for execution, writes, and reads at specific locations."
 
How do we do that?

To toggle an execution breakpoint
 
breakpoint <label>
 
To break when a variable is written to
trapwrite <label>
 
To break when a variable is read from
trapread <label>
 
Of course there is much more you can do, but that's the minimum any bB developer should know.

All of the bug fixes to 1.1d that I'm aware of have been added here. Hopefully at some point batari will roll this up into the official dist.

 
Regarding that batch file. Once it's been thoroughly verified it would be nice to push out a new bB update so everyone has proper symbols in stella.

#17 kdgarris OFFLINE  

kdgarris

    Moonsweeper

  • 336 posts

Posted Sat Jun 16, 2018 11:16 AM

That plus the shell script for Mac/Linux. I modified my own for that purpose, but it would be good if it's in the next release.

#18 ultima OFFLINE  

ultima

    Chopper Commander

  • 169 posts
  • Location:Yuma, AZ USA

Posted Sat Jun 16, 2018 1:05 PM

Thanks for that batch file it's very useful. It's good to see what is going on under the hood.



#19 Mr SQL OFFLINE  

Mr SQL

    Stargunner

  • 1,918 posts

Posted Mon Jun 18, 2018 11:43 AM

Cool idea. You should be able to parse the .asm to find the starting address for the label behind each line of the BASIC program - I'm pretty sure bB creates an internal label even when there is no line number just like Flashback BASIC.

 

 

vbb looks a lot like Visual BASIC already, would look even more like it if you display only the commented BASIC lines from the asm in the debug window and allow break points on any line so you could step through each line of code. Maybe add a mode step over or step into, where step into would allow you to step through the individual asm statements contained in the line (no easy way to tie those blocks to the BASIC statements so step into would be necessarily more technical). 






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users