2010-03-02 00:00:00 +00:00
|
|
|
/*
|
2019-08-03 05:10:55 +02:00
|
|
|
* Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
|
* Copyright (C) 2010-2015 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
|
* Copyright (C) 2013-2015 John Emmas <john@creativepost.co.uk>
|
|
|
|
|
* Copyright (C) 2014-2015 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*/
|
2010-03-02 00:00:00 +00:00
|
|
|
|
|
|
|
|
#ifndef __libpbd_debug_h__
|
|
|
|
|
#define __libpbd_debug_h__
|
|
|
|
|
|
2015-06-12 18:14:09 -04:00
|
|
|
#include <bitset>
|
2010-03-02 00:00:00 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
2013-10-16 23:30:28 -04:00
|
|
|
#include "pbd/libpbd_visibility.h"
|
2014-12-27 13:18:38 +07:00
|
|
|
#include "pbd/timing.h"
|
2013-10-16 23:30:28 -04:00
|
|
|
|
2021-07-14 16:04:07 +02:00
|
|
|
/* check for PTW32_VERSION */
|
|
|
|
|
#ifdef COMPILER_MSVC
|
|
|
|
|
#include <ardourext/pthread.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <pthread.h>
|
2015-07-18 15:22:43 +01:00
|
|
|
#endif
|
|
|
|
|
|
2010-03-02 00:00:00 +00:00
|
|
|
namespace PBD {
|
|
|
|
|
|
2015-06-18 08:59:49 -04:00
|
|
|
typedef std::bitset<128> DebugBits;
|
2015-06-12 18:14:09 -04:00
|
|
|
|
|
|
|
|
LIBPBD_API extern DebugBits debug_bits;
|
|
|
|
|
LIBPBD_API DebugBits new_debug_bit (const char* name);
|
2013-10-16 23:30:28 -04:00
|
|
|
LIBPBD_API void debug_print (const char* prefix, std::string str);
|
2015-06-12 18:14:09 -04:00
|
|
|
LIBPBD_API void set_debug_bits (DebugBits bits);
|
2013-10-16 23:30:28 -04:00
|
|
|
LIBPBD_API int parse_debug_options (const char* str);
|
|
|
|
|
LIBPBD_API void list_debug_options ();
|
2010-03-02 00:00:00 +00:00
|
|
|
|
|
|
|
|
namespace DEBUG {
|
|
|
|
|
|
|
|
|
|
/* this namespace is so that we can write DEBUG::bit_name */
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2015-06-12 18:14:09 -04:00
|
|
|
LIBPBD_API extern DebugBits Stateful;
|
|
|
|
|
LIBPBD_API extern DebugBits Properties;
|
|
|
|
|
LIBPBD_API extern DebugBits FileManager;
|
|
|
|
|
LIBPBD_API extern DebugBits Pool;
|
|
|
|
|
LIBPBD_API extern DebugBits EventLoop;
|
|
|
|
|
LIBPBD_API extern DebugBits AbstractUI;
|
|
|
|
|
LIBPBD_API extern DebugBits Configuration;
|
|
|
|
|
LIBPBD_API extern DebugBits FileUtils;
|
2015-08-19 13:41:19 +10:00
|
|
|
LIBPBD_API extern DebugBits UndoHistory;
|
2015-09-12 21:41:00 +10:00
|
|
|
LIBPBD_API extern DebugBits Timing;
|
2015-09-14 12:22:39 +10:00
|
|
|
LIBPBD_API extern DebugBits Threads;
|
2016-05-07 12:15:12 +02:00
|
|
|
LIBPBD_API extern DebugBits Locale;
|
2015-08-16 22:02:27 +10:00
|
|
|
LIBPBD_API extern DebugBits StringConvert;
|
2019-10-28 16:52:18 -06:00
|
|
|
LIBPBD_API extern DebugBits DebugTimestamps;
|
2020-10-13 21:26:26 +02:00
|
|
|
LIBPBD_API extern DebugBits DebugLogToGUI;
|
2015-05-13 19:37:15 -04:00
|
|
|
|
|
|
|
|
/* See notes in ../debug.cc on why these are defined here */
|
|
|
|
|
|
|
|
|
|
LIBPBD_API extern DebugBits WavesMIDI;
|
|
|
|
|
LIBPBD_API extern DebugBits WavesAudio;
|
2010-03-02 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2019-12-05 15:01:41 -07:00
|
|
|
|
2015-06-12 18:14:09 -04:00
|
|
|
#define DEBUG_TRACE(bits,str) if (((bits) & PBD::debug_bits).any()) { PBD::debug_print (# bits, str); }
|
2010-03-02 00:00:00 +00:00
|
|
|
#define DEBUG_STR_DECL(id) std::stringstream __debug_str ## id;
|
|
|
|
|
#define DEBUG_STR(id) __debug_str ## id
|
|
|
|
|
#define DEBUG_STR_APPEND(id,s) __debug_str ## id << s;
|
2015-06-12 18:14:09 -04:00
|
|
|
#define DEBUG_ENABLED(bits) (((bits) & PBD::debug_bits).any())
|
2015-03-12 22:34:54 +10:00
|
|
|
#ifdef PTW32_VERSION
|
2015-03-12 22:15:41 +10:00
|
|
|
#define DEBUG_THREAD_SELF pthread_self().p
|
|
|
|
|
#else
|
|
|
|
|
#define DEBUG_THREAD_SELF pthread_self()
|
|
|
|
|
#endif
|
2014-12-27 13:18:38 +07:00
|
|
|
|
2015-06-12 18:14:09 -04:00
|
|
|
#define DEBUG_TIMING_START(bits,td) if (DEBUG_ENABLED (bits)) { td.start_timing (); }
|
|
|
|
|
#define DEBUG_TIMING_ADD_ELAPSED(bits,td) if (DEBUG_ENABLED (bits)) { td.add_elapsed (); }
|
|
|
|
|
#define DEBUG_TIMING_RESET(bits,td) if (DEBUG_ENABLED (bits)) { td.reset (); }
|
2014-12-27 13:18:38 +07:00
|
|
|
|
2010-03-02 00:00:00 +00:00
|
|
|
#else
|
|
|
|
|
#define DEBUG_TRACE(bits,fmt,...) /*empty*/
|
|
|
|
|
#define DEBUG_STR(a) /* empty */
|
|
|
|
|
#define DEBUG_STR_APPEND(a,b) /* empty */
|
2011-12-28 21:01:52 +00:00
|
|
|
#define DEBUG_ENABLED(b) (0)
|
2015-03-12 22:15:41 +10:00
|
|
|
#define DEBUG_THREAD_SELF 0
|
2014-12-27 13:18:38 +07:00
|
|
|
|
|
|
|
|
#define DEBUG_TIMING_START(bits,td) /*empty*/
|
|
|
|
|
#define DEBUG_TIMING_ADD_ELAPSED(bits,td) /*empty*/
|
|
|
|
|
#define DEBUG_TIMING_RESET(bits,td) /*empty*/
|
|
|
|
|
|
2010-03-02 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
|
#endif /* __libpbd_debug_h__ */
|
|
|
|
|
|