diff options
author | Brian Behlendorf <[email protected]> | 2012-02-27 10:42:07 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-02-27 14:24:22 -0800 |
commit | 3c208a5480960c9610676dbabeee35fd8b8bb3d8 (patch) | |
tree | cc3ebd553d4f6f1f44bc9541a13b26c95e96f486 | |
parent | feedc4360114941021ff0053a8f979235dd673da (diff) |
Cleanly support debug packages
Allow a source rpm to be rebuilt with debugging enabled. This
avoids the need to have to manually modify the spec file. By
default debugging is still largely disabled. To enable specific
debugging features use the following options with rpmbuild.
'--with debug' - Enables ASSERTs
'--with debug-log' - Enables the internal debug log
'--with debug-kmem' - Enables basic memory accounting
'--with debug-kmem-tracking' - Enables detailed memory tracking
# For example:
$ rpmbuild --rebuild --with debug spl-modules-0.6.0-rc6.src.rpm
Signed-off-by: Brian Behlendorf <[email protected]>
-rw-r--r-- | Makefile.in | 8 | ||||
-rw-r--r-- | cmd/Makefile.in | 4 | ||||
-rw-r--r-- | config/rpm.am | 4 | ||||
-rw-r--r-- | config/spl-build.m4 | 36 | ||||
-rwxr-xr-x | configure | 98 | ||||
-rw-r--r-- | include/Makefile.in | 4 | ||||
-rw-r--r-- | lib/Makefile.in | 4 | ||||
-rw-r--r-- | scripts/Makefile.in | 4 | ||||
-rw-r--r-- | spl-modules.spec.in | 48 |
9 files changed, 180 insertions, 30 deletions
diff --git a/Makefile.in b/Makefile.in index 90c10c074..7c8f696a5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -181,6 +181,10 @@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEBUG_CFLAGS = @DEBUG_CFLAGS@ +DEBUG_KMEM = @DEBUG_KMEM@ +DEBUG_KMEM_TRACKING = @DEBUG_KMEM_TRACKING@ +DEBUG_LOG = @DEBUG_LOG@ +DEBUG_SPL = @DEBUG_SPL@ DEFAULT_PACKAGE = @DEFAULT_PACKAGE@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -905,6 +909,10 @@ rpm-common: --define "require_kdir $(LINUX)" \ --define "require_kobj $(LINUX_OBJ)" \ --define "require_kver $(LINUX_VERSION)" \ + --define "$(DEBUG_SPL) 1" \ + --define "$(DEBUG_LOG) 1" \ + --define "$(DEBUG_KMEM) 1" \ + --define "$(DEBUG_KMEM_TRACKING) 1" \ --nodeps --rebuild $$rpmpkg || exit 1; \ cp $$rpmbuild/RPMS/*/* . || exit 1; \ $(RM) -R $$rpmbuild diff --git a/cmd/Makefile.in b/cmd/Makefile.in index 5d6e0c9f0..9406aeb2c 100644 --- a/cmd/Makefile.in +++ b/cmd/Makefile.in @@ -117,6 +117,10 @@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEBUG_CFLAGS = @DEBUG_CFLAGS@ +DEBUG_KMEM = @DEBUG_KMEM@ +DEBUG_KMEM_TRACKING = @DEBUG_KMEM_TRACKING@ +DEBUG_LOG = @DEBUG_LOG@ +DEBUG_SPL = @DEBUG_SPL@ DEFAULT_PACKAGE = @DEFAULT_PACKAGE@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ diff --git a/config/rpm.am b/config/rpm.am index 0aae42586..7dfe4fd9b 100644 --- a/config/rpm.am +++ b/config/rpm.am @@ -73,6 +73,10 @@ rpm-common: --define "require_kdir $(LINUX)" \ --define "require_kobj $(LINUX_OBJ)" \ --define "require_kver $(LINUX_VERSION)" \ + --define "$(DEBUG_SPL) 1" \ + --define "$(DEBUG_LOG) 1" \ + --define "$(DEBUG_KMEM) 1" \ + --define "$(DEBUG_KMEM_TRACKING) 1" \ --nodeps --rebuild $$rpmpkg || exit 1; \ cp $$rpmbuild/RPMS/*/* . || exit 1; \ $(RM) -R $$rpmbuild diff --git a/config/spl-build.m4 b/config/spl-build.m4 index 205eb6bc5..eee950c67 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -476,13 +476,15 @@ AC_DEFUN([SPL_AC_DEBUG], [ [ KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" DEBUG_CFLAGS="-DDEBUG -Werror" - ], - [ + DEBUG_SPL="_with_debug" + ], [ KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" DEBUG_CFLAGS="-DNDEBUG" + DEBUG_SPL="_without_debug" ]) AC_SUBST(DEBUG_CFLAGS) + AC_SUBST(DEBUG_SPL) AC_MSG_RESULT([$enable_debug]) ]) @@ -505,10 +507,16 @@ AC_DEFUN([SPL_AC_DEBUG_LOG], [ [enable_debug_log=yes]) AS_IF([test "x$enable_debug_log" = xyes], - [AC_DEFINE([DEBUG_LOG], [1], + [ + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG" + DEBUG_LOG="_with_debug_log" + AC_DEFINE([DEBUG_LOG], [1], [Define to 1 to enable basic debug logging]) - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"]) + ], [ + DEBUG_LOG="_without_debug_log" + ]) + AC_SUBST(DEBUG_LOG) AC_MSG_CHECKING([whether basic debug logging is enabled]) AC_MSG_RESULT([$enable_debug_log]) ]) @@ -528,10 +536,16 @@ AC_DEFUN([SPL_AC_DEBUG_KMEM], [ [enable_debug_kmem=yes]) AS_IF([test "x$enable_debug_kmem" = xyes], - [AC_DEFINE([DEBUG_KMEM], [1], + [ + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" + DEBUG_KMEM="_with_debug_kmem" + AC_DEFINE([DEBUG_KMEM], [1], [Define to 1 to enable basic kmem accounting]) - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"]) + ], [ + DEBUG_KMEM="_without_debug_kmem" + ]) + AC_SUBST(DEBUG_KMEM) AC_MSG_CHECKING([whether basic kmem accounting is enabled]) AC_MSG_RESULT([$enable_debug_kmem]) ]) @@ -553,10 +567,16 @@ AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ [enable_debug_kmem_tracking=no]) AS_IF([test "x$enable_debug_kmem_tracking" = xyes], - [AC_DEFINE([DEBUG_KMEM_TRACKING], [1], + [ + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" + DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" + AC_DEFINE([DEBUG_KMEM_TRACKING], [1], [Define to 1 to enable detailed kmem tracking]) - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"]) + ], [ + DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" + ]) + AC_SUBST(DEBUG_KMEM_TRACKING) AC_MSG_CHECKING([whether detailed kmem tracking is enabled]) AC_MSG_RESULT([$enable_debug_kmem_tracking]) ]) @@ -791,6 +791,10 @@ CONFIG_KERNEL_FALSE CONFIG_KERNEL_TRUE CONFIG_USER_FALSE CONFIG_USER_TRUE +DEBUG_KMEM_TRACKING +DEBUG_KMEM +DEBUG_LOG +DEBUG_SPL DEBUG_CFLAGS KERNELCPPFLAGS KERNELMAKE_PARAMS @@ -4785,13 +4789,13 @@ if test "${lt_cv_nm_interface+set}" = set; then else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:4788: $ac_compile\"" >&5) + (eval echo "\"\$as_me:4792: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:4791: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:4795: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:4794: output\"" >&5) + (eval echo "\"\$as_me:4798: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5997,7 +6001,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6000 "configure"' > conftest.$ac_ext + echo '#line 6004 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7850,11 +7854,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7853: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7857: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7857: \$? = $ac_status" >&5 + echo "$as_me:7861: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8189,11 +8193,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8192: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8196: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8196: \$? = $ac_status" >&5 + echo "$as_me:8200: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8294,11 +8298,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8297: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8301: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8301: \$? = $ac_status" >&5 + echo "$as_me:8305: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8349,11 +8353,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8352: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8356: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8356: \$? = $ac_status" >&5 + echo "$as_me:8360: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11152,7 +11156,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11155 "configure" +#line 11159 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11248,7 +11252,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11251 "configure" +#line 11255 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11968,16 +11972,19 @@ fi KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" DEBUG_CFLAGS="-DDEBUG -Werror" + DEBUG_SPL="_with_debug" else KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" DEBUG_CFLAGS="-DNDEBUG" + DEBUG_SPL="_without_debug" fi + { $as_echo "$as_me:$LINENO: result: $enable_debug" >&5 $as_echo "$enable_debug" >&6; } @@ -11992,14 +11999,22 @@ fi if test "x$enable_debug_log" = xyes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG" + DEBUG_LOG="_with_debug_log" + cat >>confdefs.h <<\_ACEOF #define DEBUG_LOG 1 _ACEOF - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG" + +else + + DEBUG_LOG="_without_debug_log" + fi + { $as_echo "$as_me:$LINENO: checking whether basic debug logging is enabled" >&5 $as_echo_n "checking whether basic debug logging is enabled... " >&6; } { $as_echo "$as_me:$LINENO: result: $enable_debug_log" >&5 @@ -12016,14 +12031,22 @@ fi if test "x$enable_debug_kmem" = xyes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" + DEBUG_KMEM="_with_debug_kmem" + cat >>confdefs.h <<\_ACEOF #define DEBUG_KMEM 1 _ACEOF - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" + +else + + DEBUG_KMEM="_without_debug_kmem" + fi + { $as_echo "$as_me:$LINENO: checking whether basic kmem accounting is enabled" >&5 $as_echo_n "checking whether basic kmem accounting is enabled... " >&6; } { $as_echo "$as_me:$LINENO: result: $enable_debug_kmem" >&5 @@ -12040,14 +12063,22 @@ fi if test "x$enable_debug_kmem_tracking" = xyes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" + DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" + cat >>confdefs.h <<\_ACEOF #define DEBUG_KMEM_TRACKING 1 _ACEOF - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" + +else + + DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" + fi + { $as_echo "$as_me:$LINENO: checking whether detailed kmem tracking is enabled" >&5 $as_echo_n "checking whether detailed kmem tracking is enabled... " >&6; } { $as_echo "$as_me:$LINENO: result: $enable_debug_kmem_tracking" >&5 @@ -16371,16 +16402,19 @@ fi KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" DEBUG_CFLAGS="-DDEBUG -Werror" + DEBUG_SPL="_with_debug" else KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" DEBUG_CFLAGS="-DNDEBUG" + DEBUG_SPL="_without_debug" fi + { $as_echo "$as_me:$LINENO: result: $enable_debug" >&5 $as_echo "$enable_debug" >&6; } @@ -16395,14 +16429,22 @@ fi if test "x$enable_debug_log" = xyes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG" + DEBUG_LOG="_with_debug_log" + cat >>confdefs.h <<\_ACEOF #define DEBUG_LOG 1 _ACEOF - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG" + +else + + DEBUG_LOG="_without_debug_log" + fi + { $as_echo "$as_me:$LINENO: checking whether basic debug logging is enabled" >&5 $as_echo_n "checking whether basic debug logging is enabled... " >&6; } { $as_echo "$as_me:$LINENO: result: $enable_debug_log" >&5 @@ -16419,14 +16461,22 @@ fi if test "x$enable_debug_kmem" = xyes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" + DEBUG_KMEM="_with_debug_kmem" + cat >>confdefs.h <<\_ACEOF #define DEBUG_KMEM 1 _ACEOF - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" + +else + + DEBUG_KMEM="_without_debug_kmem" + fi + { $as_echo "$as_me:$LINENO: checking whether basic kmem accounting is enabled" >&5 $as_echo_n "checking whether basic kmem accounting is enabled... " >&6; } { $as_echo "$as_me:$LINENO: result: $enable_debug_kmem" >&5 @@ -16443,14 +16493,22 @@ fi if test "x$enable_debug_kmem_tracking" = xyes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" + DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" + cat >>confdefs.h <<\_ACEOF #define DEBUG_KMEM_TRACKING 1 _ACEOF - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" + +else + + DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" + fi + { $as_echo "$as_me:$LINENO: checking whether detailed kmem tracking is enabled" >&5 $as_echo_n "checking whether detailed kmem tracking is enabled... " >&6; } { $as_echo "$as_me:$LINENO: result: $enable_debug_kmem_tracking" >&5 diff --git a/include/Makefile.in b/include/Makefile.in index 37fce0449..1e6aa5fe6 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -76,6 +76,10 @@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEBUG_CFLAGS = @DEBUG_CFLAGS@ +DEBUG_KMEM = @DEBUG_KMEM@ +DEBUG_KMEM_TRACKING = @DEBUG_KMEM_TRACKING@ +DEBUG_LOG = @DEBUG_LOG@ +DEBUG_SPL = @DEBUG_SPL@ DEFAULT_PACKAGE = @DEFAULT_PACKAGE@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ diff --git a/lib/Makefile.in b/lib/Makefile.in index 4fdae68e2..12315faf0 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -109,6 +109,10 @@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEBUG_CFLAGS = @DEBUG_CFLAGS@ +DEBUG_KMEM = @DEBUG_KMEM@ +DEBUG_KMEM_TRACKING = @DEBUG_KMEM_TRACKING@ +DEBUG_LOG = @DEBUG_LOG@ +DEBUG_SPL = @DEBUG_SPL@ DEFAULT_PACKAGE = @DEFAULT_PACKAGE@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ diff --git a/scripts/Makefile.in b/scripts/Makefile.in index d007d0bd8..ed9c78461 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -71,6 +71,10 @@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEBUG_CFLAGS = @DEBUG_CFLAGS@ +DEBUG_KMEM = @DEBUG_KMEM@ +DEBUG_KMEM_TRACKING = @DEBUG_KMEM_TRACKING@ +DEBUG_LOG = @DEBUG_LOG@ +DEBUG_SPL = @DEBUG_SPL@ DEFAULT_PACKAGE = @DEFAULT_PACKAGE@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ diff --git a/spl-modules.spec.in b/spl-modules.spec.in index ace5cbcd6..2a2c8f468 100644 --- a/spl-modules.spec.in +++ b/spl-modules.spec.in @@ -22,6 +22,50 @@ %define kobj %{require_kobj} %endif +# Set using 'rpmbuild ... --with debug ...', defaults to disabled. +%if %{defined _with_debug} + %define kdebug --enable-debug +%else + %if %{defined _without_debug} + %define kdebug --disable-debug + %else + %define kdebug --disable-debug + %endif +%endif + +# Set using 'rpmbuild ... --with debug-log ...', defaults to enabled. +%if %{defined _with_debug_log} + %define kdebug_log --enable-debug-log +%else + %if %{defined _without_debug_log} + %define kdebug_log --disable-debug-log + %else + %define kdebug_log --enable-debug-log + %endif +%endif + +# Set using 'rpmbuild ... --with debug-kmem ...', defaults to enabled. +%if %{defined _with_debug_kmem} + %define kdebug_kmem --enable-debug-kmem +%else + %if %{defined _without_debug_kmem} + %define kdebug_kmem --disable-debug-kmem + %else + %define kdebug_kmem --enable-debug-kmem + %endif +%endif + +# Set using 'rpmbuild ... --with debug-tracking ...', defaults to disabled. +%if %{defined _with_debug_kmem_tracking} + %define kdebug_kmem_tracking --enable-debug-kmem-tracking +%else + %if %{defined _without_debug_kmem_tracking} + %define kdebug_kmem_tracking --disable-debug-kmem-tracking + %else + %define kdebug_kmem_tracking --disable-debug-kmem-tracking + %endif +%endif + # SLES: %if %{defined suse_version} %if %{undefined kver} @@ -213,8 +257,8 @@ symbols needed for building additional modules which use %{name}. %prep %setup -n @PACKAGE@-%{version} %build -%configure --with-linux=%{kdir} --with-linux-obj=%{kobj} \ - --with-config=kernel +%configure --with-linux=%{kdir} --with-linux-obj=%{kobj} --with-config=kernel \ + %{kdebug} %{kdebug_log} %{kdebug_kmem} %{kdebug_kmem_tracking} make %install |