Merge all remaining changes from branches/PTRCHECK. These are some
relatively minor extensions to m_debuginfo, a major overhaul of
m_debuginfo/readdwarf3.c to get its space usage under control, and
changes throughout the system to enable heap-use profiling.
The majority of the merged changes were committed into
branches/PTRCHECK as the following revs: 8591 8595 8598 8599 8601 and
8161.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8621 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c
index 54d76cd..19de00d 100644
--- a/helgrind/hg_main.c
+++ b/helgrind/hg_main.c
@@ -208,10 +208,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;
@@ -575,7 +575,7 @@
static Thread* mk_Thread ( SegmentID csegid ) {
static Int indx = 1;
- Thread* thread = hg_zalloc( sizeof(Thread) );
+ Thread* thread = hg_zalloc( "hg", sizeof(Thread) );
thread->locksetA = HG_(emptyWS)( univ_lsets );
thread->locksetW = HG_(emptyWS)( univ_lsets );
thread->csegid = csegid;
@@ -590,7 +590,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", sizeof(Lock) );
lock->admin = admin_locks;
lock->unique = unique++;
lock->magic = LockN_MAGIC;
@@ -605,7 +605,7 @@
return lock;
}
static Segment* mk_Segment ( Thread* thr, Segment* prev, Segment* other ) {
- Segment* seg = hg_zalloc( sizeof(Segment) );
+ Segment* seg = hg_zalloc( "hg", sizeof(Segment) );
seg->dfsver = 0;
seg->thr = thr;
seg->prev = prev;
@@ -729,7 +729,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", hg_free );
VG_(addToBag)( lk->heldBy, (Word)thr );
break;
case LK_mbRec:
@@ -783,7 +783,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", hg_free );
VG_(addToBag)( lk->heldBy, (Word)thr );
}
tl_assert(!lk->heldW);
@@ -1380,25 +1380,25 @@
tl_assert(sizeof(Addr) == sizeof(Word));
tl_assert(map_shmem == NULL);
- map_shmem = VG_(newFM)( hg_zalloc, hg_free, NULL/*unboxed Word cmp*/);
+ map_shmem = VG_(newFM)( hg_zalloc, "hg", hg_free, NULL/*unboxed Word cmp*/);
tl_assert(map_shmem != NULL);
shmem__invalidate_scache();
tl_assert(map_threads == NULL);
- map_threads = hg_zalloc( VG_N_THREADS * sizeof(Thread*) );
+ map_threads = hg_zalloc( "hg", VG_N_THREADS * sizeof(Thread*) );
tl_assert(map_threads != NULL);
/* re <=: < on 64-bit platforms, == on 32-bit ones */
tl_assert(sizeof(SegmentID) <= sizeof(Word));
tl_assert(sizeof(Segment*) == sizeof(Word));
tl_assert(map_segments == NULL);
- map_segments = VG_(newFM)( hg_zalloc, hg_free, NULL/*unboxed Word cmp*/);
+ map_segments = VG_(newFM)( hg_zalloc, "hg", hg_free, NULL/*unboxed Word cmp*/);
tl_assert(map_segments != NULL);
hbefore__invalidate_cache();
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", hg_free, NULL/*unboxed Word cmp*/);
tl_assert(map_locks != NULL);
__bus_lock_Lock = mk_LockN( LK_nonRec, (Addr)&__bus_lock );
@@ -1640,7 +1640,7 @@
}
static XArray* new_VTS ( void ) {
- return VG_(newXA)( hg_zalloc, hg_free, sizeof(ScalarTS) );
+ return VG_(newXA)( hg_zalloc, "hg", hg_free, sizeof(ScalarTS) );
}
static XArray* singleton_VTS ( Thread* thr, UWord tym ) {
ScalarTS st;
@@ -2071,7 +2071,7 @@
dfsver_current++;
if (dfsver_stack == NULL) {
- dfsver_stack = VG_(newXA)( hg_zalloc, hg_free, sizeof(Segment*) );
+ dfsver_stack = VG_(newXA)( hg_zalloc, "hg", hg_free, sizeof(Segment*) );
tl_assert(dfsver_stack);
}
@@ -2740,7 +2740,7 @@
VG_(doneIterFM)( map_shmem );
// check the cache
- valid_tags = hg_zalloc(N_WAY_NENT * sizeof(Addr));
+ valid_tags = hg_zalloc("hg", N_WAY_NENT * sizeof(Addr));
n_valid_tags = 0;
tl_assert(valid_tags);
for (i = 0; i < N_WAY_NENT; i++) {
@@ -2929,7 +2929,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", hg_free, NULL );
VG_(addToFM)( ga_to_lastlock, ga_of_access, (Word)lk->appeared_at );
stats__ga_LL_adds++;
}
@@ -3438,7 +3438,7 @@
/* No free F line found. Expand existing array and try again. */
new_size = sm->linesF_size==0 ? 1 : 2 * sm->linesF_size;
- nyu = hg_zalloc( new_size * sizeof(CacheLineF) );
+ nyu = hg_zalloc( "hg", new_size * sizeof(CacheLineF) );
tl_assert(nyu);
stats__secmap_linesF_allocd += (new_size - sm->linesF_size);
@@ -5435,7 +5435,7 @@
static
void evh__new_mem_w_perms ( Addr a, SizeT len,
- Bool rr, Bool ww, Bool xx ) {
+ Bool rr, Bool ww, Bool xx, ULong di_handle ) {
if (SHOW_EVENTS >= 1)
VG_(printf)("evh__new_mem_w_perms(%p, %lu, %d,%d,%d)\n",
(void*)a, len, (Int)rr, (Int)ww, (Int)xx );
@@ -6021,7 +6021,7 @@
static void map_cond_to_Segment_INIT ( void ) {
if (UNLIKELY(map_cond_to_Segment == NULL)) {
- map_cond_to_Segment = VG_(newFM)( hg_zalloc, hg_free, NULL );
+ map_cond_to_Segment = VG_(newFM)( hg_zalloc, "hg", hg_free, NULL );
tl_assert(map_cond_to_Segment != NULL);
}
}
@@ -6362,7 +6362,7 @@
static void map_sem_to_Segment_stack_INIT ( void ) {
if (map_sem_to_Segment_stack == NULL) {
- map_sem_to_Segment_stack = VG_(newFM)( hg_zalloc, hg_free, NULL );
+ map_sem_to_Segment_stack = VG_(newFM)( hg_zalloc, "hg", hg_free, NULL );
tl_assert(map_sem_to_Segment_stack != NULL);
}
}
@@ -6376,7 +6376,7 @@
tl_assert(xa);
VG_(addToXA)( xa, &seg );
} else {
- xa = VG_(newXA)( hg_zalloc, hg_free, sizeof(Segment*) );
+ xa = VG_(newXA)( hg_zalloc, "hg", hg_free, sizeof(Segment*) );
VG_(addToXA)( xa, &seg );
VG_(addToFM)( map_sem_to_Segment_stack, (Word)sem, (Word)xa );
}
@@ -6689,7 +6689,7 @@
presentF = outs_new == links->outs;
links->outs = outs_new;
} else {
- links = hg_zalloc(sizeof(LAOGLinks));
+ links = hg_zalloc("hg", sizeof(LAOGLinks));
links->inns = HG_(emptyWS)( univ_laog );
links->outs = HG_(singletonWS)( univ_laog, (Word)dst );
VG_(addToFM)( laog, (Word)src, (Word)links );
@@ -6705,7 +6705,7 @@
presentR = inns_new == links->inns;
links->inns = inns_new;
} else {
- links = hg_zalloc(sizeof(LAOGLinks));
+ links = hg_zalloc("hg", sizeof(LAOGLinks));
links->inns = HG_(singletonWS)( univ_laog, (Word)src );
links->outs = HG_(emptyWS)( univ_laog );
VG_(addToFM)( laog, (Word)dst, (Word)links );
@@ -6730,7 +6730,7 @@
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", sizeof(LAOGLinkExposition));
expo2->src_ga = src->guestaddr;
expo2->dst_ga = dst->guestaddr;
expo2->src_ec = src->acquired_at;
@@ -6859,8 +6859,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", hg_free, sizeof(Lock*) );
+ visited = VG_(newFM)( hg_zalloc, "hg", hg_free, NULL/*unboxedcmp*/ );
(void) VG_(addToXA)( stack, &src );
@@ -6913,9 +6913,9 @@
return;
if (!laog)
- laog = VG_(newFM)( hg_zalloc, hg_free, NULL/*unboxedcmp*/ );
+ laog = VG_(newFM)( hg_zalloc, "hg", hg_free, NULL/*unboxedcmp*/ );
if (!laog_exposition)
- laog_exposition = VG_(newFM)( hg_zalloc, hg_free,
+ laog_exposition = VG_(newFM)( hg_zalloc, "hg", hg_free,
cmp_LAOGLinkExposition );
/* First, the check. Complain if there is any path in laog from lk
@@ -7021,9 +7021,9 @@
UWord* ws_words;
if (!laog)
- laog = VG_(newFM)( hg_zalloc, hg_free, NULL/*unboxedcmp*/ );
+ laog = VG_(newFM)( hg_zalloc, "hg", hg_free, NULL/*unboxedcmp*/ );
if (!laog_exposition)
- laog_exposition = VG_(newFM)( hg_zalloc, hg_free,
+ laog_exposition = VG_(newFM)( hg_zalloc, "hg", hg_free,
cmp_LAOGLinkExposition );
HG_(getPayloadWS)( &ws_words, &ws_size, univ_lsets, locksToDelete );
@@ -7055,7 +7055,7 @@
static MallocMeta* new_MallocMeta ( void ) {
- MallocMeta* md = hg_zalloc( sizeof(MallocMeta) );
+ MallocMeta* md = hg_zalloc( "hg", sizeof(MallocMeta) );
tl_assert(md);
return md;
}
@@ -7499,7 +7499,7 @@
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", hg_free, NULL );
tl_assert(map_pthread_t_to_Thread != NULL);
}
}
@@ -7736,7 +7736,7 @@
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", hg_free, string_table_cmp );
tl_assert(string_table);
}
if (VG_(lookupFM)( string_table,
@@ -7745,7 +7745,7 @@
if (0) VG_(printf)("string_table_strdup: %p -> %p\n", str, copy );
return copy;
} else {
- copy = VG_(strdup)(str);
+ copy = VG_(strdup)("hg", str);
tl_assert(copy);
VG_(addToFM)( string_table, (Word)copy, (Word)copy );
return copy;
@@ -7771,11 +7771,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", 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", sizeof(Lock) );
*lkp = *lkn;
lkp->admin = NULL;
lkp->magic = LockP_MAGIC;
@@ -8113,7 +8113,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", hg_free, sizeof(Thread*) );
tl_assert(xa);
HG_(getPayloadWS)( &ts_words, &ts_size, univ_tsets, tset );
tl_assert(ts_words);