Commit 139e8afc authored by Monty's avatar Monty

Re-enable 'S' for --debug (sf_sanity checking for each call)

- Fixed also a wrong comment and a wrong argument to printf
parent 1464f480
......@@ -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)
......@@ -272,6 +271,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
......@@ -1121,7 +1125,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)
{
......@@ -1190,7 +1194,7 @@ void _db_return_(struct _db_stack_frame_ *_stack_frame_)
if (DoTrace(cs) & DO_TRACE)
{
int org_cs_locked;
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)
{
......@@ -2248,6 +2252,12 @@ const char* _db_get_func_(void)
return cs->func;
}
static int default_my_dbug_sanity(void)
{
return 0;
}
#else
/*
......
......@@ -63,6 +63,7 @@ extern void _db_flush_(void);
extern void dbug_swap_code_state(void **code_state_store);
extern void dbug_free_code_state(void **code_state_store);
extern const char* _db_get_func_(void);
extern int (*dbug_sanity)(void);
#define DBUG_LEAVE do { \
_db_stack_frame_.line= __LINE__; \
......
......@@ -157,6 +157,7 @@ char *guess_malloc_library();
/* If we have our own safemalloc (for debugging) */
#if defined(SAFEMALLOC)
void sf_report_leaked_memory(my_thread_id id);
int sf_sanity();
extern my_thread_id (*sf_malloc_dbug_id)(void);
#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X)
#else
......
......@@ -105,6 +105,10 @@ my_bool my_init(void)
if (my_thread_global_init())
return 1;
#if defined(SAFEMALLOC) && !defined(DBUG_OFF)
dbug_sanity= sf_sanity;
#endif
/* $HOME is needed early to parse configuration files located in ~/ */
if ((home_dir= getenv("HOME")) != 0)
home_dir= intern_filename(home_dir_buff, home_dir);
......
......@@ -200,8 +200,6 @@ void *my_realloc(void *oldpoint, size_t size, myf my_flags)
/**
Free memory allocated with my_malloc.
@remark Relies on free being able to handle a NULL argument.
@param ptr Pointer to the memory allocated by my_malloc.
*/
void my_free(void *ptr)
......
......@@ -330,7 +330,7 @@ static int bad_ptr(const char *where, void *ptr)
magicend[3] != MAGICEND3)
{
DBUG_PRINT("error",("Overrun buffer %p", ptr));
warn("Error: %s overrun buffer %p", where);
warn("Error: %s overrun buffer %p", where, ptr);
fprintf(stderr, "Allocated at ");
print_stack(irem->frame);
return 1;
......@@ -340,7 +340,7 @@ static int bad_ptr(const char *where, void *ptr)
}
/* check all allocated memory list for consistency */
static int sf_sanity()
int sf_sanity()
{
struct st_irem *irem;
int flag= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment