| OLD | NEW |
| (Empty) |
| 1 Index: coregrind/m_replacemalloc/vg_replace_malloc.c | |
| 2 =================================================================== | |
| 3 --- coregrind/m_replacemalloc/vg_replace_malloc.c (revision 11055) | |
| 4 +++ coregrind/m_replacemalloc/vg_replace_malloc.c (working copy) | |
| 5 @@ -234,6 +234,23 @@ | |
| 6 // malloc | |
| 7 ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, malloc, malloc); | |
| 8 ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc, malloc); | |
| 9 +// Handle libtcmalloc's malloc() function. | |
| 10 +// Similar interceptors are added below to handle other libtcmalloc | |
| 11 +// allocation/deallocation functions. | |
| 12 +// soname=NONE means that a user's allocation function is intercepted. | |
| 13 +ALLOC_or_NULL(NONE, malloc, malloc); | |
| 14 +// Handle libtcmalloc's malloc() function. | |
| 15 +// Similar interceptors are added below to handle other libtcmalloc | |
| 16 +// allocation/deallocation functions. | |
| 17 +// soname=NONE means that a user's allocation function is intercepted. | |
| 18 +ALLOC_or_NULL(NONE, tc_malloc, malloc); | |
| 19 +// Bash has sh_malloc() and sh_free() along with standard malloc() and free(). | |
| 20 +// Sometimes these functions are called inconsistently (e.g. free() after | |
| 21 +// sh_malloc()). To deal with this we have to intercept the sh_*() functions | |
| 22 +// as well. | |
| 23 +ALLOC_or_NULL(NONE, sh_malloc, malloc); | |
| 24 +// Handle Python's malloc. | |
| 25 +ALLOC_or_NULL(NONE, PyObject_Malloc, malloc); | |
| 26 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) | |
| 27 ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_common, malloc); | |
| 28 #elif defined(VGO_darwin) | |
| 29 @@ -246,20 +263,24 @@ | |
| 30 // operator new(unsigned int), not mangled (for gcc 2.96) | |
| 31 ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, builtin_new, __builtin_new); | |
| 32 ALLOC_or_BOMB(VG_Z_LIBC_SONAME, builtin_new, __builtin_new); | |
| 33 +ALLOC_or_BOMB(NONE, builtin_new, __builtin_new); | |
| 34 | |
| 35 ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_new, __builtin_new); | |
| 36 ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_new, __builtin_new); | |
| 37 +ALLOC_or_BOMB(NONE, __builtin_new, __builtin_new); | |
| 38 | |
| 39 // operator new(unsigned int), GNU mangling | |
| 40 #if VG_WORDSIZE == 4 | |
| 41 ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwj, __builtin_new); | |
| 42 ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwj, __builtin_new); | |
| 43 + ALLOC_or_BOMB(NONE, _Znwj, __builtin_new); | |
| 44 #endif | |
| 45 | |
| 46 // operator new(unsigned long), GNU mangling | |
| 47 #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGO_darwin) | |
| 48 ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwm, __builtin_new); | |
| 49 ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwm, __builtin_new); | |
| 50 + ALLOC_or_BOMB(NONE, _Znwm, __builtin_new); | |
| 51 #endif | |
| 52 | |
| 53 // operator new(unsigned long), ARM/cfront mangling | |
| 54 @@ -267,19 +288,24 @@ | |
| 55 ALLOC_or_BOMB(VG_Z_LIBC_DOT_A, __nw__FUl, __builtin_new); | |
| 56 #endif | |
| 57 | |
| 58 +// libtcmalloc's new | |
| 59 +ALLOC_or_BOMB(NONE, tc_new, __builtin_new); | |
| 60 | |
| 61 + | |
| 62 /*---------------------- new nothrow ----------------------*/ | |
| 63 | |
| 64 // operator new(unsigned, std::nothrow_t const&), GNU mangling | |
| 65 #if VG_WORDSIZE == 4 | |
| 66 ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new); | |
| 67 ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new); | |
| 68 + ALLOC_or_NULL(NONE, _ZnwjRKSt9nothrow_t, __builtin_new); | |
| 69 #endif | |
| 70 | |
| 71 // operator new(unsigned long, std::nothrow_t const&), GNU mangling | |
| 72 #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || d
efined(VGO_darwin) | |
| 73 ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new); | |
| 74 ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new); | |
| 75 + ALLOC_or_NULL(NONE, _ZnwmRKSt9nothrow_t, __builtin_new); | |
| 76 #endif | |
| 77 | |
| 78 // operator new(unsigned long, std::nothrow_t const&), ARM/cfront mangling | |
| 79 @@ -287,23 +313,29 @@ | |
| 80 ALLOC_or_NULL(VG_Z_LIBC_DOT_A, __nw__FUlRCQ2_3std9nothrow_t, __builtin_new)
; | |
| 81 #endif | |
| 82 | |
| 83 +// libtcmalloc's new nothrow | |
| 84 +ALLOC_or_NULL(NONE, tc_new_nothrow, __builtin_new); | |
| 85 | |
| 86 + | |
| 87 /*---------------------- new [] ----------------------*/ | |
| 88 | |
| 89 // operator new[](unsigned int), not mangled (for gcc 2.96) | |
| 90 ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_new, __builtin_vec_new ); | |
| 91 ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_vec_new, __builtin_vec_new ); | |
| 92 +ALLOC_or_BOMB(NONE, __builtin_vec_new, __builtin_vec_new ); | |
| 93 | |
| 94 // operator new[](unsigned int), GNU mangling | |
| 95 #if VG_WORDSIZE == 4 | |
| 96 ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znaj, __builtin_vec_new ); | |
| 97 ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znaj, __builtin_vec_new ); | |
| 98 + ALLOC_or_BOMB(NONE, _Znaj, __builtin_vec_new ); | |
| 99 #endif | |
| 100 | |
| 101 // operator new[](unsigned long), GNU mangling | |
| 102 #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || d
efined(VGO_darwin) | |
| 103 ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znam, __builtin_vec_new ); | |
| 104 ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znam, __builtin_vec_new ); | |
| 105 + ALLOC_or_BOMB(NONE, _Znam, __builtin_vec_new ); | |
| 106 #endif | |
| 107 | |
| 108 // operator new[](unsigned long), ARM/cfront mangling | |
| 109 @@ -311,19 +343,24 @@ | |
| 110 ALLOC_or_BOMB(VG_Z_LIBC_DOT_A, __vn__FUl, __builtin_vec_new); | |
| 111 #endif | |
| 112 | |
| 113 +// libtcmalloc's new [] | |
| 114 +ALLOC_or_BOMB(NONE, tc_newarray, __builtin_vec_new); | |
| 115 | |
| 116 + | |
| 117 /*---------------------- new [] nothrow ----------------------*/ | |
| 118 | |
| 119 // operator new[](unsigned, std::nothrow_t const&), GNU mangling | |
| 120 #if VG_WORDSIZE == 4 | |
| 121 ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new ); | |
| 122 ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new ); | |
| 123 + ALLOC_or_NULL(NONE, _ZnajRKSt9nothrow_t, __builtin_vec_new ); | |
| 124 #endif | |
| 125 | |
| 126 // operator new[](unsigned long, std::nothrow_t const&), GNU mangling | |
| 127 #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || d
efined(VGO_darwin) | |
| 128 ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new ); | |
| 129 ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new ); | |
| 130 + ALLOC_or_NULL(NONE, _ZnamRKSt9nothrow_t, __builtin_vec_new ); | |
| 131 #endif | |
| 132 | |
| 133 // operator new [](unsigned long, std::nothrow_t const&), ARM/cfront mangling | |
| 134 @@ -331,7 +368,10 @@ | |
| 135 ALLOC_or_BOMB(VG_Z_LIBC_DOT_A, __vn__FUlRCQ2_3std9nothrow_t, __builtin_vec_n
ew ); | |
| 136 #endif | |
| 137 | |
| 138 +// libtcmalloc's new [] nothrow | |
| 139 +ALLOC_or_NULL(NONE, tc_newarray_nothrow, __builtin_vec_new); | |
| 140 | |
| 141 + | |
| 142 /*---------------------- free ----------------------*/ | |
| 143 | |
| 144 /* Generate a replacement for 'fnname' in object 'soname', which calls | |
| 145 @@ -364,6 +404,10 @@ | |
| 146 // free | |
| 147 FREE(VG_Z_LIBSTDCXX_SONAME, free, free ); | |
| 148 FREE(VG_Z_LIBC_SONAME, free, free ); | |
| 149 +FREE(NONE, free, free ); | |
| 150 +FREE(NONE, sh_free, free ); | |
| 151 +FREE(NONE, tc_free, free ); | |
| 152 +FREE(NONE, PyObject_Free, free ); | |
| 153 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) | |
| 154 FREE(VG_Z_LIBC_SONAME, free_common, free ); | |
| 155 #elif defined(VGO_darwin) | |
| 156 @@ -376,43 +420,57 @@ | |
| 157 // cfree | |
| 158 FREE(VG_Z_LIBSTDCXX_SONAME, cfree, free ); | |
| 159 FREE(VG_Z_LIBC_SONAME, cfree, free ); | |
| 160 +FREE(NONE, cfree, free ); | |
| 161 +FREE(NONE, tc_cfree, free ); | |
| 162 +FREE(NONE, sh_cfree, free ); | |
| 163 | |
| 164 | |
| 165 /*---------------------- delete ----------------------*/ | |
| 166 // operator delete(void*), not mangled (for gcc 2.96) | |
| 167 FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_delete, __builtin_delete ); | |
| 168 FREE(VG_Z_LIBC_SONAME, __builtin_delete, __builtin_delete ); | |
| 169 +FREE(NONE, __builtin_delete, __builtin_delete ); | |
| 170 | |
| 171 // operator delete(void*), GNU mangling | |
| 172 FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); | |
| 173 FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete ); | |
| 174 +FREE(NONE, _ZdlPv, __builtin_delete ); | |
| 175 | |
| 176 // operator delete(void*), ARM/cfront mangling | |
| 177 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) | |
| 178 FREE(VG_Z_LIBC_DOT_A, __dl__FPv, __builtin_delete ); | |
| 179 #endif | |
| 180 | |
| 181 +// libtcmalloc's delete | |
| 182 +FREE(NONE, tc_delete, __builtin_delete); | |
| 183 | |
| 184 + | |
| 185 /*---------------------- delete nothrow ----------------------*/ | |
| 186 | |
| 187 // operator delete(void*, std::nothrow_t const&), GNU mangling | |
| 188 FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete ); | |
| 189 FREE(VG_Z_LIBC_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete ); | |
| 190 +FREE(NONE, _ZdlPvRKSt9nothrow_t, __builtin_delete ); | |
| 191 +// libtcmalloc's delete nothrow | |
| 192 +FREE(NONE, tc_delete_nothrow, __builtin_delete); | |
| 193 | |
| 194 - | |
| 195 /*---------------------- delete [] ----------------------*/ | |
| 196 // operator delete[](void*), not mangled (for gcc 2.96) | |
| 197 FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_delete, __builtin_vec_delete ); | |
| 198 FREE(VG_Z_LIBC_SONAME, __builtin_vec_delete, __builtin_vec_delete ); | |
| 199 +FREE(NONE, __builtin_vec_delete, __builtin_vec_delete ); | |
| 200 | |
| 201 // operator delete[](void*), GNU mangling | |
| 202 FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete ); | |
| 203 FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete ); | |
| 204 +FREE(NONE, _ZdaPv, __builtin_vec_delete ); | |
| 205 | |
| 206 // operator delete[](void*), ARM/cfront mangling | |
| 207 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) | |
| 208 FREE(VG_Z_LIBC_DOT_A, __vd__FPv, __builtin_vec_delete ); | |
| 209 #endif | |
| 210 +// libtcmalloc's delete [] | |
| 211 +FREE(NONE, tc_deletearray, __builtin_vec_delete); | |
| 212 | |
| 213 | |
| 214 /*---------------------- delete [] nothrow ----------------------*/ | |
| 215 @@ -420,6 +478,9 @@ | |
| 216 // operator delete[](void*, std::nothrow_t const&), GNU mangling | |
| 217 FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); | |
| 218 FREE(VG_Z_LIBC_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); | |
| 219 +FREE(NONE, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); | |
| 220 +// libtcmalloc's delete [] nothrow | |
| 221 +FREE(NONE, tc_deletearray_nothrow, __builtin_vec_delete); | |
| 222 | |
| 223 | |
| 224 /*---------------------- calloc ----------------------*/ | |
| 225 @@ -465,6 +526,9 @@ | |
| 226 } | |
| 227 | |
| 228 CALLOC(VG_Z_LIBC_SONAME, calloc); | |
| 229 +CALLOC(NONE, calloc); | |
| 230 +CALLOC(NONE, tc_calloc); | |
| 231 +CALLOC(NONE, sh_calloc); | |
| 232 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) | |
| 233 CALLOC(VG_Z_LIBC_SONAME, calloc_common); | |
| 234 #elif defined(VGO_darwin) | |
| 235 @@ -523,6 +587,10 @@ | |
| 236 } | |
| 237 | |
| 238 REALLOC(VG_Z_LIBC_SONAME, realloc); | |
| 239 +REALLOC(NONE, realloc); | |
| 240 +REALLOC(NONE, tc_realloc); | |
| 241 +REALLOC(NONE, sh_realloc); | |
| 242 +REALLOC(NONE, PyObject_Realloc); | |
| 243 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) | |
| 244 REALLOC(VG_Z_LIBC_SONAME, realloc_common); | |
| 245 #elif defined(VGO_darwin) | |
| 246 @@ -579,6 +647,9 @@ | |
| 247 } | |
| 248 | |
| 249 MEMALIGN(VG_Z_LIBC_SONAME, memalign); | |
| 250 +MEMALIGN(NONE, memalign); | |
| 251 +MEMALIGN(NONE, tc_memalign); | |
| 252 +MEMALIGN(NONE, sh_memalign); | |
| 253 #if defined(VGO_darwin) | |
| 254 ZONEMEMALIGN(VG_Z_LIBC_SONAME, malloc_zone_memalign); | |
| 255 #endif | |
| 256 @@ -621,6 +692,9 @@ | |
| 257 } | |
| 258 | |
| 259 VALLOC(VG_Z_LIBC_SONAME, valloc); | |
| 260 +VALLOC(NONE, valloc); | |
| 261 +VALLOC(NONE, tc_valloc); | |
| 262 +VALLOC(NONE, sh_valloc); | |
| 263 #if defined(VGO_darwin) | |
| 264 ZONEVALLOC(VG_Z_LIBC_SONAME, malloc_zone_valloc); | |
| 265 #endif | |
| 266 @@ -641,6 +715,8 @@ | |
| 267 } | |
| 268 | |
| 269 MALLOPT(VG_Z_LIBC_SONAME, mallopt); | |
| 270 +MALLOPT(NONE, mallopt); | |
| 271 +MALLOPT(NONE, tc_mallopt); | |
| 272 | |
| 273 | |
| 274 /*---------------------- malloc_trim ----------------------*/ | |
| 275 @@ -677,6 +753,7 @@ | |
| 276 } | |
| 277 | |
| 278 MALLOC_TRIM(VG_Z_LIBC_SONAME, malloc_trim); | |
| 279 +MALLOC_TRIM(NONE, malloc_trim); | |
| 280 | |
| 281 | |
| 282 /*---------------------- posix_memalign ----------------------*/ | |
| 283 @@ -707,6 +784,8 @@ | |
| 284 } | |
| 285 | |
| 286 POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign); | |
| 287 +POSIX_MEMALIGN(NONE, posix_memalign); | |
| 288 +POSIX_MEMALIGN(NONE, tc_posix_memalign); | |
| 289 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) | |
| 290 /* 27 Nov 07: it appears that xlc links into executables, a | |
| 291 posix_memalign, which calls onwards to memalign_common, with the | |
| 292 @@ -737,6 +816,7 @@ | |
| 293 | |
| 294 MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_usable_size); | |
| 295 MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_size); | |
| 296 +MALLOC_USABLE_SIZE(NONE, malloc_size); | |
| 297 | |
| 298 | |
| 299 /*---------------------- (unimplemented) ----------------------*/ | |
| 300 @@ -791,6 +871,8 @@ | |
| 301 } | |
| 302 | |
| 303 MALLINFO(VG_Z_LIBC_SONAME, mallinfo); | |
| 304 +MALLINFO(NONE, mallinfo); | |
| 305 +MALLINFO(NONE, tc_mallinfo); | |
| 306 | |
| 307 | |
| 308 #if defined(VGO_darwin) | |
| OLD | NEW |