libctf, dedup: add new configure option --enable-libctf-hash-debugging
authorNick Alcock <nick.alcock@oracle.com>
Fri, 5 Jun 2020 17:38:03 +0000 (18:38 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 17:02:19 +0000 (18:02 +0100)
Add a new debugging configure option, --enable-libctf-hash-debugging,
off by default, which lets you configure in expensive internal
consistency checks and enable the printing of debugging output when
LIBCTF_DEBUG=t before type deduplication has happened.

In this commit we just add the option and cause it to turn ctf_assert
into a real, hard assert for easier debugging.

libctf/
* configure.ac: Add --enable-libctf-hash-debugging.
* aclocal.m4: Pull in enable.m4, for GCC_ENABLE.
* Makefile.in: Regenerated.
* configure: Likewise.
* config.h.in: Likewise.
* ctf-impl.h [ENABLE_LIBCTF_HASH_DEBUGGING]
(ctf_assert): Define to assert.

libctf/ChangeLog
libctf/Makefile.in
libctf/aclocal.m4
libctf/config.h.in
libctf/configure
libctf/configure.ac
libctf/ctf-impl.h

index 66e15522e09223560134a6d5e3c26ea5c78a5566..be00e92016007c6d3d55887e5826c13dcd4cb652 100644 (file)
@@ -1,3 +1,13 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * configure.ac: Add --enable-libctf-hash-debugging.
+       * aclocal.m4: Pull in enable.m4, for GCC_ENABLE.
+       * Makefile.in: Regenerated.
+       * configure: Likewise.
+       * config.h.in: Likewise.
+       * ctf-impl.h [ENABLE_LIBCTF_HASH_DEBUGGING]
+       (ctf_assert): Define to assert.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-sha1.h: New, inline wrappers around sha1_init_ctx and
index 328edcd5511ff1120c0f8619fdf6e19217e99239..bc385278e0903c13eef83637e0e9142baf3cecbf 100644 (file)
@@ -113,6 +113,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
        $(top_srcdir)/../config/acx.m4 \
        $(top_srcdir)/../config/depstand.m4 \
+       $(top_srcdir)/../config/enable.m4 \
        $(top_srcdir)/../config/gettext-sister.m4 \
        $(top_srcdir)/../config/lead-dot.m4 \
        $(top_srcdir)/../config/override.m4 \
index 8ae4b5346299c76daece6361db0bfe2c0bccc814..df51584d8371cdb7b318ee5234c200e042ddc518 100644 (file)
@@ -1230,6 +1230,7 @@ AC_SUBST([am__untar])
 m4_include([../bfd/acinclude.m4])
 m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/enable.m4])
 m4_include([../config/gettext-sister.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/override.m4])
index 897587e587530cdaa646b9d6fdcf9fe1e9bb2eac..2ddd512608843a339b5c2bffeabfa7ecdd56cf12 100644 (file)
@@ -3,6 +3,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD
 
+/* Enable expensive debugging of CTF deduplication type hashing */
+#undef ENABLE_LIBCTF_HASH_DEBUGGING
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
index 58aaa3a529b179623bd3b234f5ace5990cb75ff1..9f16ae92b8d22a559e78da44899d0ae72167a6f4 100755 (executable)
@@ -642,6 +642,8 @@ SHARED_LIBADD
 SHARED_LDFLAGS
 NEED_CTF_QSORT_R_FALSE
 NEED_CTF_QSORT_R_TRUE
+ENABLE_LIBCTF_HASH_DEBUGGING_FALSE
+ENABLE_LIBCTF_HASH_DEBUGGING_TRUE
 zlibinc
 zlibdir
 ac_libctf_warn_cflags
@@ -796,6 +798,7 @@ enable_werror_always
 enable_maintainer_mode
 enable_install_libbfd
 with_system_zlib
+enable_libctf_hash_debugging
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1441,6 +1444,9 @@ Optional Features:
                           enable make rules and dependencies not useful (and
                           sometimes confusing) to the casual installer
   --enable-install-libbfd controls installation of libbfd and related headers
+  --enable-libctf-hash-debugging
+                          Enable expensive debugging of CTF deduplication type
+                          hashing [default=no]
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -11513,7 +11519,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11516 "configure"
+#line 11522 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11619,7 +11625,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11622 "configure"
+#line 11628 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
 
 
 
+ # Check whether --enable-libctf-hash-debugging was given.
+if test "${enable_libctf_hash_debugging+set}" = set; then :
+  enableval=$enable_libctf_hash_debugging;
+      case "$enableval" in
+       yes|no) ;;
+       *) as_fn_error $? "Argument to enable/disable libctf-hash-debugging must be yes or no" "$LINENO" 5 ;;
+      esac
+
+else
+  enable_libctf_hash_debugging=no
+fi
+
+
+if test "${enable_libctf_hash_debugging}" = yes; then
+
+$as_echo "#define ENABLE_LIBCTF_HASH_DEBUGGING 1" >>confdefs.h
+
+fi
+ if test "${enable_libctf_hash_debugging}" = yes; then
+  ENABLE_LIBCTF_HASH_DEBUGGING_TRUE=
+  ENABLE_LIBCTF_HASH_DEBUGGING_FALSE='#'
+else
+  ENABLE_LIBCTF_HASH_DEBUGGING_TRUE='#'
+  ENABLE_LIBCTF_HASH_DEBUGGING_FALSE=
+fi
+
+
 # Similar to GDB_AC_CHECK_BFD.
 OLD_CFLAGS=$CFLAGS
 OLD_LDFLAGS=$LDFLAGS
@@ -13495,6 +13528,10 @@ if test -z "${INSTALL_LIBBFD_TRUE}" && test -z "${INSTALL_LIBBFD_FALSE}"; then
   as_fn_error $? "conditional \"INSTALL_LIBBFD\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${ENABLE_LIBCTF_HASH_DEBUGGING_TRUE}" && test -z "${ENABLE_LIBCTF_HASH_DEBUGGING_FALSE}"; then
+  as_fn_error $? "conditional \"ENABLE_LIBCTF_HASH_DEBUGGING\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 
 if test -z "${NEED_CTF_QSORT_R_TRUE}" && test -z "${NEED_CTF_QSORT_R_FALSE}"; then
   as_fn_error $? "conditional \"NEED_CTF_QSORT_R\" was never defined.
index 26b062e7a54b762689b355203e39b92cd3984ad7..3799a0cb906624296ac906c7d8cbb188fde3a18c 100644 (file)
@@ -67,6 +67,12 @@ AC_FUNC_MMAP
 AC_SEARCH_LIBS(dlopen, dl)
 AM_ZLIB
 
+GCC_ENABLE([libctf-hash-debugging], [no], [], [Enable expensive debugging of CTF deduplication type hashing])
+if test "${enable_libctf_hash_debugging}" = yes; then
+    AC_DEFINE(ENABLE_LIBCTF_HASH_DEBUGGING, 1, [Enable expensive debugging of CTF deduplication type hashing])
+fi
+AM_CONDITIONAL(ENABLE_LIBCTF_HASH_DEBUGGING, test "${enable_libctf_hash_debugging}" = yes)
+
 # Similar to GDB_AC_CHECK_BFD.
 OLD_CFLAGS=$CFLAGS
 OLD_LDFLAGS=$LDFLAGS
index 9c5f7bac65a8f406dc317e8e0227235e5bf1171e..c2fcc92d67229da5c4cd9eb80d0255f8262e975c 100644 (file)
@@ -71,9 +71,14 @@ extern "C"
 
 #endif
 
+#if defined (ENABLE_LIBCTF_HASH_DEBUGGING) && !defined (NDEBUG)
+#include <assert.h>
+#define ctf_assert(fp, expr) (assert (expr), 1)
+#else
 #define ctf_assert(fp, expr)                                           \
   _libctf_unlikely_ (ctf_assert_internal (fp, __FILE__, __LINE__,      \
                                          #expr, !!(expr)))
+#endif
 
 /* libctf in-memory state.  */