|
From: <sv...@va...> - 2008-09-06 18:34:45
|
Author: sewardj
Date: 2008-09-06 19:34:50 +0100 (Sat, 06 Sep 2008)
New Revision: 8562
Log:
* libhb_core.c: add hashing to backtrace comparison for the
event-map's context-tree
* libhb_core.c: fix massive space leak in msm_handle_{read,write}
* add cost-center annotations to all allocation points
Modified:
branches/YARD/helgrind/hg_main.c
branches/YARD/helgrind/hg_wordset.c
branches/YARD/helgrind/hg_wordset.h
branches/YARD/helgrind/libhb.h
branches/YARD/helgrind/libhb_vg.c
Modified: branches/YARD/helgrind/hg_main.c
===================================================================
--- branches/YARD/helgrind/hg_main.c 2008-08-29 23:34:06 UTC (rev 8561)
+++ branches/YARD/helgrind/hg_main.c 2008-09-06 18:34:50 UTC (rev 8562)
@@ -198,10 +198,10 @@
/*--- Some very basic stuff ---*/
/*----------------------------------------------------------------*/
-static void* hg_zalloc ( SizeT n ) {
+static void* hg_zalloc ( HChar* cc, SizeT n ) {
void* p;
tl_assert(n > 0);
- p = VG_(malloc)( n );
+ p = VG_(malloc)( cc, n );
tl_assert(p);
VG_(memset)(p, 0, n);
return p;
@@ -357,7 +357,7 @@
static Thread* mk_Thread ( Thr* hbthr ) {
static Int indx = 1;
- Thread* thread = hg_zalloc( sizeof(Thread) );
+ Thread* thread = hg_zalloc( "hg.mk_Thread.1", sizeof(Thread) );
thread->locksetA = HG_(emptyWS)( univ_lsets );
thread->locksetW = HG_(emptyWS)( univ_lsets );
thread->magic = Thread_MAGIC;
@@ -373,7 +373,7 @@
// Make a new lock which is unlocked (hence ownerless)
static Lock* mk_LockN ( LockKind kind, Addr guestaddr ) {
static ULong unique = 0;
- Lock* lock = hg_zalloc( sizeof(Lock) );
+ Lock* lock = hg_zalloc( "hg.mk_Lock.1", sizeof(Lock) );
lock->admin = admin_locks;
lock->unique = unique++;
lock->magic = LockN_MAGIC;
@@ -500,7 +500,7 @@
tl_assert(lk->heldBy == NULL); /* can't w-lock recursively */
tl_assert(!lk->heldW);
lk->heldW = True;
- lk->heldBy = VG_(newBag)( hg_zalloc, hg_free );
+ lk->heldBy = VG_(newBag)( hg_zalloc, "hg.lNaw.1", hg_free );
VG_(addToBag)( lk->heldBy, (Word)thr );
break;
case LK_mbRec:
@@ -554,7 +554,7 @@
VG_(addToBag)(lk->heldBy, (Word)thr);
} else {
lk->heldW = False;
- lk->heldBy = VG_(newBag)( hg_zalloc, hg_free );
+ lk->heldBy = VG_(newBag)( hg_zalloc, "hg.lNar.1", hg_free );
VG_(addToBag)( lk->heldBy, (Word)thr );
}
tl_assert(!lk->heldW);
@@ -801,12 +801,13 @@
tl_assert(sizeof(Addr) == sizeof(Word));
tl_assert(map_threads == NULL);
- map_threads = hg_zalloc( VG_N_THREADS * sizeof(Thread*) );
+ map_threads = hg_zalloc( "hg.ids.1", VG_N_THREADS * sizeof(Thread*) );
tl_assert(map_threads != NULL);
tl_assert(sizeof(Addr) == sizeof(Word));
tl_assert(map_locks == NULL);
- map_locks = VG_(newFM)( hg_zalloc, hg_free, NULL/*unboxed Word cmp*/);
+ map_locks = VG_(newFM)( hg_zalloc, "hg.ids.2", hg_free,
+ NULL/*unboxed Word cmp*/);
tl_assert(map_locks != NULL);
__bus_lock_Lock = mk_LockN( LK_nonRec, (Addr)&__bus_lock );
@@ -814,15 +815,18 @@
VG_(addToFM)( map_locks, (Word)&__bus_lock, (Word)__bus_lock_Lock );
tl_assert(univ_tsets == NULL);
- univ_tsets = HG_(newWordSetU)( hg_zalloc, hg_free, 8/*cacheSize*/ );
+ univ_tsets = HG_(newWordSetU)( hg_zalloc, "hg.ids.3", hg_free,
+ 8/*cacheSize*/ );
tl_assert(univ_tsets != NULL);
tl_assert(univ_lsets == NULL);
- univ_lsets = HG_(newWordSetU)( hg_zalloc, hg_free, 8/*cacheSize*/ );
+ univ_lsets = HG_(newWordSetU)( hg_zalloc, "hg.ids.4", hg_free,
+ 8/*cacheSize*/ );
tl_assert(univ_lsets != NULL);
tl_assert(univ_laog == NULL);
- univ_laog = HG_(newWordSetU)( hg_zalloc, hg_free, 24/*cacheSize*/ );
+ univ_laog = HG_(newWordSetU)( hg_zalloc, "hg.ids.5 (univ_laog)",
+ hg_free, 24/*cacheSize*/ );
tl_assert(univ_laog != NULL);
/* Set up entries for the root thread */
@@ -1322,7 +1326,7 @@
HG_(cardinalityWS)( univ_lsets, lset_old), lk );
if (lk->appeared_at) {
if (ga_to_lastlock == NULL)
- ga_to_lastlock = VG_(newFM)( hg_zalloc, hg_free, NULL );
+ ga_to_lastlock = VG_(newFM)( hg_zalloc, "hg.rlll.1", hg_free, NULL );
VG_(addToFM)( ga_to_lastlock, ga_of_access, (Word)lk->appeared_at );
stats__ga_LL_adds++;
}
@@ -2339,7 +2343,7 @@
static void map_cond_to_SO_INIT ( void ) {
if (UNLIKELY(map_cond_to_SO == NULL)) {
- map_cond_to_SO = VG_(newFM)( hg_zalloc, hg_free, NULL );
+ map_cond_to_SO = VG_(newFM)( hg_zalloc, "hg.mctSI.1", hg_free, NULL );
tl_assert(map_cond_to_SO != NULL);
}
}
@@ -2672,7 +2676,8 @@
static void map_sem_to_SO_stack_INIT ( void ) {
if (map_sem_to_SO_stack == NULL) {
- map_sem_to_SO_stack = VG_(newFM)( hg_zalloc, hg_free, NULL );
+ map_sem_to_SO_stack = VG_(newFM)( hg_zalloc, "hg.mstSs.1",
+ hg_free, NULL );
tl_assert(map_sem_to_SO_stack != NULL);
}
}
@@ -2688,7 +2693,7 @@
tl_assert(xa);
VG_(addToXA)( xa, &so );
} else {
- xa = VG_(newXA)( hg_zalloc, hg_free, sizeof(SO*) );
+ xa = VG_(newXA)( hg_zalloc, "hg.pSfs.1", hg_free, sizeof(SO*) );
VG_(addToXA)( xa, &so );
VG_(addToFM)( map_sem_to_SO_stack, (Word)sem, (Word)xa );
}
@@ -2978,7 +2983,7 @@
presentF = outs_new == links->outs;
links->outs = outs_new;
} else {
- links = hg_zalloc(sizeof(LAOGLinks));
+ links = hg_zalloc("hg.lae.1", sizeof(LAOGLinks));
links->inns = HG_(emptyWS)( univ_laog );
links->outs = HG_(singletonWS)( univ_laog, (Word)dst );
VG_(addToFM)( laog, (Word)src, (Word)links );
@@ -2994,7 +2999,7 @@
presentR = inns_new == links->inns;
links->inns = inns_new;
} else {
- links = hg_zalloc(sizeof(LAOGLinks));
+ links = hg_zalloc("hg.lae.2", sizeof(LAOGLinks));
links->inns = HG_(singletonWS)( univ_laog, (Word)src );
links->outs = HG_(emptyWS)( univ_laog );
VG_(addToFM)( laog, (Word)dst, (Word)links );
@@ -3019,7 +3024,8 @@
if (VG_(lookupFM)( laog_exposition, NULL, NULL, (Word)&expo )) {
/* we already have it; do nothing */
} else {
- LAOGLinkExposition* expo2 = hg_zalloc(sizeof(LAOGLinkExposition));
+ LAOGLinkExposition* expo2 = hg_zalloc("hg.lae.3",
+ sizeof(LAOGLinkExposition));
expo2->src_ga = src->guestaddr;
expo2->dst_ga = dst->guestaddr;
expo2->src_ec = src->acquired_at;
@@ -3148,8 +3154,8 @@
return NULL;
ret = NULL;
- stack = VG_(newXA)( hg_zalloc, hg_free, sizeof(Lock*) );
- visited = VG_(newFM)( hg_zalloc, hg_free, NULL/*unboxedcmp*/ );
+ stack = VG_(newXA)( hg_zalloc, "hg.lddft.1", hg_free, sizeof(Lock*) );
+ visited = VG_(newFM)( hg_zalloc, "hg.lddft.2", hg_free, NULL/*unboxedcmp*/ );
(void) VG_(addToXA)( stack, &src );
@@ -3202,9 +3208,10 @@
return;
if (!laog)
- laog = VG_(newFM)( hg_zalloc, hg_free, NULL/*unboxedcmp*/ );
+ laog = VG_(newFM)( hg_zalloc, "hg.lptal.1",
+ hg_free, NULL/*unboxedcmp*/ );
if (!laog_exposition)
- laog_exposition = VG_(newFM)( hg_zalloc, hg_free,
+ laog_exposition = VG_(newFM)( hg_zalloc, "hg.lptal.2", hg_free,
cmp_LAOGLinkExposition );
/* First, the check. Complain if there is any path in laog from lk
@@ -3310,9 +3317,9 @@
UWord* ws_words;
if (!laog)
- laog = VG_(newFM)( hg_zalloc, hg_free, NULL/*unboxedcmp*/ );
+ laog = VG_(newFM)( hg_zalloc, "hg.lhld.1", hg_free, NULL/*unboxedcmp*/ );
if (!laog_exposition)
- laog_exposition = VG_(newFM)( hg_zalloc, hg_free,
+ laog_exposition = VG_(newFM)( hg_zalloc, "hg.lhld.2", hg_free,
cmp_LAOGLinkExposition );
HG_(getPayloadWS)( &ws_words, &ws_size, univ_lsets, locksToDelete );
@@ -3344,7 +3351,7 @@
static MallocMeta* new_MallocMeta ( void ) {
- MallocMeta* md = hg_zalloc( sizeof(MallocMeta) );
+ MallocMeta* md = hg_zalloc( "hg.new_MallocMeta.1", sizeof(MallocMeta) );
tl_assert(md);
return md;
}
@@ -3806,7 +3813,8 @@
static void map_pthread_t_to_Thread_INIT ( void ) {
if (UNLIKELY(map_pthread_t_to_Thread == NULL)) {
- map_pthread_t_to_Thread = VG_(newFM)( hg_zalloc, hg_free, NULL );
+ map_pthread_t_to_Thread = VG_(newFM)( hg_zalloc, "hg.mpttT.1",
+ hg_free, NULL );
tl_assert(map_pthread_t_to_Thread != NULL);
}
}
@@ -4051,7 +4059,8 @@
if (!str)
str = "(null)";
if (!string_table) {
- string_table = VG_(newFM)( hg_zalloc, hg_free, string_table_cmp );
+ string_table = VG_(newFM)( hg_zalloc, "hg.sts.1",
+ hg_free, string_table_cmp );
tl_assert(string_table);
}
if (VG_(lookupFM)( string_table,
@@ -4060,7 +4069,7 @@
if (0) VG_(printf)("string_table_strdup: %p -> %p\n", str, copy );
return copy;
} else {
- copy = VG_(strdup)(str);
+ copy = VG_(strdup)("hg.sts.2", str);
tl_assert(copy);
VG_(addToFM)( string_table, (Word)copy, (Word)copy );
return copy;
@@ -4086,11 +4095,11 @@
stats__ga_LockN_to_P_queries++;
tl_assert( is_sane_LockN(lkn) );
if (!yaWFM) {
- yaWFM = VG_(newFM)( hg_zalloc, hg_free, lock_unique_cmp );
+ yaWFM = VG_(newFM)( hg_zalloc, "hg.mLPfLN.1", hg_free, lock_unique_cmp );
tl_assert(yaWFM);
}
if (!VG_(lookupFM)( yaWFM, NULL, (Word*)&lkp, (Word)lkn)) {
- lkp = hg_zalloc( sizeof(Lock) );
+ lkp = hg_zalloc( "hg.mLPfLN.2", sizeof(Lock) );
*lkp = *lkn;
lkp->admin = NULL;
lkp->magic = LockP_MAGIC;
@@ -4452,7 +4461,7 @@
XArray* xa;
UWord* ts_words;
UWord ts_size, i;
- xa = VG_(newXA)( hg_zalloc, hg_free, sizeof(Thread*) );
+ xa = VG_(newXA)( hg_zalloc, "hg.cTbei.1", hg_free, sizeof(Thread*) );
tl_assert(xa);
HG_(getPayloadWS)( &ts_words, &ts_size, univ_tsets, tset );
tl_assert(ts_words);
Modified: branches/YARD/helgrind/hg_wordset.c
===================================================================
--- branches/YARD/helgrind/hg_wordset.c 2008-08-29 23:34:06 UTC (rev 8561)
+++ branches/YARD/helgrind/hg_wordset.c 2008-09-06 18:34:50 UTC (rev 8562)
@@ -140,7 +140,8 @@
corresponding ix2vec entry number. The two mappings are mutually
redundant. */
struct _WordSetU {
- void* (*alloc)(SizeT);
+ void* (*alloc)(HChar*,SizeT);
+ HChar* cc;
void (*dealloc)(void*);
WordFM* vec2ix; /* WordVec-to-WordSet mapping tree */
WordVec** ix2vec; /* WordSet-to-WordVec mapping array */
@@ -176,12 +177,12 @@
{
WordVec* wv;
tl_assert(sz >= 0);
- wv = wsu->alloc( sizeof(WordVec) );
+ wv = wsu->alloc( wsu->cc, sizeof(WordVec) );
wv->owner = wsu;
wv->words = NULL;
wv->size = sz;
if (sz > 0) {
- wv->words = wsu->alloc( (SizeT)sz * sizeof(UWord) );
+ wv->words = wsu->alloc( wsu->cc, (SizeT)sz * sizeof(UWord) );
}
return wv;
}
@@ -238,7 +239,7 @@
return;
new_sz = 2 * wsu->ix2vec_size;
if (new_sz == 0) new_sz = 2;
- new_vec = wsu->alloc( new_sz * sizeof(WordVec*) );
+ new_vec = wsu->alloc( wsu->cc, new_sz * sizeof(WordVec*) );
tl_assert(new_vec);
for (i = 0; i < wsu->ix2vec_size; i++)
new_vec[i] = wsu->ix2vec[i];
@@ -305,18 +306,21 @@
}
-WordSetU* HG_(newWordSetU) ( void* (*alloc_nofail)( SizeT ),
+WordSetU* HG_(newWordSetU) ( void* (*alloc_nofail)( HChar*, SizeT ),
+ HChar* cc,
void (*dealloc)(void*),
Word cacheSize )
{
WordSetU* wsu;
WordVec* empty;
- wsu = alloc_nofail( sizeof(WordSetU) );
+ wsu = alloc_nofail( cc, sizeof(WordSetU) );
VG_(memset)( wsu, 0, sizeof(WordSetU) );
wsu->alloc = alloc_nofail;
+ wsu->cc = cc;
wsu->dealloc = dealloc;
- wsu->vec2ix = VG_(newFM)( alloc_nofail, dealloc, cmp_WordVecs_for_FM );
+ wsu->vec2ix = VG_(newFM)( alloc_nofail, cc,
+ dealloc, cmp_WordVecs_for_FM );
wsu->ix2vec_used = 0;
wsu->ix2vec_size = 0;
wsu->ix2vec = NULL;
Modified: branches/YARD/helgrind/hg_wordset.h
===================================================================
--- branches/YARD/helgrind/hg_wordset.h 2008-08-29 23:34:06 UTC (rev 8561)
+++ branches/YARD/helgrind/hg_wordset.h 2008-09-06 18:34:50 UTC (rev 8562)
@@ -47,7 +47,8 @@
typedef UInt WordSet; /* opaque, small int index */
/* Allocate and initialise a WordSetU */
-WordSetU* HG_(newWordSetU) ( void* (*alloc_nofail)( SizeT ),
+WordSetU* HG_(newWordSetU) ( void* (*alloc_nofail)( HChar*, SizeT ),
+ HChar* cc,
void (*dealloc)(void*),
Word cacheSize );
Modified: branches/YARD/helgrind/libhb.h
===================================================================
--- branches/YARD/helgrind/libhb.h 2008-08-29 23:34:06 UTC (rev 8561)
+++ branches/YARD/helgrind/libhb.h 2008-09-06 18:34:50 UTC (rev 8562)
@@ -52,7 +52,7 @@
'shadow_alloc' should never return NULL, instead they should simply
not return if they encounter an out-of-memory condition. */
Thr* libhb_init (
- void* (*zalloc)( SizeT ),
+ void* (*zalloc)( HChar*, SizeT ),
void (*dealloc)( void* ),
void* (*shadow_alloc)( SizeT ),
void (*get_stacktrace)( Thr*, Addr*, UWord ),
Modified: branches/YARD/helgrind/libhb_vg.c
===================================================================
--- branches/YARD/helgrind/libhb_vg.c 2008-08-29 23:34:06 UTC (rev 8561)
+++ branches/YARD/helgrind/libhb_vg.c 2008-09-06 18:34:50 UTC (rev 8562)
@@ -60,8 +60,8 @@
#define libhbPlainVG_OSetGen_Insert(_arg1, _arg2) \
vgPlain_OSetGen_Insert((_arg1),(_arg2))
-#define libhbPlainVG_OSetGen_Create(_arg1, _arg2, _arg3, _arg4) \
- vgPlain_OSetGen_Create((_arg1),(_arg2),(_arg3),(_arg4))
+#define libhbPlainVG_OSetGen_Create(_arg1, _arg2, _arg3, _arg4, _arg5) \
+ vgPlain_OSetGen_Create((_arg1),(_arg2),(_arg3),(_arg4),(_arg5))
#define libhbPlainVG_OSetGen_Size(_arg1) \
vgPlain_OSetGen_Size((_arg1))
|