From: Philippe Waroquiers Date: Mon, 1 Sep 2014 21:46:52 +0000 (+0000) Subject: Prepare to change the default for --read-inline-info from =no to =yes X-Git-Tag: svn/VALGRIND_3_10_0~88 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad93992adcd109c4feb86f7224b77724dc17cb74;p=thirdparty%2Fvalgrind.git Prepare to change the default for --read-inline-info from =no to =yes The interception/replacements functions should preferrably not depend on the value of --read-inline-info. The idea is to change the default from no to yes. Depending on the no or yes, some intercept/replacement functions that are inlined will be shown or not shown in stacktraces. To have such stack traces not depending on the value of --read-inline-info, such functions should either be marked as noinline or be defined as macros. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14419 --- diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 8d34ebb9b9..5c5dd1b1cc 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -208,16 +208,14 @@ static void init(void); to a NON SIMD call. The definedness of such 'unused' arguments will not be verified by memcheck. - A call to 'trigger_memcheck_error_if_undefined' allows + The macro 'TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED' allows memcheck to detect such errors for the otherwise unused args. - Apart of allowing memcheck to detect an error, the function - trigger_memcheck_error_if_undefined has no effect and + Apart of allowing memcheck to detect an error, the macro + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED has no effect and has a minimal cost for other tools replacing malloc functions. */ -static inline void trigger_memcheck_error_if_undefined ( ULong x ) -{ - if (x == 0) __asm__ __volatile__( "" ::: "memory" ); -} +#define TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(x) \ + if ((ULong)x == 0) __asm__ __volatile__( "" ::: "memory" ) /*---------------------- malloc ----------------------*/ @@ -232,7 +230,7 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) void* v; \ \ DO_INIT; \ - trigger_memcheck_error_if_undefined((ULong)n ); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(n); \ MALLOC_TRACE(#fnname "(%llu)", (ULong)n ); \ \ v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, n ); \ @@ -248,8 +246,8 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) void* v; \ \ DO_INIT; \ - trigger_memcheck_error_if_undefined((ULong)(UWord) zone); \ - trigger_memcheck_error_if_undefined((ULong) n); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(n); \ MALLOC_TRACE(#fnname "(%p, %llu)", zone, (ULong)n ); \ \ v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, n ); \ @@ -270,7 +268,7 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) void* v; \ \ DO_INIT; \ - trigger_memcheck_error_if_undefined((ULong) n); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(n); \ MALLOC_TRACE(#fnname "(%llu)", (ULong)n ); \ \ v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, n ); \ @@ -450,7 +448,7 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) void VG_REPLACE_FUNCTION_EZU(10040,soname,fnname) (void *zone, void *p) \ { \ DO_INIT; \ - trigger_memcheck_error_if_undefined((ULong)(UWord) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord) zone); \ MALLOC_TRACE(#fnname "(%p, %p)\n", zone, p ); \ if (p == NULL) \ return; \ @@ -584,9 +582,9 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) void* v; \ \ DO_INIT; \ - trigger_memcheck_error_if_undefined((ULong)(UWord) zone); \ - trigger_memcheck_error_if_undefined((ULong) nmemb); \ - trigger_memcheck_error_if_undefined((ULong) size); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(nmemb); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(size); \ MALLOC_TRACE("zone_calloc(%p, %llu,%llu)", zone, (ULong)nmemb, (ULong)size ); \ \ v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_calloc, nmemb, size ); \ @@ -715,8 +713,8 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) void* v; \ \ DO_INIT; \ - trigger_memcheck_error_if_undefined((ULong)(UWord) zone); \ - trigger_memcheck_error_if_undefined((ULong) n); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(n); \ MALLOC_TRACE("zone_memalign(%p, al %llu, size %llu)", \ zone, (ULong)alignment, (ULong)n ); \ \ @@ -742,7 +740,7 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) void* v; \ \ DO_INIT; \ - trigger_memcheck_error_if_undefined((ULong) n); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(n); \ MALLOC_TRACE("memalign(al %llu, size %llu)", \ (ULong)alignment, (ULong)n ); \ \ @@ -795,7 +793,7 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) static int pszB = 0; \ if (pszB == 0) \ pszB = my_getpagesize(); \ - trigger_memcheck_error_if_undefined((ULong)(UWord) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(UWord) zone); \ return VG_REPLACE_FUNCTION_EZU(10110,VG_Z_LIBC_SONAME,memalign) \ ((SizeT)pszB, size); \ } @@ -824,8 +822,8 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) { \ /* In glibc-2.2.4, 1 denotes a successful return value for \ mallopt */ \ - trigger_memcheck_error_if_undefined((ULong) cmd); \ - trigger_memcheck_error_if_undefined((ULong) value); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(cmd); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(value); \ return 1; \ } @@ -869,7 +867,7 @@ static inline void trigger_memcheck_error_if_undefined ( ULong x ) { \ /* 0 denotes that malloc_trim() either wasn't able \ to do anything, or was not implemented */ \ - trigger_memcheck_error_if_undefined((ULong) pad); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(pad); \ return 0; \ } @@ -1046,8 +1044,8 @@ static size_t my_malloc_size ( void* zone, void* ptr ) /* Implement "malloc_size" by handing the request through to the tool's .tl_usable_size method. */ DO_INIT; - trigger_memcheck_error_if_undefined((ULong)(UWord) zone); - trigger_memcheck_error_if_undefined((ULong)(UWord) ptr); + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord) zone); + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord) ptr); size_t res = (size_t)VALGRIND_NON_SIMD_CALL1( info.tl_malloc_usable_size, ptr); return res; @@ -1119,7 +1117,7 @@ ZONE_FROM_PTR(SO_SYN_MALLOC, malloc_zone_from_ptr); int VG_REPLACE_FUNCTION_EZU(10240,soname,fnname)(void* zone); \ int VG_REPLACE_FUNCTION_EZU(10240,soname,fnname)(void* zone) \ { \ - trigger_memcheck_error_if_undefined((ULong) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(zone); \ panic(#fnname); \ return 1; \ } @@ -1133,7 +1131,7 @@ ZONE_CHECK(SO_SYN_MALLOC, malloc_zone_check); void VG_REPLACE_FUNCTION_EZU(10250,soname,fnname)(void* zone); \ void VG_REPLACE_FUNCTION_EZU(10250,soname,fnname)(void* zone) \ { \ - trigger_memcheck_error_if_undefined((ULong) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(zone); \ } ZONE_REGISTER(VG_Z_LIBC_SONAME, malloc_zone_register); @@ -1145,7 +1143,7 @@ ZONE_REGISTER(SO_SYN_MALLOC, malloc_zone_register); void VG_REPLACE_FUNCTION_EZU(10260,soname,fnname)(void* zone); \ void VG_REPLACE_FUNCTION_EZU(10260,soname,fnname)(void* zone) \ { \ - trigger_memcheck_error_if_undefined((ULong) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(zone); \ } ZONE_UNREGISTER(VG_Z_LIBC_SONAME, malloc_zone_unregister); @@ -1157,7 +1155,7 @@ ZONE_UNREGISTER(SO_SYN_MALLOC, malloc_zone_unregister); void VG_REPLACE_FUNCTION_EZU(10270,soname,fnname)(void* zone, char* nm); \ void VG_REPLACE_FUNCTION_EZU(10270,soname,fnname)(void* zone, char* nm) \ { \ - trigger_memcheck_error_if_undefined((ULong) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(zone); \ } ZONE_SET_NAME(VG_Z_LIBC_SONAME, malloc_set_zone_name); @@ -1169,7 +1167,7 @@ ZONE_SET_NAME(SO_SYN_MALLOC, malloc_set_zone_name); char* VG_REPLACE_FUNCTION_EZU(10280,soname,fnname)(void* zone); \ char* VG_REPLACE_FUNCTION_EZU(10280,soname,fnname)(void* zone) \ { \ - trigger_memcheck_error_if_undefined((ULong) zone); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(zone); \ return vg_default_zone.zone_name; \ }