<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.26.0">
</HEAD>
<BODY>
On Wed, 2010-04-21 at 11:22 +1000, Peter Hutterer wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
On Tue, Apr 20, 2010 at 08:32:46PM -0400, Gaetan Nadon wrote:
> Provides a common configure option for all x.org modules.
> Script friendly for turning on debug in several modules.
> Integrates easily into existing modules debug code.
> For both source code and makefiles
> Configurable on/off default setting.
>
> Signed-off-by: Gaetan Nadon <<A HREF="mailto:memsize@videotron.ca">memsize@videotron.ca</A>>
> ---
> xorg-macros.m4.in | 32 ++++++++++++++++++++++++++++++++
> 1 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> index 66c8e98..112db89 100644
> --- a/xorg-macros.m4.in
> +++ b/xorg-macros.m4.in
> @@ -1029,3 +1029,35 @@ test -e \"\$\$OUTFILE\" || echo \"\$\$OUTSTR\" > \"\$\$OUTFILE\"; \
> CONTENT=\`cat \$\$OUTFILE\` && test \"\$\$CONTENT\" = \"\$\$OUTSTR\" || echo \$\$OUTSTR > \$\$OUTFILE;"
> AC_SUBST([GIT_MODULE_VERSION_CMD])
> ]) # XORG_GIT_MODULE_VERSION
> +
> +# XORG_ENABLE_DEBUG (enable_debug=no)
> +# -----------------------------------
> +# Minimum version: 1.8.0
> +#
> +# This macro defines a C preprocessor macro and a makefile conditional
> +# to compile code for debugging purpose. (Not related to compiler options)
> +#
> +# Interface to module:
> +# HAVE_DEBUG:         used in makefiles to conditionally build targets
> +#                 used in source code to conditionally debug code
> +# --enable-debug: 'yes' user instructs the module to compile debug code
> +#                 'no' user instructs the module not to compile debug code
> +# parm1:        specify the default value, yes or no.
> +#
> +AC_DEFUN([XORG_ENABLE_DEBUG],[
> +default=$1
> +if test "x$default" = x ; then
> + default="no"
> +fi
> +AC_ARG_ENABLE([debug],
> +        AS_HELP_STRING([--enable-debug],
> +         [Enable debugging code (default: no)]),
> +         [enable_debug=$enableval], [enable_debug=$default])
> +
> +if test x$enable_debug = xyes; then
> + AC_DEFINE([HAVE_DEBUG], [1], [Enable debugging code])
> +fi
> +AM_CONDITIONAL([HAVE_DEBUG], [test x$enable_debug = xyes])
> +AC_MSG_CHECKING([whether to enable debug code])
> +AC_MSG_RESULT([$enable_debug])
> +]) # XORG_ENABLE_DEBUG
> --
> 1.6.0.4
> There are 4 modules with --enable-debug configure option but many more modules (44) do
> have something like #define DEBUG with a wide variety of names. One has to dig in the code
> to figure out how each module does it.
>
> This macro will give the opportunity for modules to have a common configure option where
> debug can be turned on without having to read all the code and to change it.
>
> It was tempting to use DEBUG as the #define name, but there were already conflicts.
can you specify what those conflicts were?
</PRE>
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>
Existing definitions in various drivers
#define DEBUG(str,param1) (void)screen
#define DEBUG(x)
#define DEBUG
#undef DEBUG
</PRE>
</BLOCKQUOTE>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE>
the use of ifdef DEBUG is quite common and having it turned on/off by a
configure option isn't really a conflict if the package didn't do it before.
</PRE>
</BLOCKQUOTE>
No conflict from a configure.ac perspective.
<BLOCKQUOTE TYPE=CITE>
<PRE>
I'd even argue that this macro should go into the XORG_DEFAULT_OPTIONS.
</PRE>
</BLOCKQUOTE>
Sure.
<BLOCKQUOTE TYPE=CITE>
<PRE>
> I checked HAVE_DEBUG was not already used so it's easy to wrap whatever #define is there
> without changing much code.
</PRE>
</BLOCKQUOTE>
Except for the 4 modules having a configure options, others edit the c file to turn debug on.<BR>
<BR>
For example, aiptek has:
<BLOCKQUOTE>
<PRE>
#define DEBUG 1
#if DEBUG
# define DBG(lvl, f) {if ((lvl) <= debug_level) f;}
#else
# define DBG(lvl, f)
#endif
</PRE>
</BLOCKQUOTE>
which can be changed to:
<BLOCKQUOTE>
<PRE>
#ifdef HAVE_DEBUG
#define DEBUG 1
#endif
#if DEBUG
# define DBG(lvl, f) {if ((lvl) <= debug_level) f;}
#else
# define DBG(lvl, f)
#endif
</PRE>
</BLOCKQUOTE>
which does not change the rest of the code and prevents conversion errors. <BR>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE>
Cheers,
Peter
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>