1
0
Fork 0

Fix disabling debugging

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.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9811a0101c9cbb4ab95c55a2b41fd10ff4c77d9f)
This commit is contained in:
Neil Roberts 2012-05-17 14:51:43 +01:00 committed by Robert Bragg
parent 06c3a7bc70
commit b977d75059
4 changed files with 22 additions and 10 deletions

View file

@ -72,17 +72,16 @@ typedef enum {
COGL_DEBUG_N_FLAGS COGL_DEBUG_N_FLAGS
} CoglDebugFlags; } 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) #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 /* _cogl_debug_flags currently needs to exported outside of the shared
library for cogl-pango. The special COGL_EXPORT macro is needed to library for cogl-pango. The special COGL_EXPORT macro is needed to
get this to work when building with MSVC */ get this to work when building with MSVC */
COGL_EXPORT extern unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS]; COGL_EXPORT extern unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS];
extern GHashTable *_cogl_debug_instances;
#define COGL_DEBUG_ENABLED(flag) \ #define COGL_DEBUG_ENABLED(flag) \
COGL_FLAGS_GET (_cogl_debug_flags, flag) COGL_FLAGS_GET (_cogl_debug_flags, flag)

View file

@ -119,7 +119,9 @@ typedef struct _CoglFramebufferStackEntry
extern CoglObjectClass _cogl_onscreen_class; extern CoglObjectClass _cogl_onscreen_class;
#ifdef COGL_ENABLE_DEBUG
static CoglUserDataKey wire_pipeline_key; static CoglUserDataKey wire_pipeline_key;
#endif
static void _cogl_offscreen_free (CoglOffscreen *offscreen); static void _cogl_offscreen_free (CoglOffscreen *offscreen);

View file

@ -175,7 +175,18 @@ _cogl_util_popcountl (unsigned long num)
#define _COGL_RETURN_IF_FAIL(EXPR) g_return_if_fail(EXPR) #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) #define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) g_return_val_if_fail(EXPR, VAL)
#else #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)) \ if (!(EXPR)) \
{ \ { \
fprintf (stderr, "file %s: line %d: assertion `%s' failed", \ fprintf (stderr, "file %s: line %d: assertion `%s' failed", \
@ -184,8 +195,8 @@ _cogl_util_popcountl (unsigned long num)
#EXPR); \ #EXPR); \
return; \ return; \
}; \ }; \
} while(0) } _COGL_RETURN_END
#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) do { \ #define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) _COGL_RETURN_START { \
if (!(EXPR)) \ if (!(EXPR)) \
{ \ { \
fprintf (stderr, "file %s: line %d: assertion `%s' failed", \ fprintf (stderr, "file %s: line %d: assertion `%s' failed", \
@ -194,7 +205,7 @@ _cogl_util_popcountl (unsigned long num)
#EXPR); \ #EXPR); \
return (VAL); \ return (VAL); \
}; \ }; \
} while(0) } _COGL_RETURN_END
#endif /* COGL_HAS_GLIB_SUPPORT */ #endif /* COGL_HAS_GLIB_SUPPORT */
/* Match a CoglPixelFormat according to channel masks, color depth, /* Match a CoglPixelFormat according to channel masks, color depth,

View file

@ -181,11 +181,11 @@ AS_CASE(
[yes], [yes],
[ [
test "$cflags_set" = set || CFLAGS="$CFLAGS -g -O0" 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], [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])] [AC_MSG_ERROR([Unknown argument for --enable-debug])]
) )