tweaks to logging for stack hash debugging

This commit is contained in:
Eric House 2018-04-08 20:46:35 -07:00
parent afbf5a2218
commit fecbfdddb6
3 changed files with 14 additions and 5 deletions

View file

@ -398,7 +398,7 @@ mem_stream_getHash( const XWStreamCtxt* p_sctx, XWStreamPos pos,
} }
hash = finishHash( hash ); hash = finishHash( hash );
LOG_RETURNF( "%X(%d:%d)", hash, len, bits ); LOG_RETURNF( "%X (nBytes=%d;nBits=%d)", hash, len, bits );
return hash; return hash;
} /* mem_stream_getHash */ } /* mem_stream_getHash */

View file

@ -369,8 +369,14 @@ model_popToHash( ModelCtxt* model, const XP_U32 hash, PoolContext* pool )
/* Assert not needed for long */ /* Assert not needed for long */
XP_ASSERT( hash == stack_getHash( model->vol.stack, XP_TRUE ) XP_ASSERT( hash == stack_getHash( model->vol.stack, XP_TRUE )
|| hash == stack_getHash( model->vol.stack, XP_FALSE ) ); || hash == stack_getHash( model->vol.stack, XP_FALSE ) );
} else {
XP_ASSERT( nEntries == stack_getNEntries(stack) );
} }
#ifdef DEBUG_HASHING
XP_LOGF( "%s(%X) => %s (nEntries=%d)", __func__, hash, boolToStr(found),
nEntries );
#endif
return found; return found;
} }

View file

@ -2119,7 +2119,7 @@ sendMoveTo( ServerCtxt* server, XP_U16 devIndex, XP_U16 turn,
XP_ASSERT( version == server->nv.streamVersion ); XP_ASSERT( version == server->nv.streamVersion );
XP_U32 hash = model_getHash( server->vol.model ); XP_U32 hash = model_getHash( server->vol.model );
#ifdef DEBUG_HASHING #ifdef DEBUG_HASHING
XP_LOGF( "%s: adding hash %x", __func__, (unsigned int)hash ); XP_LOGF( "%s: adding hash %X", __func__, (unsigned int)hash );
#endif #endif
stream_putU32( stream, hash ); stream_putU32( stream, hash );
} }
@ -2164,6 +2164,7 @@ readMoveInfo( ServerCtxt* server, XWStreamCtxt* stream,
TrayTileSet* newTiles, TrayTileSet* tradedTiles, TrayTileSet* newTiles, TrayTileSet* tradedTiles,
XP_Bool* legalP ) XP_Bool* legalP )
{ {
LOG_FUNC();
XP_Bool success = XP_TRUE; XP_Bool success = XP_TRUE;
XP_Bool legalMove = XP_TRUE; XP_Bool legalMove = XP_TRUE;
XP_Bool isTrade; XP_Bool isTrade;
@ -2171,15 +2172,17 @@ readMoveInfo( ServerCtxt* server, XWStreamCtxt* stream,
#ifdef STREAM_VERS_BIGBOARD #ifdef STREAM_VERS_BIGBOARD
if ( STREAM_VERS_BIGBOARD <= stream_getVersion( stream ) ) { if ( STREAM_VERS_BIGBOARD <= stream_getVersion( stream ) ) {
XP_U32 hashReceived = stream_getU32( stream ); XP_U32 hashReceived = stream_getU32( stream );
success = model_hashMatches( server->vol.model, hashReceived ) success = model_hashMatches( server->vol.model, hashReceived );
|| model_popToHash( server->vol.model, hashReceived, server->pool ); if ( !success ) {
// XP_ASSERT( success ); /* I need to understand when this can fail */ success = model_popToHash( server->vol.model, hashReceived, server->pool );
}
#ifdef DEBUG_HASHING #ifdef DEBUG_HASHING
if ( success ) { if ( success ) {
XP_LOGF( "%s: hash match: %X",__func__, hashReceived ); XP_LOGF( "%s: hash match: %X",__func__, hashReceived );
} else { } else {
XP_LOGF( "%s: hash mismatch: %X not found",__func__, hashReceived ); XP_LOGF( "%s: hash mismatch: %X not found",__func__, hashReceived );
} }
// XP_ASSERT( success ); /* I need to understand when this can fail */
#endif #endif
} }
#endif #endif