Add LOG_FATAL

This commit is contained in:
Jeffrey Pfau 2014-01-29 22:44:40 -08:00
parent 70afe23fe4
commit 13d3146d0b
3 changed files with 13 additions and 11 deletions

View File

@ -50,7 +50,7 @@ void GBAMemoryInit(struct GBAMemory* memory) {
if (!memory->wram || !memory->iwram) { if (!memory->wram || !memory->iwram) {
GBAMemoryDeinit(memory); GBAMemoryDeinit(memory);
GBALog(memory->p, GBA_LOG_ERROR, "Could not map memory"); GBALog(memory->p, GBA_LOG_FATAL, "Could not map memory");
return; return;
} }
@ -125,10 +125,9 @@ static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t address) {
memory->activeMask = SIZE_CART0 - 1; memory->activeMask = SIZE_CART0 - 1;
break; break;
default: default:
GBALog(gbaMemory->p, GBA_LOG_ERROR, "Jumped to invalid address");
memory->activeRegion = 0; memory->activeRegion = 0;
memory->activeMask = 0; memory->activeMask = 0;
abort(); GBALog(gbaMemory->p, GBA_LOG_FATAL, "Jumped to invalid address");
break; break;
} }
} }

View File

@ -130,7 +130,7 @@ void GBAInit(struct GBA* gba) {
gba->rotationSource = 0; gba->rotationSource = 0;
gba->rumble = 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); gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
@ -521,7 +521,7 @@ void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...) {
return; return;
} }
if (gba && !(level & gba->logLevel)) { if (gba && !(level & gba->logLevel) && level != GBA_LOG_FATAL) {
return; return;
} }
@ -530,20 +530,22 @@ void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...) {
vprintf(format, args); vprintf(format, args);
va_end(args); va_end(args);
printf("\n"); printf("\n");
if (level == GBA_LOG_FATAL) {
abort();
}
} }
void GBAHitStub(struct ARMBoard* board, uint32_t opcode) { void GBAHitStub(struct ARMBoard* board, uint32_t opcode) {
struct GBABoard* gbaBoard = (struct GBABoard*) board; 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 #ifdef USE_DEBUGGER
if (!gbaBoard->p->debugger) { if (gbaBoard->p->debugger) {
abort(); level = GBA_LOG_STUB;
} else {
ARMDebuggerEnter(gbaBoard->p->debugger); ARMDebuggerEnter(gbaBoard->p->debugger);
} }
#else
abort();
#endif #endif
GBALog(gbaBoard->p, level, "Stub opcode: %08x", opcode);
} }
void GBAIllegal(struct ARMBoard* board, uint32_t opcode) { void GBAIllegal(struct ARMBoard* board, uint32_t opcode) {

View File

@ -39,6 +39,7 @@ enum GBALogLevel {
GBA_LOG_INFO = 0x04, GBA_LOG_INFO = 0x04,
GBA_LOG_WARN = 0x08, GBA_LOG_WARN = 0x08,
GBA_LOG_ERROR = 0x10, GBA_LOG_ERROR = 0x10,
GBA_LOG_FATAL = 0x20,
GBA_LOG_GAME_ERROR = 0x100 GBA_LOG_GAME_ERROR = 0x100
}; };