heap: Add heap_caps_dump() / heap_caps_dump_all() functions

Dump the structure of the heap for debugging purposes.
This commit is contained in:
Angus Gratton
2017-10-18 16:25:17 +08:00
committed by Angus Gratton
parent b19fe80baf
commit 47aaf402b8
4 changed files with 57 additions and 14 deletions

View File

@@ -276,3 +276,33 @@ void *heap_caps_realloc_prefer( void *ptr, size_t size, size_t num, ... );
* @return A pointer to the memory allocated on success, NULL on failure
*/
void *heap_caps_calloc_prefer( size_t n, size_t size, size_t num, ... );
/**
* @brief Dump the full structure of all heaps with matching capabilities.
*
* Prints a large amount of output to serial (because of locking limitations,
* the output bypasses stdout/stderr). For each (variable sized) block
* in each matching heap, the following output is printed on a single line:
*
* - Block address (the data buffer returned by malloc is 4 bytes after this
* if heap debugging is set to Basic, or 8 bytes otherwise).
* - Data size (the data size may be larger than the size requested by malloc,
* either due to heap fragmentation or because of heap debugging level).
* - Address of next block in the heap.
* - If the block is free, the address of the next free block is also printed.
*
* @param caps Bitwise OR of MALLOC_CAP_* flags indicating the type
* of memory
*/
void heap_caps_dump(uint32_t caps);
/**
* @brief Dump the full structure of all heaps.
*
* Covers all registered heaps. Prints a large amount of output to serial.
*
* Output is the same as for heap_caps_dump.
*
*/
void heap_caps_dump_all();