From patchwork Sat Oct 26 07:14:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: l00420122 X-Patchwork-Id: 35357 Received: (qmail 124177 invoked by alias); 26 Oct 2019 07:13:53 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 124066 invoked by uid 89); 26 Oct 2019 07:13:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1088 X-HELO: huawei.com From: liusirui To: CC: Subject: [PATCH v2 1/2] malloc: malloc_stats print all heaps except heaps of main_arena Date: Sat, 26 Oct 2019 15:14:02 +0800 Message-ID: <1572074043-28091-1-git-send-email-liusirui@huawei.com> MIME-Version: 1.0 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;