1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-07 00:35:37 +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

View File

@ -1,22 +1,28 @@
/***********************************************************************************************************************************
Common Command Routines
***********************************************************************************************************************************/
#include <assert.h>
#include <string.h>
#include "common/debug.h"
#include "common/log.h"
#include "common/memContext.h"
#include "config/config.h"
#include "version.h"
/***********************************************************************************************************************************
Debug Asserts
***********************************************************************************************************************************/
// The command must be set
#define ASSERT_DEBUG_COMMAND_SET() \
ASSERT_DEBUG(cfgCommand() != cfgCmdNone)
/***********************************************************************************************************************************
Begin the command
***********************************************************************************************************************************/
void
cmdBegin()
{
// A command must be set
assert(cfgCommand() != cfgCmdNone);
ASSERT_DEBUG_COMMAND_SET();
// This is fairly expensive log message to generate so skip it if it won't be output
if (logWill(cfgLogLevelDefault()))
@ -112,8 +118,7 @@ End the command
void
cmdEnd(int code)
{
// A command must be set
assert(cfgCommand() != cfgCmdNone);
ASSERT_DEBUG_COMMAND_SET();
// Skip this log message if it won't be output. It's not too expensive but since we skipped cmdBegin(), may as well.
if (logWill(cfgLogLevelDefault()))