There is a great deal of code in ARM's fault.c which is invoked from FAULT_DUMP(). This code is supposed to dump out fault information to the console and only that, but buried within it is code to actually handle the exception like clear sticky bits.
This is problematic:
- FAULT_DUMP() resolves to nothing if CONFIG_FAULT_DUMP is not set, since this code as documented is only supposed to dump info to the console
- There's no way to handle a specific exception without printing a bunch of stuff
- There's no way to return from an exception if the fault was expected instead of calling NanoFatalErrorHandler
- The code is calling SysFatalErrorHandler directly instead of NanoFatalErrorHandler like it should.
Open task: switch to _NanoFatalErrorHandler.
There needs to be a clean separation between handling the fault, and dumping information about it, and handling the fault should provide the opportunity to clean up and exit from the exception if the fault is non-fatal.