Use DEBUG macros for SessionEvent debugging.
authorCarl Hetherington <carl@carlh.net>
Sat, 8 Jan 2011 15:19:32 +0000 (15:19 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 8 Jan 2011 15:19:32 +0000 (15:19 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8482 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/session_events.cc
libs/pbd/debug.cc
libs/pbd/pbd/debug.h
libs/pbd/pool.cc

index c50ba1e68a3aaad9b7eaca349c64ef70461868d5..df47cd5baf25752a156285c4891ac2737a99f7f4 100644 (file)
@@ -61,7 +61,7 @@ SessionEvent::operator new (size_t)
 {
        CrossThreadPool* p = pool->per_thread_pool ();
        SessionEvent* ev = static_cast<SessionEvent*> (p->alloc ());
-        cerr << pthread_self() << " Allocating SessionEvent from " << p->name() << " ev @ " << ev << endl;
+       DEBUG_TRACE (DEBUG::SessionEvents, string_compose ("%1 Allocating SessionEvent from %2 ev @ %3\n", pthread_self(), p->name(), ev));
        ev->own_pool = p;
        return ev;
 }
@@ -72,8 +72,17 @@ SessionEvent::operator delete (void *ptr, size_t /*size*/)
        Pool* p = pool->per_thread_pool ();
        SessionEvent* ev = static_cast<SessionEvent*> (ptr);
 
-        cerr << pthread_self() << " Deleting SessionEvent @ " << ev << " thread pool =  " << p->name() << " ev pool = " << ev->own_pool->name() << endl;
-        stacktrace (cerr, 20);
+        DEBUG_TRACE (DEBUG::SessionEvents, string_compose (
+                            "%1 Deleting SessionEvent @ %2 ev thread pool = %3 ev pool = %4\n",
+                            pthread_self(), ev, p->name(), ev->own_pool->name()
+                            ));
+
+#ifdef NDEBUG
+       if (DEBUG::SessionEvents & PBD::debug_bits) {
+               stacktrace (cerr, 20);
+       }
+#endif
+       
        if (p == ev->own_pool) {
                p->release (ptr);
        } else {
index 4f97ccff86ca080e9ea6dbe02dd5a310e33f0909..e7ec767f873c2b41c3b9c3f5ab815fa1f6f72ddd 100644 (file)
@@ -33,6 +33,7 @@ static std::map<const char*,uint64_t> _debug_bit_map;
 uint64_t PBD::DEBUG::Stateful = PBD::new_debug_bit ("stateful");
 uint64_t PBD::DEBUG::Properties = PBD::new_debug_bit ("properties");
 uint64_t PBD::DEBUG::FileManager = PBD::new_debug_bit ("filemanager");
+uint64_t PBD::DEBUG::Pool = PBD::new_debug_bit ("pool");
 
 uint64_t PBD::debug_bits = 0x0;
 
index d3ce495a1b65c80b17f1c09fb0ddc20fb50d35bc..8245b99b12738386c1544b5456e73edec2b382a1 100644 (file)
@@ -40,6 +40,7 @@ namespace PBD {
                 extern uint64_t Stateful;
                 extern uint64_t Properties;
                extern uint64_t FileManager;
+               extern uint64_t Pool;
        }
 }
 
index c58f0d1071dc14a530ce8d624cc2d7ec99e824eb..8919f10f9a64114bfcb36c8c1cef17616492e1bd 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "pbd/pool.h"
 #include "pbd/error.h"
+#include "pbd/debug.h"
+#include "pbd/compose.h"
 
 using namespace std;
 using namespace PBD;
@@ -246,9 +248,10 @@ void*
 CrossThreadPool::alloc () 
 {
        void* ptr;
-        cerr << pthread_self() << ' ' << name() << " has " << pending.read_space() << " pending free entries waiting\n";
+
+       DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 has %3 pending free entries waiting\n", pthread_self(), name(), pending.read_space()));
        while (pending.read (&ptr, 1) == 1) {
-                cerr << pthread_self() << ' ' << name() << " pushes back a pending free list entry before allocating\n";
+               DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 pushes back a pending free list entry before allocating\n", pthread_self(), name()));
                free_list.write (&ptr, 1);
        }
        return Pool::alloc ();