forked from zbackup/zbackup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.hh
44 lines (29 loc) · 1.01 KB
/
debug.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2012-2014 Konstantin Isakov <[email protected]> and ZBackup contributors, see CONTRIBUTORS
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
#ifndef DEBUG_HH_INCLUDED
#define DEBUG_HH_INCLUDED
#include <stdio.h>
#include <typeinfo>
// Macros we use to output debugging information
#define __CLASS typeid( *this ).name()
#ifndef NDEBUG
#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__ ); })
#ifdef HAVE_LIBUNWIND
#define UNW_LOCAL_ONLY
#include <libunwind.h>
// TODO: pretty backtraces
#define dPrintBacktrace( ... ) ()
#else
#define dPrintBacktrace( ... ) ()
#endif
#else
#define dPrintf( ... )
#define dPrintBacktrace( ... ) ()
#endif
extern bool verboseMode;
#define verbosePrintf( ... ) ({ if ( verboseMode ) \
fprintf( stderr, __VA_ARGS__ ); })
#endif