]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
The name-mangled versions of __builtin_new() and __builtin_vec_new() now
authorNicholas Nethercote <njn@valgrind.org>
Tue, 30 Sep 2003 16:52:47 +0000 (16:52 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Tue, 30 Sep 2003 16:52:47 +0000 (16:52 +0000)
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

coregrind/vg_replace_malloc.c
memcheck/tests/Makefile.am
memcheck/tests/filter_mismatches [deleted file]
memcheck/tests/mismatches.stderr.exp
memcheck/tests/mismatches.vgtest

index 636e85128ee4dfb134f521cb47b19f34ae80185c..9c3ca2560e3474841cfe67c270c7819e4189d5d7 100644 (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;
-}
-
-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;
+/* 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; \
 }
-
-/* 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);
+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) );
+
+#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 )
 {
index 7573eda0e3454902c04a35b862dfc74037408ed2..715ab0cdd437a62c8fc24444afa0ed1847a94760 100644 (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
 
diff --git a/memcheck/tests/filter_mismatches b/memcheck/tests/filter_mismatches
deleted file mode 100755 (executable)
index 5c94eda..0000000
+++ /dev/null
@@ -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"
-
-
index 388c702ac408207d42b66cfecfd59157a6dfe948..db6a53188439344908fe8d5bf4ada3809f2d3c88 100644 (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........: ...
index 92e8473b2eeaf0f836b05dbd7aa357cffbf5b6ab..5574afdd4f70d8dd2b77e237a0f83dbf443c7237 100644 (file)
@@ -1,3 +1,2 @@
 prog: mismatches
-stderr_filter: filter_mismatches
 vgopts: -q