Merge pull request #398 from xiulipan/allocdbgfix

Add alloc debug support
This commit is contained in:
Liam Girdwood 2018-09-26 12:06:21 +01:00 committed by GitHub
commit cb0644c450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -344,6 +344,10 @@ found:
block = ((uint32_t)ptr - block_map->base) / block_map->block_size;
hdr = cache_to_uncache(&block_map->block[block]);
/* report a error if prt is not aligned to block */
if (block_map->base + block_map->block_size * block != (uint32_t)ptr)
panic(SOF_IPC_PANIC_MEM);
/* free block header and continuous blocks */
for (i = block; i < block + hdr->size; i++) {
hdr = cache_to_uncache(&block_map->block[i]);
@ -359,7 +363,9 @@ found:
block_map->first_free = block;
#if DEBUG_BLOCK_FREE
alloc_memset_region(ptr, block_map->block_size * (i - 1), DEBUG_BLOCK_FREE_VALUE);
/* memset the whole block incase some not aligned ptr*/
alloc_memset_region((void *)(block_map->base + block_map->block_size * block),
block_map->block_size * (i - block), DEBUG_BLOCK_FREE_VALUE);
#endif
}