2014-12-11 10:50:15 +03:00
|
|
|
// Copyright (c) 2012-2014 Konstantin Isakov <ikm@zbackup.org> and ZBackup contributors, see CONTRIBUTORS
|
2014-10-10 13:50:55 +04:00
|
|
|
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
|
2013-07-18 21:33:25 +04:00
|
|
|
|
2015-01-25 19:44:15 +03:00
|
|
|
#ifndef DEBUG_HH_INCLUDED
|
|
|
|
#define DEBUG_HH_INCLUDED
|
2013-07-18 21:33:25 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-01-20 15:46:08 +03:00
|
|
|
#include <typeinfo>
|
2013-07-18 21:33:25 +04:00
|
|
|
|
|
|
|
// Macros we use to output debugging information
|
|
|
|
|
2015-01-20 15:46:08 +03:00
|
|
|
#define __CLASS typeid( *this ).name()
|
|
|
|
|
2013-07-18 21:33:25 +04:00
|
|
|
#ifndef NDEBUG
|
|
|
|
|
2014-12-26 14:16:44 +03:00
|
|
|
#define __FILE_BASE (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
|
|
|
|
|
|
|
#define dPrintf( ... ) ({ fprintf( stderr, "[DEBUG] at %s( %s:%d ): ", __func__,\
|
|
|
|
__FILE_BASE, __LINE__ );\
|
|
|
|
fprintf( stderr, __VA_ARGS__ ); })
|
2013-07-18 21:33:25 +04:00
|
|
|
|
2014-12-31 06:49:06 +03:00
|
|
|
#ifdef HAVE_LIBUNWIND
|
|
|
|
#define UNW_LOCAL_ONLY
|
|
|
|
#include <libunwind.h>
|
|
|
|
|
2015-01-20 15:46:08 +03:00
|
|
|
// TODO: pretty backtraces
|
2014-12-31 06:49:06 +03:00
|
|
|
#define dPrintBacktrace( ... ) ()
|
|
|
|
#else
|
|
|
|
#define dPrintBacktrace( ... ) ()
|
|
|
|
#endif
|
|
|
|
|
2013-07-18 21:33:25 +04:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define dPrintf( ... )
|
2014-12-31 06:49:06 +03:00
|
|
|
#define dPrintBacktrace( ... ) ()
|
2013-07-18 21:33:25 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern bool verboseMode;
|
|
|
|
|
|
|
|
#define verbosePrintf( ... ) ({ if ( verboseMode ) \
|
|
|
|
fprintf( stderr, __VA_ARGS__ ); })
|
|
|
|
|
|
|
|
#endif
|