Author: sewardj
Date: 2008-09-06 20:34:12 +0100 (Sat, 06 Sep 2008)
New Revision: 8572
Log:
* add cost-center annotations to all allocation points in the core.
* add handling for the new flag --profile-heap
Modified:
branches/YARD/coregrind/m_commandline.c
branches/YARD/coregrind/m_coredump/coredump-elf.c
branches/YARD/coregrind/m_demangle/cp-demangle.c
branches/YARD/coregrind/m_demangle/cplus-dem.c
branches/YARD/coregrind/m_demangle/dyn-string.c
branches/YARD/coregrind/m_errormgr.c
branches/YARD/coregrind/m_execontext.c
branches/YARD/coregrind/m_hashtable.c
branches/YARD/coregrind/m_initimg/initimg-linux.c
branches/YARD/coregrind/m_libcproc.c
branches/YARD/coregrind/m_main.c
branches/YARD/coregrind/m_options.c
branches/YARD/coregrind/m_oset.c
branches/YARD/coregrind/m_redir.c
branches/YARD/coregrind/m_replacemalloc/replacemalloc_core.c
branches/YARD/coregrind/m_signals.c
branches/YARD/coregrind/m_stacks.c
branches/YARD/coregrind/m_syswrap/syswrap-generic.c
branches/YARD/coregrind/m_syswrap/syswrap-x86-linux.c
branches/YARD/coregrind/m_transtab.c
branches/YARD/coregrind/m_ume.c
branches/YARD/coregrind/m_wordfm.c
branches/YARD/coregrind/m_xarray.c
branches/YARD/coregrind/pub_core_debuginfo.h
branches/YARD/coregrind/pub_core_options.h
branches/YARD/include/pub_tool_oset.h
branches/YARD/include/pub_tool_wordfm.h
branches/YARD/include/pub_tool_xarray.h
Modified: branches/YARD/coregrind/m_commandline.c
===================================================================
--- branches/YARD/coregrind/m_commandline.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_commandline.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -67,7 +67,7 @@
if ( !fd.isError ) {
size = VG_(fsize)(fd.res);
if (size > 0) {
- f_clo = VG_(malloc)(size+1);
+ f_clo = VG_(malloc)("commandline.rdv.1", size+1);
vg_assert(f_clo);
n = VG_(read)(fd.res, f_clo, size);
if (n == -1) n = 0;
@@ -154,17 +154,20 @@
vg_assert(!already_called);
already_called = True;
- tmp_xarray = VG_(newXA)( VG_(malloc), VG_(free), sizeof(HChar*) );
+ tmp_xarray = VG_(newXA)( VG_(malloc), "commandline.sua.1",
+ VG_(free), sizeof(HChar*) );
vg_assert(tmp_xarray);
vg_assert( ! VG_(args_for_valgrind) );
VG_(args_for_valgrind)
- = VG_(newXA)( VG_(malloc), VG_(free), sizeof(HChar*) );
+ = VG_(newXA)( VG_(malloc), "commandline.sua.2",
+ VG_(free), sizeof(HChar*) );
vg_assert( VG_(args_for_valgrind) );
vg_assert( ! VG_(args_for_client) );
VG_(args_for_client)
- = VG_(newXA)( VG_(malloc), VG_(free), sizeof(HChar*) );
+ = VG_(newXA)( VG_(malloc), "commandline.sua.3",
+ VG_(free), sizeof(HChar*) );
vg_assert( VG_(args_for_client) );
/* Collect up the args-for-V. */
@@ -203,7 +206,8 @@
// put into VG_(args_for_valgrind) and so must persist.
HChar* home = VG_(getenv)("HOME");
HChar* f1_clo = home ? read_dot_valgrindrc( home ) : NULL;
- HChar* env_clo = VG_(strdup)( VG_(getenv)(VALGRIND_OPTS) );
+ HChar* env_clo = VG_(strdup)( "commandline.sua.4",
+ VG_(getenv)(VALGRIND_OPTS) );
HChar* f2_clo = NULL;
// Don't read ./.valgrindrc if "." is the same as "$HOME", else its
Modified: branches/YARD/coregrind/m_coredump/coredump-elf.c
===================================================================
--- branches/YARD/coregrind/m_coredump/coredump-elf.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_coredump/coredump-elf.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -79,7 +79,7 @@
n_starts = 1;
while (True) {
- starts = VG_(malloc)( n_starts * sizeof(Addr) );
+ starts = VG_(malloc)( "coredump-elf.gss.1", n_starts * sizeof(Addr) );
if (starts == NULL)
break;
r = VG_(am_get_segment_starts)( starts, n_starts );
@@ -184,7 +184,7 @@
Int notelen = sizeof(struct note) +
VG_ROUNDUP(namelen, 4) +
VG_ROUNDUP(datasz, 4);
- struct note *n = VG_(arena_malloc)(VG_AR_CORE, notelen);
+ struct note *n = VG_(arena_malloc)(VG_AR_CORE, "coredump-elf.an.1", notelen);
VG_(memset)(n, 0, notelen);
@@ -349,7 +349,8 @@
notelist = NULL;
/* Second, work out their layout */
- phdrs = VG_(arena_malloc)(VG_AR_CORE, sizeof(*phdrs) * num_phdrs);
+ phdrs = VG_(arena_malloc)(VG_AR_CORE, "coredump-elf.mec.1",
+ sizeof(*phdrs) * num_phdrs);
for(i = 1; i < VG_N_THREADS; i++) {
vki_elf_fpregset_t fpu;
Modified: branches/YARD/coregrind/m_demangle/cp-demangle.c
===================================================================
--- branches/YARD/coregrind/m_demangle/cp-demangle.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_demangle/cp-demangle.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -51,9 +51,9 @@
#ifndef STANDALONE
#define size_t Int
-#define malloc(s) VG_(arena_malloc) (VG_AR_DEMANGLE, s)
-#define free(p) VG_(arena_free) (VG_AR_DEMANGLE, p)
-#define realloc(p,s) VG_(arena_realloc)(VG_AR_DEMANGLE, p, s)
+#define malloc(_cc,s) VG_(arena_malloc) (VG_AR_DEMANGLE, _cc, s)
+#define free(p) VG_(arena_free) (VG_AR_DEMANGLE, p)
+#define realloc(_cc,p,s) VG_(arena_realloc)(VG_AR_DEMANGLE, _cc, p, s)
#endif
/* If CP_DEMANGLE_DEBUG is defined, a trace of the grammar evaluation,
@@ -423,7 +423,8 @@
string_list_new (length)
int length;
{
- string_list_t s = (string_list_t) malloc (sizeof (struct string_list_def));
+ string_list_t s = (string_list_t) malloc ("demangle.sln.1",
+ sizeof (struct string_list_def));
if (s == NULL)
return NULL;
s->caret_position = 0;
@@ -594,7 +595,7 @@
sizeof (struct substitution_def) * dm->substitutions_allocated;
dm->substitutions = (struct substitution_def *)
- realloc (dm->substitutions, new_array_size);
+ realloc ("demangle.sa.1", dm->substitutions, new_array_size);
if (dm->substitutions == NULL)
/* Realloc failed. */
{
@@ -672,7 +673,8 @@
template_arg_list_new ()
{
template_arg_list_t new_list =
- (template_arg_list_t) malloc (sizeof (struct template_arg_list_def));
+ (template_arg_list_t) malloc ("demangle.talt.1",
+ sizeof (struct template_arg_list_def));
if (new_list == NULL)
return NULL;
/* Initialize the new list to have no arguments. */
@@ -820,7 +822,8 @@
int style;
{
demangling_t dm;
- dm = (demangling_t) malloc (sizeof (struct demangling_def));
+ dm = (demangling_t) malloc ("demangle.dn.1",
+ sizeof (struct demangling_def));
if (dm == NULL)
return NULL;
@@ -834,7 +837,8 @@
if (dm->last_source_name == NULL)
return NULL;
dm->substitutions = (struct substitution_def *)
- malloc (dm->substitutions_allocated * sizeof (struct substitution_def));
+ malloc ("demangle.dn.2",
+ dm->substitutions_allocated * sizeof (struct substitution_def));
if (dm->substitutions == NULL)
{
dyn_string_delete (dm->last_source_name);
Modified: branches/YARD/coregrind/m_demangle/cplus-dem.c
===================================================================
--- branches/YARD/coregrind/m_demangle/cplus-dem.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_demangle/cplus-dem.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -76,10 +76,10 @@
#ifndef STANDALONE
#define size_t Int
-#define xstrdup(ptr) VG_(arena_strdup) (VG_AR_DEMANGLE, ptr)
-#define free(ptr) VG_(arena_free) (VG_AR_DEMANGLE, ptr)
-#define xmalloc(size) VG_(arena_malloc) (VG_AR_DEMANGLE, size)
-#define xrealloc(ptr, size) VG_(arena_realloc)(VG_AR_DEMANGLE, ptr, size)
+#define xstrdup(_cc,ptr) VG_(arena_strdup) (VG_AR_DEMANGLE, _cc, ptr)
+#define free(ptr) VG_(arena_free) (VG_AR_DEMANGLE, ptr)
+#define xmalloc(_cc,size) VG_(arena_malloc) (VG_AR_DEMANGLE, _cc, size)
+#define xrealloc(_cc,ptr, size) VG_(arena_realloc)(VG_AR_DEMANGLE, _cc, ptr, size)
#define abort() vg_assert(0)
#undef strstr
@@ -948,7 +948,7 @@
struct work_stuff work[1];
if (current_demangling_style == no_demangling)
- return xstrdup (mangled);
+ return xstrdup ("demangle.cd.1", mangled);
memset ((char *) work, 0, sizeof (work));
work->options = options;
@@ -995,7 +995,7 @@
*size *= 2;
if (*size < min_size)
*size = min_size;
- *old_vect = xrealloc (*old_vect, *size * element_size);
+ *old_vect = xrealloc ("demangle.gv.1", *old_vect, *size * element_size);
}
}
@@ -1219,55 +1219,60 @@
/* Deep-copy dynamic storage. */
if (from->typevec_size)
to->typevec
- = (char **) xmalloc (from->typevec_size * sizeof (to->typevec[0]));
+ = (char **) xmalloc ("demangle.wsctf.1",
+ from->typevec_size * sizeof (to->typevec[0]));
for (i = 0; i < from->ntypes; i++)
{
int len = strlen (from->typevec[i]) + 1;
- to->typevec[i] = xmalloc (len);
+ to->typevec[i] = xmalloc ("demangle.wsctf.2", len);
memcpy (to->typevec[i], from->typevec[i], len);
}
if (from->ksize)
to->ktypevec
- = (char **) xmalloc (from->ksize * sizeof (to->ktypevec[0]));
+ = (char **) xmalloc ("demangle.wsctf.3",
+ from->ksize * sizeof (to->ktypevec[0]));
for (i = 0; i < from->numk; i++)
{
int len = strlen (from->ktypevec[i]) + 1;
- to->ktypevec[i] = xmalloc (len);
+ to->ktypevec[i] = xmalloc ("demangle.wsctf.4", len);
memcpy (to->ktypevec[i], from->ktypevec[i], len);
}
if (from->bsize)
to->btypevec
- = (char **) xmalloc (from->bsize * sizeof (to->btypevec[0]));
+ = (char **) xmalloc ("demangle.wsctf.5",
+ from->bsize * sizeof (to->btypevec[0]));
for (i = 0; i < from->numb; i++)
{
int len = strlen (from->btypevec[i]) + 1;
- to->btypevec[i] = xmalloc (len);
+ to->btypevec[i] = xmalloc ("demangle.wsctf.6", len);
memcpy (to->btypevec[i], from->btypevec[i], len);
}
if (from->ntmpl_args)
to->tmpl_argvec
- = xmalloc (from->ntmpl_args * sizeof (to->tmpl_argvec[0]));
+ = xmalloc ("demangle.wsctf.7",
+ from->ntmpl_args * sizeof (to->tmpl_argvec[0]));
for (i = 0; i < from->ntmpl_args; i++)
{
int len = strlen (from->tmpl_argvec[i]) + 1;
- to->tmpl_argvec[i] = xmalloc (len);
+ to->tmpl_argvec[i] = xmalloc ("demangle.wsctf.8", len);
memcpy (to->tmpl_argvec[i], from->tmpl_argvec[i], len);
}
if (from->previous_argument)
{
- to->previous_argument = (string*) xmalloc (sizeof (string));
+ to->previous_argument = (string*) xmalloc ("demangle.wsctf.9",
+ sizeof (string));
string_init (to->previous_argument);
string_appends (to->previous_argument, from->previous_argument);
}
@@ -2018,7 +2023,7 @@
string_appendn (s, "0", 1);
else
{
- char *p = xmalloc (symbol_len + 1), *q;
+ char *p = xmalloc ("demangle.dtvp.1", symbol_len + 1), *q;
strncpy (p, *mangled, symbol_len);
p [symbol_len] = '\0';
/* We use cplus_demangle here, rather than
@@ -2133,7 +2138,8 @@
if (!is_type)
{
/* Create an array for saving the template argument values. */
- work->tmpl_argvec = (char**) xmalloc (r * sizeof (char *));
+ work->tmpl_argvec = (char**) xmalloc ("demangle.dt.1",
+ r * sizeof (char *));
work->ntmpl_args = r;
for (i = 0; i < r; i++)
work->tmpl_argvec[i] = 0;
@@ -2158,7 +2164,7 @@
{
/* Save the template argument. */
int len = temp.p - temp.b;
- work->tmpl_argvec[i] = xmalloc (len + 1);
+ work->tmpl_argvec[i] = xmalloc ("demangle.dt.2", len + 1);
memcpy (work->tmpl_argvec[i], temp.b, len);
work->tmpl_argvec[i][len] = '\0';
}
@@ -2186,7 +2192,7 @@
{
/* Save the template argument. */
int len = r2;
- work->tmpl_argvec[i] = xmalloc (len + 1);
+ work->tmpl_argvec[i] = xmalloc ("demangle.dt.3", len + 1);
memcpy (work->tmpl_argvec[i], *mangled, len);
work->tmpl_argvec[i][len] = '\0';
}
@@ -2232,7 +2238,7 @@
if (!is_type)
{
int len = s->p - s->b;
- work->tmpl_argvec[i] = xmalloc (len + 1);
+ work->tmpl_argvec[i] = xmalloc ("demangle.dt.4", len + 1);
memcpy (work->tmpl_argvec[i], s->b, len);
work->tmpl_argvec[i][len] = '\0';
@@ -3131,7 +3137,7 @@
char * recurse = (char *)NULL;
char * recurse_dem = (char *)NULL;
- recurse = (char *) xmalloc (namelength + 1);
+ recurse = (char *) xmalloc ("demangle.rd.1", namelength + 1);
memcpy (recurse, *mangled, namelength);
recurse[namelength] = '\000';
@@ -4130,7 +4136,7 @@
string_append (result, "&");
/* Now recursively demangle the literal name */
- recurse = (char *) xmalloc (literal_len + 1);
+ recurse = (char *) xmalloc ("demangle.dhtl.1", literal_len + 1);
memcpy (recurse, *mangled, literal_len);
recurse[literal_len] = '\000';
@@ -4240,7 +4246,8 @@
string_clear (work->previous_argument);
else
{
- work->previous_argument = (string*) xmalloc (sizeof (string));
+ work->previous_argument = (string*) xmalloc ("demangle.da.1",
+ sizeof (string));
string_init (work->previous_argument);
}
@@ -4275,17 +4282,18 @@
{
work -> typevec_size = 3;
work -> typevec
- = (char **) xmalloc (sizeof (char *) * work -> typevec_size);
+ = (char **) xmalloc ("demangle.rt.1",
+ sizeof (char *) * work -> typevec_size);
}
else
{
work -> typevec_size *= 2;
work -> typevec
- = (char **) xrealloc ((char *)work -> typevec,
+ = (char **) xrealloc ("demangle.rt.2", (char *)work -> typevec,
sizeof (char *) * work -> typevec_size);
}
}
- tem = xmalloc (len + 1);
+ tem = xmalloc ("demangle.rt.3", len + 1);
memcpy (tem, start, len);
tem[len] = '\0';
work -> typevec[work -> ntypes++] = tem;
@@ -4307,17 +4315,18 @@
{
work -> ksize = 5;
work -> ktypevec
- = (char **) xmalloc (sizeof (char *) * work -> ksize);
+ = (char **) xmalloc ("demangle.rK.1",
+ sizeof (char *) * work -> ksize);
}
else
{
work -> ksize *= 2;
work -> ktypevec
- = (char **) xrealloc ((char *)work -> ktypevec,
+ = (char **) xrealloc ("demangle.rK.2", (char *)work -> ktypevec,
sizeof (char *) * work -> ksize);
}
}
- tem = xmalloc (len + 1);
+ tem = xmalloc ("demangle.rK.3", len + 1);
memcpy (tem, start, len);
tem[len] = '\0';
work -> ktypevec[work -> numk++] = tem;
@@ -4339,13 +4348,14 @@
{
work -> bsize = 5;
work -> btypevec
- = (char **) xmalloc (sizeof (char *) * work -> bsize);
+ = (char **) xmalloc ("demangle.rB.1",
+ sizeof (char *) * work -> bsize);
}
else
{
work -> bsize *= 2;
work -> btypevec
- = (char **) xrealloc ((char *)work -> btypevec,
+ = (char **) xrealloc ("demangle.rB.2", (char *)work -> btypevec,
sizeof (char *) * work -> bsize);
}
}
@@ -4364,7 +4374,7 @@
{
char *tem;
- tem = xmalloc (len + 1);
+ tem = xmalloc ("demangle.remember_Btype.1", len + 1);
memcpy (tem, start, len);
tem[len] = '\0';
work -> btypevec[ind] = tem;
@@ -4815,7 +4825,7 @@
{
n = 32;
}
- s->p = s->b = xmalloc (n);
+ s->p = s->b = xmalloc ("demangle.sn.1", n);
s->e = s->b + n;
}
else if (s->e - s->p < n)
@@ -4823,7 +4833,7 @@
tem = s->p - s->b;
n += tem;
n *= 2;
- s->b = xrealloc (s->b, n);
+ s->b = xrealloc ("demangle.sn.2", s->b, n);
s->p = s->b + tem;
s->e = s->b + n;
}
Modified: branches/YARD/coregrind/m_demangle/dyn-string.c
===================================================================
--- branches/YARD/coregrind/m_demangle/dyn-string.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_demangle/dyn-string.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -39,9 +39,9 @@
#include "dyn-string.h"
#ifndef STANDALONE
-#define malloc(s) VG_(arena_malloc) (VG_AR_DEMANGLE, s)
-#define free(p) VG_(arena_free) (VG_AR_DEMANGLE, p)
-#define realloc(p,s) VG_(arena_realloc)(VG_AR_DEMANGLE, p, s)
+#define malloc(_cc,s) VG_(arena_malloc) (VG_AR_DEMANGLE, _cc, s)
+#define free(p) VG_(arena_free) (VG_AR_DEMANGLE, p)
+#define realloc(_cc,p,s) VG_(arena_realloc)(VG_AR_DEMANGLE, _cc, p, s)
#endif
/* If this file is being compiled for inclusion in the C++ runtime
@@ -77,7 +77,7 @@
if (ds_struct_ptr->s == NULL)
return 0;
#else
- ds_struct_ptr->s = (char *) malloc (space);
+ ds_struct_ptr->s = (char *) malloc ("demangle.dsi.1", space);
#endif
ds_struct_ptr->allocated = space;
ds_struct_ptr->length = 0;
@@ -98,7 +98,7 @@
{
dyn_string_t result;
#ifdef RETURN_ON_ALLOCATION_FAILURE
- result = (dyn_string_t) malloc (sizeof (struct dyn_string));
+ result = (dyn_string_t) malloc ("demangle.dsn.1", sizeof (struct dyn_string));
if (result == NULL)
return NULL;
if (!dyn_string_init (result, space))
@@ -107,7 +107,7 @@
return NULL;
}
#else
- result = (dyn_string_t) malloc (sizeof (struct dyn_string));
+ result = (dyn_string_t) malloc ("demangle.dsn.2", sizeof (struct dyn_string));
dyn_string_init (result, space);
#endif
return result;
@@ -167,14 +167,14 @@
ds->allocated = new_allocated;
/* We actually need more space. */
#ifdef RETURN_ON_ALLOCATION_FAILURE
- ds->s = (char *) realloc (ds->s, ds->allocated);
+ ds->s = (char *) realloc ("demangle.dsr.1", ds->s, ds->allocated);
if (ds->s == NULL)
{
free (ds);
return NULL;
}
#else
- ds->s = (char *) realloc (ds->s, ds->allocated);
+ ds->s = (char *) realloc ("demangle.dsr.2", ds->s, ds->allocated);
#endif
}
Modified: branches/YARD/coregrind/m_errormgr.c
===================================================================
--- branches/YARD/coregrind/m_errormgr.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_errormgr.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -600,7 +600,7 @@
*/
/* copy main part */
- p = VG_(arena_malloc)(VG_AR_ERRORS, sizeof(Error));
+ p = VG_(arena_malloc)(VG_AR_ERRORS, "errormgr.mre.1", sizeof(Error));
*p = err;
/* update 'extra' */
@@ -618,7 +618,7 @@
/* copy block pointed to by 'extra', if there is one */
if (NULL != p->extra && 0 != extra_size) {
- void* new_extra = VG_(malloc)(extra_size);
+ void* new_extra = VG_(malloc)("errormgr.mre.2", extra_size);
VG_(memcpy)(new_extra, p->extra, extra_size);
p->extra = new_extra;
}
@@ -979,7 +979,8 @@
while (True) {
/* Assign and initialise the two suppression halves (core and tool) */
Supp* supp;
- supp = VG_(arena_malloc)(VG_AR_CORE, sizeof(Supp));
+ supp = VG_(arena_malloc)(VG_AR_CORE, "errormgr.losf.1",
+ sizeof(Supp));
supp->count = 0;
// Initialise temporary reading-in buffer.
@@ -999,7 +1000,7 @@
if (eof || VG_STREQ(buf, "}")) BOMB("unexpected '}'");
- supp->sname = VG_(arena_strdup)(VG_AR_CORE, buf);
+ supp->sname = VG_(arena_strdup)(VG_AR_CORE, "errormgr.losf.2", buf);
eof = VG_(get_line) ( fd, buf, N_BUF );
@@ -1069,7 +1070,8 @@
BOMB("too many callers in stack trace");
if (i > 0 && i >= VG_(clo_backtrace_size))
break;
- tmp_callers[i].name = VG_(arena_strdup)(VG_AR_CORE, buf);
+ tmp_callers[i].name = VG_(arena_strdup)(VG_AR_CORE,
+ "errormgr.losf.3", buf);
if (!setLocationTy(&(tmp_callers[i])))
BOMB("location should start with 'fun:' or 'obj:'");
i++;
@@ -1085,7 +1087,8 @@
// Copy tmp_callers[] into supp->callers[]
supp->n_callers = i;
- supp->callers = VG_(arena_malloc)(VG_AR_CORE, i*sizeof(SuppLoc));
+ supp->callers = VG_(arena_malloc)(VG_AR_CORE, "errormgr.losf.4",
+ i*sizeof(SuppLoc));
for (i = 0; i < supp->n_callers; i++) {
supp->callers[i] = tmp_callers[i];
}
Modified: branches/YARD/coregrind/m_execontext.c
===================================================================
--- branches/YARD/coregrind/m_execontext.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_execontext.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -135,7 +135,7 @@
ec_htab_size_idx = 0;
ec_htab_size = ec_primes[ec_htab_size_idx];
- ec_htab = VG_(arena_malloc)(VG_AR_EXECTXT,
+ ec_htab = VG_(arena_malloc)(VG_AR_EXECTXT, "execontext.iEs1",
sizeof(ExeContext*) * ec_htab_size);
for (i = 0; i < ec_htab_size; i++)
ec_htab[i] = NULL;
@@ -260,7 +260,7 @@
return; /* out of primes - can't resize further */
new_size = ec_primes[ec_htab_size_idx + 1];
- new_ec_htab = VG_(arena_malloc)(VG_AR_EXECTXT,
+ new_ec_htab = VG_(arena_malloc)(VG_AR_EXECTXT, "execontext.reh1",
sizeof(ExeContext*) * new_size);
VG_(debugLog)(
@@ -395,7 +395,7 @@
/* Bummer. We have to allocate a new context record. */
ec_totstored++;
- new_ec = VG_(arena_malloc)( VG_AR_EXECTXT,
+ new_ec = VG_(arena_malloc)( VG_AR_EXECTXT, "execontext.rEw2.2",
sizeof(struct _ExeContext)
+ n_ips * sizeof(Addr) );
Modified: branches/YARD/coregrind/m_hashtable.c
===================================================================
--- branches/YARD/coregrind/m_hashtable.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_hashtable.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -69,8 +69,9 @@
/* Initialises to zero, ie. all entries NULL */
SizeT n_chains = primes[0];
SizeT sz = n_chains * sizeof(VgHashNode*);
- VgHashTable table = VG_(calloc)(1, sizeof(struct _VgHashTable));
- table->chains = VG_(calloc)(1, sz);
+ VgHashTable table = VG_(calloc)("hashtable.Hc.1",
+ 1, sizeof(struct _VgHashTable));
+ table->chains = VG_(calloc)("hashtable.Hc.2", 1, sz);
table->n_chains = n_chains;
table->n_elements = 0;
table->iterOK = True;
@@ -119,7 +120,7 @@
table->n_chains = new_chains;
sz = new_chains * sizeof(VgHashNode*);
- chains = VG_(calloc)(1, sz);
+ chains = VG_(calloc)("hashtable.resize.1", 1, sz);
for (i = 0; i < old_chains; i++) {
node = table->chains[i];
@@ -209,7 +210,7 @@
if (*n_elems == 0)
return NULL;
- arr = VG_(malloc)( *n_elems * sizeof(VgHashNode*) );
+ arr = VG_(malloc)( "hashtable.Hta.1", *n_elems * sizeof(VgHashNode*) );
j = 0;
for (i = 0; i < table->n_chains; i++) {
Modified: branches/YARD/coregrind/m_initimg/initimg-linux.c
===================================================================
--- branches/YARD/coregrind/m_initimg/initimg-linux.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_initimg/initimg-linux.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -241,12 +241,13 @@
Int preload_tool_path_len = vglib_len + VG_(strlen)(toolname)
+ sizeof(VG_PLATFORM) + 16;
Int preload_string_len = preload_core_path_len + preload_tool_path_len;
- HChar* preload_string = VG_(malloc)(preload_string_len);
+ HChar* preload_string = VG_(malloc)("initimg-linux.sce.1",
+ preload_string_len);
vg_assert(preload_string);
/* Determine if there's a vgpreload_<tool>.so file, and setup
preload_string. */
- preload_tool_path = VG_(malloc)(preload_tool_path_len);
+ preload_tool_path = VG_(malloc)("initimg-linux.sce.2", preload_tool_path_len);
vg_assert(preload_tool_path);
VG_(snprintf)(preload_tool_path, preload_tool_path_len,
"%s/%s/vgpreload_%s.so", VG_(libdir), VG_PLATFORM, toolname);
@@ -268,7 +269,8 @@
envc++;
/* Allocate a new space */
- ret = VG_(malloc) (sizeof(HChar *) * (envc+1+1)); /* 1 new entry + NULL */
+ ret = VG_(malloc) ("initimg-linux.sce.3",
+ sizeof(HChar *) * (envc+1+1)); /* 1 new entry + NULL */
vg_assert(ret);
/* copy it over */
@@ -282,7 +284,7 @@
for (cpp = ret; cpp && *cpp; cpp++) {
if (VG_(memcmp)(*cpp, ld_preload, ld_preload_len) == 0) {
Int len = VG_(strlen)(*cpp) + preload_string_len;
- HChar *cp = VG_(malloc)(len);
+ HChar *cp = VG_(malloc)("initimg-linux.sce.4", len);
vg_assert(cp);
VG_(snprintf)(cp, len, "%s%s:%s",
@@ -297,7 +299,7 @@
/* Add the missing bits */
if (!ld_preload_done) {
Int len = ld_preload_len + preload_string_len;
- HChar *cp = VG_(malloc) (len);
+ HChar *cp = VG_(malloc) ("initimg-linux.sce.5", len);
vg_assert(cp);
VG_(snprintf)(cp, len, "%s%s", ld_preload, preload_string);
Modified: branches/YARD/coregrind/m_libcproc.c
===================================================================
--- branches/YARD/coregrind/m_libcproc.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_libcproc.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -89,7 +89,8 @@
Char **env = (*envp);
Char **cpp;
Int len = VG_(strlen)(varname);
- Char *valstr = VG_(arena_malloc)(VG_AR_CORE, len + VG_(strlen)(val) + 2);
+ Char *valstr = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.1",
+ len + VG_(strlen)(val) + 2);
Char **oldenv = NULL;
VG_(sprintf)(valstr, "%s=%s", varname, val);
@@ -102,7 +103,7 @@
}
if (env == NULL) {
- env = VG_(arena_malloc)(VG_AR_CORE, sizeof(Char **) * 2);
+ env = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.2", sizeof(Char **) * 2);
env[0] = valstr;
env[1] = NULL;
@@ -110,7 +111,8 @@
} else {
Int envlen = (cpp-env) + 2;
- Char **newenv = VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Char **));
+ Char **newenv = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.3",
+ envlen * sizeof(Char **));
for (cpp = newenv; *env; )
*cpp++ = *env++;
@@ -203,7 +205,8 @@
ld_library_path_str = &envp[i][16];
}
- buf = VG_(arena_malloc)(VG_AR_CORE, VG_(strlen)(VG_(libdir)) + 20);
+ buf = VG_(arena_malloc)(VG_AR_CORE, "libcproc.erves.1",
+ VG_(strlen)(VG_(libdir)) + 20);
// Remove Valgrind-specific entries from LD_*.
VG_(sprintf)(buf, "%s*/vgpreload_*.so", VG_(libdir));
@@ -253,7 +256,8 @@
envlen = oldenvp - oldenv + 1;
- newenv = VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Char **));
+ newenv = VG_(arena_malloc)(VG_AR_CORE, "libcproc.ec.1",
+ envlen * sizeof(Char **));
oldenvp = oldenv;
newenvp = newenv;
Modified: branches/YARD/coregrind/m_main.c
===================================================================
--- branches/YARD/coregrind/m_main.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_main.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -170,6 +170,7 @@
" --debug-dump=frames mimic /usr/bin/readelf --debug-dump=frames\n"
" --trace-redir=no|yes show redirection details? [no]\n"
" --trace-sched=no|yes show thread scheduler details? [no]\n"
+" --profile-heap=no|yes profile Valgrind's own space use\n"
" --wait-for-gdb=yes|no pause on startup to wait for gdb attach\n"
" --sym-offsets=yes|no show syms in form 'name+offset' ? [no]\n"
" --read-var-info=yes|no read variable type & location info? [no]\n"
@@ -364,7 +365,7 @@
// wouldn't disappear on them.)
if (0)
VG_(printf)("tool-specific arg: %s\n", arg);
- arg = VG_(strdup)(arg + toolname_len + 1);
+ arg = VG_(strdup)("main.mpclo.1", arg + toolname_len + 1);
arg[0] = '-';
arg[1] = '-';
@@ -419,7 +420,7 @@
else VG_BOOL_CLO(arg, "--trace-redir", VG_(clo_trace_redir))
else VG_BOOL_CLO(arg, "--trace-syscalls", VG_(clo_trace_syscalls))
- else VG_BOOL_CLO(arg, "--trace-pthreads", VG_(clo_trace_pthreads))
+ else VG_BOOL_CLO(arg, "--profile-heap", VG_(clo_profile_heap))
else VG_BOOL_CLO(arg, "--wait-for-gdb", VG_(clo_wait_for_gdb))
else VG_STR_CLO (arg, "--db-command", VG_(clo_db_command))
else VG_STR_CLO (arg, "--sim-hints", VG_(clo_sim_hints))
@@ -595,6 +596,8 @@
VG_(clo_track_fds) = False;
/* Disable timestamped output */
VG_(clo_time_stamp) = False;
+ /* Disable heap profiling, since that prints lots of stuff. */
+ VG_(clo_profile_heap) = False;
/* Also, we want to set options for the leak checker, but that
will have to be done in Memcheck's flag-handling code, not
here. */
@@ -710,7 +713,7 @@
the default one. */
static const Char default_supp[] = "default.supp";
Int len = VG_(strlen)(VG_(libdir)) + 1 + sizeof(default_supp);
- Char *buf = VG_(arena_malloc)(VG_AR_CORE, len);
+ Char *buf = VG_(arena_malloc)(VG_AR_CORE, "main.mpclo.2", len);
VG_(sprintf)(buf, "%s/%s", VG_(libdir), default_supp);
VG_(clo_suppressions)[VG_(clo_n_suppressions)] = buf;
VG_(clo_n_suppressions)++;
@@ -1151,7 +1154,7 @@
n_starts = 1;
while (True) {
- starts = VG_(malloc)( n_starts * sizeof(Addr) );
+ starts = VG_(malloc)( "main.gss.1", n_starts * sizeof(Addr) );
if (starts == NULL)
break;
r = VG_(am_get_segment_starts)( starts, n_starts );
@@ -1330,7 +1333,7 @@
// free pair right now to check that nothing is broken.
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Starting the dynamic memory manager\n");
- { void* p = VG_(malloc)( 12345 );
+ { void* p = VG_(malloc)( "main.vm.1", 12345 );
if (p) VG_(free)( p );
}
VG_(debugLog)(1, "main", "Dynamic memory manager is running\n");
@@ -2076,6 +2079,14 @@
if (VG_(clo_verbosity) > 1)
print_all_stats();
+ /* Show a profile of the heap(s) at shutdown. Optionally, first
+ throw away all the debug info, as that makes it easy to spot
+ leaks in the debuginfo reader. */
+ if (VG_(clo_profile_heap)) {
+ if (0) VG_(di_discard_ALL_debuginfo)();
+ VG_(print_arena_cc_analysis)();
+ }
+
if (VG_(clo_profile_flags) > 0) {
#define N_MAX 200
BBProfEntry tops[N_MAX];
Modified: branches/YARD/coregrind/m_options.c
===================================================================
--- branches/YARD/coregrind/m_options.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_options.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -75,7 +75,7 @@
Bool VG_(clo_debug_dump_frames) = False;
Bool VG_(clo_trace_redir) = False;
Bool VG_(clo_trace_sched) = False;
-Bool VG_(clo_trace_pthreads) = False;
+Bool VG_(clo_profile_heap) = False;
Int VG_(clo_dump_error) = 0;
Int VG_(clo_backtrace_size) = 12;
Char* VG_(clo_sim_hints) = NULL;
@@ -153,7 +153,7 @@
// The 10 is slop, it should be enough in most cases.
len = j + VG_(strlen)(format) + 10;
- out = VG_(malloc)( len );
+ out = VG_(malloc)( "options.efn.1", len );
if (format[0] != '/') {
VG_(strcpy)(out, base_dir);
out[j++] = '/';
@@ -162,7 +162,7 @@
#define ENSURE_THIS_MUCH_SPACE(x) \
if (j + x >= len) { \
len += (10 + x); \
- out = VG_(realloc)(out, len); \
+ out = VG_(realloc)("options.efn.2(multiple)", out, len); \
}
while (format[i]) {
@@ -240,7 +240,8 @@
bad: {
Char* opt = // 2: 1 for the '=', 1 for the NUL.
- VG_(malloc)( VG_(strlen)(option_name) + VG_(strlen)(format) + 2 );
+ VG_(malloc)( "options.efn.3",
+ VG_(strlen)(option_name) + VG_(strlen)(format) + 2 );
VG_(strcpy)(opt, option_name);
VG_(strcat)(opt, "=");
VG_(strcat)(opt, format);
Modified: branches/YARD/coregrind/m_oset.c
===================================================================
--- branches/YARD/coregrind/m_oset.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_oset.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -112,6 +112,7 @@
SizeT keyOff; // key offset
OSetCmp_t cmp; // compare a key and an element, or NULL
OSetAlloc_t alloc; // allocator
+ HChar* cc; // cc for allocator
OSetFree_t free; // deallocator
Word nElems; // number of elements in the tree
AvlNode* root; // root node
@@ -282,7 +283,8 @@
// The underscores avoid GCC complaints about overshadowing global names.
AvlTree* VG_(OSetGen_Create)(OffT _keyOff, OSetCmp_t _cmp,
- OSetAlloc_t _alloc, OSetFree_t _free)
+ OSetAlloc_t _alloc, HChar* _cc,
+ OSetFree_t _free)
{
AvlTree* t;
@@ -294,10 +296,11 @@
vg_assert(_free);
if (!_cmp) vg_assert(0 == _keyOff); // If no cmp, offset must be zero
- t = _alloc(sizeof(AvlTree));
+ t = _alloc(_cc, sizeof(AvlTree));
t->keyOff = _keyOff;
t->cmp = _cmp;
t->alloc = _alloc;
+ t->cc = _cc;
t->free = _free;
t->nElems = 0;
t->root = NULL;
@@ -306,9 +309,10 @@
return t;
}
-AvlTree* VG_(OSetWord_Create)(OSetAlloc_t _alloc, OSetFree_t _free)
+AvlTree* VG_(OSetWord_Create)(OSetAlloc_t _alloc, HChar* _cc,
+ OSetFree_t _free)
{
- return VG_(OSetGen_Create)(/*keyOff*/0, /*cmp*/NULL, _alloc, _free);
+ return VG_(OSetGen_Create)(/*keyOff*/0, /*cmp*/NULL, _alloc, _cc, _free);
}
// Destructor, frees up all memory held by remaining nodes.
@@ -356,7 +360,7 @@
void* VG_(OSetGen_AllocNode)(AvlTree* t, SizeT elemSize)
{
Int nodeSize = sizeof(AvlNode) + elemSize;
- AvlNode* n = t->alloc( nodeSize );
+ AvlNode* n = t->alloc( t->cc, nodeSize );
vg_assert(elemSize > 0);
VG_(memset)(n, 0, nodeSize);
n->magic = OSET_MAGIC;
Modified: branches/YARD/coregrind/m_redir.c
===================================================================
--- branches/YARD/coregrind/m_redir.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_redir.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -280,9 +280,9 @@
static void maybe_add_active ( Active /*by value; callee copies*/ );
-static void* dinfo_zalloc(SizeT);
+static void* dinfo_zalloc(HChar* ec, SizeT);
static void dinfo_free(void*);
-static HChar* dinfo_strdup(HChar*);
+static HChar* dinfo_strdup(HChar* ec, HChar*);
static Bool is_plausible_guest_addr(Addr);
static Bool is_aix5_glink_idiom(Addr);
@@ -369,10 +369,10 @@
the following loop, and complain at that point. */
continue;
}
- spec = dinfo_zalloc(sizeof(Spec));
+ spec = dinfo_zalloc("redir.rnnD.1", sizeof(Spec));
vg_assert(spec);
- spec->from_sopatt = dinfo_strdup(demangled_sopatt);
- spec->from_fnpatt = dinfo_strdup(demangled_fnpatt);
+ spec->from_sopatt = dinfo_strdup("redir.rnnD.2", demangled_sopatt);
+ spec->from_fnpatt = dinfo_strdup("redir.rnnD.3", demangled_fnpatt);
vg_assert(spec->from_sopatt);
vg_assert(spec->from_fnpatt);
spec->to_addr = sym_addr;
@@ -418,7 +418,7 @@
/* Ok. Now specList holds the list of specs from the DebugInfo.
Build a new TopSpec, but don't add it to topSpecs yet. */
- newts = dinfo_zalloc(sizeof(TopSpec));
+ newts = dinfo_zalloc("redir.rnnD.4", sizeof(TopSpec));
vg_assert(newts);
newts->next = NULL; /* not significant */
newts->seginfo = newsi;
@@ -691,7 +691,7 @@
/* Traverse the actives, copying the addresses of those we intend
to delete into tmpSet. */
- tmpSet = VG_(OSetWord_Create)(dinfo_zalloc, dinfo_free);
+ tmpSet = VG_(OSetWord_Create)(dinfo_zalloc, "redir.rndD.1", dinfo_free);
ts->mark = True;
@@ -809,11 +809,11 @@
Addr to_addr,
const HChar* const mandatory )
{
- Spec* spec = dinfo_zalloc(sizeof(Spec));
+ Spec* spec = dinfo_zalloc("redir.ahs.1", sizeof(Spec));
vg_assert(spec);
if (topSpecs == NULL) {
- topSpecs = dinfo_zalloc(sizeof(TopSpec));
+ topSpecs = dinfo_zalloc("redir.ahs.2", sizeof(TopSpec));
vg_assert(topSpecs);
/* symtab_zalloc sets all fields to zero */
}
@@ -851,6 +851,7 @@
activeSet = VG_(OSetGen_Create)(offsetof(Active, from_addr),
NULL, // Use fast comparison
dinfo_zalloc,
+ "redir.ri.1",
dinfo_free);
// The rest of this function just adds initial Specs.
@@ -970,10 +971,10 @@
/*--- MISC HELPERS ---*/
/*------------------------------------------------------------*/
-static void* dinfo_zalloc(SizeT n) {
+static void* dinfo_zalloc(HChar* ec, SizeT n) {
void* p;
vg_assert(n > 0);
- p = VG_(arena_malloc)(VG_AR_DINFO, n);
+ p = VG_(arena_malloc)(VG_AR_DINFO, ec, n);
tl_assert(p);
VG_(memset)(p, 0, n);
return p;
@@ -984,9 +985,9 @@
return VG_(arena_free)(VG_AR_DINFO, p);
}
-static HChar* dinfo_strdup(HChar* str)
+static HChar* dinfo_strdup(HChar* ec, HChar* str)
{
- return VG_(arena_strdup)(VG_AR_DINFO, str);
+ return VG_(arena_strdup)(VG_AR_DINFO, ec, str);
}
/* Really this should be merged with translations_allowable_from_seg
Modified: branches/YARD/coregrind/m_replacemalloc/replacemalloc_core.c
===================================================================
--- branches/YARD/coregrind/m_replacemalloc/replacemalloc_core.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_replacemalloc/replacemalloc_core.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -98,9 +98,11 @@
// 'align' should be valid (ie. big enough and a power of two) by now.
// VG_(arena_memalign)() will abort if it's not.
if (VG_MIN_MALLOC_SZB == align)
- return VG_(arena_malloc) ( VG_AR_CLIENT, nbytes );
+ return VG_(arena_malloc) ( VG_AR_CLIENT, "replacemalloc.cm.1",
+ nbytes );
else
- return VG_(arena_memalign) ( VG_AR_CLIENT, align, nbytes );
+ return VG_(arena_memalign) ( VG_AR_CLIENT, "replacemalloc.cm.2",
+ align, nbytes );
}
void VG_(cli_free) ( void* p )
Modified: branches/YARD/coregrind/m_signals.c
===================================================================
--- branches/YARD/coregrind/m_signals.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_signals.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -1528,7 +1528,8 @@
block_all_host_signals(&savedmask);
if (tst->sig_queue == NULL) {
- tst->sig_queue = VG_(arena_malloc)(VG_AR_CORE, sizeof(*tst->sig_queue));
+ tst->sig_queue = VG_(arena_malloc)(VG_AR_CORE, "signals.qs.1",
+ sizeof(*tst->sig_queue));
VG_(memset)(tst->sig_queue, 0, sizeof(*tst->sig_queue));
}
sq = tst->sig_queue;
Modified: branches/YARD/coregrind/m_stacks.c
===================================================================
--- branches/YARD/coregrind/m_stacks.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_stacks.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -185,7 +185,7 @@
start = t;
}
- i = (Stack *)VG_(arena_malloc)(VG_AR_CORE, sizeof(Stack));
+ i = (Stack *)VG_(arena_malloc)(VG_AR_CORE, "stacks.rs.1", sizeof(Stack));
i->start = start;
i->end = end;
i->id = next_id++;
Modified: branches/YARD/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- branches/YARD/coregrind/m_syswrap/syswrap-generic.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_syswrap/syswrap-generic.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -539,7 +539,7 @@
/* Not already one: allocate an OpenFd */
if (i == NULL) {
- i = VG_(arena_malloc)(VG_AR_CORE, sizeof(OpenFd));
+ i = VG_(arena_malloc)(VG_AR_CORE, "syswrap.rfdowgn.1", sizeof(OpenFd));
i->prev = NULL;
i->next = allocated_fds;
@@ -549,7 +549,7 @@
}
i->fd = fd;
- i->pathname = VG_(arena_strdup)(VG_AR_CORE, pathname);
+ i->pathname = VG_(arena_strdup)(VG_AR_CORE, "syswrap.rfdowgn.2", pathname);
i->where = (tid == -1) ? NULL : VG_(record_ExeContext)(tid, 0/*first_ip_delta*/);
}
@@ -752,10 +752,10 @@
}
static
-Char *strdupcat ( const Char *s1, const Char *s2, ArenaId aid )
+Char *strdupcat ( HChar* cc, const Char *s1, const Char *s2, ArenaId aid )
{
UInt len = VG_(strlen) ( s1 ) + VG_(strlen) ( s2 ) + 1;
- Char *result = VG_(arena_malloc) ( aid, len );
+ Char *result = VG_(arena_malloc) ( aid, cc, len );
VG_(strcpy) ( result, s1 );
VG_(strcat) ( result, s2 );
return result;
@@ -765,7 +765,8 @@
void pre_mem_read_sendmsg ( ThreadId tid, Bool read,
Char *msg, Addr base, SizeT size )
{
- Char *outmsg = strdupcat ( "socketcall.sendmsg", msg, VG_AR_CORE );
+ Char *outmsg = strdupcat ( "di.syswrap.pmrs.1",
+ "socketcall.sendmsg", msg, VG_AR_CORE );
PRE_MEM_READ( outmsg, base, size );
VG_(arena_free) ( VG_AR_CORE, outmsg );
}
@@ -774,7 +775,8 @@
void pre_mem_write_recvmsg ( ThreadId tid, Bool read,
Char *msg, Addr base, SizeT size )
{
- Char *outmsg = strdupcat ( "socketcall.recvmsg", msg, VG_AR_CORE );
+ Char *outmsg = strdupcat ( "di.syswrap.pmwr.1",
+ "socketcall.recvmsg", msg, VG_AR_CORE );
if ( read )
PRE_MEM_READ( outmsg, base, size );
else
@@ -866,7 +868,7 @@
/* NULL/zero-length sockaddrs are legal */
if ( sa == NULL || salen == 0 ) return;
- outmsg = VG_(arena_malloc) ( VG_AR_CORE,
+ outmsg = VG_(arena_malloc) ( VG_AR_CORE, "di.syswrap.pmr_sockaddr.1",
VG_(strlen)( description ) + 30 );
VG_(sprintf) ( outmsg, description, ".sa_family" );
@@ -2553,7 +2555,8 @@
tot_args++;
}
// allocate
- argv = VG_(malloc)( (tot_args+1) * sizeof(HChar*) );
+ argv = VG_(malloc)( "di.syswrap.pre_sys_execve.1",
+ (tot_args+1) * sizeof(HChar*) );
if (argv == 0) goto hosed;
// copy
j = 0;
Modified: branches/YARD/coregrind/m_syswrap/syswrap-x86-linux.c
===================================================================
--- branches/YARD/coregrind/m_syswrap/syswrap-x86-linux.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_syswrap/syswrap-x86-linux.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -444,14 +444,14 @@
static VexGuestX86SegDescr* alloc_zeroed_x86_GDT ( void )
{
Int nbytes = VEX_GUEST_X86_GDT_NENT * sizeof(VexGuestX86SegDescr);
- return VG_(arena_calloc)(VG_AR_CORE, nbytes, 1);
+ return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxG.1", nbytes, 1);
}
/* Create a zeroed-out LDT. */
static VexGuestX86SegDescr* alloc_zeroed_x86_LDT ( void )
{
Int nbytes = VEX_GUEST_X86_LDT_NENT * sizeof(VexGuestX86SegDescr);
- return VG_(arena_calloc)(VG_AR_CORE, nbytes, 1);
+ return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxL.1", nbytes, 1);
}
/* Free up an LDT or GDT allocated by the above fns. */
Modified: branches/YARD/coregrind/m_transtab.c
===================================================================
--- branches/YARD/coregrind/m_transtab.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_transtab.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -384,7 +384,8 @@
old_sz = sec->ec2tte_size[ec];
old_ar = sec->ec2tte[ec];
new_sz = old_sz==0 ? 8 : old_sz<64 ? 2*old_sz : (3*old_sz)/2;
- new_ar = VG_(arena_malloc)(VG_AR_TTAUX, new_sz * sizeof(UShort));
+ new_ar = VG_(arena_malloc)(VG_AR_TTAUX, "transtab.aECN.1",
+ new_sz * sizeof(UShort));
for (i = 0; i < old_sz; i++)
new_ar[i] = old_ar[i];
if (old_ar)
Modified: branches/YARD/coregrind/m_ume.c
===================================================================
--- branches/YARD/coregrind/m_ume.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_ume.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -120,7 +120,7 @@
struct elfinfo *readelf(Int fd, const char *filename)
{
SysRes sres;
- struct elfinfo *e = VG_(malloc)(sizeof(*e));
+ struct elfinfo *e = VG_(malloc)("ume.re.1", sizeof(*e));
Int phsz;
vg_assert(e);
@@ -163,7 +163,7 @@
}
phsz = sizeof(ESZ(Phdr)) * e->e.e_phnum;
- e->p = VG_(malloc)(phsz);
+ e->p = VG_(malloc)("ume.re.2", phsz);
vg_assert(e->p);
sres = VG_(pread)(fd, e->p, phsz, e->e.e_phoff);
@@ -378,7 +378,7 @@
break;
case PT_INTERP: {
- char *buf = VG_(malloc)(ph->p_filesz+1);
+ HChar *buf = VG_(malloc)("ume.LE.1", ph->p_filesz+1);
Int j;
Int intfd;
Int baseaddr_set;
@@ -613,10 +613,10 @@
*cp = '\0';
}
- info->interp_name = VG_(strdup)(interp);
+ info->interp_name = VG_(strdup)("ume.ls.1", interp);
vg_assert(NULL != info->interp_name);
if (arg != NULL && *arg != '\0') {
- info->interp_args = VG_(strdup)(arg);
+ info->interp_args = VG_(strdup)("ume.ls.2", arg);
vg_assert(NULL != info->interp_args);
}
@@ -788,7 +788,7 @@
// Looks like a script. Run it with /bin/sh. This includes
// zero-length files.
- info->interp_name = VG_(strdup)(default_interp_name);
+ info->interp_name = VG_(strdup)("ume.desf.1", default_interp_name);
info->interp_args = NULL;
if (info->argv && info->argv[0] != NULL)
info->argv[0] = (char *)exe_name;
Modified: branches/YARD/coregrind/m_wordfm.c
===================================================================
--- branches/YARD/coregrind/m_wordfm.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_wordfm.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -81,7 +81,8 @@
struct _WordFM {
AvlNode* root;
- void* (*alloc_nofail)( SizeT );
+ void* (*alloc_nofail)( HChar*, SizeT );
+ HChar* cc;
void (*dealloc)(void*);
Word (*kCmp)(UWord,UWord);
AvlNode* nodeStack[WFM_STKMAX]; // Iterator node stack
@@ -459,12 +460,13 @@
AvlNode* avl_dopy ( AvlNode* nd,
UWord(*dopyK)(UWord),
UWord(*dopyV)(UWord),
- void*(alloc_nofail)(SizeT) )
+ void*(alloc_nofail)(HChar*,SizeT),
+ HChar* cc )
{
AvlNode* nyu;
if (! nd)
return NULL;
- nyu = alloc_nofail(sizeof(AvlNode));
+ nyu = alloc_nofail(cc, sizeof(AvlNode));
tl_assert(nyu);
nyu->child[0] = nd->child[0];
@@ -493,12 +495,14 @@
/* Copy subtrees */
if (nyu->child[0]) {
- nyu->child[0] = avl_dopy( nyu->child[0], dopyK, dopyV, alloc_nofail );
+ nyu->child[0] = avl_dopy( nyu->child[0], dopyK, dopyV,
+ alloc_nofail, cc );
if (! nyu->child[0])
return NULL;
}
if (nyu->child[1]) {
- nyu->child[1] = avl_dopy( nyu->child[1], dopyK, dopyV, alloc_nofail );
+ nyu->child[1] = avl_dopy( nyu->child[1], dopyK, dopyV,
+ alloc_nofail, cc );
if (! nyu->child[1])
return NULL;
}
@@ -508,13 +512,15 @@
/* Initialise a WordFM. */
static void initFM ( WordFM* fm,
- void* (*alloc_nofail)( SizeT ),
+ void* (*alloc_nofail)( HChar*, SizeT ),
+ HChar* cc,
void (*dealloc)(void*),
Word (*kCmp)(UWord,UWord) )
{
fm->root = 0;
fm->kCmp = kCmp;
fm->alloc_nofail = alloc_nofail;
+ fm->cc = cc;
fm->dealloc = dealloc;
fm->stackTop = 0;
}
@@ -528,13 +534,14 @@
sections of the map, or the whole thing. If kCmp is NULL then the
ordering used is unsigned word ordering (UWord) on the key
values. */
-WordFM* VG_(newFM) ( void* (*alloc_nofail)( SizeT ),
+WordFM* VG_(newFM) ( void* (*alloc_nofail)( HChar*, SizeT ),
+ HChar* cc,
void (*dealloc)(void*),
Word (*kCmp)(UWord,UWord) )
{
- WordFM* fm = alloc_nofail(sizeof(WordFM));
+ WordFM* fm = alloc_nofail(cc, sizeof(WordFM));
tl_assert(fm);
- initFM(fm, alloc_nofail, dealloc, kCmp);
+ initFM(fm, alloc_nofail, cc, dealloc, kCmp);
return fm;
}
@@ -572,7 +579,7 @@
{
MaybeWord oldV;
AvlNode* node;
- node = fm->alloc_nofail( sizeof(struct _AvlNode) );
+ node = fm->alloc_nofail( fm->cc, sizeof(struct _AvlNode) );
node->key = k;
node->val = v;
oldV.b = False;
@@ -735,7 +742,7 @@
/* can't clone the fm whilst iterating on it */
tl_assert(fm->stackTop == 0);
- nyu = fm->alloc_nofail( sizeof(WordFM) );
+ nyu = fm->alloc_nofail( fm->cc, sizeof(WordFM) );
tl_assert(nyu);
*nyu = *fm;
@@ -745,7 +752,8 @@
VG_(memset)(fm->numStack, 0, sizeof(fm->numStack));
if (nyu->root) {
- nyu->root = avl_dopy( nyu->root, dopyK, dopyV, fm->alloc_nofail );
+ nyu->root = avl_dopy( nyu->root, dopyK, dopyV,
+ fm->alloc_nofail, fm->cc );
if (! nyu->root)
return NULL;
}
@@ -768,11 +776,12 @@
WordFM* fm;
};
-WordBag* VG_(newBag) ( void* (*alloc_nofail)( SizeT ),
+WordBag* VG_(newBag) ( void* (*alloc_nofail)( HChar*, SizeT ),
+ HChar* cc,
void (*dealloc)(void*) )
{
- WordBag* bag = alloc_nofail(sizeof(WordBag));
- bag->fm = VG_(newFM)( alloc_nofail, dealloc, NULL );
+ WordBag* bag = alloc_nofail(cc, sizeof(WordBag));
+ bag->fm = VG_(newFM)( alloc_nofail, cc, dealloc, NULL );
return bag;
}
Property changes on: branches/YARD/coregrind/m_wordfm.c
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: branches/YARD/coregrind/m_xarray.c
===================================================================
--- branches/YARD/coregrind/m_xarray.c 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/m_xarray.c 2008-09-06 19:34:12 UTC (rev 8572)
@@ -38,7 +38,8 @@
/* See pub_tool_xarray.h for details of what this is all about. */
struct _XArray {
- void* (*alloc) ( SizeT ); /* alloc fn (nofail) */
+ void* (*alloc) ( HChar*, SizeT ); /* alloc fn (nofail) */
+ HChar* cc; /* cost centre for alloc */
void (*free) ( void* ); /* free fn */
Int (*cmpFn) ( void*, void* ); /* cmp fn (may be NULL) */
Word elemSzB; /* element size in bytes */
@@ -49,7 +50,8 @@
};
-XArray* VG_(newXA) ( void*(*alloc_fn)(SizeT),
+XArray* VG_(newXA) ( void*(*alloc_fn)(HChar*,SizeT),
+ HChar* cc,
void(*free_fn)(void*),
Word elemSzB )
{
@@ -63,9 +65,10 @@
vg_assert(alloc_fn);
vg_assert(free_fn);
vg_assert(elemSzB > 0);
- xa = alloc_fn( sizeof(struct _XArray) );
+ xa = alloc_fn( cc, sizeof(struct _XArray) );
vg_assert(xa);
xa->alloc = alloc_fn;
+ xa->cc = cc;
xa->free = free_fn;
xa->cmpFn = NULL;
xa->elemSzB = elemSzB;
@@ -76,22 +79,32 @@
return xa;
}
-XArray* VG_(cloneXA)( XArray* xao )
+XArray* VG_(cloneXA)( HChar* cc, XArray* xao )
{
struct _XArray* xa = (struct _XArray*)xao;
struct _XArray* nyu;
+ HChar* nyu_cc;
vg_assert(xa);
vg_assert(xa->alloc);
vg_assert(xa->free);
vg_assert(xa->elemSzB >= 1);
- nyu = xa->alloc( sizeof(struct _XArray) );
+ nyu_cc = cc ? cc : xa->cc;
+ nyu = xa->alloc( nyu_cc, sizeof(struct _XArray) );
if (!nyu)
return NULL;
/* Copy everything verbatim ... */
*nyu = *xa;
+ nyu->cc = nyu_cc;
/* ... except we have to clone the contents-array */
if (nyu->arr) {
- nyu->arr = nyu->alloc( nyu->totsizeE * nyu->elemSzB );
+ /* Restrict the total size of the new array to its current
+ actual size. That means we don't waste space copying the
+ unused tail of the original. The tradeoff is that it
+ guarantees we will have to resize the child if even one more
+ element is later added to it, unfortunately. */
+ nyu->totsizeE = nyu->usedsizeE;
+ /* and allocate .. */
+ nyu->arr = nyu->alloc( nyu->cc, nyu->totsizeE * nyu->elemSzB );
if (!nyu->arr) {
nyu->free(nyu);
return NULL;
@@ -151,10 +164,10 @@
} else {
newsz = 2 * xa->totsizeE;
}
- if (0)
+ if (0 && xa->totsizeE >= 10000)
VG_(printf)("addToXA: increasing from %ld to %ld\n",
xa->totsizeE, newsz);
- tmp = xa->alloc(newsz * xa->elemSzB);
+ tmp = xa->alloc(xa->cc, newsz * xa->elemSzB);
vg_assert(tmp);
if (xa->usedsizeE > 0)
VG_(memcpy)(tmp, xa->arr, xa->usedsizeE * xa->elemSzB);
Modified: branches/YARD/coregrind/pub_core_debuginfo.h
===================================================================
--- branches/YARD/coregrind/pub_core_debuginfo.h 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/pub_core_debuginfo.h 2008-09-06 19:34:12 UTC (rev 8572)
@@ -72,6 +72,8 @@
);
#endif
+extern void VG_(di_discard_ALL_debuginfo)( void );
+
extern Bool VG_(get_fnname_nodemangle)( Addr a,
Char* fnname, Int n_fnname );
Modified: branches/YARD/coregrind/pub_core_options.h
===================================================================
--- branches/YARD/coregrind/pub_core_options.h 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/coregrind/pub_core_options.h 2008-09-06 19:34:12 UTC (rev 8572)
@@ -126,10 +126,10 @@
extern Bool VG_(clo_trace_redir);
/* DEBUG: print thread scheduling events? default: NO */
extern Bool VG_(clo_trace_sched);
-/* DEBUG: print pthreads calls? default: NO */
-extern Bool VG_(clo_trace_pthreads);
-/* Display gory details for the k'th most popular error. default:
- Infinity. */
+/* DEBUG: do heap profiling? default: NO */
+extern Bool VG_(clo_profile_heap);
+/* DEBUG: display gory details for the k'th most popular error.
+ default: Infinity. */
extern Int VG_(clo_dump_error);
/* Engage miscellaneous weird hacks needed for some progs. */
extern Char* VG_(clo_sim_hints);
Modified: branches/YARD/include/pub_tool_oset.h
===================================================================
--- branches/YARD/include/pub_tool_oset.h 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/include/pub_tool_oset.h 2008-09-06 19:34:12 UTC (rev 8572)
@@ -77,7 +77,7 @@
// - Free: frees a chunk of memory allocated with Alloc.
typedef Word (*OSetCmp_t) ( const void* key, const void* elem );
-typedef void* (*OSetAlloc_t) ( SizeT szB );
+typedef void* (*OSetAlloc_t) ( HChar* ec, SizeT szB );
typedef void (*OSetFree_t) ( void* p );
/*--------------------------------------------------------------------*/
@@ -98,7 +98,8 @@
// to allow the destruction of any attached resources; if NULL it is not
// called.
-extern OSet* VG_(OSetWord_Create) ( OSetAlloc_t alloc, OSetFree_t free );
+extern OSet* VG_(OSetWord_Create) ( OSetAlloc_t alloc, HChar* ec,
+ OSetFree_t free );
extern void VG_(OSetWord_Destroy) ( OSet* os );
/*--------------------------------------------------------------------*/
@@ -183,7 +184,8 @@
// lead to assertions in Valgrind's allocator.
extern OSet* VG_(OSetGen_Create) ( OffT keyOff, OSetCmp_t cmp,
- OSetAlloc_t alloc, OSetFree_t free );
+ OSetAlloc_t alloc, HChar* ec,
+ OSetFree_t free );
extern void VG_(OSetGen_Destroy) ( OSet* os );
extern void* VG_(OSetGen_AllocNode) ( OSet* os, SizeT elemSize );
extern void VG_(OSetGen_FreeNode) ( OSet* os, void* elem );
Modified: branches/YARD/include/pub_tool_wordfm.h
===================================================================
--- branches/YARD/include/pub_tool_wordfm.h 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/include/pub_tool_wordfm.h 2008-09-06 19:34:12 UTC (rev 8572)
@@ -76,7 +76,8 @@
sections of the map, or the whole thing. If kCmp is NULL then the
ordering used is unsigned word ordering (UWord) on the key
values. */
-WordFM* VG_(newFM) ( void* (*alloc_nofail)( SizeT ),
+WordFM* VG_(newFM) ( void* (*alloc_nofail)( HChar* cc, SizeT ),
+ HChar* cc,
void (*dealloc)(void*),
Word (*kCmp)(UWord,UWord) );
@@ -139,7 +140,8 @@
typedef struct _WordBag WordBag; /* opaque */
/* Allocate and initialise a WordBag */
-WordBag* VG_(newBag) ( void* (*alloc_nofail)( SizeT ),
+WordBag* VG_(newBag) ( void* (*alloc_nofail)( HChar* cc, SizeT ),
+ HChar* cc,
void (*dealloc)(void*) );
/* Free up the Bag. */
Property changes on: branches/YARD/include/pub_tool_wordfm.h
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: branches/YARD/include/pub_tool_xarray.h
===================================================================
--- branches/YARD/include/pub_tool_xarray.h 2008-09-06 19:29:04 UTC (rev 8571)
+++ branches/YARD/include/pub_tool_xarray.h 2008-09-06 19:34:12 UTC (rev 8572)
@@ -44,12 +44,13 @@
/* It's an abstract type. Bwaha. */
-typedef void XArray;
+typedef struct _XArray XArray;
/* Create new XArray, using given allocation and free function, and
for elements of the specified size. Alloc fn must not fail (that
is, if it returns it must have succeeded.) */
-extern XArray* VG_(newXA) ( void*(*alloc_fn)(SizeT),
+extern XArray* VG_(newXA) ( void*(*alloc_fn)(HChar*,SizeT),
+ HChar* cc,
void(*free_fn)(void*),
Word elemSzB );
@@ -102,8 +103,10 @@
/* Make a new, completely independent copy of the given XArray, using
the existing allocation function to allocate the new space.
Returns NULL if the allocation function didn't manage to allocate
- space (but did return NULL rather than merely abort.) */
-extern XArray* VG_(cloneXA)( XArray* xa );
+ space (but did return NULL rather than merely abort.) Space for
+ the clone (and all additions to it) is billed to 'cc' unless that
+ is NULL, in which case the parent's cost-center is used. */
+extern XArray* VG_(cloneXA)( HChar* cc, XArray* xa );
#endif // __PUB_TOOL_XARRAY_H
|