[PATCH util-macros] XORG_ENABLE_DEBUG: a configure option to enable code debugging
Peter Hutterer
peter.hutterer at who-t.net
Tue Apr 20 18:22:11 PDT 2010
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 <memsize at videotron.ca>
> ---
> 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?
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.
I'd even argue that this macro should go into the XORG_DEFAULT_OPTIONS.
> I checked HAVE_DEBUG was not already used so it's easy to wrap whatever #define is there
> without changing much code.
Cheers,
Peter
More information about the xorg-devel
mailing list