mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-11 07:26:08 +01:00
thermosphere: better self-debug fault reporting
This commit is contained in:
parent
0b7efc0501
commit
b0ae19a6f9
@ -26,6 +26,7 @@
|
|||||||
#include "spinlock.h"
|
#include "spinlock.h"
|
||||||
#include "debug_manager.h"
|
#include "debug_manager.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
#include "memory_map.h"
|
||||||
|
|
||||||
#include "fpu.h"
|
#include "fpu.h"
|
||||||
|
|
||||||
@ -56,6 +57,8 @@ bool spsrEvaluateConditionCode(u64 spsr, u32 conditionCode)
|
|||||||
void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
|
void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
uintptr_t stackTop = memoryMapGetStackTop(currentCoreCtx->coreId);
|
||||||
|
|
||||||
for (u32 i = 0; i < 30; i += 2) {
|
for (u32 i = 0; i < 30; i += 2) {
|
||||||
DEBUG("x%u\t\t%016llx\t\tx%u\t\t%016llx\n", i, frame->x[i], i + 1, frame->x[i + 1]);
|
DEBUG("x%u\t\t%016llx\t\tx%u\t\t%016llx\n", i, frame->x[i], i + 1, frame->x[i + 1]);
|
||||||
}
|
}
|
||||||
@ -74,15 +77,18 @@ void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
|
|||||||
if (frame == currentCoreCtx->guestFrame) {
|
if (frame == currentCoreCtx->guestFrame) {
|
||||||
DEBUG("cntp_ctl_el0\t%016llx\n", frame->cntp_ctl_el0);
|
DEBUG("cntp_ctl_el0\t%016llx\n", frame->cntp_ctl_el0);
|
||||||
DEBUG("cntv_ctl_el0\t%016llx\n", frame->cntv_ctl_el0);
|
DEBUG("cntv_ctl_el0\t%016llx\n", frame->cntv_ctl_el0);
|
||||||
}/* else {
|
} else if ((frame->sp_el2 & ~0xFFFul) + 0x1000 == stackTop) {
|
||||||
// Try to dump the stack (comment if this crashes)
|
// Try to dump the stack (comment if this crashes)
|
||||||
u64 *sp = (u64 *)(frame->sp_el2 - 8);
|
u64 *sp = (u64 *)frame->sp_el2;
|
||||||
u64 *spEnd = (u64 *)((frame->sp_el2 & ~0xFFF) + 0x1000);
|
u64 *spEnd = sp + 0x20;
|
||||||
|
u64 *spMax = (u64 *)((frame->sp_el2 + 0xFFF) & ~0xFFFul);
|
||||||
DEBUG("Stack trace:\n");
|
DEBUG("Stack trace:\n");
|
||||||
while (sp < spEnd) {
|
while (sp < spEnd && sp < spMax) {
|
||||||
DEBUG("\t%016lx\n", *--sp);
|
DEBUG("\t%016lx\n", *sp++);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DEBUG("Stack overflow/double fault detected!\n");
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
#else
|
#else
|
||||||
(void)frame;
|
(void)frame;
|
||||||
(void)sameEl;
|
(void)sameEl;
|
||||||
|
@ -60,5 +60,7 @@ typedef struct LoadImageLayout {
|
|||||||
|
|
||||||
extern LoadImageLayout g_loadImageLayout;
|
extern LoadImageLayout g_loadImageLayout;
|
||||||
|
|
||||||
|
uintptr_t memoryMapGetStackTop(u32 coreId);
|
||||||
|
|
||||||
// Non-reentrant
|
// Non-reentrant
|
||||||
uintptr_t memoryMapPlatformMmio(uintptr_t pa, size_t size);
|
uintptr_t memoryMapPlatformMmio(uintptr_t pa, size_t size);
|
||||||
|
Loading…
Reference in New Issue
Block a user