configure.ac: add a generic --enable-debug, replace --enable-hashmap-debug
There will be more debugging options later. --enable-debug will enable them all. --enable-debug=hashmap will enable only hashmap debugging. Also rename the C #define to ENABLE_DEBUG_* pattern.
This commit is contained in:
parent
90df619ef5
commit
fc86aa0ed2
32
configure.ac
32
configure.ac
|
@ -1323,16 +1323,33 @@ AS_IF([test "x$0" != "x./configure"], [
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_ARG_ENABLE(tests,
|
AC_ARG_ENABLE(tests,
|
||||||
[AC_HELP_STRING([--disable-tests], [disable tests])],
|
[AC_HELP_STRING([--disable-tests], [disable tests])],
|
||||||
enable_tests=$enableval, enable_tests=yes)
|
enable_tests=$enableval, enable_tests=yes)
|
||||||
AM_CONDITIONAL(ENABLE_TESTS, [test x$enable_tests = xyes])
|
AM_CONDITIONAL(ENABLE_TESTS, [test x$enable_tests = xyes])
|
||||||
|
|
||||||
AC_ARG_ENABLE(hashmap-debug,
|
AC_ARG_ENABLE(debug,
|
||||||
[AC_HELP_STRING([--enable-hashmap-debug], [enable hashmap debugging])],
|
[AC_HELP_STRING([--enable-debug@<:@=LIST@:>@], [enable extra debugging (hashmap)])],
|
||||||
enable_hashmap_debug=$enableval, enable_hashmap_debug=no)
|
[if test "x$enableval" = "xyes"; then
|
||||||
AS_IF([test x$enable_hashmap_debug = xyes], [
|
enableval="hashmap"
|
||||||
AC_DEFINE(ENABLE_HASHMAP_DEBUG, 1, [Define if hashmap debugging is to be enabled])
|
fi
|
||||||
|
saved_ifs="$IFS"
|
||||||
|
IFS="$IFS$PATH_SEPARATOR,"
|
||||||
|
for name in $enableval; do
|
||||||
|
case $name in
|
||||||
|
hashmap)
|
||||||
|
enable_debug_hashmap=yes
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
IFS="$saved_ifs"],[])
|
||||||
|
|
||||||
|
enable_debug=""
|
||||||
|
AS_IF([test x$enable_debug_hashmap = xyes], [
|
||||||
|
AC_DEFINE(ENABLE_DEBUG_HASHMAP, 1, [Define if hashmap debugging is to be enabled])
|
||||||
|
enable_debug="hashmap $enable_debug"
|
||||||
])
|
])
|
||||||
|
])
|
||||||
|
test -z "$enable_debug" && enable_debug="none"
|
||||||
|
|
||||||
AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
|
AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
|
||||||
AC_SUBST([dbussessionservicedir], [$with_dbussessionservicedir])
|
AC_SUBST([dbussessionservicedir], [$with_dbussessionservicedir])
|
||||||
|
@ -1419,6 +1436,7 @@ AC_MSG_RESULT([
|
||||||
SysV compatibility: ${SYSTEM_SYSV_COMPAT}
|
SysV compatibility: ${SYSTEM_SYSV_COMPAT}
|
||||||
compatibility libraries: ${have_compat_libs}
|
compatibility libraries: ${have_compat_libs}
|
||||||
utmp/wtmp support: ${have_utmp}
|
utmp/wtmp support: ${have_utmp}
|
||||||
|
extra debugging: ${enable_debug}
|
||||||
|
|
||||||
prefix: ${prefix}
|
prefix: ${prefix}
|
||||||
rootprefix: ${with_rootprefix}
|
rootprefix: ${with_rootprefix}
|
||||||
|
|
|
@ -137,7 +137,7 @@ typedef uint8_t dib_raw_t;
|
||||||
|
|
||||||
#define DIB_FREE UINT_MAX
|
#define DIB_FREE UINT_MAX
|
||||||
|
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
struct hashmap_debug_info {
|
struct hashmap_debug_info {
|
||||||
LIST_FIELDS(struct hashmap_debug_info, debug_list);
|
LIST_FIELDS(struct hashmap_debug_info, debug_list);
|
||||||
unsigned max_entries; /* high watermark of n_entries */
|
unsigned max_entries; /* high watermark of n_entries */
|
||||||
|
@ -158,9 +158,9 @@ static LIST_HEAD(struct hashmap_debug_info, hashmap_debug_list);
|
||||||
|
|
||||||
#define HASHMAP_DEBUG_FIELDS struct hashmap_debug_info debug;
|
#define HASHMAP_DEBUG_FIELDS struct hashmap_debug_info debug;
|
||||||
|
|
||||||
#else /* !ENABLE_HASHMAP_DEBUG */
|
#else /* !ENABLE_DEBUG_HASHMAP */
|
||||||
#define HASHMAP_DEBUG_FIELDS
|
#define HASHMAP_DEBUG_FIELDS
|
||||||
#endif /* ENABLE_HASHMAP_DEBUG */
|
#endif /* ENABLE_DEBUG_HASHMAP */
|
||||||
|
|
||||||
enum HashmapType {
|
enum HashmapType {
|
||||||
HASHMAP_TYPE_PLAIN,
|
HASHMAP_TYPE_PLAIN,
|
||||||
|
@ -552,7 +552,7 @@ static void base_remove_entry(HashmapBase *h, unsigned idx) {
|
||||||
dibs = dib_raw_ptr(h);
|
dibs = dib_raw_ptr(h);
|
||||||
assert(dibs[idx] != DIB_RAW_FREE);
|
assert(dibs[idx] != DIB_RAW_FREE);
|
||||||
|
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
h->debug.rem_count++;
|
h->debug.rem_count++;
|
||||||
h->debug.last_rem_idx = idx;
|
h->debug.last_rem_idx = idx;
|
||||||
#endif
|
#endif
|
||||||
|
@ -631,7 +631,7 @@ static unsigned hashmap_iterate_in_insertion_order(OrderedHashmap *h, Iterator *
|
||||||
assert(e->p.b.key == i->next_key);
|
assert(e->p.b.key == i->next_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
i->prev_idx = idx;
|
i->prev_idx = idx;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ static unsigned hashmap_iterate_in_internal_order(HashmapBase *h, Iterator *i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = i->idx;
|
idx = i->idx;
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
i->prev_idx = idx;
|
i->prev_idx = idx;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ static unsigned hashmap_iterate_entry(HashmapBase *h, Iterator *i) {
|
||||||
return IDX_NIL;
|
return IDX_NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
if (i->idx == IDX_FIRST) {
|
if (i->idx == IDX_FIRST) {
|
||||||
i->put_count = h->debug.put_count;
|
i->put_count = h->debug.put_count;
|
||||||
i->rem_count = h->debug.rem_count;
|
i->rem_count = h->debug.rem_count;
|
||||||
|
@ -799,7 +799,7 @@ static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enu
|
||||||
shared_hash_key_initialized= true;
|
shared_hash_key_initialized= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
LIST_PREPEND(debug_list, hashmap_debug_list, &h->debug);
|
LIST_PREPEND(debug_list, hashmap_debug_list, &h->debug);
|
||||||
h->debug.func = func;
|
h->debug.func = func;
|
||||||
h->debug.file = file;
|
h->debug.file = file;
|
||||||
|
@ -854,7 +854,7 @@ static void hashmap_free_no_clear(HashmapBase *h) {
|
||||||
assert(!h->has_indirect);
|
assert(!h->has_indirect);
|
||||||
assert(!h->n_direct_entries);
|
assert(!h->n_direct_entries);
|
||||||
|
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
LIST_REMOVE(debug_list, hashmap_debug_list, &h->debug);
|
LIST_REMOVE(debug_list, hashmap_debug_list, &h->debug);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -961,7 +961,7 @@ static bool hashmap_put_robin_hood(HashmapBase *h, unsigned idx,
|
||||||
dib_raw_t raw_dib, *dibs;
|
dib_raw_t raw_dib, *dibs;
|
||||||
unsigned dib, distance;
|
unsigned dib, distance;
|
||||||
|
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
h->debug.put_count++;
|
h->debug.put_count++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1055,7 +1055,7 @@ static int hashmap_base_put_boldly(HashmapBase *h, unsigned idx,
|
||||||
assert_se(hashmap_put_robin_hood(h, idx, swap) == false);
|
assert_se(hashmap_put_robin_hood(h, idx, swap) == false);
|
||||||
|
|
||||||
n_entries_inc(h);
|
n_entries_inc(h);
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
h->debug.max_entries = MAX(h->debug.max_entries, n_entries(h));
|
h->debug.max_entries = MAX(h->debug.max_entries, n_entries(h));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1283,7 +1283,7 @@ int hashmap_replace(Hashmap *h, const void *key, void *value) {
|
||||||
idx = bucket_scan(h, hash, key);
|
idx = bucket_scan(h, hash, key);
|
||||||
if (idx != IDX_NIL) {
|
if (idx != IDX_NIL) {
|
||||||
e = plain_bucket_at(h, idx);
|
e = plain_bucket_at(h, idx);
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
/* Although the key is equal, the key pointer may have changed,
|
/* Although the key is equal, the key pointer may have changed,
|
||||||
* and this would break our assumption for iterating. So count
|
* and this would break our assumption for iterating. So count
|
||||||
* this operation as incompatible with iteration. */
|
* this operation as incompatible with iteration. */
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
* will be treated as empty hashmap for all read operations. That way it is not
|
* will be treated as empty hashmap for all read operations. That way it is not
|
||||||
* necessary to instantiate an object for each Hashmap use.
|
* necessary to instantiate an object for each Hashmap use.
|
||||||
*
|
*
|
||||||
* If ENABLE_HASHMAP_DEBUG is defined (by configuring with --enable-hashmap-debug),
|
* If ENABLE_DEBUG_HASHMAP is defined (by configuring with --enable-debug=hashmap),
|
||||||
* the implemention will:
|
* the implemention will:
|
||||||
* - store extra data for debugging and statistics (see tools/gdb-sd_dump_hashmaps.py)
|
* - store extra data for debugging and statistics (see tools/gdb-sd_dump_hashmaps.py)
|
||||||
* - perform extra checks for invalid use of iterators
|
* - perform extra checks for invalid use of iterators
|
||||||
|
@ -57,7 +57,7 @@ typedef struct Set Set; /* Stores just keys */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned idx; /* index of an entry to be iterated next */
|
unsigned idx; /* index of an entry to be iterated next */
|
||||||
const void *next_key; /* expected value of that entry's key pointer */
|
const void *next_key; /* expected value of that entry's key pointer */
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
unsigned put_count; /* hashmap's put_count recorded at start of iteration */
|
unsigned put_count; /* hashmap's put_count recorded at start of iteration */
|
||||||
unsigned rem_count; /* hashmap's rem_count in previous iteration */
|
unsigned rem_count; /* hashmap's rem_count in previous iteration */
|
||||||
unsigned prev_idx; /* idx in previous iteration */
|
unsigned prev_idx; /* idx in previous iteration */
|
||||||
|
@ -129,7 +129,7 @@ extern const struct hash_ops devt_hash_ops = {
|
||||||
(Hashmap*)(h), \
|
(Hashmap*)(h), \
|
||||||
(void)0)
|
(void)0)
|
||||||
|
|
||||||
#ifdef ENABLE_HASHMAP_DEBUG
|
#ifdef ENABLE_DEBUG_HASHMAP
|
||||||
# define HASHMAP_DEBUG_PARAMS , const char *func, const char *file, int line
|
# define HASHMAP_DEBUG_PARAMS , const char *func, const char *file, int line
|
||||||
# define HASHMAP_DEBUG_SRC_ARGS , __func__, __FILE__, __LINE__
|
# define HASHMAP_DEBUG_SRC_ARGS , __func__, __FILE__, __LINE__
|
||||||
# define HASHMAP_DEBUG_PASS_ARGS , func, file, line
|
# define HASHMAP_DEBUG_PASS_ARGS , func, file, line
|
||||||
|
|
Loading…
Reference in a new issue