From 5132ac05ba431d4ec2a71f8ffa5feb23df5fb5de Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 31 Oct 2013 17:33:26 +0000 Subject: [PATCH 7/7] Always enable compile-time debug messages --- Makefile.am | 1 - configure.ac | 7 ------- examples/cm/call/main.c | 2 -- examples/cm/channelspecific/main.c | 2 -- examples/cm/contactlist/main.c | 2 -- examples/cm/echo-message-parts/main.c | 2 -- examples/cm/extended/main.c | 2 -- examples/cm/no-protocols/main.c | 2 -- telepathy-glib/dbus-properties-mixin.c | 8 -------- telepathy-glib/debug-internal.h | 18 ++---------------- telepathy-glib/debug.c | 4 ---- telepathy-glib/protocol.c | 4 ---- telepathy-logger/debug.c | 2 -- telepathy-logger/telepathy-logger.c | 7 ------- tests/debug-domain.c | 9 --------- tests/internal-debug.c | 8 -------- tests/logger/dbus/test-log-manager.c | 4 ---- tests/logger/dbus/test-tpl-log-iter-pidgin.c | 2 -- tests/logger/dbus/test-tpl-log-iter-xml.c | 2 -- tests/logger/dbus/test-tpl-log-store-pidgin.c | 4 ---- tests/logger/dbus/test-tpl-log-store-xml.c | 2 -- tests/logger/dbus/test-tpl-log-walker.c | 2 -- 22 files changed, 2 insertions(+), 94 deletions(-) diff --git a/Makefile.am b/Makefile.am index d61417e..14a0ffb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,7 +31,6 @@ SUBDIRS += docs DISTCHECK_CONFIGURE_FLAGS = \ --enable-gtk-doc \ - --disable-debug \ --disable-scrollkeeper \ --disable-schemas-install \ $(NULL) diff --git a/configure.ac b/configure.ac index 1afc1f9..ec4379e 100644 --- a/configure.ac +++ b/configure.ac @@ -191,10 +191,6 @@ AC_SUBST([ERROR_SCANNERFLAGS]) # use ${enable_fatal_warnings} instead. AM_CONDITIONAL([OFFICIAL_RELEASE], [test "x$official_release" = xyes]) -AC_ARG_ENABLE(debug, - AC_HELP_STRING([--disable-debug],[compile without debug code (note that this will disable much of the debug code in all GLib connection managers)]), - enable_debug=$enableval, enable_debug=yes ) - AC_ARG_ENABLE(debug-cache, AS_HELP_STRING([--enable-debug-cache], [compile with code to unconditionally cache all debug messages whether or not they are actually emitted]), @@ -208,9 +204,6 @@ AC_ARG_ENABLE(backtrace, AC_HELP_STRING([--enable-backtrace],[enable printing out the backtrace in case of crash (in most GLib connection managers)]), enable_backtrace=$enableval, enable_backtrace=no ) -AS_IF([test x$enable_debug = xyes], - [AC_DEFINE([ENABLE_DEBUG], [], [Enable debug code])]) - AS_IF([test x$enable_backtrace = xyes], [AC_DEFINE([ENABLE_BACKTRACE], [], [Enable backtrace output on crashes])]) diff --git a/examples/cm/call/main.c b/examples/cm/call/main.c index aee9f17..b96a5c6 100644 --- a/examples/cm/call/main.c +++ b/examples/cm/call/main.c @@ -39,7 +39,6 @@ int main (int argc, char **argv) { -#ifdef ENABLE_DEBUG tp_debug_divert_messages (g_getenv ("EXAMPLE_CM_LOGFILE")); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); @@ -48,7 +47,6 @@ main (int argc, if (g_getenv ("EXAMPLE_PERSIST") != NULL) tp_debug_set_persistent (TRUE); -#endif /* strictly speaking, this is only necessary for client code, but it's * harmless here */ diff --git a/examples/cm/channelspecific/main.c b/examples/cm/channelspecific/main.c index 5ba4ac3..bafd553 100644 --- a/examples/cm/channelspecific/main.c +++ b/examples/cm/channelspecific/main.c @@ -27,7 +27,6 @@ int main (int argc, char **argv) { -#ifdef ENABLE_DEBUG tp_debug_divert_messages (g_getenv ("EXAMPLE_CM_LOGFILE")); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); @@ -36,7 +35,6 @@ main (int argc, if (g_getenv ("EXAMPLE_PERSIST") != NULL) tp_debug_set_persistent (TRUE); -#endif return tp_run_connection_manager ("telepathy-example-cm-csh", VERSION, construct_cm, argc, argv); diff --git a/examples/cm/contactlist/main.c b/examples/cm/contactlist/main.c index 222c7bb..006c68b 100644 --- a/examples/cm/contactlist/main.c +++ b/examples/cm/contactlist/main.c @@ -27,7 +27,6 @@ int main (int argc, char **argv) { -#ifdef ENABLE_DEBUG tp_debug_divert_messages (g_getenv ("EXAMPLE_CM_LOGFILE")); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); @@ -36,7 +35,6 @@ main (int argc, if (g_getenv ("EXAMPLE_PERSIST") != NULL) tp_debug_set_persistent (TRUE); -#endif return tp_run_connection_manager ("telepathy-example-cm-contactlist", VERSION, construct_cm, argc, argv); diff --git a/examples/cm/echo-message-parts/main.c b/examples/cm/echo-message-parts/main.c index e3941cc..8143c85 100644 --- a/examples/cm/echo-message-parts/main.c +++ b/examples/cm/echo-message-parts/main.c @@ -26,7 +26,6 @@ int main (int argc, char **argv) { -#ifdef ENABLE_DEBUG tp_debug_divert_messages (g_getenv ("EXAMPLE_CM_LOGFILE")); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); @@ -35,7 +34,6 @@ main (int argc, if (g_getenv ("EXAMPLE_PERSIST") != NULL) tp_debug_set_persistent (TRUE); -#endif return tp_run_connection_manager ("telepathy-example-cm-echo-2", VERSION, construct_cm, argc, argv); diff --git a/examples/cm/extended/main.c b/examples/cm/extended/main.c index a265ca3..b3c010c 100644 --- a/examples/cm/extended/main.c +++ b/examples/cm/extended/main.c @@ -27,7 +27,6 @@ int main (int argc, char **argv) { -#ifdef ENABLE_DEBUG tp_debug_divert_messages (g_getenv ("EXAMPLE_CM_LOGFILE")); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); @@ -36,7 +35,6 @@ main (int argc, if (g_getenv ("EXAMPLE_PERSIST") != NULL) tp_debug_set_persistent (TRUE); -#endif return tp_run_connection_manager ("telepathy-example-cm-extended", VERSION, construct_cm, argc, argv); diff --git a/examples/cm/no-protocols/main.c b/examples/cm/no-protocols/main.c index a88ac7d..63908a6 100644 --- a/examples/cm/no-protocols/main.c +++ b/examples/cm/no-protocols/main.c @@ -27,7 +27,6 @@ int main (int argc, char **argv) { -#ifdef ENABLE_DEBUG tp_debug_divert_messages (g_getenv ("EXAMPLE_CM_LOGFILE")); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); @@ -36,7 +35,6 @@ main (int argc, if (g_getenv ("EXAMPLE_PERSIST") != NULL) tp_debug_set_persistent (TRUE); -#endif return tp_run_connection_manager ("telepathy-example-no-protocols", VERSION, construct_cm, argc, argv); diff --git a/telepathy-glib/dbus-properties-mixin.c b/telepathy-glib/dbus-properties-mixin.c index ed9f9c0..050e2d8 100644 --- a/telepathy-glib/dbus-properties-mixin.c +++ b/telepathy-glib/dbus-properties-mixin.c @@ -456,7 +456,6 @@ tp_dbus_properties_mixin_implement_interface (GObjectClass *cls, { TpDBusPropertiesMixinIfaceImpl *next = g_type_get_qdata (type, extras_quark); -#ifdef ENABLE_DEBUG GQuark offset_quark = _prop_mixin_offset_quark (); gpointer offset_qdata = g_type_get_qdata (type, offset_quark); TpDBusPropertiesMixinClass *mixin = NULL; @@ -505,16 +504,13 @@ tp_dbus_properties_mixin_implement_interface (GObjectClass *cls, } } } -#endif /* form a linked list */ iface_impl->mixin_next = next; g_type_set_qdata (type, extras_quark, iface_impl); } -#ifdef ENABLE_DEBUG out: -#endif g_free (interfaces); } @@ -581,15 +577,12 @@ tp_dbus_properties_mixin_class_init (GObjectClass *cls, iface_impl++) { GQuark iface_quark = g_quark_try_string (iface_impl->name); -#ifdef ENABLE_DEBUG TpDBusPropertiesMixinIfaceImpl *other_impl; -#endif if (G_UNLIKELY (!link_interface (type, interfaces, iface_quark, iface_impl))) goto out; -#ifdef ENABLE_DEBUG for (other_impl = mixin->interfaces; other_impl != iface_impl; other_impl++) @@ -603,7 +596,6 @@ tp_dbus_properties_mixin_class_init (GObjectClass *cls, goto out; } } -#endif } out: diff --git a/telepathy-glib/debug-internal.h b/telepathy-glib/debug-internal.h index 4f8c0fe..7e75684 100644 --- a/telepathy-glib/debug-internal.h +++ b/telepathy-glib/debug-internal.h @@ -101,23 +101,9 @@ G_END_DECLS #undef DEBUG #undef DEBUGGING -#ifdef ENABLE_DEBUG -# define DEBUG(format, ...) \ +#define DEBUG(format, ...) \ _tp_log (G_LOG_LEVEL_DEBUG, DEBUG_FLAG, "%s: " format, \ G_STRFUNC, ##__VA_ARGS__) -# define DEBUGGING _tp_debug_flag_is_set (DEBUG_FLAG) -#else /* !defined (ENABLE_DEBUG) */ -# ifndef DEBUG_STUB_DEFINED -static inline void -DEBUG ( - const gchar *format, - ...) -{ -} -# define DEBUG_STUB_DEFINED 1 -# endif // ifndef DEBUG_STUB_DEFINED - -# define DEBUGGING 0 -#endif /* !defined (ENABLE_DEBUG) */ +#define DEBUGGING _tp_debug_flag_is_set (DEBUG_FLAG) #endif /* defined (DEBUG_FLAG) */ diff --git a/telepathy-glib/debug.c b/telepathy-glib/debug.c index 36a6732..6209955 100644 --- a/telepathy-glib/debug.c +++ b/telepathy-glib/debug.c @@ -370,7 +370,6 @@ tp_debug_timestamped_log_handler (const gchar *log_domain, const gchar *message, gpointer ignored) { -#ifdef ENABLE_DEBUG GTimeVal now; gchar *tmp, *now_str; @@ -379,11 +378,8 @@ tp_debug_timestamped_log_handler (const gchar *log_domain, tmp = g_strdup_printf ("%s: %s", now_str, message); g_free (now_str); message = tmp; -#endif g_log_default_handler (log_domain, log_level, message, NULL); -#ifdef ENABLE_DEBUG g_free (tmp); -#endif } diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c index 3bec5c1..3d98b38 100644 --- a/telepathy-glib/protocol.c +++ b/telepathy-glib/protocol.c @@ -217,7 +217,6 @@ tp_protocol_params_from_param_specs (const GPtrArray *parameters, param->flags |= TP_CONN_MGR_PARAM_FLAG_SECRET; } -#ifdef ENABLE_DEBUG { gchar *repr = g_strdup_value_contents (&(param->default_value)); @@ -225,7 +224,6 @@ tp_protocol_params_from_param_specs (const GPtrArray *parameters, G_VALUE_TYPE_NAME (&(param->default_value))); g_free (repr); } -#endif } return output; @@ -1595,7 +1593,6 @@ _tp_protocol_parse_manager_file (GKeyFile *file, DEBUG ("\tParam flags: 0x%x", param.flags); DEBUG ("\tParam sig: %s", param.dbus_signature); -#ifdef ENABLE_DEBUG if (G_IS_VALUE (¶m.default_value)) { gchar *repr = g_strdup_value_contents (&(param.default_value)); @@ -1608,7 +1605,6 @@ _tp_protocol_parse_manager_file (GKeyFile *file, { DEBUG ("\tParam default value: not set"); } -#endif g_ptr_array_add (param_specs, tp_value_array_build (4, G_TYPE_STRING, param.name, diff --git a/telepathy-logger/debug.c b/telepathy-logger/debug.c index e25b6ba..cd59a12 100644 --- a/telepathy-logger/debug.c +++ b/telepathy-logger/debug.c @@ -88,7 +88,6 @@ void _tpl_debug (TplDebugFlags flag, const gchar *format, ...) { -#ifdef ENABLE_DEBUG gchar *message; va_list args; @@ -100,7 +99,6 @@ void _tpl_debug (TplDebugFlags flag, g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s", message); g_free (message); -#endif } /* The following function has to be always define or CRITICAL messages won't diff --git a/telepathy-logger/telepathy-logger.c b/telepathy-logger/telepathy-logger.c index 9f63bdf..cc0bc85 100644 --- a/telepathy-logger/telepathy-logger.c +++ b/telepathy-logger/telepathy-logger.c @@ -32,7 +32,6 @@ static GMainLoop *loop = NULL; -#ifdef ENABLE_DEBUG static TpDebugSender *debug_sender = NULL; static gboolean stamp_logs = FALSE; @@ -83,8 +82,6 @@ log_handler (const gchar *log_domain, log_to_debug_sender (log_domain, log_level, message); } -#endif /* ENABLE_DEBUG */ - static TplDBusService * telepathy_logger_dbus_init (void) @@ -141,14 +138,12 @@ main (int argc, tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); -#ifdef ENABLE_DEBUG _tpl_debug_set_flags_from_env (); stamp_logs = (g_getenv ("TPL_TIMING") != NULL); debug_sender = tp_debug_sender_dup (); g_log_set_default_handler (log_handler, NULL); -#endif /* ENABLE_DEBUG */ observer = _tpl_observer_dup (&error); @@ -176,10 +171,8 @@ out: if (dbus_srv != NULL) g_object_unref (dbus_srv); -#ifdef ENABLE_DEBUG g_log_set_default_handler (g_log_default_handler, NULL); g_object_unref (debug_sender); -#endif /* ENABLE_DEBUG */ return 0; } diff --git a/tests/debug-domain.c b/tests/debug-domain.c index 37ef418..d3ec89d 100644 --- a/tests/debug-domain.c +++ b/tests/debug-domain.c @@ -6,10 +6,6 @@ #include "telepathy-glib/debug-internal.h" -/* Only run test if ENABLE_DEBUG is defined, otherwise we won't have - * _tp_log and the TpDebugFlags enum. */ -#ifdef ENABLE_DEBUG - typedef struct { guint flag; @@ -47,11 +43,9 @@ handler (const gchar *log_domain, g_strfreev (parts); } -#endif int main (int argc, char **argv) { -#ifdef ENABLE_DEBUG TestItem i; g_type_init (); @@ -66,8 +60,5 @@ int main (int argc, char **argv) _tp_log (G_LOG_LEVEL_DEBUG, i.flag, "foo"); } -#else - g_print ("Not running test-debug-domain test as ENABLE_DEBUG is undefined\n"); -#endif return 0; } diff --git a/tests/internal-debug.c b/tests/internal-debug.c index 8949249..d0b3249 100644 --- a/tests/internal-debug.c +++ b/tests/internal-debug.c @@ -21,11 +21,7 @@ test_debugging (void) #error internal-debug.h should always define DEBUGGING #endif -#ifdef ENABLE_DEBUG g_assert (DEBUGGING == 1); -#else - g_assert (DEBUGGING == 0); -#endif } #undef DEBUG_FLAG @@ -59,11 +55,7 @@ test_debugging_again (void) #error internal-debug.h should always define DEBUGGING #endif -#ifdef ENABLE_DEBUG g_assert (DEBUGGING == 1); -#else - g_assert (DEBUGGING == 0); -#endif } int diff --git a/tests/logger/dbus/test-log-manager.c b/tests/logger/dbus/test-log-manager.c index 6bd7b66..c09dfd9 100644 --- a/tests/logger/dbus/test-log-manager.c +++ b/tests/logger/dbus/test-log-manager.c @@ -41,7 +41,6 @@ typedef struct -#ifdef ENABLE_DEBUG static TpDebugSender *debug_sender = NULL; static gboolean stamp_logs = FALSE; @@ -92,7 +91,6 @@ log_handler (const gchar *log_domain, log_to_debug_sender (log_domain, log_level, message); } -#endif /* ENABLE_DEBUG */ static void @@ -263,14 +261,12 @@ setup_debug (void) { tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); -#ifdef ENABLE_DEBUG _tpl_debug_set_flags_from_env (); stamp_logs = (g_getenv ("TPL_TIMING") != NULL); debug_sender = tp_debug_sender_dup (); g_log_set_default_handler (log_handler, NULL); -#endif /* ENABLE_DEBUG */ } diff --git a/tests/logger/dbus/test-tpl-log-iter-pidgin.c b/tests/logger/dbus/test-tpl-log-iter-pidgin.c index 11e1b5e..e90247a 100644 --- a/tests/logger/dbus/test-tpl-log-iter-pidgin.c +++ b/tests/logger/dbus/test-tpl-log-iter-pidgin.c @@ -112,9 +112,7 @@ setup (PidginTestCaseFixture* fixture, tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); -#ifdef ENABLE_DEBUG _tpl_debug_set_flags_from_env (); -#endif /* ENABLE_DEBUG */ } diff --git a/tests/logger/dbus/test-tpl-log-iter-xml.c b/tests/logger/dbus/test-tpl-log-iter-xml.c index 9053f7d..ae077f5 100644 --- a/tests/logger/dbus/test-tpl-log-iter-xml.c +++ b/tests/logger/dbus/test-tpl-log-iter-xml.c @@ -58,9 +58,7 @@ setup (XmlTestCaseFixture* fixture, tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); -#ifdef ENABLE_DEBUG _tpl_debug_set_flags_from_env (); -#endif /* ENABLE_DEBUG */ } diff --git a/tests/logger/dbus/test-tpl-log-store-pidgin.c b/tests/logger/dbus/test-tpl-log-store-pidgin.c index edd3ddb..7c9dc2b 100644 --- a/tests/logger/dbus/test-tpl-log-store-pidgin.c +++ b/tests/logger/dbus/test-tpl-log-store-pidgin.c @@ -43,7 +43,6 @@ typedef struct TplEntity *contact; } PidginTestCaseFixture; -#ifdef ENABLE_DEBUG static TpDebugSender *debug_sender = NULL; static gboolean stamp_logs = FALSE; @@ -94,7 +93,6 @@ log_handler (const gchar *log_domain, log_to_debug_sender (log_domain, log_level, message); } -#endif /* ENABLE_DEBUG */ static void @@ -513,14 +511,12 @@ setup_debug (void) { tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); -#ifdef ENABLE_DEBUG _tpl_debug_set_flags_from_env (); stamp_logs = (g_getenv ("TPL_TIMING") != NULL); debug_sender = tp_debug_sender_dup (); g_log_set_default_handler (log_handler, NULL); -#endif /* ENABLE_DEBUG */ } diff --git a/tests/logger/dbus/test-tpl-log-store-xml.c b/tests/logger/dbus/test-tpl-log-store-xml.c index 22c6d9c..f8d7d95 100644 --- a/tests/logger/dbus/test-tpl-log-store-xml.c +++ b/tests/logger/dbus/test-tpl-log-store-xml.c @@ -57,9 +57,7 @@ setup (XmlTestCaseFixture* fixture, tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); -#ifdef ENABLE_DEBUG _tpl_debug_set_flags_from_env (); -#endif /* ENABLE_DEBUG */ } diff --git a/tests/logger/dbus/test-tpl-log-walker.c b/tests/logger/dbus/test-tpl-log-walker.c index b924a12..56a92f2 100644 --- a/tests/logger/dbus/test-tpl-log-walker.c +++ b/tests/logger/dbus/test-tpl-log-walker.c @@ -112,9 +112,7 @@ setup (WalkerTestCaseFixture* fixture, tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); -#ifdef ENABLE_DEBUG _tpl_debug_set_flags_from_env (); -#endif /* ENABLE_DEBUG */ } -- 1.8.4.rc3