#include "pbd/compose.h"
#include "pbd/cpus.h"
+#include "pbd/debug_rt_alloc.h"
#include "ardour/debug.h"
#include "ardour/graph.h"
using namespace PBD;
using namespace std;
+#ifdef DEBUG_RT_ALLOC
+static Graph* graph = 0;
+extern "C" {
+
+int alloc_allowed ()
+{
+ return !graph->in_process_thread ();
+}
+
+}
+#endif
Graph::Graph (Session & session)
: SessionHandleRef (session)
_thread_list.push_back (a_thread);
}
}
+
+#ifdef DEBUG_RT_ALLOC
+ graph = this;
+ pbd_alloc_allowed = &::alloc_allowed;
+#endif
}
void
void
Graph::helper_thread()
{
- ProcessThread *pt = new ProcessThread;
+ ProcessThread* pt = new ProcessThread ();
pt->get_buffers();
get_rt();
void
Graph::main_thread()
{
- ProcessThread *pt = new ProcessThread;
+ ProcessThread* pt = new ProcessThread ();
pt->get_buffers();
get_rt();
}
}
+bool
+Graph::in_process_thread () const
+{
+ list<pthread_t>::const_iterator i = _thread_list.begin ();
+ while (i != _thread_list.end() && *i != pthread_self ()) {
+ ++i;
+ }
-
+ return i != _thread_list.end ();
+}
if opt.stl_debug:
conf.env.append_value('CXXFLAGS', "-D_GLIBCXX_DEBUG")
+ if conf.env['DEBUG_RT_ALLOC']:
+ conf.env.append_value('CCFLAGS', '-DDEBUG_RT_ALLOC')
+ conf.env.append_value('CXXFLAGS', '-DDEBUG_RT_ALLOC')
+ conf.env.append_value('LINKFLAGS', '-ldl')
+
if opt.universal:
conf.env.append_value('CCFLAGS', "-arch i386 -arch ppc")
conf.env.append_value('CXXFLAGS', "-arch i386 -arch ppc")
conf.env.append_value('CXXFLAGS', '-DENABLE_NLS')
conf.env.append_value('CCFLAGS', '-DENABLE_NLS')
-
#----------------------------------------------------------------
# Waf stages
opt.add_option('--phone-home', action='store_false', default=True, dest='phone_home')
opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
help='Build with debugging for the STL')
+ opt.add_option('--rt-alloc-debug', action='store_true', default=False, dest='rt_alloc_debug',
+ help='Build with debugging for memory allocation in the real-time thread')
opt.add_option('--test', action='store_true', default=False, dest='build_tests',
help="Build unit tests")
opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
autowaf.display_msg(conf, 'Windows Key', opts.windows_key)
conf.env['PROGRAM_NAME'] = opts.program_name
autowaf.display_msg(conf, 'Program Name', opts.program_name)
+ if opts.rt_alloc_debug:
+ conf.define('DEBUG_RT_ALLOC', 1)
set_compiler_flags (conf, Options.options)