diff options
author | Noah Misch <noah@leadboat.com> | 2013-06-26 20:00:08 -0400 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2013-06-26 20:22:25 -0400 |
commit | 19085116eeecfde0a3fc1611eaffccc35bcec204 (patch) | |
tree | 415f6a5e558f735c107cda09a81709898ee1f028 /src/include/utils/memdebug.h | |
parent | a855148a29b786b179308b3bd5c59fe5b67110d8 (diff) | |
download | postgresql-19085116eeecfde0a3fc1611eaffccc35bcec204.tar.gz postgresql-19085116eeecfde0a3fc1611eaffccc35bcec204.zip |
Cooperate with the Valgrind instrumentation framework.
Valgrind "client requests" in aset.c and mcxt.c teach Valgrind and its
Memcheck tool about the PostgreSQL allocator. This makes Valgrind
roughly as sensitive to memory errors involving palloc chunks as it is
to memory errors involving malloc chunks. Further client requests in
PageAddItem() and printtup() verify that all bits being added to a
buffer page or furnished to an output function are predictably-defined.
Those tests catch failures of C-language functions to fully initialize
the bits of a Datum, which in turn stymie optimizations that rely on
_equalConst(). Define the USE_VALGRIND symbol in pg_config_manual.h to
enable these additions. An included "suppression file" silences nominal
errors we don't plan to fix.
Reviewed in earlier versions by Peter Geoghegan and Korry Douglas.
Diffstat (limited to 'src/include/utils/memdebug.h')
-rw-r--r-- | src/include/utils/memdebug.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/include/utils/memdebug.h b/src/include/utils/memdebug.h new file mode 100644 index 00000000000..0b955693e61 --- /dev/null +++ b/src/include/utils/memdebug.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * + * memdebug.h + * Memory debugging support. + * + * Currently, this file either wraps <valgrind/memcheck.h> or substitutes + * empty definitions for Valgrind client request macros we use. + * + * + * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/utils/memdebug.h + * + *------------------------------------------------------------------------- + */ +#ifndef MEMDEBUG_H +#define MEMDEBUG_H + +#ifdef USE_VALGRIND +#include <valgrind/memcheck.h> +#else +#define VALGRIND_CHECK_MEM_IS_DEFINED(addr, size) do {} while (0) +#define VALGRIND_CREATE_MEMPOOL(context, redzones, zeroed) do {} while (0) +#define VALGRIND_DESTROY_MEMPOOL(context) do {} while (0) +#define VALGRIND_MAKE_MEM_DEFINED(addr, size) do {} while (0) +#define VALGRIND_MAKE_MEM_NOACCESS(addr, size) do {} while (0) +#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size) do {} while (0) +#define VALGRIND_MEMPOOL_ALLOC(context, addr, size) do {} while (0) +#define VALGRIND_MEMPOOL_FREE(context, addr) do {} while (0) +#define VALGRIND_MEMPOOL_CHANGE(context, optr, nptr, size) do {} while (0) +#endif + +#endif /* MEMDEBUG_H */ |