Merge branch 'master' of https://github.com/AuroraWright/Luma3DS
This commit is contained in:
commit
0790a3ceb3
@ -90,6 +90,13 @@ def makeRegisterLine(A, rA, B, rB):
|
||||
handledExceptionNames = ("FIQ", "undefined instruction", "prefetch abort", "data abort")
|
||||
registerNames = tuple("r{0}".format(i) for i in range(13)) + ("sp", "lr", "pc", "cpsr") + ("dfsr", "ifsr", "far") + ("fpexc", "fpinst", "fpinst2")
|
||||
svcBreakReasons = ("(svcBreak: panic)", "(svcBreak: assertion failed)", "(svcBreak: user-related)")
|
||||
faultStatusSources = {
|
||||
0b1:'Alignment', 0b100:'Instruction cache maintenance operation fault',
|
||||
0b1100:'External Abort on translation - First-level', 0b1110:'External Abort on translation - Second-level',
|
||||
0b101:'Translation - Section', 0b111:'Translation - Page', 0b11:'Access bit - Section', 0b110:'Access bit - Page',
|
||||
0b1001:'Domain - Section', 0b1011:'Domain - Page', 0b1101:'Permission - Section', 0b1111:'Permission - Page',
|
||||
0b1000:'Precise External Abort', 0b10110:'Imprecise External Abort', 0b10:'Debug event'
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Parse Luma3DS exception dumps")
|
||||
@ -146,13 +153,18 @@ if __name__ == "__main__":
|
||||
thumb = registers[16] & 0x20 != 0
|
||||
addr = registers[15] - codeDumpSize + (2 if thumb else 4)
|
||||
|
||||
xfsr = registers[18] if exceptionType == 2 else registers[17] if exceptionType == 3 else 0
|
||||
if xfsr != 0:
|
||||
print("\nFault Status Source: " + faultStatusSources[xfsr & 0xf])
|
||||
|
||||
print("\nCode dump:\n")
|
||||
|
||||
objdump_res = ""
|
||||
try:
|
||||
path = os.path.join(os.environ["DEVKITARM"], "bin", "arm-none-eabi-objdump")
|
||||
if os.name == "nt":
|
||||
path = ''.join((path[1], ':', path[2:])).replace('/', '\\')
|
||||
|
||||
if os.name == "nt" and path[0] == '/':
|
||||
path = ''.join((path[1], ':', path[2:]))
|
||||
|
||||
objdump_res = subprocess.check_output((
|
||||
path, "-marm", "-b", "binary",
|
||||
|
@ -69,8 +69,21 @@ void detectAndProcessExceptionDumps(void)
|
||||
*registerNames[] = {
|
||||
"R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12",
|
||||
"SP", "LR", "PC", "CPSR", "FPEXC"
|
||||
},
|
||||
*faultStatusNames[] = {
|
||||
"Alignment", "Instruction cache maintenance operation",
|
||||
"External Abort on translation - First-level", "External Abort on translation - Second-level",
|
||||
"Translation - Section", "Translation - Page", "Access bit - Section", "Access bit - Page",
|
||||
"Domain - Section", "Domain - Page", "Permission - Section", "Permission - Page",
|
||||
"Precise External Abort", "Imprecise External Abort", "Debug event"
|
||||
};
|
||||
|
||||
static const u32 faultStatusValues[] = {
|
||||
0b1, 0b100, 0b1100, 0b1110, 0b101, 0b111, 0b11, 0b110, 0b1001, 0b1011, 0b1101,
|
||||
0b1111, 0b1000, 0b10110, 0b10
|
||||
};
|
||||
|
||||
|
||||
initScreens();
|
||||
|
||||
drawString(true, 10, 10, COLOR_RED, "An exception occurred");
|
||||
@ -78,6 +91,17 @@ void detectAndProcessExceptionDumps(void)
|
||||
if(dumpHeader->processor == 11) posY = drawFormattedString(true, 10, 30, COLOR_WHITE, "Processor: ARM11 (core %u)", dumpHeader->core);
|
||||
else posY = drawString(true, 10, 30, COLOR_WHITE, "Processor: ARM9");
|
||||
|
||||
const char *faultStatusInfos = NULL;
|
||||
if (dumpHeader->type >= 2)
|
||||
{
|
||||
u32 xfsr = dumpHeader->type == 2 ? regs[18] : regs[17];
|
||||
xfsr &= 0xF;
|
||||
for (int i = 0; i < 15; i++)
|
||||
if (xfsr == faultStatusValues[i]){
|
||||
faultStatusInfos = faultStatusNames[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(dumpHeader->type == 2)
|
||||
{
|
||||
if((regs[16] & 0x20) == 0 && dumpHeader->codeDumpSize >= 4)
|
||||
@ -101,6 +125,7 @@ void detectAndProcessExceptionDumps(void)
|
||||
}
|
||||
else
|
||||
posY = drawFormattedString(true, 10, posY + SPACING_Y, COLOR_WHITE, "Exception type: %s", handledExceptionNames[dumpHeader->type]);
|
||||
if (faultStatusInfos != NULL) posY = drawFormattedString(true, 10, posY + SPACING_Y, COLOR_WHITE, "Fault status: %s", faultStatusInfos);
|
||||
|
||||
if(dumpHeader->processor == 11 && dumpHeader->additionalDataSize != 0)
|
||||
posY = drawFormattedString(true, 10, posY + SPACING_Y, COLOR_WHITE,
|
||||
@ -116,6 +141,8 @@ void detectAndProcessExceptionDumps(void)
|
||||
else if(dumpHeader->processor == 11)
|
||||
posY = drawFormattedString(true, 10 + 22 * SPACING_X, posY, COLOR_WHITE, "%-7s%08X", registerNames[i + 1], regs[20]);
|
||||
}
|
||||
if (dumpHeader->type == 3)
|
||||
posY = drawFormattedString(true, 10, posY + SPACING_Y, COLOR_WHITE, "%-7s%08X Access type: %s", "FAR", regs[19], regs[17] & (1u << 11) ? "Write":"Read");
|
||||
|
||||
posY += SPACING_Y;
|
||||
|
||||
|
@ -60,7 +60,7 @@ static void K_EnableMonitorModeDebugging(void)
|
||||
__asm__ __volatile__("cpsid aif");
|
||||
|
||||
u32 DSCR;
|
||||
__asm__ __volatile__("mrc p15, 0, %[val], c0, c1, 0" : [val] "=r" (DSCR));
|
||||
__asm__ __volatile__("mrc p14, 0, %[val], c0, c1, 0" : [val] "=r" (DSCR));
|
||||
DSCR |= 0x8000;
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 0" :: [val] "r" (DSCR));
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ void MiscellaneousMenu_SaveSettings(void)
|
||||
do
|
||||
{
|
||||
Draw_Lock();
|
||||
Draw_DrawString(10, 10, COLOR_TITLE, "Process patches menu");
|
||||
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
|
||||
if(R_SUCCEEDED(res))
|
||||
Draw_DrawString(10, 30, COLOR_WHITE, "Operation succeeded.");
|
||||
else
|
||||
|
Reference in New Issue
Block a user