[Cogl] [PATCH] Fix disabling debugging
Neil Roberts
neil at linux.intel.com
Thu May 17 07:22:27 PDT 2012
When --disable-debug is passed to the configure script it was actually
still defining COGL_ENABLE_DEBUG so very little would end up being
disabled. If COGL_ENABLE_DEBUG actually got defined it would also fail
to compile because _cogl_debug_instances and COGL_DEBUG_N_LONGS from
cogl-debug.h were only defined if debugging is enabled but they are
used regardless.
This patch also makes it so that the _COGL_RETURN_IF_FAIL family of
macros that are used when glib support is disabled are now disabled if
debugging is disabled. When the glib macros are used they are already
disabled because we additionally define G_DISABLE_CHECKS.
'COGL_HANDLE_DEBUG' has been removed from the list of defines passed
when debugging is enabled because CoglHandle has already been removed
and it is not used anywhere in the code.
---
cogl/cogl-debug.h | 7 +++----
cogl/cogl-framebuffer.c | 2 ++
cogl/cogl-util.h | 19 +++++++++++++++----
configure.ac | 4 ++--
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/cogl/cogl-debug.h b/cogl/cogl-debug.h
index efb60e1..abe8f9e 100644
--- a/cogl/cogl-debug.h
+++ b/cogl/cogl-debug.h
@@ -72,17 +72,16 @@ typedef enum {
COGL_DEBUG_N_FLAGS
} CoglDebugFlags;
-#ifdef COGL_ENABLE_DEBUG
-
+extern GHashTable *_cogl_debug_instances;
#define COGL_DEBUG_N_LONGS COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_DEBUG_N_FLAGS)
+#ifdef COGL_ENABLE_DEBUG
+
/* _cogl_debug_flags currently needs to exported outside of the shared
library for cogl-pango. The special COGL_EXPORT macro is needed to
get this to work when building with MSVC */
COGL_EXPORT extern unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS];
-extern GHashTable *_cogl_debug_instances;
-
#define COGL_DEBUG_ENABLED(flag) \
COGL_FLAGS_GET (_cogl_debug_flags, flag)
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 45af11b..cce0ccb 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -126,7 +126,9 @@ typedef struct _CoglFramebufferStackEntry
extern CoglObjectClass _cogl_onscreen_class;
+#ifdef COGL_ENABLE_DEBUG
static CoglUserDataKey wire_pipeline_key;
+#endif
static void _cogl_offscreen_free (CoglOffscreen *offscreen);
diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h
index 4458985..67861bc 100644
--- a/cogl/cogl-util.h
+++ b/cogl/cogl-util.h
@@ -175,7 +175,18 @@ _cogl_util_popcountl (unsigned long num)
#define _COGL_RETURN_IF_FAIL(EXPR) g_return_if_fail(EXPR)
#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) g_return_val_if_fail(EXPR, VAL)
#else
-#define _COGL_RETURN_IF_FAIL(EXPR) do { \
+#if COGL_ENABLE_DEBUG
+#define _COGL_RETURN_START do {
+#define _COGL_RETURN_END } while (0)
+#else /* COGL_ENABLE_DEBUG */
+/* If debugging is disabled then we don't actually want to do the
+ * check but we still want the code for the expression to be generated
+ * so that it won't give loads of warnings about unused variables.
+ * Therefore we just surround the block with if(0) */
+#define _COGL_RETURN_START do { if (0) {
+#define _COGL_RETURN_END } } while (0)
+#endif /* COGL_ENABLE_DEBUG */
+#define _COGL_RETURN_IF_FAIL(EXPR) _COGL_RETURN_START { \
if (!(EXPR)) \
{ \
fprintf (stderr, "file %s: line %d: assertion `%s' failed", \
@@ -184,8 +195,8 @@ _cogl_util_popcountl (unsigned long num)
#EXPR); \
return; \
}; \
- } while(0)
-#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) do { \
+ } _COGL_RETURN_END
+#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) _COGL_RETURN_START { \
if (!(EXPR)) \
{ \
fprintf (stderr, "file %s: line %d: assertion `%s' failed", \
@@ -194,7 +205,7 @@ _cogl_util_popcountl (unsigned long num)
#EXPR); \
return (VAL); \
}; \
- } while(0)
+ } _COGL_RETURN_END
#endif /* COGL_HAS_GLIB_SUPPORT */
/* Match a CoglPixelFormat according to channel masks, color depth,
diff --git a/configure.ac b/configure.ac
index c92f6dc..f2df96b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -171,11 +171,11 @@ AS_CASE(
[yes],
[
test "$cflags_set" = set || CFLAGS="$CFLAGS -g -O0"
- COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_HANDLE_DEBUG -DCOGL_ENABLE_DEBUG"
+ COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_ENABLE_DEBUG"
],
[no],
[
- COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DCOGL_ENABLE_DEBUG -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
+ COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
],
[AC_MSG_ERROR([Unknown argument for --enable-debug])]
)
--
1.7.3.16.g9464b
More information about the Cogl
mailing list