Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
23 
24 #include <bitset>
25 #include <stdint.h>
26 
27 #include <sstream>
28 
29 #include "pbd/libpbd_visibility.h"
30 #include "pbd/timing.h"
31 
32 /* check for PTW32_VERSION */
33 #ifdef COMPILER_MSVC
34 #include <ardourext/pthread.h>
35 #else
36 #include <pthread.h>
37 #endif
38 
39 namespace PBD {
40 
41  typedef std::bitset<256> DebugBits;
42 
45  LIBPBD_API void debug_print (const char* prefix, std::string str);
46  LIBPBD_API void debug_only_print (const char* prefix, std::string str);
48  LIBPBD_API int parse_debug_options (const char* str);
50 
51  namespace DEBUG {
52 
53  /* this namespace is so that we can write DEBUG::bit_name */
54 
58  LIBPBD_API extern DebugBits Pool;
71 
72  /* See notes in ../debug.cc on why these are defined here */
73 
76  }
77 }
78 
79 #ifndef NDEBUG
80 
81 #define DEBUG_TRACE(bits,str) if (((bits) & PBD::debug_bits).any()) { PBD::debug_print (# bits, str); }
82 #define DEBUG_STR_DECL(id) std::stringstream __debug_str ## id;
83 #define DEBUG_STR(id) __debug_str ## id
84 #define DEBUG_STR_APPEND(id,s) __debug_str ## id << s;
85 #define DEBUG_ENABLED(bits) (((bits) & PBD::debug_bits).any())
86 #ifdef PTW32_VERSION
87 #define DEBUG_THREAD_SELF pthread_self().p
88 #define DEBUG_THREAD_PRINT(t) t.p
89 #else
90 #define DEBUG_THREAD_SELF pthread_self()
91 #define DEBUG_THREAD_PRINT(t) t
92 #endif
93 
94 #define DEBUG_TIMING_START(bits,td) if (DEBUG_ENABLED (bits)) { td.start_timing (); }
95 #define DEBUG_TIMING_ADD_ELAPSED(bits,td) if (DEBUG_ENABLED (bits)) { td.add_elapsed (); }
96 #define DEBUG_TIMING_RESET(bits,td) if (DEBUG_ENABLED (bits)) { td.reset (); }
97 
98 #define DEBUG_RESULT(type,var,...) type var = __VA_ARGS__
99 #define DEBUG_RESULT_CAST(type,var,cast_expr,...) type var = cast_expr __VA_ARGS__
100 #define DEBUG_ASSIGN(var,expr) var = expr
101 
102 #else
103 
104 
105 #define DEBUG_TRACE(bits,fmt,...) /*empty*/
106 #define DEBUG_STR(a) /* empty */
107 #define DEBUG_STR_APPEND(a,b) /* empty */
108 #define DEBUG_ENABLED(b) (0)
109 #define DEBUG_THREAD_SELF 0
110 
111 #define DEBUG_TIMING_START(bits,td) /*empty*/
112 #define DEBUG_TIMING_ADD_ELAPSED(bits,td) /*empty*/
113 #define DEBUG_TIMING_RESET(bits,td) /*empty*/
114 
115 #define DEBUG_RESULT(type,var,...) __VA_ARGS__
116 #define DEBUG_RESULT_CAST(type,var,cast_expr,...) __VA_ARGS__
117 #define DEBUG_ASSIGN(var,expr)
118 #endif
119 
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)
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)
std::bitset< 256 > DebugBits
DebugBits debug_bits
const guchar * bits
Definition: xcursors.h:1