This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/2] malloc: malloc_stats print all heaps except heaps


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(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 5d3e82a..351e95f 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -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;
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]