summaryrefslogtreecommitdiff
path: root/dbug
diff options
context:
space:
mode:
Diffstat (limited to 'dbug')
-rw-r--r--dbug/dbug.c50
1 files changed, 45 insertions, 5 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c
index e7bf69a14e5..847a8cc2b5d 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -128,7 +128,6 @@
#define SANITY_CHECK_ON (1U << 12) /* Check memory on every DBUG_ENTER/RETURN */
#define TRACE_ON (1U << 31) /* Trace enabled. MUST be the highest bit!*/
-#define sf_sanity() (0)
#define TRACING (cs->stack->flags & TRACE_ON)
#define DEBUGGING (cs->stack->flags & DEBUG_ON)
@@ -269,6 +268,11 @@ static void PushState(CODE_STATE *cs);
static void FreeState (CODE_STATE *cs, int free_state);
/* Test for tracing enabled */
static int DoTrace(CODE_STATE *cs);
+static int default_my_dbug_sanity(void);
+
+int (*dbug_sanity)(void)= default_my_dbug_sanity;
+
+
/*
return values of DoTrace.
Can also be used as bitmask: ret & DO_TRACE
@@ -308,7 +312,7 @@ static void DbugVfprintf(FILE *stream, const char* format, va_list args);
#undef EXISTS
#if !defined(HAVE_ACCESS)
-#define EXISTS(pathname) (FALSE) /* Assume no existance */
+#define EXISTS(pathname) (FALSE) /* Assume no existence */
#define Writable(name) (TRUE)
#else
#define EXISTS(pathname) (access(pathname, F_OK) == 0)
@@ -1148,7 +1152,7 @@ void _db_enter_(const char *_func_, const char *_file_,
if (!TRACING) break;
/* fall through */
case DO_TRACE:
- if ((cs->stack->flags & SANITY_CHECK_ON) && sf_sanity())
+ if ((cs->stack->flags & SANITY_CHECK_ON) && (*dbug_sanity)())
cs->stack->flags &= ~SANITY_CHECK_ON;
if (TRACING)
{
@@ -1208,7 +1212,7 @@ void _db_return_(struct _db_stack_frame_ *_stack_frame_)
if (DoTrace(cs) & DO_TRACE)
{
- if ((cs->stack->flags & SANITY_CHECK_ON) && sf_sanity())
+ if ((cs->stack->flags & SANITY_CHECK_ON) && (*dbug_sanity)())
cs->stack->flags &= ~SANITY_CHECK_ON;
if (TRACING)
{
@@ -2168,7 +2172,7 @@ static BOOLEAN Writable(const char *pathname)
/*
flush dbug-stream, free mutex lock & wait delay
- This is because some systems (MSDOS!!) dosn't flush fileheader
+ This is because some systems (MSDOS!!) doesn't flush fileheader
and dbug-file isn't readable after a system crash !!
*/
@@ -2236,6 +2240,22 @@ const char* _db_get_func_(void)
return cs->func;
}
+
+static int default_my_dbug_sanity(void)
+{
+ return 0;
+}
+
+extern my_bool my_assert;
+ATTRIBUTE_COLD
+my_bool _db_my_assert(const char *file, int line, const char *msg)
+{
+ my_bool a = my_assert;
+ _db_flush_();
+ if (!a)
+ fprintf(stderr, "%s:%d: assert: %s\n", file, line, msg);
+ return a;
+}
#else
/*
@@ -2247,3 +2267,23 @@ int i_am_a_dummy_function() {
}
#endif /* DBUG_OFF */
+
+/*
+ This function is called by default on DBUG_ASSERT() when compiled with
+ DBUG_ASSERT_AS_PRINTF
+*/
+
+#ifdef DBUG_ASSERT_AS_PRINTF
+
+static void default_my_dbug_assert_failed(const char *assert_expr,
+ const char *file,
+ unsigned long line)
+{
+ fprintf(stderr, "Warning: assertion failed: %s at %s line %lu\n",
+ assert_expr, file, line);
+}
+
+void (*my_dbug_assert_failed)(const char *assert_expr, const char* file,
+ unsigned long line)= default_my_dbug_assert_failed;
+
+#endif /* DBUG_ASSERT_AS_PRINTF */