From 5cd347ff181b9af9075e0c4c895631abb281a3df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 23 Jan 2017 09:59:47 +0200 Subject: [PATCH] Add the expression to debug assertion log message The actual expression that failed should help figure out what went wrong from the logs alone. --- include/maxscale/debug.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/maxscale/debug.h b/include/maxscale/debug.h index e78ada35a..c2f3532d0 100644 --- a/include/maxscale/debug.h +++ b/include/maxscale/debug.h @@ -35,10 +35,12 @@ MXS_BEGIN_DECLS #if defined(SS_DEBUG) && defined(LOG_ASSERT) #include # define ss_dassert(exp) do { if(!(exp)){\ - MXS_ERROR("debug assert %s:%d\n", (char*)__FILE__, __LINE__);\ + const char *debug_expr = #exp; /** The MXS_ERROR marco doesn't seem to like stringification */ \ + MXS_ERROR("debug assert at %s:%d failed: %s\n", (char*)__FILE__, __LINE__, debug_expr);\ mxs_log_flush_sync(); assert(exp);} } while (false) #define ss_info_dassert(exp,info) do { if(!(exp)){\ - MXS_ERROR("debug assert %s:%d %s\n", (char*)__FILE__, __LINE__, info);\ + const char *debug_expr = #exp; \ + MXS_ERROR("debug assert at %s:%d failed: %s (%s)\n", (char*)__FILE__, __LINE__, info, debug_expr);\ mxs_log_flush_sync();assert(exp);} } while (false) # define ss_debug(exp) exp # define ss_dfprintf fprintf