port: don't use the existing log system in crashlog in case it crashes

This commit is contained in:
fgsfds committed 2024-01-07 17:07:12 +01:00
1 parent ba52580e0c
commit 8645d0a82a
3 files changed
+13 -8

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ u64 sysGetMicroseconds(void);
void sysFatalError(const char *fmt, ...) __attribute__((noreturn));
void sysLogStartCrash(void);
s32 sysLogIsOpen(void);
void sysLogPrintf(s32 level, const char *fmt, ...);
void sysGetExecutablePath(char *outPath, const u32 outLen);
+10 -3
View File
@@ -10,6 +10,7 @@
#include "system.h"
#include "platform.h"
#define CRASH_LOG_FNAME "pd.crash.log"
#define CRASH_MAX_MSG 8192
#define CRASH_MAX_SYM 256
#define CRASH_MAX_FRAMES 32
@@ -132,9 +133,6 @@ static long __stdcall crashHandler(PEXCEPTION_POINTERS exinfo)
return EXCEPTION_CONTINUE_EXECUTION;
}
// start writing to a crash log file
sysLogStartCrash();
sysLogPrintf(LOG_ERROR, "FATAL: Crashed: PC=%p CODE=0x%08lx", exinfo->ExceptionRecord->ExceptionAddress, exinfo->ExceptionRecord->ExceptionCode);
fflush(stderr);
@@ -142,6 +140,15 @@ static long __stdcall crashHandler(PEXCEPTION_POINTERS exinfo)
crashStackTrace(msg, exinfo);
// open log file for the crash dump if one hasn't been opened yet
if (!sysLogIsOpen()) {
FILE *f = fopen(CRASH_LOG_FNAME, "wb");
if (f) {
fprintf(f, "Crash!\n\n%s", msg);
fclose(f);
}
}
sysFatalError("Crash!\n\n%s", msg);
return EXCEPTION_CONTINUE_EXECUTION;
+2 -4
View File
@@ -103,11 +103,9 @@ u64 sysGetMicroseconds(void)
return ((u64)tv.tv_sec * USEC_IN_SEC + (u64)tv.tv_usec) - startTick;
}
void sysLogStartCrash(void)
s32 sysLogIsOpen(void)
{
if (!logPath[0]) {
sysLogSetPath(CRASHLOG_FNAME);
}
return (logPath[0] != '\0');
}
void sysLogPrintf(s32 level, const char *fmt, ...)