LCOV - differential code coverage report
Current view: top level - src/include/utils - memdebug.h (source / functions) Coverage Total Hit CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 100.0 % 11 11 11
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 3 3 3
Baseline: lcov-20250906-005545-baseline Line coverage date bins:
Baseline Date: 2025-09-05 08:21:35 +0100 (360..) days: 100.0 % 11 11 11
Legend: Lines:     hit not hit Function coverage date bins:
(360..) days: 100.0 % 3 3 3

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*-------------------------------------------------------------------------
                                  2                 :  *
                                  3                 :  * memdebug.h
                                  4                 :  *    Memory debugging support.
                                  5                 :  *
                                  6                 :  * Currently, this file either wraps <valgrind/memcheck.h> or substitutes
                                  7                 :  * empty definitions for Valgrind client request macros we use.
                                  8                 :  *
                                  9                 :  *
                                 10                 :  * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
                                 11                 :  * Portions Copyright (c) 1994, Regents of the University of California
                                 12                 :  *
                                 13                 :  * src/include/utils/memdebug.h
                                 14                 :  *
                                 15                 :  *-------------------------------------------------------------------------
                                 16                 :  */
                                 17                 : #ifndef MEMDEBUG_H
                                 18                 : #define MEMDEBUG_H
                                 19                 : 
                                 20                 : #ifdef USE_VALGRIND
                                 21                 : #include <valgrind/memcheck.h>
                                 22                 : #else
                                 23                 : #define VALGRIND_CHECK_MEM_IS_DEFINED(addr, size)           do {} while (0)
                                 24                 : #define VALGRIND_CREATE_MEMPOOL(context, redzones, zeroed)  do {} while (0)
                                 25                 : #define VALGRIND_DESTROY_MEMPOOL(context)                   do {} while (0)
                                 26                 : #define VALGRIND_MAKE_MEM_DEFINED(addr, size)               do {} while (0)
                                 27                 : #define VALGRIND_MAKE_MEM_NOACCESS(addr, size)              do {} while (0)
                                 28                 : #define VALGRIND_MAKE_MEM_UNDEFINED(addr, size)             do {} while (0)
                                 29                 : #define VALGRIND_MEMPOOL_ALLOC(context, addr, size)         do {} while (0)
                                 30                 : #define VALGRIND_MEMPOOL_FREE(context, addr)                do {} while (0)
                                 31                 : #define VALGRIND_MEMPOOL_CHANGE(context, optr, nptr, size)  do {} while (0)
                                 32                 : #define VALGRIND_MEMPOOL_TRIM(context, addr, size)          do {} while (0)
                                 33                 : #endif
                                 34                 : 
                                 35                 : 
                                 36                 : #ifdef CLOBBER_FREED_MEMORY
                                 37                 : 
                                 38                 : /* Wipe freed memory for debugging purposes */
                                 39                 : static inline void
 3113 andres@anarazel.de         40 CBC   273718752 : wipe_mem(void *ptr, size_t size)
                                 41                 : {
                                 42                 :     VALGRIND_MAKE_MEM_UNDEFINED(ptr, size);
                                 43       273718752 :     memset(ptr, 0x7F, size);
                                 44                 :     VALGRIND_MAKE_MEM_NOACCESS(ptr, size);
                                 45       273718752 : }
                                 46                 : 
                                 47                 : #endif                          /* CLOBBER_FREED_MEMORY */
                                 48                 : 
                                 49                 : #ifdef MEMORY_CONTEXT_CHECKING
                                 50                 : 
                                 51                 : static inline void
                                 52       366844263 : set_sentinel(void *base, Size offset)
                                 53                 : {
                                 54       366844263 :     char       *ptr = (char *) base + offset;
                                 55                 : 
                                 56                 :     VALGRIND_MAKE_MEM_UNDEFINED(ptr, 1);
                                 57       366844263 :     *ptr = 0x7E;
                                 58                 :     VALGRIND_MAKE_MEM_NOACCESS(ptr, 1);
                                 59       366844263 : }
                                 60                 : 
                                 61                 : static inline bool
                                 62      1884376180 : sentinel_ok(const void *base, Size offset)
                                 63                 : {
                                 64      1884376180 :     const char *ptr = (const char *) base + offset;
                                 65                 :     bool        ret;
                                 66                 : 
                                 67                 :     VALGRIND_MAKE_MEM_DEFINED(ptr, 1);
                                 68      1884376180 :     ret = *ptr == 0x7E;
                                 69                 :     VALGRIND_MAKE_MEM_NOACCESS(ptr, 1);
                                 70                 : 
                                 71      1884376180 :     return ret;
                                 72                 : }
                                 73                 : 
                                 74                 : #endif                          /* MEMORY_CONTEXT_CHECKING */
                                 75                 : 
                                 76                 : #ifdef RANDOMIZE_ALLOCATED_MEMORY
                                 77                 : 
                                 78                 : void        randomize_mem(char *ptr, size_t size);
                                 79                 : 
                                 80                 : #endif                          /* RANDOMIZE_ALLOCATED_MEMORY */
                                 81                 : 
                                 82                 : 
                                 83                 : #endif                          /* MEMDEBUG_H */
        

Generated by: LCOV version 2.4-beta