ZackAttack #1 Posted March 31, 2015 (edited) 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 March 31, 2015 by ZackAttack 1 Quote Share this post Link to post Share on other sites
+Random Terrain #2 Posted March 31, 2015 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? Quote Share this post Link to post Share on other sites
ZackAttack #3 Posted April 1, 2015 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. 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. 1 Quote Share this post Link to post Share on other sites
+Atarius Maximus #4 Posted April 6, 2015 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. Quote Share this post Link to post Share on other sites
ZackAttack #5 Posted April 10, 2015 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? Quote Share this post Link to post Share on other sites
+Atarius Maximus #6 Posted April 18, 2015 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. Quote Share this post Link to post Share on other sites
+Gemintronic #7 Posted April 18, 2015 The most critical must have feature would be viewing of variable values in realtime. Debugging with the score has always been HIGHLY imperfect. Quote Share this post Link to post Share on other sites
ZackAttack #8 Posted April 18, 2015 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. 1 Quote Share this post Link to post Share on other sites
+Random Terrain #9 Posted June 15, 2018 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. Quote Share this post Link to post Share on other sites
ZackAttack #10 Posted June 15, 2018 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. Quote Share this post Link to post Share on other sites
+Random Terrain #11 Posted June 15, 2018 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: Quote Share this post Link to post Share on other sites
ZackAttack #12 Posted June 15, 2018 Did you try moving those files and changing the extension? You should be able to get the batch file to do it for you. Quote Share this post Link to post Share on other sites
+Random Terrain #13 Posted June 15, 2018 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. Quote Share this post Link to post Share on other sites
ZackAttack #14 Posted June 16, 2018 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: Open %bb% in file explorer. (win + r) Copy 2600bas.bat so you can revert the change if needed. Edit 2600bas.bat with notepad. 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 2 Quote Share this post Link to post Share on other sites
+Random Terrain #15 Posted June 16, 2018 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. Quote Share this post Link to post Share on other sites
ZackAttack #16 Posted June 16, 2018 "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. 1 Quote Share this post Link to post Share on other sites
+Karl G #17 Posted June 16, 2018 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. Quote Share this post Link to post Share on other sites
ultima #18 Posted June 16, 2018 Thanks for that batch file it's very useful. It's good to see what is going on under the hood. Quote Share this post Link to post Share on other sites
Mr SQL #19 Posted June 18, 2018 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). Quote Share this post Link to post Share on other sites