-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Error Handler with backtrace and symbol support #377
Conversation
…code symbols The original SGDK's error handler is available via LEGACY_ERROR_HANDLER option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments explaining key changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far it's an important but perfectly well prepared and detailed PR 👍 Thanks a ton for it ! it's a terribly useful and great addition to SGDK which ease a lot debugging :)
The only change I would request if possible, is to include the sources of your neat convsym tool in the SGDK tools subfolder so people using others OS (unix mainly) can rebuild the tool from sources without searching for hours for it ;)
@Stephane-D Thanks a lot for reviewing it quickly and liking my debugger in the first place :) I made a few updates following your feedback:
One tiny thing: Codacy freaked out about about ConvSym's source code (mostly unusual Markdown syntax, haha), so I think it's better to add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stephane-D I also recommend rebuilding libmd on your machine just so builds are consistent. I'm not sure why libmd.a
is almost 1 MiB bigger now, but libmd_debug.a
is 18.7 KiB smaller :)
Thanks, that sounds perfect 👍 |
This PR aims to install a new error handler from the MD Debugger project to SGDK. The old error handler is still preserved for compatibility and is available by setting
LEGACY_ERROR_HANDLER
to1
inconfig.h
.It also enhances
symbol.txt
files by adding source-line information (file path and line number for every symbol, where applicable).Overview
bin\convsym.exe
utility.New error handler with "debug" profile
Backtrace in action
SGDK API changes
busErrorCB
,addressErrorCB
and other error callbacks as well asregisterState
and other global variables used by the old error handler;sys.c
(unlessLEGACY_ERROR_HANDLER
flag is set);boot/sega.s
to include the new error handler as a pre-compiled blob;bin/convsym.exe
utility version 2.12 (compiled from https://github.com/vladikcomper/md-modules/tree/master/utils/convsym) to convert symbols for the MD Debugger;makefile.gen
to add newinjectSymbolsInROM
target for "debug" build profile, so debug symbols are only injected in debug ROMs.convsym.exe
after building the ROM: it appends symbols to the end of the ROM and injects symbol data pointer at the offset ofMDDBG_SymbolDataPtr
variable defined insega.s
(barebones linking).symbol.txt
enhancement: modifymakefile.gen
to compile object files with-g
flag to include source-line information, invokenm
with-l
flag to dump this information.Error handler implementation details
convsym.exe
); format is optimized for fast searching (faster thanO(log n)
), symbol data is compressed;How to test
You can apply the following patch to
sample/game/sonic
(my favourite game):You should now see it crash when pressing Start. You should see crash offset as
joEvent+XXX
with "debug" build profile.Compatibility
boot/sega.s
.LEGACY_ERROR_HANDLER
is disabled.