diff options
author | Marko Mäkelä <marko.makela@oracle.com> | 2010-05-20 13:40:42 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@oracle.com> | 2010-05-20 13:40:42 +0300 |
commit | 98406ba452be5fc8b0ee53cf69812342af1c9ffb (patch) | |
tree | e35668f8c56a797b5b3dbc27c5b20a1fbf607a7e /include | |
parent | 3564a2643f49e3b4a75f2c6af9cf697971d2aa4f (diff) | |
download | mariadb-git-98406ba452be5fc8b0ee53cf69812342af1c9ffb.tar.gz |
Bug#53593: Add some instrumentation to improve Valgrind sensitivity
BUILD/*: Add valgrind_configs=--with-valgrind.
BUILD/*: Remove -USAFEMALLOC from valgrind_flags.
configure.in: Add AC_ARG_WITH(valgrind) and HAVE_VALGRIND.
include/my_sys.h: Define a number of MEM_ wrappers for VALGRIND_ functions.
include/my_sys.h: Make TRASH do MEM_UNDEFINED().
include/m_string.h: Remove unused macro bzero_if_purify(A,B).
_mymalloc(): Declare MEM_UNDEFINED() on the allocated memory.
_myfree(): Declare MEM_NOACCESS() on the freed memory.
storage/innobase/include/univ.i: Enable UNIV_DEBUG_VALGRIND based on
HAVE_VALGRIND rather than HAVE_purify.
Possible things to do:
* In my_global.h, remove the defined(HAVE_purify) condition
from the _WIN32 uint3korr().
* In my_global.h *int*korr(), use | instead of +
in order to keep the Valgrind V bits accurate
* Consider replacing HAVE_purify with HAVE_VALGRIND
* Use VALGRIND_CREATE_BLOCK, VALGRIND_DISCARD in mem_root and similar places
Diffstat (limited to 'include')
-rw-r--r-- | include/m_string.h | 3 | ||||
-rw-r--r-- | include/my_sys.h | 17 |
2 files changed, 15 insertions, 5 deletions
diff --git a/include/m_string.h b/include/m_string.h index a25675f2638..b2a1d9ff2f4 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -127,9 +127,6 @@ extern size_t bcmp(const uchar *s1,const uchar *s2,size_t len); extern size_t my_bcmp(const uchar *s1,const uchar *s2,size_t len); #undef bcmp #define bcmp(A,B,C) my_bcmp((A),(B),(C)) -#define bzero_if_purify(A,B) bzero(A,B) -#else -#define bzero_if_purify(A,B) #endif /* HAVE_purify */ #ifndef bmove512 diff --git a/include/my_sys.h b/include/my_sys.h index 59b44307b6f..4b26cbee8cd 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -25,6 +25,19 @@ typedef struct my_aio_result { } my_aio_result; #endif +#ifdef HAVE_VALGRIND +# include <valgrind/memcheck.h> +# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len) +# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len) +# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len) +# define MEM_CHECK_DEFINED(a,len) VALGRIND_CHECK_MEM_IS_DEFINED(a,len) +#else /* HAVE_VALGRIND */ +# define MEM_UNDEFINED(a,len) ((void) 0) +# define MEM_NOACCESS(a,len) ((void) 0) +# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0) +# define MEM_CHECK_DEFINED(a,len) ((void) 0) +#endif /* HAVE_VALGRIND */ + #ifndef THREAD extern int NEAR my_errno; /* Last error in mysys */ #else @@ -141,7 +154,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C) #define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C) #define my_strndup(A,B,C) _my_strndup((A),(B),__FILE__,__LINE__,C) -#define TRASH(A,B) bfill(A, B, 0x8F) +#define TRASH(A,B) do { bfill(A, B, 0x8F); MEM_UNDEFINED(A, B); } while (0) #define QUICK_SAFEMALLOC sf_malloc_quick=1 #define NORMAL_SAFEMALLOC sf_malloc_quick=0 extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick; @@ -169,7 +182,7 @@ extern char *my_strndup(const char *from, size_t length, #define CALLER_INFO_PROTO /* nothing */ #define CALLER_INFO /* nothing */ #define ORIG_CALLER_INFO /* nothing */ -#define TRASH(A,B) /* nothing */ +#define TRASH(A,B) do{MEM_CHECK_ADDRESSABLE(A,B);MEM_UNDEFINED(A,B);} while (0) #endif #if defined(ENABLED_DEBUG_SYNC) |