diff options
author | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 18:04:35 +0000 |
---|---|---|
committer | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 18:04:35 +0000 |
commit | 7fe2c0f6df1bf3bd495cf39f2cd7dcb515740455 (patch) | |
tree | 44a96aff7077c1bb395ed4687851a242d6e29188 /tools | |
parent | 6fa5f305ce11aeec76e5f45eff425833ff41acaa (diff) | |
download | chromium_src-7fe2c0f6df1bf3bd495cf39f2cd7dcb515740455.zip chromium_src-7fe2c0f6df1bf3bd495cf39f2cd7dcb515740455.tar.gz chromium_src-7fe2c0f6df1bf3bd495cf39f2cd7dcb515740455.tar.bz2 |
Patch Valgrind to intercept libtcmalloc memory functions.
tools/valgrind/intercept_tcmalloc.patch modifies Valgrind's
coregrind/m_replacemalloc/vg_replace_malloc.c to intercept the
allocation/deallocation functions introduced by tcmalloc.
This patch was prepared by Alexander Potapenko (cc'ed)
and originally reviewed as http://codereview.chromium.org/434118
TBR=dank
Review URL: http://codereview.chromium.org/467020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/valgrind/build-valgrind-for-chromium.sh | 4 | ||||
-rw-r--r-- | tools/valgrind/intercept_tcmalloc.patch | 216 |
2 files changed, 220 insertions, 0 deletions
diff --git a/tools/valgrind/build-valgrind-for-chromium.sh b/tools/valgrind/build-valgrind-for-chromium.sh index 4feeaa6..e18339d 100755 --- a/tools/valgrind/build-valgrind-for-chromium.sh +++ b/tools/valgrind/build-valgrind-for-chromium.sh @@ -84,6 +84,10 @@ then # which prevented valgrind from handling wine patch -p0 < "${THISDIR}/vbug205541.patch" + # Add intercepts for tcmalloc memory functions. + patch -p0 < "${THISDIR}/intercept_tcmalloc.patch" + + if [ "${INSTALL_TSAN}" = "yes" ] then # Add ThreadSanitier to the installation. diff --git a/tools/valgrind/intercept_tcmalloc.patch b/tools/valgrind/intercept_tcmalloc.patch new file mode 100644 index 0000000..ea1e952 --- /dev/null +++ b/tools/valgrind/intercept_tcmalloc.patch @@ -0,0 +1,216 @@ +Index: coregrind/m_replacemalloc/vg_replace_malloc.c +=================================================================== +--- coregrind/m_replacemalloc/vg_replace_malloc.c (revision 10880) ++++ coregrind/m_replacemalloc/vg_replace_malloc.c (working copy) +@@ -193,6 +193,7 @@ + // malloc + ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, malloc, malloc); + ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc, malloc); ++ALLOC_or_NULL(NONE, malloc, malloc); + #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) + ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_common, malloc); + #elif defined(VGO_darwin) +@@ -205,20 +206,24 @@ + // operator new(unsigned int), not mangled (for gcc 2.96) + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, builtin_new, __builtin_new); + ALLOC_or_BOMB(VG_Z_LIBC_SONAME, builtin_new, __builtin_new); ++ALLOC_or_BOMB(NONE, builtin_new, __builtin_new); + + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_new, __builtin_new); + ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_new, __builtin_new); ++ALLOC_or_BOMB(NONE, __builtin_new, __builtin_new); + + // operator new(unsigned int), GNU mangling + #if VG_WORDSIZE == 4 + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwj, __builtin_new); + ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwj, __builtin_new); ++ ALLOC_or_BOMB(NONE, _Znwj, __builtin_new); + #endif + + // operator new(unsigned long), GNU mangling + #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGO_darwin) + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwm, __builtin_new); + ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwm, __builtin_new); ++ ALLOC_or_BOMB(NONE, _Znwm, __builtin_new); + #endif + + // operator new(unsigned long), ARM/cfront mangling +@@ -233,12 +238,14 @@ + #if VG_WORDSIZE == 4 + ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new); + ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new); ++ ALLOC_or_NULL(NONE, _ZnwjRKSt9nothrow_t, __builtin_new); + #endif + + // operator new(unsigned long, std::nothrow_t const&), GNU mangling + #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || defined(VGO_darwin) + ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new); + ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new); ++ ALLOC_or_NULL(NONE, _ZnwmRKSt9nothrow_t, __builtin_new); + #endif + + // operator new(unsigned long, std::nothrow_t const&), ARM/cfront mangling +@@ -252,17 +259,20 @@ + // operator new[](unsigned int), not mangled (for gcc 2.96) + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_new, __builtin_vec_new ); + ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_vec_new, __builtin_vec_new ); ++ALLOC_or_BOMB(NONE, __builtin_vec_new, __builtin_vec_new ); + + // operator new[](unsigned int), GNU mangling + #if VG_WORDSIZE == 4 + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znaj, __builtin_vec_new ); + ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znaj, __builtin_vec_new ); ++ ALLOC_or_BOMB(NONE, _Znaj, __builtin_vec_new ); + #endif + + // operator new[](unsigned long), GNU mangling + #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || defined(VGO_darwin) + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znam, __builtin_vec_new ); + ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znam, __builtin_vec_new ); ++ ALLOC_or_BOMB(NONE, _Znam, __builtin_vec_new ); + #endif + + // operator new[](unsigned long), ARM/cfront mangling +@@ -277,12 +287,14 @@ + #if VG_WORDSIZE == 4 + ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new ); + ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new ); ++ ALLOC_or_NULL(NONE, _ZnajRKSt9nothrow_t, __builtin_vec_new ); + #endif + + // operator new[](unsigned long, std::nothrow_t const&), GNU mangling + #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || defined(VGO_darwin) + ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new ); + ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new ); ++ ALLOC_or_NULL(NONE, _ZnamRKSt9nothrow_t, __builtin_vec_new ); + #endif + + // operator new [](unsigned long, std::nothrow_t const&), ARM/cfront mangling +@@ -323,6 +335,7 @@ + // free + FREE(VG_Z_LIBSTDCXX_SONAME, free, free ); + FREE(VG_Z_LIBC_SONAME, free, free ); ++FREE(NONE, free, free ); + #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) + FREE(VG_Z_LIBC_SONAME, free_common, free ); + #elif defined(VGO_darwin) +@@ -335,16 +348,19 @@ + // cfree + FREE(VG_Z_LIBSTDCXX_SONAME, cfree, free ); + FREE(VG_Z_LIBC_SONAME, cfree, free ); ++FREE(NONE, cfree, free ); + + + /*---------------------- delete ----------------------*/ + // operator delete(void*), not mangled (for gcc 2.96) + FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_delete, __builtin_delete ); + FREE(VG_Z_LIBC_SONAME, __builtin_delete, __builtin_delete ); ++FREE(NONE, __builtin_delete, __builtin_delete ); + + // operator delete(void*), GNU mangling + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); + FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete ); ++FREE(NONE, _ZdlPv, __builtin_delete ); + + // operator delete(void*), ARM/cfront mangling + #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) +@@ -357,16 +373,19 @@ + // operator delete(void*, std::nothrow_t const&), GNU mangling + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete ); + FREE(VG_Z_LIBC_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete ); ++FREE(NONE, _ZdlPvRKSt9nothrow_t, __builtin_delete ); + + + /*---------------------- delete [] ----------------------*/ + // operator delete[](void*), not mangled (for gcc 2.96) + FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_delete, __builtin_vec_delete ); + FREE(VG_Z_LIBC_SONAME, __builtin_vec_delete, __builtin_vec_delete ); ++FREE(NONE, __builtin_vec_delete, __builtin_vec_delete ); + + // operator delete[](void*), GNU mangling + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete ); + FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete ); ++FREE(NONE, _ZdaPv, __builtin_vec_delete ); + + // operator delete[](void*), ARM/cfront mangling + #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) +@@ -379,6 +398,7 @@ + // operator delete[](void*, std::nothrow_t const&), GNU mangling + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); + FREE(VG_Z_LIBC_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); ++FREE(NONE, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); + + + /*---------------------- calloc ----------------------*/ +@@ -416,6 +436,7 @@ + } + + CALLOC(VG_Z_LIBC_SONAME, calloc); ++CALLOC(NONE, calloc); + #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) + CALLOC(VG_Z_LIBC_SONAME, calloc_common); + #elif defined(VGO_darwin) +@@ -474,6 +495,7 @@ + } + + REALLOC(VG_Z_LIBC_SONAME, realloc); ++REALLOC(NONE, realloc); + #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) + REALLOC(VG_Z_LIBC_SONAME, realloc_common); + #elif defined(VGO_darwin) +@@ -530,6 +552,7 @@ + } + + MEMALIGN(VG_Z_LIBC_SONAME, memalign); ++MEMALIGN(NONE, memalign); + #if defined(VGO_darwin) + ZONEMEMALIGN(VG_Z_LIBC_SONAME, malloc_zone_memalign); + #endif +@@ -572,6 +595,7 @@ + } + + VALLOC(VG_Z_LIBC_SONAME, valloc); ++VALLOC(NONE, valloc); + #if defined(VGO_darwin) + ZONEVALLOC(VG_Z_LIBC_SONAME, malloc_zone_valloc); + #endif +@@ -592,6 +616,7 @@ + } + + MALLOPT(VG_Z_LIBC_SONAME, mallopt); ++MALLOPT(NONE, mallopt); + + + /*---------------------- malloc_trim ----------------------*/ +@@ -628,6 +653,7 @@ + } + + MALLOC_TRIM(VG_Z_LIBC_SONAME, malloc_trim); ++MALLOC_TRIM(NONE, malloc_trim); + + + /*---------------------- posix_memalign ----------------------*/ +@@ -658,6 +684,7 @@ + } + + POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign); ++POSIX_MEMALIGN(NONE, posix_memalign); + #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) + /* 27 Nov 07: it appears that xlc links into executables, a + posix_memalign, which calls onwards to memalign_common, with the +@@ -688,6 +715,7 @@ + + MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_usable_size); + MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_size); ++MALLOC_USABLE_SIZE(NONE, malloc_size); + + + /*---------------------- (unimplemented) ----------------------*/ +@@ -742,6 +770,7 @@ + } + + MALLINFO(VG_Z_LIBC_SONAME, mallinfo); ++MALLINFO(NONE, mallinfo); + + + #if defined(VGO_darwin) |