mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
WL 2826: Eigth step
Inserted monty patch to allow for adding and dropping DBUG keywords per thread dbug/dbug.c: Inserted monty patch to allow for adding and dropping DBUG keywords per thread include/my_dbug.h: Inserted monty patch to allow for adding and dropping DBUG keywords per thread
This commit is contained in:
parent
7ea92dcc3c
commit
846adac5e9
2 changed files with 89 additions and 6 deletions
87
dbug/dbug.c
87
dbug/dbug.c
|
@ -249,6 +249,7 @@ typedef struct st_code_state {
|
|||
uint u_line; /* User source code line number */
|
||||
int locked; /* If locked with _db_lock_file */
|
||||
const char *u_keyword; /* Keyword for current macro */
|
||||
struct link *keywords; /* Thread specific, active keywords */
|
||||
} CODE_STATE;
|
||||
|
||||
/* Parse a debug command string */
|
||||
|
@ -1252,7 +1253,9 @@ static BOOLEAN DoProfile ()
|
|||
BOOLEAN _db_strict_keyword_ (
|
||||
const char *keyword)
|
||||
{
|
||||
if (stack -> keywords == NULL)
|
||||
CODE_STATE *state;
|
||||
if (stack->keywords == NULL &&
|
||||
(!(state= code_state()) || state->keywords == NULL))
|
||||
return FALSE;
|
||||
return _db_keyword_ (keyword);
|
||||
}
|
||||
|
@ -1288,16 +1291,15 @@ const char *keyword)
|
|||
REGISTER BOOLEAN result;
|
||||
CODE_STATE *state;
|
||||
|
||||
if (!init_done)
|
||||
_db_push_ ("");
|
||||
/* Sasha: pre-my_thread_init() safety */
|
||||
if (!(state=code_state()))
|
||||
return FALSE;
|
||||
result = FALSE;
|
||||
if (DEBUGGING && !state->disable_output &&
|
||||
state->level <= stack -> maxdepth &&
|
||||
InList (stack -> functions, state->func) &&
|
||||
InList (stack -> keywords, keyword) &&
|
||||
(InList (stack -> keywords, keyword) ||
|
||||
(state -> keywords &&
|
||||
InList (state -> keywords, keyword))) &&
|
||||
InList (stack -> processes, _db_process_))
|
||||
result = TRUE;
|
||||
return (result);
|
||||
|
@ -1373,6 +1375,81 @@ struct link *linkp)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* FUNCTION
|
||||
*
|
||||
* Add key word to _db_strict_keyword_ list
|
||||
*
|
||||
* SYNOPSIS
|
||||
*
|
||||
* VOID _db_add_strict_keyword(keyword)
|
||||
* const char *keyword;
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Add key word to _db_strict_keyword_ to active DEBUG_EXECUTE_IF
|
||||
* statements for this thread only
|
||||
*
|
||||
* Returns TRUE if keyword accepted, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
|
||||
BOOLEAN _db_add_strict_keyword_(const char *keyword)
|
||||
{
|
||||
CODE_STATE *state;
|
||||
struct link *tmp;
|
||||
uint length;
|
||||
|
||||
if (!(state=code_state()) ||
|
||||
!(tmp= (struct link *) DbugMalloc(sizeof(struct link) +
|
||||
(length= strlen(keyword)+1))))
|
||||
return FALSE;
|
||||
tmp->str= (char*) (tmp+1);
|
||||
memcpy(tmp->str, keyword, length);
|
||||
tmp->next_link= state->keywords;
|
||||
state->keywords= tmp;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* FUNCTION
|
||||
*
|
||||
* Remove key word from thread specific _db_strict_keyword_ list
|
||||
*
|
||||
* SYNOPSIS
|
||||
*
|
||||
* VOID _db_del_strict_keyword_(keyword)
|
||||
* const char *keyword;
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Delete key word from _db_strict_keyword_ to decative DEBUG_EXECUTE_IF
|
||||
* statements for this thread only
|
||||
*
|
||||
* Returns TRUE if keyword deleted, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
|
||||
BOOLEAN _db_del_strict_keyword_(const char *keyword)
|
||||
{
|
||||
CODE_STATE *state;
|
||||
struct link *link, **linkp;
|
||||
|
||||
if (!(state=code_state()))
|
||||
return FALSE;
|
||||
|
||||
for (linkp= &state->keywords; (link= *linkp); linkp= &link->next_link)
|
||||
{
|
||||
if (STREQ(link->str, keyword))
|
||||
{
|
||||
*linkp= link->next_link;
|
||||
free(link);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* FUNCTION
|
||||
*
|
||||
|
|
|
@ -24,8 +24,10 @@ extern "C" {
|
|||
extern int _db_on_,_no_db_;
|
||||
extern FILE *_db_fp_;
|
||||
extern char *_db_process_;
|
||||
extern int _db_keyword_(const char *keyword);
|
||||
extern int _db_keyword_(const char *keyword);
|
||||
extern int _db_strict_keyword_(const char *keyword);
|
||||
extern int _db_add_strict_keyword_(const char *keyword);
|
||||
extern int _db_del_strict_keyword_(const char *keyword);
|
||||
extern void _db_setjmp_(void);
|
||||
extern void _db_longjmp_(void);
|
||||
extern void _db_push_(const char *control);
|
||||
|
@ -76,6 +78,8 @@ extern void _db_unlock_file(void);
|
|||
(_db_on_ ? ((_db_strict_keyword_ (keyword)) ? ((a1), 0) : 0) : 0)
|
||||
#define DBUG_COND(keyword) \
|
||||
((_db_on_ && _db_strict_keyword_ (keyword)) ? 1 : 0)
|
||||
#define DBUG_ADD_KEYWORD(key) _db_add_strict_keyword_(key)
|
||||
#define DBUG_DEL_KEYWORD(key) _db_del_strict_keyword_(key)
|
||||
#else /* No debugger */
|
||||
|
||||
#define DBUG_ENTER(a1)
|
||||
|
@ -85,6 +89,8 @@ extern void _db_unlock_file(void);
|
|||
#define DBUG_EXECUTE_IF(keyword,a1) {}
|
||||
#define DBUG_EXECUTE_COND(keyword, a1) 0
|
||||
#define DBUG_COND(keyword) 0
|
||||
#define DBUG_ADD_KEYWORD(key)
|
||||
#define DBUG_DEL_KEYWORD(key)
|
||||
#define DBUG_PRINT(keyword,arglist) {}
|
||||
#define DBUG_PUSH(a1) {}
|
||||
#define DBUG_POP() {}
|
||||
|
|
Loading…
Reference in a new issue