1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-01 00:25:06 +02:00

Add ASSERT_DEBUG() macro for debugging.

Replace all current assert() calls except in tests that can't use the debug code.
This commit is contained in:
David Steele
2018-03-12 14:31:22 -04:00
parent dd31ae832d
commit cced6ec03a
17 changed files with 133 additions and 25 deletions

29
src/common/debug.h Normal file
View File

@ -0,0 +1,29 @@
/***********************************************************************************************************************************
Debug Routines
***********************************************************************************************************************************/
#ifndef COMMON_DEBUG_H
#define COMMON_DEBUG_H
#include "common/log.h"
/***********************************************************************************************************************************
NDEBUG indicates to C library routines that debugging is off -- set a more readable flag to use when debugging is on
***********************************************************************************************************************************/
#ifndef NDEBUG
#define DEBUG
#endif
/***********************************************************************************************************************************
Assert Macros
***********************************************************************************************************************************/
#ifdef DEBUG
#define ASSERT_DEBUG(condition) \
{ \
if (!(condition)) \
THROW(AssertError, "assertion '%s' failed", #condition); \
}
#else
#define ASSERT_DEBUG(condition)
#endif
#endif