Don't include backtraces in syncDebug CRCs.

This should allow using syncDebugBacktrace() without causing a desynch if some clients don't support them or print them differently.
master
Cyp 2010-12-08 17:18:16 +01:00
parent 707e7d45ee
commit f5893a7fe5
2 changed files with 9 additions and 3 deletions

View File

@ -3000,8 +3000,10 @@ void _syncDebug(const char *function, const char *str, ...)
}
}
void syncDebugBacktrace(void)
void _syncDebugBacktrace(const char *function)
{
uint32_t backupCrc = syncDebugCrcs[syncDebugNext]; // Ignore CRC changes from _syncDebug(), since identical backtraces can be printed differently.
#ifdef WZ_OS_LINUX
void *btv[20];
unsigned num = backtrace(btv, sizeof(btv)/sizeof(*btv));
@ -3013,8 +3015,11 @@ void syncDebugBacktrace(void)
}
free(btc);
#else
_syncDebug("BT", "Sorry, syncDebugBacktrace() not implemented on your system.");
_syncDebug("BT", "Sorry, syncDebugBacktrace() not implemented on your system. Called from %s.", function);
#endif
// Use CRC of something platform-independent, to avoid false positive desynchs.
syncDebugCrcs[syncDebugNext] = crcSum(backupCrc, function, strlen(function) + 1);
}
static void clearSyncDebugNext(void)

View File

@ -364,7 +364,8 @@ const char *messageTypeToString(unsigned messageType);
#define syncDebug(...) do { _syncDebug(__FUNCTION__, __VA_ARGS__); } while(0)
void _syncDebug(const char *function, const char *str, ...)
WZ_DECL_FORMAT(printf, 2, 3);
void syncDebugBacktrace(void); ///< Adds a backtrace to syncDebug. (Expect lots of false positives, if all clients aren't using the exact same binaries.)
#define syncDebugBacktrace() do { _syncDebugBacktrace(__FUNCTION__); } while(0)
void _syncDebugBacktrace(const char *function); ///< Adds a backtrace to syncDebug, if the platform supports it. Can be a bit slow, don't call way too often, unless desperate.
void resetSyncDebug(void); ///< Resets the syncDebug, so syncDebug from a previous game doesn't cause a spurious desynch dump.
uint32_t nextDebugSync(void); ///< Returns a CRC corresponding to all syncDebug() calls since the last nextDebugSync() or resetSyncDebug() call.