Jump to content
IGNORED

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


ZackAttack

bB debugging  

9 members have voted

  1. 1. Do you use the stella debugger during bB development?

  2. 2. Would displaying bB labels in disassembly window be helpful?


  • Please sign in to vote in this poll.

Recommended Posts

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
  • Like 1
Link to comment
Share on other sites

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.

post-40226-0-46703400-1427857543_thumb.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.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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?

Link to comment
Share on other sites

  • 2 weeks later...

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:

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

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.

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

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:

 

post-13-0-74819000-1529042582.png

Link to comment
Share on other sites

 

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

  • Like 2
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

"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.

  • Like 1
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...