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/drd/drd_barrier.c b/drd/drd_barrier.c
index 0f2d4db..542c610 100644
--- a/drd/drd_barrier.c
+++ b/drd/drd_barrier.c
@@ -112,7 +112,8 @@
   tl_assert(sizeof(((struct barrier_thread_info*)0)->tid) == sizeof(Word));
   tl_assert(sizeof(((struct barrier_thread_info*)0)->tid)
             >= sizeof(DrdThreadId));
-  p->oset = VG_(OSetGen_Create)(0, 0, VG_(malloc), VG_(free));
+  p->oset = VG_(OSetGen_Create)(0, 0, VG_(malloc), "drd.barrier.bi.1",
+                                      VG_(free));
 }
 
 /** Deallocate the memory allocated by barrier_initialize() and in p->oset. 
diff --git a/drd/drd_bitmap.c b/drd/drd_bitmap.c
index c02bd49..9e5d1ba 100644
--- a/drd/drd_bitmap.c
+++ b/drd/drd_bitmap.c
@@ -63,7 +63,7 @@
   /* in drd_bitmap.h.                                                    */
   tl_assert((1 << BITS_PER_BITS_PER_UWORD) == BITS_PER_UWORD);
 
-  bm = VG_(malloc)(sizeof(*bm));
+  bm = VG_(malloc)("drd.bitmap.bn.1", sizeof(*bm));
   tl_assert(bm);
   /* Cache initialization. a1 is initialized with a value that never can */
   /* match any valid address: the upper ADDR0_BITS bits of a1 are always */
@@ -73,7 +73,8 @@
     bm->cache[i].a1  = ~(UWord)1;
     bm->cache[i].bm2 = 0;
   }
-  bm->oset = VG_(OSetGen_Create)(0, 0, VG_(malloc), VG_(free));
+  bm->oset = VG_(OSetGen_Create)(0, 0, VG_(malloc), "drd.bitmap.bn.2",
+                                       VG_(free));
 
   s_bitmap_creation_count++;
 
@@ -917,7 +918,7 @@
 {
   struct bitmap2* bm2;
 
-  bm2 = VG_(malloc)(sizeof(*bm2));
+  bm2 = VG_(malloc)("drd.bitmap.bm2n.1", sizeof(*bm2));
   bm2->addr   = a1;
   bm2->refcnt = 1;
 
diff --git a/drd/drd_clientobj.c b/drd/drd_clientobj.c
index 1d62db1..768079a 100644
--- a/drd/drd_clientobj.c
+++ b/drd/drd_clientobj.c
@@ -53,7 +53,8 @@
 void clientobj_init(void)
 {
   tl_assert(s_clientobj == 0);
-  s_clientobj = VG_(OSetGen_Create)(0, 0, VG_(malloc), VG_(free));
+  s_clientobj = VG_(OSetGen_Create)(0, 0, VG_(malloc), "drd.clientobj.ci.1",
+                                          VG_(free));
   tl_assert(s_clientobj);
 }
 
diff --git a/drd/drd_error.c b/drd/drd_error.c
index a8c0052..c3eb745 100644
--- a/drd/drd_error.c
+++ b/drd/drd_error.c
@@ -95,8 +95,8 @@
 {
   AddrInfo ai;
   const unsigned descr_size = 256;
-  Char* descr1 = VG_(malloc)(descr_size);
-  Char* descr2 = VG_(malloc)(descr_size);
+  Char* descr1 = VG_(malloc)("drd.error.drdr2.1", descr_size);
+  Char* descr2 = VG_(malloc)("drd.error.drdr2.2", descr_size);
 
   tl_assert(dri);
   tl_assert(dri->addr);
diff --git a/drd/drd_main.c b/drd/drd_main.c
index 3f9ff30..5f49203 100644
--- a/drd/drd_main.c
+++ b/drd/drd_main.c
@@ -548,7 +548,8 @@
 
 static
 void drd_start_using_mem_w_perms(const Addr a, const SizeT len,
-                                 const Bool rr, const Bool ww, const Bool xx)
+                                 const Bool rr, const Bool ww, const Bool xx,
+                                 ULong di_handle)
 {
   thread_set_vg_running_tid(VG_(get_running_tid)());
 
@@ -654,7 +655,7 @@
     const unsigned msg_size = 256;
     char* msg;
 
-    msg = VG_(malloc)(msg_size);
+    msg = VG_(malloc)("drd.main.dptj.1", msg_size);
     tl_assert(msg);
     VG_(snprintf)(msg, msg_size,
                   "drd_post_thread_join joiner = %d/%d, joinee = %d/%d",
diff --git a/drd/drd_malloc_wrappers.c b/drd/drd_malloc_wrappers.c
index e9cbbf8..5a47ed7 100644
--- a/drd/drd_malloc_wrappers.c
+++ b/drd/drd_malloc_wrappers.c
@@ -70,7 +70,8 @@
 static
 DRD_Chunk* create_DRD_Chunk(ThreadId tid, Addr p, SizeT size)
 {
-  DRD_Chunk* mc = VG_(malloc)(sizeof(DRD_Chunk));
+  DRD_Chunk* mc = VG_(malloc)("drd.malloc_wrappers.cDC.1",
+                              sizeof(DRD_Chunk));
   mc->data      = p;
   mc->size      = size;
   mc->where     = VG_(record_ExeContext)(tid, 0);
diff --git a/drd/drd_rwlock.c b/drd/drd_rwlock.c
index 44058b4..c7d0fc6 100644
--- a/drd/drd_rwlock.c
+++ b/drd/drd_rwlock.c
@@ -180,7 +180,8 @@
   tl_assert(p->type == ClientRwlock);
 
   p->cleanup         = (void(*)(DrdClientobj*))&rwlock_cleanup;
-  p->thread_info     = VG_(OSetGen_Create)(0, 0, VG_(malloc), VG_(free));
+  p->thread_info     = VG_(OSetGen_Create)(
+                          0, 0, VG_(malloc), "drd.rwlock.ri.1", VG_(free));
   p->acquiry_time_ms = 0;
   p->acquired_at     = 0;
 }
diff --git a/drd/drd_segment.c b/drd/drd_segment.c
index 8fe1707..7e3022a 100644
--- a/drd/drd_segment.c
+++ b/drd/drd_segment.c
@@ -116,7 +116,7 @@
   if (s_max_alive_segments_count < s_alive_segments_count)
     s_max_alive_segments_count = s_alive_segments_count;
 
-  sg = VG_(malloc)(sizeof(*sg));
+  sg = VG_(malloc)("drd.segment.sn.1", sizeof(*sg));
   tl_assert(sg);
   sg_init(sg, creator, created);
   return sg;
diff --git a/drd/drd_vc.c b/drd/drd_vc.c
index b083974..1d4d833 100644
--- a/drd/drd_vc.c
+++ b/drd/drd_vc.c
@@ -320,11 +320,13 @@
   {
     if (vc->vc)
     {
-      vc->vc = VG_(realloc)(vc->vc, new_capacity * sizeof(vc->vc[0]));
+      vc->vc = VG_(realloc)("drd.vc.vr.1",
+                            vc->vc, new_capacity * sizeof(vc->vc[0]));
     }
     else if (new_capacity > 0)
     {
-      vc->vc = VG_(malloc)(new_capacity * sizeof(vc->vc[0]));
+      vc->vc = VG_(malloc)("drd.vc.vr.2",
+                           new_capacity * sizeof(vc->vc[0]));
     }
     else
     {
diff --git a/drd/tests/drd_bitmap_test.c b/drd/tests/drd_bitmap_test.c
index d2855ad..f653f42 100644
--- a/drd/tests/drd_bitmap_test.c
+++ b/drd/tests/drd_bitmap_test.c
@@ -10,7 +10,7 @@
 
 /* Replacements for core functionality. */
 
-void* VG_(malloc)(SizeT nbytes)
+void* VG_(malloc)(HChar* cc, SizeT nbytes)
 { return malloc(nbytes); }
 void  VG_(free)(void* p)
 { return free(p); }