From: Paul Davis Date: Wed, 10 Dec 2014 14:32:25 +0000 (-0500) Subject: add DEBUG_THREAD_SELF to allow use of DEBUG_TRACE with thread IDs on both normal... X-Git-Tag: 4.0-rc1~1052 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=c06c15596b65b253b1a3d6156f02aad593c7f826;p=ardour.git add DEBUG_THREAD_SELF to allow use of DEBUG_TRACE with thread IDs on both normal pthreads platforms and PTW32 --- diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index 424312a8a4..c33b6e333d 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -137,7 +137,7 @@ Butler::terminate_thread () { if (have_thread) { void* status; - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: ask butler to quit @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: ask butler to quit @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); queue_request (Request::Quit); pthread_join (thread, &status); } @@ -173,7 +173,7 @@ Butler::wait_for_requests () break; } - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler awake at @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler awake at @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); if (pfd[0].revents & ~POLLIN) { error << string_compose (_("Error on butler thread request pipe: fd=%1 err=%2"), pfd[0].fd, pfd[0].revents) << endmsg; @@ -223,10 +223,10 @@ Butler::thread_work () RouteList::iterator i; while (true) { - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1 butler main loop, disk work outstanding ? %2 @ %3\n", pthread_self(), disk_work_outstanding, g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1 butler main loop, disk work outstanding ? %2 @ %3\n", DEBUG_THREAD_SELF, disk_work_outstanding, g_get_monotonic_time())); if(!disk_work_outstanding) { - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1 butler waits for requests @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1 butler waits for requests @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); if (wait_for_requests ()) { Request::Type req; @@ -239,17 +239,17 @@ Butler::thread_work () switch (req) { case Request::Run: - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler asked to run @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler asked to run @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); should_run = true; break; case Request::Pause: - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler asked to pause @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler asked to pause @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); should_run = false; break; case Request::Quit: - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler asked to quit @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler asked to quit @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); return 0; abort(); /*NOTREACHED*/ break; @@ -404,7 +404,7 @@ Butler::thread_work () goto restart; } - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler signals pause @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: butler signals pause @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); paused.signal(); } @@ -437,7 +437,7 @@ Butler::queue_request (Request::Type r) void Butler::summon () { - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: summon butler to run @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: summon butler to run @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); queue_request (Request::Run); } @@ -445,7 +445,7 @@ void Butler::stop () { Glib::Threads::Mutex::Lock lm (request_lock); - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: asking butler to stop @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: asking butler to stop @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); queue_request (Request::Pause); paused.wait(request_lock); } @@ -454,7 +454,7 @@ void Butler::wait_until_finished () { Glib::Threads::Mutex::Lock lm (request_lock); - DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: waiting for butler to finish @ %2\n", pthread_self(), g_get_monotonic_time())); + DEBUG_TRACE (DEBUG::Butler, string_compose ("%1: waiting for butler to finish @ %2\n", DEBUG_THREAD_SELF, g_get_monotonic_time())); queue_request (Request::Pause); paused.wait(request_lock); } diff --git a/libs/pbd/pbd/debug.h b/libs/pbd/pbd/debug.h index 54577f1a7e..0f09e02d29 100644 --- a/libs/pbd/pbd/debug.h +++ b/libs/pbd/pbd/debug.h @@ -55,12 +55,17 @@ namespace PBD { #define DEBUG_STR(id) __debug_str ## id #define DEBUG_STR_APPEND(id,s) __debug_str ## id << s; #define DEBUG_ENABLED(bits) ((bits) & PBD::debug_bits) +#define DEBUG_THREAD_SELF 0 #else #define DEBUG_TRACE(bits,fmt,...) /*empty*/ #define DEBUG_STR(a) /* empty */ #define DEBUG_STR_APPEND(a,b) /* empty */ #define DEBUG_ENABLED(b) (0) +#ifdef PTW32_VERSION +#define DEBUG_THREAD_SELF pthread_self().p +#else +#define DEBUG_THREAD_SELF pthread_self() +#endif #endif - #endif /* __libpbd_debug_h__ */