LCOV - differential code coverage report
Current view: top level - src/include/utils - memdebug.h (source / functions) Coverage Total Hit CBC
Current: Differential Code Coverage HEAD vs 15 Lines: 100.0 % 11 11 11
Current Date: 2023-04-08 17:13:01 Functions: 100.0 % 3 3 3
Baseline: 15 Line coverage date bins:
Baseline Date: 2023-04-08 15:09:40 (240..) days: 100.0 % 11 11 11
Legend: Lines: hit not hit Function coverage date bins:
(240..) 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-2023, 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                 : #endif
                                 33                 : 
                                 34                 : 
                                 35                 : #ifdef CLOBBER_FREED_MEMORY
                                 36                 : 
                                 37                 : /* Wipe freed memory for debugging purposes */
                                 38                 : static inline void
 2232 andres                     39 CBC   304512360 : wipe_mem(void *ptr, size_t size)
                                 40                 : {
                                 41                 :     VALGRIND_MAKE_MEM_UNDEFINED(ptr, size);
                                 42       304512360 :     memset(ptr, 0x7F, size);
                                 43                 :     VALGRIND_MAKE_MEM_NOACCESS(ptr, size);
                                 44       304512360 : }
                                 45                 : 
                                 46                 : #endif                          /* CLOBBER_FREED_MEMORY */
                                 47                 : 
                                 48                 : #ifdef MEMORY_CONTEXT_CHECKING
                                 49                 : 
                                 50                 : static inline void
                                 51       434549281 : set_sentinel(void *base, Size offset)
                                 52                 : {
                                 53       434549281 :     char       *ptr = (char *) base + offset;
                                 54                 : 
                                 55                 :     VALGRIND_MAKE_MEM_UNDEFINED(ptr, 1);
                                 56       434549281 :     *ptr = 0x7E;
                                 57                 :     VALGRIND_MAKE_MEM_NOACCESS(ptr, 1);
                                 58       434549281 : }
                                 59                 : 
                                 60                 : static inline bool
                                 61      2740479807 : sentinel_ok(const void *base, Size offset)
                                 62                 : {
                                 63      2740479807 :     const char *ptr = (const char *) base + offset;
                                 64                 :     bool        ret;
                                 65                 : 
                                 66                 :     VALGRIND_MAKE_MEM_DEFINED(ptr, 1);
                                 67      2740479807 :     ret = *ptr == 0x7E;
                                 68                 :     VALGRIND_MAKE_MEM_NOACCESS(ptr, 1);
                                 69                 : 
                                 70      2740479807 :     return ret;
                                 71                 : }
                                 72                 : 
                                 73                 : #endif                          /* MEMORY_CONTEXT_CHECKING */
                                 74                 : 
                                 75                 : #ifdef RANDOMIZE_ALLOCATED_MEMORY
                                 76                 : 
                                 77                 : void        randomize_mem(char *ptr, size_t size);
                                 78                 : 
                                 79                 : #endif                          /* RANDOMIZE_ALLOCATED_MEMORY */
                                 80                 : 
                                 81                 : 
                                 82                 : #endif                          /* MEMDEBUG_H */
        

Generated by: LCOV version v1.16-55-g56c0a2a