From a232673454fa3583da22fdd55eea16200f90c438 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 7 May 2016 13:32:31 -0400 Subject: [PATCH] make boost shared_ptr debugging a little easier to turn on/off --- gtk2_ardour/editor_ops.cc | 1 + libs/ardour/ardour/boost_debug.h | 39 ++++++++++++++++++++++++++++++++ libs/ardour/audio_track.cc | 2 +- libs/ardour/pannable.cc | 2 +- libs/ardour/panner_shell.cc | 2 +- libs/ardour/route.cc | 2 +- libs/ardour/send.cc | 2 +- libs/ardour/session.cc | 32 ++++++++++---------------- libs/ardour/session_handle.cc | 2 +- libs/ardour/session_state.cc | 26 ++++++++------------- libs/ardour/source_factory.cc | 2 +- 11 files changed, 68 insertions(+), 44 deletions(-) create mode 100644 libs/ardour/ardour/boost_debug.h diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index a6079cac90..631b4ec68e 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -42,6 +42,7 @@ #include "ardour/audio_track.h" #include "ardour/audioregion.h" +#include "ardour/boost_debug.h" #include "ardour/dB.h" #include "ardour/location.h" #include "ardour/midi_region.h" diff --git a/libs/ardour/ardour/boost_debug.h b/libs/ardour/ardour/boost_debug.h new file mode 100644 index 0000000000..758166d8f1 --- /dev/null +++ b/libs/ardour/ardour/boost_debug.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2016 Paul Davis + From an idea by Carl Hetherington. + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __libardour_boost_debug_h__ +#define __libardour_boost_debug_h__ + +#include "pbd/boost_debug.h" + +/* these defines are intended to be switched on as-needed. They will not work + unless the program was configured with --boost-sp-debug +*/ + +//#define BOOST_MARK_ROUTE(p) boost_debug_shared_ptr_mark_interesting((p).get(),"Route") +//#define BOOST_MARK_TRACK(p) boost_debug_shared_ptr_mark_interesting((p).get(),"Track") +//#define BOOST_SHOW_POINTERS() boost_debug_list_ptrs() + +#define BOOST_MARK_ROUTE(p) +#define BOOST_MARK_TRACK(p) +#define BOOST_SHOW_POINTERS() + + +#endif /* __libardour_boost_debug_h__ */ diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index 254a3d7c6e..579b0064bc 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -19,7 +19,6 @@ #include -#include "pbd/boost_debug.h" #include "pbd/enumwriter.h" #include "pbd/error.h" @@ -30,6 +29,7 @@ #include "ardour/audio_diskstream.h" #include "ardour/audio_track.h" #include "ardour/audioplaylist.h" +#include "ardour/boost_debug.h" #include "ardour/buffer_set.h" #include "ardour/delivery.h" #include "ardour/meter.h" diff --git a/libs/ardour/pannable.cc b/libs/ardour/pannable.cc index 70fe70c728..ebf3115658 100644 --- a/libs/ardour/pannable.cc +++ b/libs/ardour/pannable.cc @@ -20,8 +20,8 @@ #include "pbd/error.h" #include "pbd/convert.h" #include "pbd/compose.h" -#include "pbd/boost_debug.h" +#include "ardour/boost_debug.h" #include "ardour/debug.h" #include "ardour/automation_control.h" #include "ardour/automation_list.h" diff --git a/libs/ardour/panner_shell.cc b/libs/ardour/panner_shell.cc index b2099af9e4..afc34c358a 100644 --- a/libs/ardour/panner_shell.cc +++ b/libs/ardour/panner_shell.cc @@ -32,7 +32,6 @@ #include #include "pbd/cartesian.h" -#include "pbd/boost_debug.h" #include "pbd/convert.h" #include "pbd/error.h" #include "pbd/failed_constructor.h" @@ -43,6 +42,7 @@ #include "ardour/audio_buffer.h" #include "ardour/audioengine.h" +#include "ardour/boost_debug.h" #include "ardour/buffer_set.h" #include "ardour/debug.h" #include "ardour/pannable.h" diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 79799ce807..57980d1f54 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -33,7 +33,6 @@ #include "pbd/memento_command.h" #include "pbd/stacktrace.h" #include "pbd/convert.h" -#include "pbd/boost_debug.h" #include "pbd/unwind.h" #include "ardour/amp.h" @@ -41,6 +40,7 @@ #include "ardour/audio_track.h" #include "ardour/audio_port.h" #include "ardour/audioengine.h" +#include "ardour/boost_debug.h" #include "ardour/buffer.h" #include "ardour/buffer_set.h" #include "ardour/capturing_processor.h" diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index 6ebaaf28b3..f1cfdc7ef3 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -21,9 +21,9 @@ #include #include "pbd/xml++.h" -#include "pbd/boost_debug.h" #include "ardour/amp.h" +#include "ardour/boost_debug.h" #include "ardour/buffer_set.h" #include "ardour/debug.h" #include "ardour/gain_control.h" diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index cddd85902e..99b803dc5c 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -36,7 +36,6 @@ #include #include "pbd/basename.h" -#include "pbd/boost_debug.h" #include "pbd/convert.h" #include "pbd/convert.h" #include "pbd/error.h" @@ -59,6 +58,7 @@ #include "ardour/audioengine.h" #include "ardour/audiofilesource.h" #include "ardour/auditioner.h" +#include "ardour/boost_debug.h" #include "ardour/buffer_manager.h" #include "ardour/buffer_set.h" #include "ardour/bundle.h" @@ -785,9 +785,7 @@ Session::destroy () DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n"); -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - boost_debug_list_ptrs (); -#endif + BOOST_SHOW_POINTERS (); } void @@ -1147,9 +1145,8 @@ Session::add_monitor_section () return; } -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (r.get(), "Route"); -#endif + BOOST_MARK_ROUTE(r); + try { Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ()); r->input()->ensure_io (_master_out->output()->n_ports(), false, this); @@ -2458,9 +2455,8 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost: track->use_new_diskstream(); -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (track.get(), "Track"); -#endif + BOOST_MARK_TRACK (track); + { Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ()); if (track->input()->ensure_io (input, false, this)) { @@ -2558,9 +2554,8 @@ Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name bus->set_strict_io (true); } -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (bus.get(), "Route"); -#endif + BOOST_MARK_ROUTE(bus); + { Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ()); @@ -2985,9 +2980,8 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod track->use_new_diskstream(); -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (track.get(), "Track"); -#endif + BOOST_MARK_TRACK (track); + { Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ()); @@ -3082,9 +3076,8 @@ Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r bus->set_strict_io (true); } -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (bus.get(), "Route"); -#endif + BOOST_MARK_ROUTE(bus); + { Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ()); @@ -3564,7 +3557,6 @@ Session::add_internal_send (boost::shared_ptr dest, boost::shared_ptr routes_to_remove) { diff --git a/libs/ardour/session_handle.cc b/libs/ardour/session_handle.cc index 99358dad03..0cf0f6d1b1 100644 --- a/libs/ardour/session_handle.cc +++ b/libs/ardour/session_handle.cc @@ -19,8 +19,8 @@ #include "pbd/demangle.h" #include "pbd/error.h" -#include "pbd/boost_debug.h" +#include "ardour/boost_debug.h" #include "ardour/session.h" #include "ardour/session_handle.h" diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 05cf89ff0a..7bc9dfdeeb 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -61,7 +61,6 @@ #include "evoral/SMF.hpp" -#include "pbd/boost_debug.h" #include "pbd/basename.h" #include "pbd/controllable_descriptor.h" #include "pbd/debug.h" @@ -83,6 +82,7 @@ #include "ardour/audiofilesource.h" #include "ardour/audioregion.h" #include "ardour/automation_control.h" +#include "ardour/boost_debug.h" #include "ardour/butler.h" #include "ardour/control_protocol_manager.h" #include "ardour/directory_names.h" @@ -637,10 +637,10 @@ Session::create (const string& session_template, BusProfile* bus_profile) if (r->init ()) { return -1; } -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (r.get(), "Route"); -#endif - { + + BOOST_MARK_ROUTE(r); + + { Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ()); r->input()->ensure_io (count, false, this); r->output()->ensure_io (count, false, this); @@ -1611,9 +1611,7 @@ Session::XMLRouteFactory (const XMLNode& node, int version) return ret; } -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (track.get(), "Track"); -#endif + BOOST_MARK_TRACK (track); ret = track; } else { @@ -1626,9 +1624,7 @@ Session::XMLRouteFactory (const XMLNode& node, int version) boost::shared_ptr r (new Route (*this, X_("toBeResetFroXML"), flags)); if (r->init () == 0 && r->set_state (node, version) == 0) { -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (r.get(), "Route"); -#endif + BOOST_MARK_ROUTE (r); ret = r; } } @@ -1689,9 +1685,7 @@ Session::XMLRouteFactory_2X (const XMLNode& node, int version) track->set_diskstream (*i); -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (track.get(), "Track"); -#endif + BOOST_MARK_TRACK (track); ret = track; } else { @@ -1704,9 +1698,7 @@ Session::XMLRouteFactory_2X (const XMLNode& node, int version) boost::shared_ptr r (new Route (*this, X_("toBeResetFroXML"), flags)); if (r->init () == 0 && r->set_state (node, version) == 0) { -#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - // boost_debug_shared_ptr_mark_interesting (r.get(), "Route"); -#endif + BOOST_MARK_ROUTE (r); ret = r; } } diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 45b39802cb..db7faeddf1 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -22,7 +22,6 @@ #include "libardour-config.h" #endif -#include "pbd/boost_debug.h" #include "pbd/error.h" #include "pbd/convert.h" #include "pbd/pthread_utils.h" @@ -30,6 +29,7 @@ #include "ardour/audioplaylist.h" #include "ardour/audio_playlist_source.h" +#include "ardour/boost_debug.h" #include "ardour/midi_playlist.h" #include "ardour/midi_playlist_source.h" #include "ardour/source.h" -- 2.30.2