result: always prefer diag::Abort to fatal

This commit is contained in:
Michael Scire 2021-01-28 00:15:24 -08:00
parent 366c265ab2
commit 8d10584a51
17 changed files with 4 additions and 120 deletions

View file

@ -15,25 +15,12 @@
*/
#include <stratosphere.hpp>
namespace ams::result {
extern bool CallFatalOnResultAssertion;
}
namespace ams::result::impl {
NORETURN WEAK_SYMBOL void OnResultAbort(const char *file, int line, const char *func, const char *expr, Result result) {
/* Assert that we should call fatal on result assertion. */
/* If we shouldn't fatal, this will abort(); */
/* If we should, we'll continue onwards. */
if (!ams::result::CallFatalOnResultAssertion) {
::ams::diag::AbortImpl(file, line, func, expr, result.GetValue(), "Result Abort: %203d-%04d", result.GetModule(), result.GetDescription());
}
/* TODO: ams::fatal:: */
fatalThrow(result.GetValue());
::ams::diag::AbortImpl(file, line, func, expr, result.GetValue(), "Result Abort: %203d-%04d", result.GetModule(), result.GetDescription());
AMS_INFINITE_LOOP();
__builtin_unreachable();
}
NORETURN WEAK_SYMBOL void OnResultAbort(Result result) {
@ -41,16 +28,9 @@ namespace ams::result::impl {
}
NORETURN WEAK_SYMBOL void OnResultAssertion(const char *file, int line, const char *func, const char *expr, Result result) {
/* Assert that we should call fatal on result assertion. */
/* If we shouldn't fatal, this will assert(); */
/* If we should, we'll continue onwards. */
if (!ams::result::CallFatalOnResultAssertion) {
::ams::diag::AssertionFailureImpl(file, line, func, expr, result.GetValue(), "Result Assertion: %203d-%04d", result.GetModule(), result.GetDescription());
}
/* TODO: ams::fatal:: */
fatalThrow(result.GetValue());
::ams::diag::AssertionFailureImpl(file, line, func, expr, result.GetValue(), "Result Assertion: %203d-%04d", result.GetModule(), result.GetDescription());
AMS_INFINITE_LOOP();
__builtin_unreachable();
}
NORETURN WEAK_SYMBOL void OnResultAssertion(Result result) {

View file

@ -47,12 +47,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::AtmosphereProgramId::Mitm;
namespace result {
bool CallFatalOnResultAssertion = false;
}
/* Override. */
void ExceptionHandler(FatalErrorContext *ctx) {
/* We're bpc-mitm (or ams_mitm, anyway), so manually reboot to fatal error. */

View file

@ -63,12 +63,6 @@ namespace ams {
boot::RebootForFatalError(ctx);
}
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -43,12 +43,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Boot2;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -46,12 +46,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Creport;
namespace result {
bool CallFatalOnResultAssertion = true;
}
}
using namespace ams;

View file

@ -41,12 +41,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Dmnt;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -38,12 +38,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Eclct;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -43,12 +43,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Erpt;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -50,12 +50,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Fatal;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -39,12 +39,6 @@ extern "C" {
namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::JpegDec;
namespace result {
bool CallFatalOnResultAssertion = true;
}
}
using namespace ams;

View file

@ -45,12 +45,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Loader;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -43,12 +43,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Ncm;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -43,12 +43,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Pgl;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -48,12 +48,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Pm;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -40,12 +40,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Ro;
namespace result {
bool CallFatalOnResultAssertion = true;
}
}
using namespace ams;

View file

@ -47,12 +47,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Sm;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;

View file

@ -53,12 +53,6 @@ namespace ams {
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Spl;
namespace result {
bool CallFatalOnResultAssertion = false;
}
}
using namespace ams;