summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-07-10 19:55:54 +0200
committerSergei Golubchik <sergii@pisem.net>2011-07-10 19:55:54 +0200
commit172f5e28ba9efceb3d3cee40c8373d2ee66f7c7a (patch)
tree2699ed6525a405595de40da2ec5e31793ee63f16 /include
parent02b8232629807ca3e37b99489f8191c549f7569a (diff)
downloadmariadb-git-172f5e28ba9efceb3d3cee40c8373d2ee66f7c7a.tar.gz
add safemalloc back
... but differently client/mysqltest.cc: my_safe_print_str() don't append \n anymore dbug/dbug.c: restore safemalloc as a part of dbug suite dbug/user.r: restore 'S' flag documentation include/my_dbug.h: restore safemalloc as a part of dbug suite include/my_sys.h: move valgrind defines to a dedicated header mysys/my_malloc.c: use new safemalloc mysys/stacktrace.c: don't append \n. let the calller do it, if needed sql/mysqld.cc: my_safe_print_str() don't append \n anymore
Diffstat (limited to 'include')
-rw-r--r--include/my_dbug.h10
-rw-r--r--include/my_sys.h25
-rw-r--r--include/my_valgrind.h46
3 files changed, 57 insertions, 24 deletions
diff --git a/include/my_dbug.h b/include/my_dbug.h
index 6aef3ac1b36..9c81b0cf919 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -66,6 +66,9 @@ extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void);
extern void _db_flush_();
extern const char* _db_get_func_(void);
+extern void *_db_malloc_(size_t size);
+extern void *_db_realloc_(void *ptr, size_t size);
+extern void _db_free_(void *ptr);
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
@@ -98,6 +101,10 @@ extern const char* _db_get_func_(void);
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
+#define DBUG_MALLOC(SIZE) _db_malloc_(SIZE)
+#define DBUG_REALLOC(PTR,SIZE) _db_realloc_(PTR,SIZE)
+#define DBUG_FREE(PTR) _db_free_(PTR)
+
#ifndef __WIN__
#define DBUG_ABORT() (_db_flush_(), abort())
#else
@@ -163,6 +170,9 @@ extern void _db_suicide_();
#define DBUG_EXPLAIN_INITIAL(buf,len)
#define DEBUGGER_OFF do { } while(0)
#define DEBUGGER_ON do { } while(0)
+#define DBUG_MALLOC(SIZE) malloc(SIZE)
+#define DBUG_REALLOC(PTR,SIZE) realloc(PTR,SIZE)
+#define DBUG_FREE(PTR) free(PTR)
#define DBUG_ABORT() do { } while(0)
#define DBUG_CRASH_ENTER(func)
#define DBUG_CRASH_RETURN(val) do { return(val); } while(0)
diff --git a/include/my_sys.h b/include/my_sys.h
index cbc5f277a52..0fdae2eb5df 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -28,24 +28,7 @@ typedef struct my_aio_result {
} my_aio_result;
#endif
-#ifdef HAVE_valgrind
-#define IF_VALGRIND(A,B) A
-#else
-#define IF_VALGRIND(A,B) B
-#endif
-
-#if defined(HAVE_valgrind) && defined(HAVE_VALGRIND_MEMCHECK_H)
-# 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 */
+#include <my_valgrind.h>
#include <my_pthread.h>
@@ -168,12 +151,6 @@ extern void *my_memdup(const void *from,size_t length,myf MyFlags);
extern char *my_strdup(const char *from,myf MyFlags);
extern char *my_strndup(const char *from, size_t length,
myf MyFlags);
-#ifdef SAFEMALLOC
-#define TRASH(A,B) do { bfill(A, B, 0x8F); MEM_UNDEFINED(A, B); } while (0)
-#else
-#define TRASH(A,B) do{MEM_CHECK_ADDRESSABLE(A,B);MEM_UNDEFINED(A,B);} while (0)
-#endif
-
#if defined(ENABLED_DEBUG_SYNC)
extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
#define DEBUG_SYNC_C(_sync_point_name_) do { \
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
new file mode 100644
index 00000000000..c0a6cef4b59
--- /dev/null
+++ b/include/my_valgrind.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 2010 Monty Program Ab
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+
+/* Some defines to make it easier to use valgrind */
+
+#ifdef HAVE_valgrind
+#define IF_VALGRIND(A,B) A
+#else
+#define IF_VALGRIND(A,B) B
+#endif
+
+#if defined(HAVE_valgrind) && defined(HAVE_VALGRIND_MEMCHECK_H)
+# 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 DBUG_OFF
+#define TRASH_FILL(A,B,C) do { bfill(A, B, C); MEM_UNDEFINED(A, B); } while (0)
+#else
+#define TRASH_FILL(A,B,C) do{ MEM_CHECK_ADDRESSABLE(A,B);MEM_UNDEFINED(A,B);} while (0)
+#endif
+#define TRASH_ALLOC(A,B) TRASH_FILL(A,B,0xA5)
+#define TRASH_FREE(A,B) TRASH_FILL(A,B,0x8F)
+#define TRASH(A,B) TRASH_FREE(A,B)
+