vladikcomper
Member
- Messages
- 3
Let me introduce you one of the most feature-rich autonomous debuggers and error handlers for the Mega-Drive:
MD Debugger and Error Handler 2.6
MD Debugger and Error Handler (or simply "MD Debugger", also known as "The Advanced Error Handler and Debugger") is a ready-to-use error handler that comes with a powerful integrated debugger. It aims to provide robust and extensible debugging tools built-in directly into the Mega-Drive ROM, that can be used anywhere (from emulators to the real hardware).
Currently, it targets The AS Macroassembler and ASM68K assemblers. It has installation instructions and full support for the mainline Sonic disassemblies, but it can be integrated into any AS or ASM68K project (both the error handler and debugger) or even any pre-existing ROM (error handler only in a binary form).
Features
Installation instructions
Version 2.5 to 2.6 migration guide
If you were already using version 2.5, migration is as simple as upgrading your Debugger.asm and ErrorHandler.asm files from the bundle for your assembler and upgrading ConvSym utility. As usual, versions are 100% backwards-compatible.
Version 2.0 to 2.5 migration guide
If you were already using version 2.0, migration is really simple as the new version is 100% backwards compatible.
Guides
Source code
MD Debugger and Error Handler is fully open-source. The source code is available in this monorepo: https://github.com/vladikcomper/md-modules
Version History
2024-12-15: Version 2.6 released
2023-07-02: Version 2.5 released
2018-01-14: Version 2.0 released
2016-04-05: Version 1.0 released
MD Debugger and Error Handler 2.6
MD Debugger and Error Handler (or simply "MD Debugger", also known as "The Advanced Error Handler and Debugger") is a ready-to-use error handler that comes with a powerful integrated debugger. It aims to provide robust and extensible debugging tools built-in directly into the Mega-Drive ROM, that can be used anywhere (from emulators to the real hardware).
Currently, it targets The AS Macroassembler and ASM68K assemblers. It has installation instructions and full support for the mainline Sonic disassemblies, but it can be integrated into any AS or ASM68K project (both the error handler and debugger) or even any pre-existing ROM (error handler only in a binary form).
Features
- Debug symbol support.
- It can extract symbols from AS and ASM68K at build time and bundle them with the ROM;
- Debug symbols are efficiently compressed to save space and stored in custom database-like format; they are not visible as plain-text.
- Error dumps will display symbols from your source code instead of raw offsets, making debugging crashes times more easier;
- Backtrace support, caller guessing and more.
- Press the B button on the exception screen to display the backtrace and see the full call chain that led to the exception;
- Press the A button to display which symbols address registers point to;
- Generic exception screen displays a caller out-of-the box.
- Detailed and informative exceptions.
- Generic exception screen is as detailed and informative as possible;
- See exception location, caller address, all the main CPU registers, stack dump and more;
- Additional details can be displayed like VInt and HInt addresses (if dynamic) as well as USP and SR registers.
- Easily write your own debuggers with "high-level" macros.
- Write your own debug programs to display what you need;
- Use "high-level" macros that debugger environment provides, like Console.Write "My d0 is %<.w d0 hex>";
- Formatted string syntax in the debugger is extremely powerful: display any value from any memory location as: hexadecimal, decimal, binary, signed, unsigned, symbol or even a null-terminated ASCII string. Control output by modifying colors or adding line breaks.
- Throw custom exceptions and customize error handling.
- You can throw custom exceptions at any time using RaiseError macro;
- Use your own debug programs in exceptions if needed;
- Customize generic exception screen showing or hiding some less frequently used exception details;
- Map your debug programs to buttons on the exception screen.
- Assertions.
- Use one of the most powerful debugging techniques and take advantage of self-testing code!
- Assertions, widely adopted by many high-level languages, are provided by the debugger out-of-the box;
- Use assert pseudo-instruction that is only compiled in DEBUG builds. This means zero run-time cost for your final (RELEASE) builds to implement self-testing code.
- KDebug integration for logging, breakpoints and cycle-counting (experimental).
- Display formatted strings at any point straight in your emulator's debug console!
- Use a similar "high-level" macro interface as in console programs (KDebug.WriteLine instead of Console.WriteLine), but without interrupting your programs;
- Currently, the only emulators to support KDebug are Gens KMod and Blastem-nightly;
- Create manual breakpoints with KDebug.BreakPoint;
- Measure your code performance using KDebug.StartTimer and KDebug.EndTimer.
- Easy to install and extremely lightweight.
- Error handler blob is below 3 KiB, which is quite small for the number of features it provides; optional debugger extensions take a few hundreds of bytes each;
- It's quite easy to install, with installation instructions and ready configurations provided for the most mainline Sonic disassemblies.
Installation instructions
- Sonic 1 GitHub Disassembly (AS version)
- Sonic 1 GitHub Disassembly (ASM68K version)
- Sonic 1 Hivebrain 2005 Disassembly
- Sonic 1 Hivebrain 2022 Disassembly
- Sonic 2 GitHub Disassembly
Version 2.5 to 2.6 migration guide
If you were already using version 2.5, migration is as simple as upgrading your Debugger.asm and ErrorHandler.asm files from the bundle for your assembler and upgrading ConvSym utility. As usual, versions are 100% backwards-compatible.
- Download errorhandler-2.6.zip;
- Inside this archive, find the directory that matches your assembler (e.g. asm68k for ASM68K, as for the AS Macro Assembler);
- Replace Debugger.asm and ErrorHandler.asm files in your projects with ones from that directory;
- Download consym-2.12.1.zip, find executable for your platform (64-bit Windows or Linux) and replace one in your project.
Version 2.0 to 2.5 migration guide
If you were already using version 2.0, migration is really simple as the new version is 100% backwards compatible.
- Download the correct version for your project (errorhandler-as.7z or errorhandler-asm68k.7z).
- Replace the old files; remove ErrorHandler.bin from the old installation because it's now inlined into ErrorHandler.asm.
- Download and replace convsym utility for your platform:
- Everything should work already, but to support features like assertions and KDebug integration you need to modify your build system to generate DEBUG builds. Just find an installation guide for your disassembly and follow the "Install ConvSym to generate debug symbols" step.
Guides
- Powerful debugging techniques
- How-to add your details in exception headers
- Using KDebug integration
- Troubleshooting
Source code
MD Debugger and Error Handler is fully open-source. The source code is available in this monorepo: https://github.com/vladikcomper/md-modules
Version History
2024-12-15: Version 2.6 released
2023-07-02: Version 2.5 released
2018-01-14: Version 2.0 released
2016-04-05: Version 1.0 released