zone: add Cache_CheckLinks for debugging cache memory trashing

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-05-12 08:49:16 +09:30
parent 84697dd12e
commit b11b840f54
2 changed files with 31 additions and 0 deletions

View File

@ -796,6 +796,30 @@ Cache_Data(const cache_system_t *c)
return (byte *)(c + 1) + c->user->pad;
}
#ifdef DEBUG
void
Cache_CheckLinks(void)
{
const cache_system_t *cache;
cache = cache_head.next;
while (cache != &cache_head)
cache = cache->next;
cache = cache_head.prev;
while (cache != &cache_head)
cache = cache->prev;
cache = cache_head.lru_next;
while (cache != &cache_head)
cache = cache->lru_next;
cache = cache_head.lru_prev;
while (cache != &cache_head)
cache = cache->lru_prev;
}
#endif
/*
* ===========
* Cache_Move

View File

@ -149,4 +149,11 @@ void Cache_Free(cache_user_t *c);
void Cache_Report(void);
/* For debugging - Walk the links to check for data corruption */
#ifdef DEBUG
void Cache_CheckLinks(void);
#else
static inline void Cache_CheckLinks(void) { }
#endif
#endif /* ZONE_H */