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> #include <stratosphere.hpp>
namespace ams::result {
extern bool CallFatalOnResultAssertion;
}
namespace ams::result::impl { namespace ams::result::impl {
NORETURN WEAK_SYMBOL void OnResultAbort(const char *file, int line, const char *func, const char *expr, Result result) { 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()); ::ams::diag::AbortImpl(file, line, func, expr, result.GetValue(), "Result Abort: %203d-%04d", result.GetModule(), result.GetDescription());
}
/* TODO: ams::fatal:: */
fatalThrow(result.GetValue());
AMS_INFINITE_LOOP(); AMS_INFINITE_LOOP();
__builtin_unreachable();
} }
NORETURN WEAK_SYMBOL void OnResultAbort(Result result) { 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) { 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()); ::ams::diag::AssertionFailureImpl(file, line, func, expr, result.GetValue(), "Result Assertion: %203d-%04d", result.GetModule(), result.GetDescription());
}
/* TODO: ams::fatal:: */
fatalThrow(result.GetValue());
AMS_INFINITE_LOOP(); AMS_INFINITE_LOOP();
__builtin_unreachable();
} }
NORETURN WEAK_SYMBOL void OnResultAssertion(Result result) { NORETURN WEAK_SYMBOL void OnResultAssertion(Result result) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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