all repos — mgba @ 13d3146d0bc5fe877207d7c9790b2ac3402fc56c

mGBA Game Boy Advance Emulator

Add LOG_FATAL
Jeffrey Pfau jeffrey@endrift.com
Wed, 29 Jan 2014 22:44:40 -0800
commit

13d3146d0bc5fe877207d7c9790b2ac3402fc56c

parent

70afe23fe4b7609ca85ee080b8dca255ff6d325a

3 files changed, 13 insertions(+), 11 deletions(-)

jump to
M src/gba/gba-memory.csrc/gba/gba-memory.c

@@ -50,7 +50,7 @@ memory->nextDMA = INT_MAX;

if (!memory->wram || !memory->iwram) { GBAMemoryDeinit(memory); - GBALog(memory->p, GBA_LOG_ERROR, "Could not map memory"); + GBALog(memory->p, GBA_LOG_FATAL, "Could not map memory"); return; }

@@ -125,10 +125,9 @@ memory->activeRegion = gbaMemory->rom;

memory->activeMask = SIZE_CART0 - 1; break; default: - GBALog(gbaMemory->p, GBA_LOG_ERROR, "Jumped to invalid address"); memory->activeRegion = 0; memory->activeMask = 0; - abort(); + GBALog(gbaMemory->p, GBA_LOG_FATAL, "Jumped to invalid address"); break; } }
M src/gba/gba.csrc/gba/gba.c

@@ -130,7 +130,7 @@ gba->keySource = 0;

gba->rotationSource = 0; gba->rumble = 0; - gba->logLevel = GBA_LOG_INFO | GBA_LOG_WARN | GBA_LOG_ERROR; + gba->logLevel = GBA_LOG_INFO | GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL; gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);

@@ -521,7 +521,7 @@ va_end(args);

return; } - if (gba && !(level & gba->logLevel)) { + if (gba && !(level & gba->logLevel) && level != GBA_LOG_FATAL) { return; }

@@ -530,20 +530,22 @@ va_start(args, format);

vprintf(format, args); va_end(args); printf("\n"); + + if (level == GBA_LOG_FATAL) { + abort(); + } } void GBAHitStub(struct ARMBoard* board, uint32_t opcode) { struct GBABoard* gbaBoard = (struct GBABoard*) board; - GBALog(gbaBoard->p, GBA_LOG_STUB, "Stub opcode: %08x", opcode); + enum GBALogLevel level = GBA_LOG_FATAL; #ifdef USE_DEBUGGER - if (!gbaBoard->p->debugger) { - abort(); - } else { + if (gbaBoard->p->debugger) { + level = GBA_LOG_STUB; ARMDebuggerEnter(gbaBoard->p->debugger); } -#else - abort(); #endif + GBALog(gbaBoard->p, level, "Stub opcode: %08x", opcode); } void GBAIllegal(struct ARMBoard* board, uint32_t opcode) {
M src/gba/gba.hsrc/gba/gba.h

@@ -39,6 +39,7 @@ GBA_LOG_DEBUG = 0x02,

GBA_LOG_INFO = 0x04, GBA_LOG_WARN = 0x08, GBA_LOG_ERROR = 0x10, + GBA_LOG_FATAL = 0x20, GBA_LOG_GAME_ERROR = 0x100 };