summaryrefslogtreecommitdiff
path: root/mysys/mf_keycache.c
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-07-03 11:35:44 +0300
committerSergei Golubchik <serg@mariadb.org>2017-08-24 01:05:50 +0200
commit536215e32fc43aa423684e9807640dcf3453924b (patch)
treed7249d3c4268c9a57becc5fea554e2379ffe1cf1 /mysys/mf_keycache.c
parent52a1e4d613a6c7de759e93da8dfbd8cac08a11ee (diff)
downloadmariadb-git-536215e32fc43aa423684e9807640dcf3453924b.tar.gz
Added DBUG_ASSERT_AS_PRINTF compile flag
If compiling a non DBUG binary with -DDBUG_ASSERT_AS_PRINTF asserts will be changed to printf + stack trace (of stack trace are enabled). - Changed #ifndef DBUG_OFF to #ifdef DBUG_ASSERT_EXISTS for those DBUG_OFF that was just used to enable assert - Assert checking that could greatly impact performance where changed to DBUG_ASSERT_SLOW which is not affected by DBUG_ASSERT_AS_PRINTF - Added one extra option to my_print_stacktrace() to get more silent in case of stack trace printing as part of assert.
Diffstat (limited to 'mysys/mf_keycache.c')
-rw-r--r--mysys/mf_keycache.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 34aeb569faf..c7fc2fbb84f 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -421,11 +421,12 @@ static int keycache_pthread_cond_signal(mysql_cond_t *cond);
#undef inline
#endif
#define inline /* disabled inline for easier debugging */
-static int fail_block(BLOCK_LINK *block);
static int fail_hlink(HASH_LINK *hlink);
static int cache_empty(SIMPLE_KEY_CACHE_CB *keycache);
#endif
-
+#ifdef DBUG_ASSERT_EXISTS
+static int fail_block(BLOCK_LINK *block);
+#endif
static inline uint next_power(uint value)
{
@@ -713,7 +714,7 @@ int prepare_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
res= 1;
goto finish;
}
- DBUG_ASSERT(cache_empty(keycache));
+ DBUG_SLOW_ASSERT(cache_empty(keycache));
/* End the flush phase. */
keycache->resize_in_flush= 0;
@@ -1088,7 +1089,7 @@ static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue,
thread->prev);
}
thread->next= NULL;
-#if !defined(DBUG_OFF)
+#ifdef DBUG_ASSERT_EXISTS
/*
This makes it easier to see it's not in a chain during debugging.
And some DBUG_ASSERT() rely on it.
@@ -1211,7 +1212,7 @@ static inline void unlink_changed(BLOCK_LINK *block)
block->next_changed->prev_changed= block->prev_changed;
*block->prev_changed= block->next_changed;
-#if !defined(DBUG_OFF)
+#ifdef DBUG_ASSERT_EXISTS
/*
This makes it easier to see it's not in a chain during debugging.
And some DBUG_ASSERT() rely on it.
@@ -1497,7 +1498,7 @@ static void unlink_block(SIMPLE_KEY_CACHE_CB *keycache, BLOCK_LINK *block)
keycache->used_ins=STRUCT_PTR(BLOCK_LINK, next_used, block->prev_used);
}
block->next_used= NULL;
-#if !defined(DBUG_OFF)
+#ifdef DBUG_ASSERT_EXISTS
/*
This makes it easier to see it's not in a chain during debugging.
And some DBUG_ASSERT() rely on it.
@@ -4309,10 +4310,8 @@ restart:
} /* if (keycache->disk_blocks > 0 */
-#ifndef DBUG_OFF
DBUG_EXECUTE("check_keycache",
test_key_cache(keycache, "end of flush_key_blocks", 0););
-#endif
err:
if (cache != cache_buff)
my_free(cache);
@@ -4790,11 +4789,12 @@ void keycache_debug_log_close(void)
#endif /* defined(KEYCACHE_DEBUG) */
-#if !defined(DBUG_OFF)
+#ifdef DBUG_ASSERT_EXISTS
#define F_B_PRT(_f_, _v_) DBUG_PRINT("assert_fail", (_f_, _v_))
-static int fail_block(BLOCK_LINK *block)
+static int fail_block(BLOCK_LINK *block __attribute__((unused)))
{
+#ifndef DBUG_OFF
F_B_PRT("block->next_used: %lx\n", (ulong) block->next_used);
F_B_PRT("block->prev_used: %lx\n", (ulong) block->prev_used);
F_B_PRT("block->next_changed: %lx\n", (ulong) block->next_changed);
@@ -4805,10 +4805,13 @@ static int fail_block(BLOCK_LINK *block)
F_B_PRT("block->offset: %u\n", block->offset);
F_B_PRT("block->requests: %u\n", block->requests);
F_B_PRT("block->temperature: %u\n", block->temperature);
+#endif
return 0; /* Let the assert fail. */
}
+#endif
-static int fail_hlink(HASH_LINK *hlink)
+#ifndef DBUG_OFF
+static int fail_hlink(HASH_LINK *hlink __attribute__((unused)))
{
F_B_PRT("hlink->next: %lx\n", (ulong) hlink->next);
F_B_PRT("hlink->prev: %lx\n", (ulong) hlink->prev);