The name-mangled versions of __builtin_new() and __builtin_vec_new() now

don't just call the unmangled versions, but do the appropriate stuff
themselves directly (this was necessary for Massif).  This means that stack
traces for them have one fewer function.  And I was able to gather up several
very similar functions into a macro, reducing the amount of code, which was
nice.  Had to update one regtest's expected output accordingly.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1875
This commit is contained in:
Nicholas Nethercote 2003-09-30 16:52:47 +00:00
parent 02494a520e
commit bc7e854aee
5 changed files with 62 additions and 136 deletions

View File

@ -140,126 +140,50 @@ void VG_(replacement_malloc_print_debug_usage)(void)
while ((n % 4) > 0) n++; \
}
/* ALL calls to malloc wind up here. */
void* malloc ( Int n )
{
void* v;
MALLOC_TRACE("malloc[simd=%d](%d)",
(UInt)VG_(is_running_on_simd_CPU)(), n );
MAYBE_SLOPPIFY(n);
if (VG_(is_running_on_simd_CPU)()) {
v = (void*)VALGRIND_NON_SIMD_CALL1( SK_(malloc), n );
} else if (VG_(clo_alignment) != 4) {
v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n);
} else {
v = VG_(arena_malloc)(VG_AR_CLIENT, n);
}
MALLOC_TRACE(" = %p\n", v );
return v;
/* ALL calls to malloc() and friends wind up here. */
#define ALLOC(fff, vgfff) \
void* fff ( Int n ) \
{ \
void* v; \
\
MALLOC_TRACE(#fff "[simd=%d](%d)", \
(UInt)VG_(is_running_on_simd_CPU)(), n ); \
MAYBE_SLOPPIFY(n); \
\
if (VG_(is_running_on_simd_CPU)()) { \
v = (void*)VALGRIND_NON_SIMD_CALL1( vgfff, n ); \
} else if (VG_(clo_alignment) != 4) { \
v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n); \
} else { \
v = VG_(arena_malloc)(VG_AR_CLIENT, n); \
} \
MALLOC_TRACE(" = %p\n", v ); \
return v; \
}
ALLOC( malloc, SK_(malloc) );
ALLOC( __builtin_new, SK_(__builtin_new) );
ALLOC( _Znwj, SK_(__builtin_new) );
ALLOC( __builtin_vec_new, SK_(__builtin_vec_new) );
ALLOC( _Znaj, SK_(__builtin_vec_new) );
void* __builtin_new ( Int n )
{
void* v;
MALLOC_TRACE("__builtin_new[simd=%d](%d)",
(UInt)VG_(is_running_on_simd_CPU)(), n );
MAYBE_SLOPPIFY(n);
if (VG_(is_running_on_simd_CPU)()) {
v = (void*)VALGRIND_NON_SIMD_CALL1( SK_(__builtin_new), n );
} else if (VG_(clo_alignment) != 4) {
v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n);
} else {
v = VG_(arena_malloc)(VG_AR_CLIENT, n);
}
MALLOC_TRACE(" = %p\n", v );
return v;
}
/* gcc 3.X.X mangles them differently. */
void* _Znwj ( Int n )
{
return __builtin_new(n);
}
void* __builtin_vec_new ( Int n )
{
void* v;
MALLOC_TRACE("__builtin_vec_new[simd=%d](%d)",
(UInt)VG_(is_running_on_simd_CPU)(), n );
MAYBE_SLOPPIFY(n);
if (VG_(is_running_on_simd_CPU)()) {
v = (void*)VALGRIND_NON_SIMD_CALL1( SK_(__builtin_vec_new), n );
} else if (VG_(clo_alignment) != 4) {
v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n);
} else {
v = VG_(arena_malloc)(VG_AR_CLIENT, n);
}
MALLOC_TRACE(" = %p\n", v );
return v;
}
/* gcc 3.X.X mangles them differently. */
void* _Znaj ( Int n )
{
return __builtin_vec_new(n);
}
void free ( void* p )
{
MALLOC_TRACE("free[simd=%d](%p)\n",
(UInt)VG_(is_running_on_simd_CPU)(), p );
if (p == NULL)
return;
if (VG_(is_running_on_simd_CPU)()) {
(void)VALGRIND_NON_SIMD_CALL1( SK_(free), p );
} else {
VG_(arena_free)(VG_AR_CLIENT, p);
}
}
void __builtin_delete ( void* p )
{
MALLOC_TRACE("__builtin_delete[simd=%d](%p)\n",
(UInt)VG_(is_running_on_simd_CPU)(), p );
if (p == NULL)
return;
if (VG_(is_running_on_simd_CPU)()) {
(void)VALGRIND_NON_SIMD_CALL1( SK_(__builtin_delete), p );
} else {
VG_(arena_free)(VG_AR_CLIENT, p);
}
}
/* gcc 3.X.X mangles them differently. */
void _ZdlPv ( void* p )
{
__builtin_delete(p);
}
void __builtin_vec_delete ( void* p )
{
MALLOC_TRACE("__builtin_vec_delete[simd=%d](%p)\n",
(UInt)VG_(is_running_on_simd_CPU)(), p );
if (p == NULL)
return;
if (VG_(is_running_on_simd_CPU)()) {
(void)VALGRIND_NON_SIMD_CALL1( SK_(__builtin_vec_delete), p );
} else {
VG_(arena_free)(VG_AR_CLIENT, p);
}
}
/* gcc 3.X.X mangles them differently. */
void _ZdaPv ( void* p )
{
__builtin_vec_delete(p);
#define FREE(fff, vgfff) \
void fff ( void* p ) \
{ \
MALLOC_TRACE(#fff "[simd=%d](%p)\n", \
(UInt)VG_(is_running_on_simd_CPU)(), p ); \
if (p == NULL) \
return; \
if (VG_(is_running_on_simd_CPU)()) { \
(void)VALGRIND_NON_SIMD_CALL1( vgfff, p ); \
} else { \
VG_(arena_free)(VG_AR_CLIENT, p); \
} \
}
FREE( free, SK_(free) );
FREE( __builtin_delete, SK_(__builtin_delete) );
FREE( _ZdlPv, SK_(__builtin_delete) );
FREE( __builtin_vec_delete, SK_(__builtin_vec_delete) );
FREE( _ZdaPv, SK_(__builtin_vec_delete) );
void* calloc ( UInt nmemb, UInt size )
{

View File

@ -3,7 +3,7 @@
## - lots more mmap/munmap/mremap/mprotect ones
##---------------------------------------------------------------------------
noinst_SCRIPTS = filter_allocs filter_leak_check_size filter_mismatches \
noinst_SCRIPTS = filter_allocs filter_leak_check_size \
filter_stderr filter_stderr_backtrace filter_pushfpopf \
filter_tronical

View File

@ -1,9 +0,0 @@
#! /bin/sh
./filter_stderr |
sed "s/: fooble ([^)]*)/: fooble (...)/" |
sed "/by 0x........: operator .*(.*) (vg_replace_malloc.c:...)/d" |
sed "/by 0x........: \.\.\./d"

View File

@ -1,53 +1,65 @@
Mismatched free() / delete / delete []
at 0x........: __builtin_delete (vg_replace_malloc.c:...)
at 0x........: operator delete(void*) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:6)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 10 alloc'd
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:5)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Mismatched free() / delete / delete []
at 0x........: __builtin_vec_delete (vg_replace_malloc.c:...)
at 0x........: operator delete[](void*) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:8)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 10 alloc'd
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:7)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Mismatched free() / delete / delete []
at 0x........: __builtin_delete (vg_replace_malloc.c:...)
at 0x........: operator delete(void*) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:13)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 40 alloc'd
at 0x........: __builtin_vec_new (vg_replace_malloc.c:...)
at 0x........: operator new[](unsigned) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:12)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Mismatched free() / delete / delete []
at 0x........: free (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:15)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 40 alloc'd
at 0x........: __builtin_vec_new (vg_replace_malloc.c:...)
at 0x........: operator new[](unsigned) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:14)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Mismatched free() / delete / delete []
at 0x........: __builtin_vec_delete (vg_replace_malloc.c:...)
at 0x........: operator delete[](void*) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:20)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 4 alloc'd
at 0x........: __builtin_new (vg_replace_malloc.c:...)
at 0x........: operator new(unsigned) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:19)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Mismatched free() / delete / delete []
at 0x........: free (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:22)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 4 alloc'd
at 0x........: __builtin_new (vg_replace_malloc.c:...)
at 0x........: operator new(unsigned) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:21)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...

View File

@ -1,3 +1,2 @@
prog: mismatches
stderr_filter: filter_mismatches
vgopts: -q