Int notelen = sizeof(struct note) +
VG_ROUNDUP(namelen, 4) +
VG_ROUNDUP(datasz, 4);
- struct note *n = VG_(arena_malloc)(VG_AR_CORE, "coredump-elf.an.1", notelen);
+ struct note *n = VG_(malloc)("coredump-elf.an.1", notelen);
VG_(memset)(n, 0, notelen);
notelist = NULL;
/* Second, work out their layout */
- phdrs = VG_(arena_malloc)(VG_AR_CORE, "coredump-elf.mec.1",
- sizeof(*phdrs) * num_phdrs);
+ phdrs = VG_(malloc)("coredump-elf.mec.1", sizeof(*phdrs) * num_phdrs);
/* Add details for all threads except the one that faulted */
for(i = 1; i < VG_N_THREADS; i++) {
DedupPoolAlloc for these strings will avoid duplicating
such string in each error using it. */
if (NULL != p->string) {
- p->string = VG_(arena_strdup)(VG_AR_CORE, "errormgr.mre.2", p->string);
+ p->string = VG_(strdup)("errormgr.mre.2", p->string);
}
/* copy block pointed to by 'extra', if there is one */
static Bool setLocationTy ( SuppLoc* p, HChar *buf )
{
if (VG_(strncmp)(buf, "fun:", 4) == 0) {
- p->name = VG_(arena_strdup)(VG_AR_CORE,
- "errormgr.sLTy.1", buf+4);
+ p->name = VG_(strdup)("errormgr.sLTy.1", buf+4);
p->name_is_simple_str = is_simple_str (p->name);
p->ty = FunName;
return True;
}
if (VG_(strncmp)(buf, "obj:", 4) == 0) {
- p->name = VG_(arena_strdup)(VG_AR_CORE,
- "errormgr.sLTy.2", buf+4);
+ p->name = VG_(strdup)("errormgr.sLTy.2", buf+4);
p->name_is_simple_str = is_simple_str (p->name);
p->ty = ObjName;
return True;
while (True) {
/* Assign and initialise the two suppression halves (core and tool) */
Supp* supp;
- supp = VG_(arena_malloc)(VG_AR_CORE, "errormgr.losf.1",
- sizeof(Supp));
+ supp = VG_(malloc)("errormgr.losf.1", sizeof(Supp));
supp->count = 0;
// Initialise temporary reading-in buffer.
eof = get_nbnc_line ( fd, &buf, &nBuf, &lineno );
if (eof) {
- VG_(arena_free)(VG_AR_CORE, supp);
+ VG_(free)(supp);
break;
}
if (eof || VG_STREQ(buf, "}")) BOMB("unexpected '}'");
- supp->sname = VG_(arena_strdup)(VG_AR_CORE, "errormgr.losf.2", buf);
+ supp->sname = VG_(strdup)("errormgr.losf.2", buf);
supp->clo_suppressions_i = clo_suppressions_i;
supp->sname_lineno = lineno;
if (VG_STREQ(buf, "}"))
break;
}
- VG_(arena_free)(VG_AR_CORE, supp->sname);
- VG_(arena_free)(VG_AR_CORE, supp);
+ VG_(free)(supp->sname);
+ VG_(free)(supp);
continue;
}
// Copy tmp_callers[] into supp->callers[]
supp->n_callers = i;
- supp->callers = VG_(arena_malloc)(VG_AR_CORE, "errormgr.losf.4",
- i*sizeof(SuppLoc));
+ supp->callers = VG_(malloc)("errormgr.losf.4", i * sizeof(SuppLoc));
for (i = 0; i < supp->n_callers; i++) {
supp->callers[i] = tmp_callers[i];
}
/* alloc and free functions for xarray and similar. */
static void* gs_alloc (const HChar* cc, SizeT sz)
{
- void* res = VG_(arena_malloc)(VG_AR_CORE, cc, sz);
- vg_assert (res);
- return res;
+ return VG_(malloc)(cc, sz);
}
static void gs_free (void* ptr)
{
- VG_(arena_free)(VG_AR_CORE, ptr);
+ VG_(free)(ptr);
}
typedef
{
GS_Address *p;
- p = VG_(arena_malloc)(VG_AR_CORE, from, sizeof(GS_Address));
+ p = VG_(malloc)(from, sizeof(GS_Address));
p->addr = HT_addr (addr);
p->kind = kind;
VG_(HT_add_node)(gs_addresses, p);
// See add_gs_address for the explanation for condition and the range 2 below.
if (VG_(clo_vgdb) != Vg_VgdbFull)
VG_(discard_translations) (g->addr, 2, from);
- VG_(arena_free) (VG_AR_CORE, g);
+ VG_(free) (g);
}
const HChar* VG_(ppPointKind) (PointKind kind)
g = lookup_gs_watch (addr, len, kind, &g_ix);
if (insert) {
if (g == NULL) {
- g = VG_(arena_malloc)(VG_AR_CORE, "gdbserver_point watchpoint",
- sizeof(GS_Watch));
+ g = VG_(malloc)("gdbserver_point watchpoint", sizeof(GS_Watch));
g->addr = addr;
g->len = len;
g->kind = kind;
} else {
if (g != NULL) {
VG_(removeIndexXA) (gs_watches, g_ix);
- VG_(arena_free) (VG_AR_CORE, g);
+ VG_(free) (g);
} else {
dlog(1,
"VG_(gdbserver_point) addr %p len %d kind %s already deleted?\n",
VG_(strtoull16) ((s),(r)) \
: VG_(strtoull10) ((s),(r)))
-#define malloc(sz) VG_(arena_malloc) (VG_AR_CORE, "gdbsrv", sz)
-#define calloc(n,sz) VG_(arena_calloc) (VG_AR_CORE, "gdbsrv", n, sz)
-#define realloc(p,size) VG_(arena_realloc) (VG_AR_CORE, "gdbsrv", p, size)
-#define strdup(s) VG_(arena_strdup) (VG_AR_CORE, "gdbsrv", (s))
-#define free(b) VG_(arena_free) (VG_AR_CORE, b)
+#define malloc(sz) VG_(malloc) ("gdbsrv", sz)
+#define calloc(n,sz) VG_(calloc) ("gdbsrv", n, sz)
+#define realloc(p,size) VG_(realloc) ("gdbsrv", p, size)
+#define strdup(s) VG_(strdup) ("gdbsrv", (s))
+#define free(b) VG_(free) (b)
#ifndef ATTR_NORETURN
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
HChar **env = (*envp);
HChar **cpp;
Int len = VG_(strlen)(varname);
- HChar *valstr = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.1",
- len + VG_(strlen)(val) + 2);
+ HChar *valstr = VG_(malloc)("libcproc.es.1", len + VG_(strlen)(val) + 2);
HChar **oldenv = NULL;
VG_(sprintf)(valstr, "%s=%s", varname, val);
}
if (env == NULL) {
- env = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.2", sizeof(HChar *) * 2);
+ env = VG_(malloc)("libcproc.es.2", sizeof(HChar *) * 2);
env[0] = valstr;
env[1] = NULL;
} else {
Int envlen = (cpp-env) + 2;
- HChar **newenv = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.3",
- envlen * sizeof(HChar *));
+ HChar **newenv = VG_(malloc)("libcproc.es.3", envlen * sizeof(HChar *));
for (cpp = newenv; *env; )
*cpp++ = *env++;
// - DYLD_INSERT_LIBRARIES and DYLD_SHARED_REGION are Darwin-only
for (i = 0; envp[i] != NULL; i++) {
if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0) {
- envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.1", envp[i]);
+ envp[i] = VG_(strdup)("libcproc.erves.1", envp[i]);
ld_preload_str = &envp[i][11];
}
if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=", 16) == 0) {
- envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.2", envp[i]);
+ envp[i] = VG_(strdup)("libcproc.erves.2", envp[i]);
ld_library_path_str = &envp[i][16];
}
if (VG_(strncmp)(envp[i], "DYLD_INSERT_LIBRARIES=", 22) == 0) {
- envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.3", envp[i]);
+ envp[i] = VG_(strdup)("libcproc.erves.3", envp[i]);
dyld_insert_libraries_str = &envp[i][22];
}
}
- buf = VG_(arena_malloc)(VG_AR_CORE, "libcproc.erves.4",
- VG_(strlen)(VG_(libdir)) + 20);
+ buf = VG_(malloc)("libcproc.erves.4", VG_(strlen)(VG_(libdir)) + 20);
// Remove Valgrind-specific entries from LD_*.
VG_(sprintf)(buf, "%s*/vgpreload_*.so", VG_(libdir));
// XXX if variable becomes empty, remove it completely?
- VG_(arena_free)(VG_AR_CORE, buf);
+ VG_(free)(buf);
}
/* ---------------------------------------------------------------------
envlen = oldenvp - oldenv + 1;
- newenv = VG_(arena_malloc)(VG_AR_CORE, "libcproc.ec.1",
- envlen * sizeof(HChar *));
+ newenv = VG_(malloc)("libcproc.ec.1", envlen * sizeof(HChar *));
oldenvp = oldenv;
newenvp = newenv;
the default one. */
static const HChar default_supp[] = "default.supp";
Int len = VG_(strlen)(VG_(libdir)) + 1 + sizeof(default_supp);
- HChar *buf = VG_(arena_malloc)(VG_AR_CORE, "main.mpclo.3", len);
+ HChar *buf = VG_(malloc)("main.mpclo.3", len);
VG_(sprintf)(buf, "%s/%s", VG_(libdir), default_supp);
VG_(clo_suppressions)[VG_(clo_n_suppressions)] = buf;
VG_(clo_n_suppressions)++;
return VG_(arena_realloc) ( VG_AR_CORE, cc, ptr, size );
}
+void VG_(realloc_shrink) ( void* ptr, SizeT size )
+{
+ VG_(arena_realloc_shrink) ( VG_AR_CORE, ptr, size );
+}
+
HChar* VG_(strdup) ( const HChar* cc, const HChar* s )
{
return VG_(arena_strdup) ( VG_AR_CORE, cc, s );
VG_(threads)[i].status = VgTs_Init;
VG_(threads)[i].exitreason = VgSrc_None;
if (VG_(threads)[i].thread_name)
- VG_(arena_free)(VG_AR_CORE, VG_(threads)[i].thread_name);
+ VG_(free)(VG_(threads)[i].thread_name);
VG_(threads)[i].thread_name = NULL;
return i;
}
{
block_all_host_signals(saved_mask);
if (VG_(threads)[tid].sig_queue != NULL) {
- VG_(arena_free)(VG_AR_CORE, VG_(threads)[tid].sig_queue);
+ VG_(free)(VG_(threads)[tid].sig_queue);
VG_(threads)[tid].sig_queue = NULL;
}
restore_all_host_signals(saved_mask);
block_all_host_signals(&savedmask);
if (tst->sig_queue == NULL) {
- tst->sig_queue = VG_(arena_malloc)(VG_AR_CORE, "signals.qs.1",
- sizeof(*tst->sig_queue));
+ tst->sig_queue = VG_(malloc)("signals.qs.1", sizeof(*tst->sig_queue));
VG_(memset)(tst->sig_queue, 0, sizeof(*tst->sig_queue));
}
sq = tst->sig_queue;
start = t;
}
- i = (Stack *)VG_(arena_malloc)(VG_AR_CORE, "stacks.rs.1", sizeof(Stack));
+ i = VG_(malloc)("stacks.rs.1", sizeof(Stack));
i->start = start;
i->end = end;
i->id = next_id++;
} else {
prev->next = i->next;
}
- VG_(arena_free)(VG_AR_CORE, i);
+ VG_(free)(i);
return;
}
prev = i;
static void port_create_vanilla(mach_port_t port)
{
OpenPort* op
- = VG_(arena_calloc)(VG_AR_CORE, "syswrap-darwin.port_create_vanilla",
- sizeof(OpenPort), 1);
+ = VG_(calloc)("syswrap-darwin.port_create_vanilla", sizeof(OpenPort), 1);
op->port = port;
/* Add it to the list. */
op->next = allocated_ports;
i = info_for_port(port);
vg_assert(i);
- if (i->name) VG_(arena_free)(VG_AR_CORE, i->name);
+ if (i->name) VG_(free)(i->name);
i->name =
- VG_(arena_malloc)(VG_AR_CORE, "syswrap-darwin.mach-port-name",
- VG_(strlen)(name) + PORT_STRLEN + 1);
+ VG_(malloc)("syswrap-darwin.mach-port-name",
+ VG_(strlen)(name) + PORT_STRLEN + 1);
VG_(sprintf)(i->name, name, port);
}
if(i->next)
i->next->prev = i->prev;
if(i->name)
- VG_(arena_free) (VG_AR_CORE, i->name);
- VG_(arena_free) (VG_AR_CORE, i);
+ VG_(free) (i->name);
+ VG_(free) (i);
allocated_port_count--;
return;
}
/* Not already one: allocate an OpenPort */
if (i == NULL) {
- i = VG_(arena_malloc)(VG_AR_CORE, "syswrap-darwin.mach-port",
- sizeof(OpenPort));
+ i = VG_(malloc)("syswrap-darwin.mach-port", sizeof(OpenPort));
i->prev = NULL;
i->next = allocated_ports;
} else {
PRINT("not found");
}
- VG_(arena_free)(VG_AR_CORE, MACH_ARG(bootstrap_look_up.service_name));
+ VG_(free)(MACH_ARG(bootstrap_look_up.service_name));
}
PRE(bootstrap_look_up)
PRINT("bootstrap_look_up(\"%s\")", req->service_name);
MACH_ARG(bootstrap_look_up.service_name) =
- VG_(arena_strdup)(VG_AR_CORE, "syswrap-darwin.bootstrap-name",
- req->service_name);
+ VG_(strdup)("syswrap-darwin.bootstrap-name", req->service_name);
AFTER = POST_FN(bootstrap_look_up);
}
static VexGuestX86SegDescr* alloc_zeroed_x86_LDT ( void )
{
Int nbytes = VEX_GUEST_X86_LDT_NENT * sizeof(VexGuestX86SegDescr);
- return VG_(arena_calloc)(VG_AR_CORE, "syswrap-darwin.ldt", nbytes, 1);
+ return VG_(calloc)("syswrap-darwin.ldt", nbytes, 1);
}
#endif
if(i->next)
i->next->prev = i->prev;
if(i->pathname)
- VG_(arena_free) (VG_AR_CORE, i->pathname);
- VG_(arena_free) (VG_AR_CORE, i);
+ VG_(free) (i->pathname);
+ VG_(free) (i);
fd_count--;
break;
}
i = allocated_fds;
while (i) {
if (i->fd == fd) {
- if (i->pathname) VG_(arena_free)(VG_AR_CORE, i->pathname);
+ if (i->pathname) VG_(free)(i->pathname);
break;
}
i = i->next;
/* Not already one: allocate an OpenFd */
if (i == NULL) {
- i = VG_(arena_malloc)(VG_AR_CORE, "syswrap.rfdowgn.1", sizeof(OpenFd));
+ i = VG_(malloc)("syswrap.rfdowgn.1", sizeof(OpenFd));
i->prev = NULL;
i->next = allocated_fds;
}
i->fd = fd;
- i->pathname = VG_(arena_strdup)(VG_AR_CORE, "syswrap.rfdowgn.2", pathname);
+ i->pathname = VG_(strdup)("syswrap.rfdowgn.2", pathname);
i->where = (tid == -1) ? NULL : VG_(record_ExeContext)(tid, 0/*first_ip_delta*/);
}
HChar *outmsg = strdupcat ( "di.syswrap.pmrs.1",
"sendmsg", msg, VG_AR_CORE );
PRE_MEM_READ( outmsg, base, size );
- VG_(arena_free) ( VG_AR_CORE, outmsg );
+ VG_(free) ( outmsg );
}
static
PRE_MEM_READ( outmsg, base, size );
else
PRE_MEM_WRITE( outmsg, base, size );
- VG_(arena_free) ( VG_AR_CORE, outmsg );
+ VG_(free) ( outmsg );
}
static
if ( !msg )
return;
- fieldName = VG_(arena_malloc) ( VG_AR_CORE, "di.syswrap.mfef", VG_(strlen)(name) + 32 );
+ fieldName = VG_(malloc) ( "di.syswrap.mfef", VG_(strlen)(name) + 32 );
VG_(sprintf) ( fieldName, "(%s)", name );
(Addr)msg->msg_control, msg->msg_controllen );
}
- VG_(arena_free) ( VG_AR_CORE, fieldName );
+ VG_(free) ( fieldName );
}
static void check_cmsg_for_fds(ThreadId tid, struct vki_msghdr *msg)
/* NULL/zero-length sockaddrs are legal */
if ( sa == NULL || salen == 0 ) return;
- outmsg = VG_(arena_malloc) ( VG_AR_CORE, "di.syswrap.pmr_sockaddr.1",
- VG_(strlen)( description ) + 30 );
+ outmsg = VG_(malloc) ( "di.syswrap.pmr_sockaddr.1",
+ VG_(strlen)( description ) + 30 );
VG_(sprintf) ( outmsg, description, "sa_family" );
PRE_MEM_READ( outmsg, (Addr) &sa->sa_family, sizeof(vki_sa_family_t));
break;
}
- VG_(arena_free) ( VG_AR_CORE, outmsg );
+ VG_(free) ( outmsg );
}
/* Dereference a pointer to a UInt. */
/* Don't bother reusing the memory. This is a rare event. */
tst->thread_name =
- VG_(arena_realloc)(VG_AR_CORE, "syswrap.prctl",
- tst->thread_name, new_len + 1);
+ VG_(realloc)("syswrap.prctl", tst->thread_name, new_len + 1);
VG_(strcpy)(tst->thread_name, new_name);
}
}
static VexGuestX86SegDescr* alloc_zeroed_x86_GDT ( void )
{
Int nbytes = VEX_GUEST_X86_GDT_NENT * sizeof(VexGuestX86SegDescr);
- return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxG.1", nbytes, 1);
+ return VG_(calloc)("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, "di.syswrap-x86.azxL.1", nbytes, 1);
+ return VG_(calloc)("di.syswrap-x86.azxL.1", nbytes, 1);
}
/* Free up an LDT or GDT allocated by the above fns. */
static void free_LDT_or_GDT ( VexGuestX86SegDescr* dt )
{
vg_assert(dt);
- VG_(arena_free)(VG_AR_CORE, (void*)dt);
+ VG_(free)(dt);
}
/* Copy contents between two existing LDTs. */
extern void VG_(free) ( void* p );
extern void* VG_(calloc) ( const HChar* cc, SizeT n, SizeT bytes_per_elem );
extern void* VG_(realloc) ( const HChar* cc, void* p, SizeT size );
+extern void VG_(realloc_shrink)( void* ptr, SizeT size );
extern HChar* VG_(strdup) ( const HChar* cc, const HChar* s );
// TODO: move somewhere else