kern: print kernel backtrace on panic

This commit is contained in:
Michael Scire 2022-03-22 14:11:35 -07:00 committed by SciresM
parent a89c5dd5d7
commit 8ef6c49d30

View file

@ -94,13 +94,16 @@ namespace ams::kern {
/* Print the state. */
MESOSPHERE_RELEASE_LOG("Core[%d] Current State:\n", core_id);
/* Print registers and user backtrace. */
KDebug::PrintRegister();
KDebug::PrintBacktrace();
/* Print kernel state. */
#ifdef ATMOSPHERE_ARCH_ARM64
MESOSPHERE_RELEASE_LOG("Kernel Registers:\n");
for (size_t i = 0; i < 31; i++) {
MESOSPHERE_RELEASE_LOG(" X[%02zu] = %016lx\n", i, core_ctx->x[i]);
}
MESOSPHERE_RELEASE_LOG(" SP = %016lx\n", core_ctx->sp);
/* Print kernel backtrace. */
MESOSPHERE_RELEASE_LOG("Backtrace:\n");
MESOSPHERE_RELEASE_LOG("Kernel Backtrace:\n");
uintptr_t fp = core_ctx != nullptr ? core_ctx->x[29] : reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
for (size_t i = 0; i < 32 && fp && util::IsAligned(fp, 0x10) && cpu::GetPhysicalAddressWritable(nullptr, fp, true); i++) {
struct {
@ -112,6 +115,10 @@ namespace ams::kern {
}
#endif
/* Print registers and user backtrace. */
KDebug::PrintRegister();
KDebug::PrintBacktrace();
MESOSPHERE_RELEASE_LOG("\n");
/* Allow the next core to print. */