[balsa/gtk3] Tools to debug threads



commit e44d14ac49014b8e92a84931278a3ff51ead5d06
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Feb 20 21:19:55 2013 -0500

    Tools to debug threads
    
        * configure.in: new option --enable-debug-threads.
        * libbalsa/libbalsa.h: use it to define gdk_threads_enter() to
        detect a sub-thread.

 ChangeLog           |    6 ++++++
 configure.in        |   12 ++++++++++++
 libbalsa/libbalsa.h |    7 +++++++
 3 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0ce32d0..b214b90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2013-02-20  Peter Bloomfield
 
+       * configure.in: new option --enable-debug-threads.
+       * libbalsa/libbalsa.h: use it to define gdk_threads_enter() to
+       detect a sub-thread.
+
+2013-02-20  Peter Bloomfield
+
        Build with enable-threads; check POP3 mail and send messages in
        threads.
 
diff --git a/configure.in b/configure.in
index 3ecf2b7..839f991 100644
--- a/configure.in
+++ b/configure.in
@@ -69,6 +69,18 @@ if test x"$use_threads" = xyes; then
         AC_DEFINE(BALSA_USE_THREADS, 1,[Defined when balsa is to use threads.])
 fi
 
+AC_ARG_ENABLE(debug-threads,
+        AC_HELP_STRING([--enable-debug-threads],
+                       [Debug threads (default=no)]),[
+       debug_threads=$enableval
+],[
+       debug_threads=no
+])
+
+if test x"$debug_threads" = xyes; then
+        AC_DEFINE(BALSA_DEBUG_THREADS, 1,[Defined to debug threads.])
+fi
+
 
 AC_ARG_WITH([gpgme],
    AC_HELP_STRING([--with-gpgme=gpgme-config],
diff --git a/libbalsa/libbalsa.h b/libbalsa/libbalsa.h
index 873e072..82c770b 100644
--- a/libbalsa/libbalsa.h
+++ b/libbalsa/libbalsa.h
@@ -150,7 +150,14 @@ gboolean libbalsa_threads_has_lock(void);
 #define libbalsa_am_i_subthread() FALSE
 #define libbalsa_threads_has_lock() TRUE
 #endif /* BALSA_USE_THREADS */
+#if defined(BALSA_DEBUG_THREADS)
+#define gdk_threads_enter()                       \
+    do if (libbalsa_am_i_subthread())             \
+        g_warning("%s: sub-thread!\n", __func__); \
+    while (0)
+#else
 #define gdk_threads_enter()
+#endif
 #define gdk_threads_leave()
 void libbalsa_message(const char *fmt, ...)
 #ifdef __GNUC__


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]