Ardour  8.12
libs/pbd/pbd/debug.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2010-2015 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2013-2015 John Emmas <john@creativepost.co.uk>
5  * Copyright (C) 2014-2015 Tim Mayberry <mojofunk@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef __libpbd_debug_h__
23 #define __libpbd_debug_h__
24 
25 #include <bitset>
26 #include <stdint.h>
27 
28 #include <sstream>
29 
30 #include "pbd/libpbd_visibility.h"
31 #include "pbd/timing.h"
32 
33 /* check for PTW32_VERSION */
34 #ifdef COMPILER_MSVC
35 #include <ardourext/pthread.h>
36 #else
37 #include <pthread.h>
38 #endif
39 
40 namespace PBD {
41 
42  typedef std::bitset<192> DebugBits;
43 
46  LIBPBD_API void debug_print (const char* prefix, std::string str);
47  LIBPBD_API void debug_only_print (const char* prefix, std::string str);
49  LIBPBD_API int parse_debug_options (const char* str);
51 
52  namespace DEBUG {
53 
54  /* this namespace is so that we can write DEBUG::bit_name */
55 
59  LIBPBD_API extern DebugBits Pool;
72 
73  /* See notes in ../debug.cc on why these are defined here */
74 
77  }
78 }
79 
80 #ifndef NDEBUG
81 
82 #define DEBUG_TRACE(bits,str) if (((bits) & PBD::debug_bits).any()) { PBD::debug_print (# bits, str); }
83 #define DEBUG_STR_DECL(id) std::stringstream __debug_str ## id;
84 #define DEBUG_STR(id) __debug_str ## id
85 #define DEBUG_STR_APPEND(id,s) __debug_str ## id << s;
86 #define DEBUG_ENABLED(bits) (((bits) & PBD::debug_bits).any())
87 #ifdef PTW32_VERSION
88 #define DEBUG_THREAD_SELF pthread_self().p
89 #define DEBUG_THREAD_PRINT(t) t.p
90 #else
91 #define DEBUG_THREAD_SELF pthread_self()
92 #define DEBUG_THREAD_PRINT(t) t
93 #endif
94 
95 #define DEBUG_TIMING_START(bits,td) if (DEBUG_ENABLED (bits)) { td.start_timing (); }
96 #define DEBUG_TIMING_ADD_ELAPSED(bits,td) if (DEBUG_ENABLED (bits)) { td.add_elapsed (); }
97 #define DEBUG_TIMING_RESET(bits,td) if (DEBUG_ENABLED (bits)) { td.reset (); }
98 
99 #define DEBUG_RESULT(type,var,...) type var = __VA_ARGS__
100 #define DEBUG_RESULT_CAST(type,var,cast_expr,...) type var = cast_expr __VA_ARGS__
101 #define DEBUG_ASSIGN(var,expr) var = expr
102 
103 #else
104 
105 
106 #define DEBUG_TRACE(bits,fmt,...) /*empty*/
107 #define DEBUG_STR(a) /* empty */
108 #define DEBUG_STR_APPEND(a,b) /* empty */
109 #define DEBUG_ENABLED(b) (0)
110 #define DEBUG_THREAD_SELF 0
111 
112 #define DEBUG_TIMING_START(bits,td) /*empty*/
113 #define DEBUG_TIMING_ADD_ELAPSED(bits,td) /*empty*/
114 #define DEBUG_TIMING_RESET(bits,td) /*empty*/
115 
116 #define DEBUG_RESULT(type,var,...) __VA_ARGS__
117 #define DEBUG_RESULT_CAST(type,var,cast_expr,...) __VA_ARGS__
118 #define DEBUG_ASSIGN(var,expr)
119 #endif
120 #endif /* __libpbd_debug_h__ */
121 
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBPBD_API
DebugBits AbstractUI
DebugBits Configuration
DebugBits StringConvert
DebugBits Locale
DebugBits UndoHistory
DebugBits Threads
DebugBits EventLoop
DebugBits DebugTimestamps
DebugBits FileManager
DebugBits WavesAudio
DebugBits ThreadName
DebugBits WavesMIDI
DebugBits FileUtils
DebugBits Properties
DebugBits Pool
DebugBits Stateful
DebugBits DebugLogToGUI
DebugBits Timing
Definition: axis_view.h:42
int parse_debug_options(const char *str)
std::bitset< 192 > DebugBits
void list_debug_options()
void debug_print(const char *prefix, std::string str)
void debug_only_print(const char *prefix, std::string str)
DebugBits new_debug_bit(const char *name)
void set_debug_bits(DebugBits bits)
DebugBits debug_bits
const guchar * bits
Definition: xcursors.h:1