[1/2] malloc: malloc_stats print all heaps except heaps
Commit Message
From: liusirui <liusirui@huawei.com>
An arena may have several heaps, and only the last heap contains top chunk.
malloc_stats only print the heap which contains top chunk. Now the function
prints all heaps of an arena.
---
malloc/malloc.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
@@ -4965,6 +4965,7 @@ __malloc_stats (void)
{
int i;
mstate ar_ptr;
+ heap_info *heap_ptr;
unsigned int in_use_b = mp_.mmapped_mem, system_b = in_use_b;
if (__malloc_initialized < 0)
@@ -4984,7 +4985,13 @@ __malloc_stats (void)
fprintf (stderr, "in use bytes = %10u\n", (unsigned int) mi.uordblks);
#if MALLOC_DEBUG > 1
if (i > 0)
- dump_heap (heap_for_ptr (top (ar_ptr)));
+ {
+ for (heap_ptr = heap_for_ptr (top (ar_ptr)); heap_ptr->ar_ptr != (mstate) (heap_ptr + 1); heap_ptr = heap_ptr->prev)
+ {
+ dump_heap (heap_ptr);
+ }
+ dump_heap (heap_ptr);
+ }
#endif
system_b += mi.arena;
in_use_b += mi.uordblks;