Sega Genesis Dev Kit (SGDK)
Moderator: Stef
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Hi Stef!
When running on Everdrive, the firmware already initializes RAM. That means that any unintentionally uninitialised variables in rom might be initialized by accident and subtle bugs not found until run as a real cart.
Would it be possible to have the SGDK set all the memory to a known debug value at start up before any code is run? Like a series of 0xdedbeef0xdeadbeef. That way it would be much easier to find variables with bad values.
Thanks!
DJCC
When running on Everdrive, the firmware already initializes RAM. That means that any unintentionally uninitialised variables in rom might be initialized by accident and subtle bugs not found until run as a real cart.
Would it be possible to have the SGDK set all the memory to a known debug value at start up before any code is run? Like a series of 0xdedbeef0xdeadbeef. That way it would be much easier to find variables with bad values.
Thanks!
DJCC
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
You can easily modify SGDK so it resets memory with a specific pattern, just replace line 83 of sega.s file :
by
sega.s is recompiled every time in your own project so you don't even need to recompile the whole library
Also i prefer to avoid doing that modification in the official version as it can lead to undesirable effect for people expecting SGDK to reset memory to 0.
For the watch variables, you have the 'debug' and 'debugall' target in the makefile but honestly support is not good enough yet in GensKMod++
You have also some watch support in GensKMod but i thing it's all manual (don't need any specific debug option in GCC).
Code: Select all
moveq #0,%d0
Code: Select all
move.l #0xDEADBEEF,%d0
Also i prefer to avoid doing that modification in the official version as it can lead to undesirable effect for people expecting SGDK to reset memory to 0.
For the watch variables, you have the 'debug' and 'debugall' target in the makefile but honestly support is not good enough yet in GensKMod++
You have also some watch support in GensKMod but i thing it's all manual (don't need any specific debug option in GCC).
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Thanks!
I remember seeing a thing where GensKMod would show the correct variable names in the watch window. You had to compile your project in a certain way to get a file out with the names and locations. And GensKMod would load it.Stef wrote: For the watch variables, you have the 'debug' and 'debugall' target in the makefile but honestly support is not good enough yet in GensKMod++
You have also some watch support in GensKMod but i thing it's all manual (don't need any specific debug option in GCC).
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Using the "debug" target you will obtain a rom.wch file, i guess KMod use it for variable watch but i think you specify which variable you want to watch directly for GensKMod then you can save watchs so it restore them automatically on next session. Honestly i never used this feature in KMod so i'm not sure about how use it but i guess Kaneda could help you there
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
SGDK use makefile to build project.
Are you using command line compilation or Code::blocks IDE ?
For command line compilation just use :
So it will choose the "debug" target instead of the default one.
In Code::Blocks you can define severals project build target, just create a debug one and modify the makefile "Build project/target" command by appending "debug" to the command line :
In the CB tutorial i just created a "default" project configuration which the default makefile setting (optimized) but usually we have "release" and "debug" configurations.
Are you using command line compilation or Code::blocks IDE ?
For command line compilation just use :
Code: Select all
make -f makefile.gen debug
In Code::Blocks you can define severals project build target, just create a debug one and modify the makefile "Build project/target" command by appending "debug" to the command line :
In the CB tutorial i just created a "default" project configuration which the default makefile setting (optimized) but usually we have "release" and "debug" configurations.
err... nobody read the help file, no ?Stef wrote:Using the "debug" target you will obtain a rom.wch file, i guess KMod use it for variable watch but i think you specify which variable you want to watch directly for GensKMod then you can save watchs so it restore them automatically on next session. Honestly i never used this feature in KMod so i'm not sure about how use it but i guess Kaneda could help you there
So...on GensKMod > Option > Debug, be sure to check "Auto load watchers & structures"
if you open a rom, it will search for <romname>.wch and will load it
Then, you'll be able to play with Cpu>Debug>Watcher
note that you could also include kdebug.h and get some trace output in Cpu>Debug > Messages
I found some times ago a better version of watchers and messages windows that my own (GensSomethingElse) if you're interested
EDIT : it's called Gens11svn304, google for it
Menu Tools > RAM Watch
Last edited by KanedaFr on Wed Feb 27, 2013 9:46 am, edited 2 times in total.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Version 0.94 released
Checkout the first page !
Checkout the first page !
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm