[Project64] Add Logging on un handled exception

This commit is contained in:
zilmar 2016-12-24 07:51:52 +11:00
parent 1c61eb68db
commit 267d19a93b
6 changed files with 37 additions and 1 deletions

View File

@ -60,6 +60,9 @@ class AndroidLogger : public CTraceModule
default: __android_log_print(ANDROID_LOG_UNKNOWN, TraceModule(module), "%05d: %s: %s",CThread::GetCurrentThreadId(),function,Message); break; default: __android_log_print(ANDROID_LOG_UNKNOWN, TraceModule(module), "%05d: %s: %s",CThread::GetCurrentThreadId(),function,Message); break;
} }
} }
void FlushTrace(void)
{
}
}; };
AndroidLogger * g_Logger = NULL; AndroidLogger * g_Logger = NULL;
static pthread_key_t g_ThreadKey; static pthread_key_t g_ThreadKey;

View File

@ -32,6 +32,9 @@ class AndroidLogger : public CTraceModule
default: __android_log_print(ANDROID_LOG_UNKNOWN, TraceModule(module), "%s: %s", function, Message); break; default: __android_log_print(ANDROID_LOG_UNKNOWN, TraceModule(module), "%s: %s", function, Message); break;
} }
} }
void FlushTrace(void)
{
}
}; };
static AndroidLogger * g_AndroidLogger = NULL; static AndroidLogger * g_AndroidLogger = NULL;
#endif #endif

View File

@ -28,6 +28,7 @@ public:
CTraceModule * AddTraceModule(CTraceModule * TraceModule); CTraceModule * AddTraceModule(CTraceModule * TraceModule);
CTraceModule * RemoveTraceModule(CTraceModule * TraceModule); CTraceModule * RemoveTraceModule(CTraceModule * TraceModule);
void CloseTrace(void); void CloseTrace(void);
void FlushTrace(void);
}; };
CTraceLog & GetTraceObjet(void) CTraceLog & GetTraceObjet(void)
@ -56,6 +57,11 @@ void WriteTraceFull(uint32_t module, uint8_t severity, const char * file, int li
va_end(args); va_end(args);
} }
void TraceFlushLog(void)
{
GetTraceObjet().FlushTrace();
}
void CloseTrace(void) void CloseTrace(void)
{ {
g_TraceClosed = true; g_TraceClosed = true;
@ -118,6 +124,16 @@ void CTraceLog::CloseTrace(void)
m_Modules.clear(); m_Modules.clear();
} }
void CTraceLog::FlushTrace(void)
{
CGuard Guard(m_CS);
for (uint32_t i = 0, n = m_Modules.size(); i < n; i++)
{
m_Modules[i]->FlushTrace();
}
}
void CTraceLog::TraceMessage(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message) void CTraceLog::TraceMessage(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message)
{ {
CGuard Guard(m_CS); CGuard Guard(m_CS);
@ -230,7 +246,13 @@ void CTraceFileLog::Write(uint32_t module, uint8_t severity, const char * /*file
} }
} }
void CTraceFileLog::FlushTrace(void)
{
m_hLogFile.Flush();
}
void CTraceFileLog::SetFlushFile(bool bFlushFile) void CTraceFileLog::SetFlushFile(bool bFlushFile)
{ {
m_FlushFile = bFlushFile; m_FlushFile = bFlushFile;
FlushTrace();
} }

View File

@ -20,6 +20,7 @@ enum TraceSeverity
__interface CTraceModule __interface CTraceModule
{ {
virtual void Write(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message) = 0; virtual void Write(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message) = 0;
virtual void FlushTrace() = 0;
}; };
class CTraceFileLog : public CTraceModule class CTraceFileLog : public CTraceModule
@ -30,6 +31,7 @@ public:
void SetFlushFile(bool bFlushFile); void SetFlushFile(bool bFlushFile);
void Write(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message); void Write(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message);
void FlushTrace (void);
private: private:
CLog m_hLogFile; CLog m_hLogFile;
@ -50,6 +52,7 @@ void TraceSetModuleName(uint8_t module, const char * Name);
void CloseTrace(void); void CloseTrace(void);
void WriteTraceFull(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char *format, ...); void WriteTraceFull(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char *format, ...);
void TraceFlushLog(void);
void TraceSetMaxModule(uint32_t MaxModule, uint8_t DefaultSeverity); void TraceSetMaxModule(uint32_t MaxModule, uint8_t DefaultSeverity);
extern uint32_t * g_ModuleLogLevel; extern uint32_t * g_ModuleLogLevel;

View File

@ -25,6 +25,10 @@ class AndroidLogger : public CTraceModule
default: __android_log_print(ANDROID_LOG_UNKNOWN, TraceModule(module), "%s: %s", function, Message); break; default: __android_log_print(ANDROID_LOG_UNKNOWN, TraceModule(module), "%s: %s", function, Message); break;
} }
} }
void FlushTrace(void)
{
}
}; };
static AndroidLogger * g_AndroidLogger = NULL; static AndroidLogger * g_AndroidLogger = NULL;
#endif #endif

View File

@ -427,6 +427,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context
WriteTrace(TraceExceptionHandler, TraceError, "OpCode32->uint32.rt: %X",OpCode32->uint32.rt); WriteTrace(TraceExceptionHandler, TraceError, "OpCode32->uint32.rt: %X",OpCode32->uint32.rt);
WriteTrace(TraceExceptionHandler, TraceError, "OpCode32->uint32.opcode2: %X",OpCode32->uint32.opcode2); WriteTrace(TraceExceptionHandler, TraceError, "OpCode32->uint32.opcode2: %X",OpCode32->uint32.opcode2);
WriteTrace(TraceExceptionHandler, TraceError, "OpCode32->uint32.rm: %X",OpCode32->uint32.rm); WriteTrace(TraceExceptionHandler, TraceError, "OpCode32->uint32.rm: %X",OpCode32->uint32.rm);
TraceFlushLog();
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
return false; return false;
} }