diff --git a/stratosphere/fatal/source/fatal_task_screen.cpp b/stratosphere/fatal/source/fatal_task_screen.cpp index 4b79cd4ef..4acd3fdc6 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -264,66 +264,82 @@ Result ShowFatalTask::ShowFatal() { } /* Print Backtrace. */ - FontManager::SetPosition(backtrace_x, backtrace_y); + u32 bt_size; if (this->ctx->cpu_ctx.is_aarch32) { - FontManager::PrintFormatLine("Backtrace (Start Address = 0x%08x)", this->ctx->cpu_ctx.aarch32_ctx.start_address); - FontManager::AddSpacingLines(0.5f); - for (u32 i = 0; i < Aarch32CpuContext::MaxStackTraceDepth / 2; i++) { - u32 bt_cur = 0, bt_next = 0; - if (i < this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size) { - bt_cur = this->ctx->cpu_ctx.aarch32_ctx.stack_trace[i]; - } - if (i + Aarch32CpuContext::MaxStackTraceDepth / 2 < this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size) { - bt_next = this->ctx->cpu_ctx.aarch32_ctx.stack_trace[i + Aarch32CpuContext::MaxStackTraceDepth / 2]; - } - - if (i < this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size) { - u32 x = FontManager::GetX(); - FontManager::PrintFormat("BT[%02X]: ", i); - FontManager::SetPosition(x + 76, FontManager::GetY()); - FontManager::PrintFormat("0x%08x ", bt_cur); - } - - if (i + Aarch32CpuContext::MaxStackTraceDepth / 2 < this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size) { - u32 x = FontManager::GetX(); - FontManager::PrintFormat("BT[%02X]: ", i + Aarch32CpuContext::MaxStackTraceDepth / 2); - FontManager::SetPosition(x + 76, FontManager::GetY()); - FontManager::PrintFormat("0x%08x ", bt_next); - } - - FontManager::PrintLine(""); - FontManager::SetPosition(backtrace_x, FontManager::GetY()); + bt_size = this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size; + } else { + bt_size = this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size; + } + + if (bt_size == 0) { + if (this->ctx->cpu_ctx.is_aarch32) { + FontManager::PrintFormatLine("Start Address: 0x%08x", this->ctx->cpu_ctx.aarch32_ctx.start_address); + } else { + FontManager::PrintFormatLine("Start Address: 0x%016lx", this->ctx->cpu_ctx.aarch64_ctx.start_address); } - } else { - FontManager::PrintFormatLine("Backtrace (Start Address = 0x%016lx)", this->ctx->cpu_ctx.aarch64_ctx.start_address); - FontManager::AddSpacingLines(0.5f); - for (u32 i = 0; i < Aarch64CpuContext::MaxStackTraceDepth / 2; i++) { - u64 bt_cur = 0, bt_next = 0; - if (i < this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size) { - bt_cur = this->ctx->cpu_ctx.aarch64_ctx.stack_trace[i]; + } else { + FontManager::SetPosition(backtrace_x, backtrace_y); + if (this->ctx->cpu_ctx.is_aarch32) { + FontManager::PrintFormatLine("Backtrace (Start Address = 0x%08x)", this->ctx->cpu_ctx.aarch32_ctx.start_address); + FontManager::AddSpacingLines(0.5f); + for (u32 i = 0; i < Aarch32CpuContext::MaxStackTraceDepth / 2; i++) { + u32 bt_cur = 0, bt_next = 0; + if (i < this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size) { + bt_cur = this->ctx->cpu_ctx.aarch32_ctx.stack_trace[i]; + } + if (i + Aarch32CpuContext::MaxStackTraceDepth / 2 < this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size) { + bt_next = this->ctx->cpu_ctx.aarch32_ctx.stack_trace[i + Aarch32CpuContext::MaxStackTraceDepth / 2]; + } + + if (i < this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size) { + u32 x = FontManager::GetX(); + FontManager::PrintFormat("BT[%02X]: ", i); + FontManager::SetPosition(x + 76, FontManager::GetY()); + FontManager::PrintFormat("0x%08x ", bt_cur); + } + + if (i + Aarch32CpuContext::MaxStackTraceDepth / 2 < this->ctx->cpu_ctx.aarch32_ctx.stack_trace_size) { + u32 x = FontManager::GetX(); + FontManager::PrintFormat("BT[%02X]: ", i + Aarch32CpuContext::MaxStackTraceDepth / 2); + FontManager::SetPosition(x + 76, FontManager::GetY()); + FontManager::PrintFormat("0x%08x ", bt_next); + } + + FontManager::PrintLine(""); + FontManager::SetPosition(backtrace_x, FontManager::GetY()); } - if (i + Aarch64CpuContext::MaxStackTraceDepth / 2 < this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size) { - bt_next = this->ctx->cpu_ctx.aarch64_ctx.stack_trace[i + Aarch64CpuContext::MaxStackTraceDepth / 2]; + } else { + FontManager::PrintFormatLine("Backtrace (Start Address = 0x%016lx)", this->ctx->cpu_ctx.aarch64_ctx.start_address); + FontManager::AddSpacingLines(0.5f); + for (u32 i = 0; i < Aarch64CpuContext::MaxStackTraceDepth / 2; i++) { + u64 bt_cur = 0, bt_next = 0; + if (i < this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size) { + bt_cur = this->ctx->cpu_ctx.aarch64_ctx.stack_trace[i]; + } + if (i + Aarch64CpuContext::MaxStackTraceDepth / 2 < this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size) { + bt_next = this->ctx->cpu_ctx.aarch64_ctx.stack_trace[i + Aarch64CpuContext::MaxStackTraceDepth / 2]; + } + + if (i < this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size) { + u32 x = FontManager::GetX(); + FontManager::PrintFormat("BT[%02X]: ", i); + FontManager::SetPosition(x + 76, FontManager::GetY()); + FontManager::PrintFormat("0x%016lx ", bt_cur); + } + + if (i + Aarch64CpuContext::MaxStackTraceDepth / 2 < this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size) { + u32 x = FontManager::GetX(); + FontManager::PrintFormat("BT[%02X]: ", i + Aarch64CpuContext::MaxStackTraceDepth / 2); + FontManager::SetPosition(x + 76, FontManager::GetY()); + FontManager::PrintFormat("0x%016lx ", bt_next); + } + + FontManager::PrintLine(""); + FontManager::SetPosition(backtrace_x, FontManager::GetY()); } - - if (i < this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size) { - u32 x = FontManager::GetX(); - FontManager::PrintFormat("BT[%02X]: ", i); - FontManager::SetPosition(x + 76, FontManager::GetY()); - FontManager::PrintFormat("0x%016lx ", bt_cur); - } - - if (i + Aarch64CpuContext::MaxStackTraceDepth / 2 < this->ctx->cpu_ctx.aarch64_ctx.stack_trace_size) { - u32 x = FontManager::GetX(); - FontManager::PrintFormat("BT[%02X]: ", i + Aarch64CpuContext::MaxStackTraceDepth / 2); - FontManager::SetPosition(x + 76, FontManager::GetY()); - FontManager::PrintFormat("0x%016lx ", bt_next); - } - - FontManager::PrintLine(""); - FontManager::SetPosition(backtrace_x, FontManager::GetY()); } - } + } + /* Enqueue the buffer. */ framebufferEnd(&fb);