From 34f504aec55bda51aac7e2bd76fec31e96b6d1ab Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 23 Jul 2003 22:51:43 +0000 Subject: [PATCH] Simplify. --- .../src/arch/ArchHooks/ArchHooks_Win32.cpp | 10 --- .../src/arch/ArchHooks/ArchHooks_Win32.h | 1 - stepmania/src/archutils/Win32/Crash.cpp | 83 +++---------------- stepmania/src/archutils/Win32/Crash.h | 3 - 4 files changed, 10 insertions(+), 87 deletions(-) diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp index c4aef35948..b13b011971 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -17,16 +17,6 @@ ArchHooks_Win32::ArchHooks_Win32() VDCHECKPOINT; } -void ArchHooks_Win32::Log(CString str, bool important) -{ - /* It's OK to send to both of these; it'll let us know when important - * events occurred in crash dumps if they're recent. */ - if(important) - StaticLog(str); - - CrashLog(str); -} - void ArchHooks_Win32::DumpDebugInfo() { /* This is a good time to do the debug search: before we actually diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h index d4b59f052c..067d7a7739 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h @@ -6,7 +6,6 @@ class ArchHooks_Win32: public ArchHooks { public: ArchHooks_Win32(); - void Log(CString str, bool important); void DumpDebugInfo(); void MessageBoxOK( CString sMessage, CString ID ); MessageBoxResult MessageBoxAbortRetryIgnore( CString sMessage, CString ID ); diff --git a/stepmania/src/archutils/Win32/Crash.cpp b/stepmania/src/archutils/Win32/Crash.cpp index aef107af56..6948db7e4c 100644 --- a/stepmania/src/archutils/Win32/Crash.cpp +++ b/stepmania/src/archutils/Win32/Crash.cpp @@ -1505,93 +1505,30 @@ void crash() { } } -/* RageLog feeds us logs; keep track of recent logs in a circular - * buffer. This lets us include recent logs in the crash report. - * We don't want to include RageLog, since we don't want to pull - * in MFC. - * - * Since this is a static, preallocated region, even if it gets - * trampled we'll just print garbage, not crash due to an invalid - * pointer. */ -static const int BACKLOG_LINES = 10; -static char backlog[BACKLOG_LINES][1024]; -static int backlog_start=0, backlog_cnt=0; - -void CrashLog(const char *str) -{ - int len = strlen(str); - if(len > sizeof(backlog[backlog_start])-1) - len = sizeof(backlog[backlog_start])-1; - - strncpy(backlog[backlog_start], str, len); - backlog[backlog_start] [ len ] = 0; - - backlog_start++; - if(backlog_start > backlog_cnt) - backlog_cnt=backlog_start; - backlog_start %= BACKLOG_LINES; -} - static void ReportCrashLog(HWND hwnd, HANDLE hFile) { + Report(NULL, hFile, ""); Report(NULL, hFile, "Partial log:"); - int i; - for(i = backlog_start; i < BACKLOG_LINES && i < backlog_cnt; ++i) - Report(hwnd, hFile, "%s", backlog[i]); - for(i = 0; i < backlog_start && i < backlog_cnt; ++i) - Report(hwnd, hFile, "%s", backlog[i]); + int i = 0; + while( const char *p = RageLog::GetRecentLog( i++ ) ) + Report(hwnd, hFile, "%s", p); } -/* Same idea, except this is for data that we *always* want to print - * in the crash log, even if it was printed when we started. */ -static const int STATICLOG_SIZE = 1024*32; -static char staticlog[STATICLOG_SIZE]=""; -static char *staticlog_ptr=staticlog, *staticlog_end=staticlog+STATICLOG_SIZE; -void StaticLog(const char *str) -{ - if(!staticlog_ptr) - return; - - int len = strlen(str)+3; /* +\r +\n +null */ - if(staticlog_ptr+len >= staticlog_end) - { - const char *txt = "\nStaticlog limit reached\n"; - char *max_ptr = staticlog_end-strlen(txt)-1; - if(staticlog_ptr > max_ptr) - staticlog_ptr = max_ptr; - - strcpy(staticlog_ptr, txt); - staticlog_ptr=NULL; /* stop */ - return; - } - - strcpy(staticlog_ptr, str); - - staticlog_ptr[len-3] = '\r'; - staticlog_ptr[len-2] = '\n'; - staticlog_ptr[len-1] = 0; - /* Advance to sit on the NULL, so the terminator will be overwritten - * on the next log. */ - staticlog_ptr += len-1; -} - - static void ReportStaticLog(HWND hwnd, HANDLE hFile) { Report(NULL, hFile, "Static log:"); + + const char *p = RageLog::GetInfo(); DWORD dwActual; - WriteFile(hFile, staticlog, staticlog_ptr-staticlog, &dwActual, NULL); + WriteFile(hFile, p, strlen(p), &dwActual, NULL); // Report(hwnd, hFile, "%s", staticlog); } static void ReportAdditionalLog(HWND hwnd, HANDLE hFile) { - DWORD dwActual; + const char *p = RageLog::GetAdditionalLog(); - /* We crashed, so this data might well be bogus; don't use strlen. */ - const char *p; - int len; - RageLog::GetAdditionalLog( p, len ); - WriteFile(hFile, p, len, &dwActual, NULL); + DWORD dwActual; + WriteFile(hFile, p, strlen(p), &dwActual, NULL); } diff --git a/stepmania/src/archutils/Win32/Crash.h b/stepmania/src/archutils/Win32/Crash.h index e4e5592f39..c85ca639f8 100644 --- a/stepmania/src/archutils/Win32/Crash.h +++ b/stepmania/src/archutils/Win32/Crash.h @@ -52,9 +52,6 @@ void VirtualDubInitializeThread(const char *pszName); void VirtualDubDeinitializeThread(); extern long __stdcall CrashHandler(struct _EXCEPTION_POINTERS *ExceptionInfo); -void CrashLog(const char *str); -void StaticLog(const char *str); - /* Exactly as advertised. (This will bring up the crash handler even * in the debugger.) */ void crash();