From 758450e6231866124af2c6628f886d505521c969 Mon Sep 17 00:00:00 2001 From: Philippe Waroquiers Date: Fri, 15 May 2015 13:17:17 +0000 Subject: [PATCH] Add statistics about the nr of used linesF git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15237 --- helgrind/libhb_core.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/helgrind/libhb_core.c b/helgrind/libhb_core.c index d7710c23f6..ef887e3160 100644 --- a/helgrind/libhb_core.c +++ b/helgrind/libhb_core.c @@ -899,6 +899,34 @@ static SecMap* shmem__find_or_alloc_SecMap ( Addr ga ) } } +/* Returns the nr of linesF which are in use. Note: this is scanning + the secmap wordFM. So, this is to be used for statistics only. */ +__attribute__((noinline)) +static UWord shmem__SecMap_used_linesF(void) +{ + UWord secmapW = 0; + Addr gaKey; + UWord inUse = 0; + UWord total = 0; + + VG_(initIterFM)( map_shmem ); + while (VG_(nextIterFM)( map_shmem, &gaKey, &secmapW )) { + UWord i; + SecMap* sm = (SecMap*)secmapW; + tl_assert(sm->magic == SecMap_MAGIC); + + for (i = 0; i < sm->linesF_size; i++) { + LineF* lineF = &sm->linesF[i]; + if (lineF->inUse) + inUse++; + total++; + } + } + VG_(doneIterFM)( map_shmem ); + tl_assert (stats__secmap_linesF_allocd == total); + + return inUse; +} /* ------------ LineF and LineZ related ------------ */ @@ -6334,9 +6362,10 @@ void libhb_shutdown ( Bool show_stats ) VG_(printf)(" linesZ: %'10lu allocd (%'12lu bytes occupied)\n", stats__secmap_linesZ_allocd, stats__secmap_linesZ_bytes); - VG_(printf)(" linesF: %'10lu allocd (%'12lu bytes occupied)\n", - stats__secmap_linesF_allocd, - stats__secmap_linesF_bytes); + VG_(printf)(" linesF: %'10lu allocd (%'12lu bytes occupied)" + " (%'10lu used)\n", + stats__secmap_linesF_allocd, stats__secmap_linesF_bytes, + shmem__SecMap_used_linesF()); VG_(printf)(" secmaps: %'10lu in map (can be scanGCed %'5lu)" " #%lu scanGC \n", stats__secmaps_in_map_shmem, -- 2.47.3