diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-11-10 16:57:15 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-11-16 07:55:55 +0100 |
commit | 29dd634a4c0b9c3579cf9d318ed64d748d848b1d (patch) | |
tree | 83968b769967aba2ca8236c9b2434f00b34674c6 /include/my_dbug.h | |
parent | 8f60656fd58610a7ed0b65321d229b44ab618f9a (diff) | |
download | mariadb-git-29dd634a4c0b9c3579cf9d318ed64d748d848b1d.tar.gz |
dbug: correct trace for DBUG_RETURN(func()); -- gcc only
when func1 calls func2 from DBUG_RETURN, dbug shows the trace as
| > func1
| < func1
| > func2
| < func2
because DBUG_LEAVE happens before func2(). Change that to invoke
DBUG_LEAVE when the local variable goes out of scope. This uses
gcc specific __attribute__((cleanup)).
Diffstat (limited to 'include/my_dbug.h')
-rw-r--r-- | include/my_dbug.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/include/my_dbug.h b/include/my_dbug.h index f4c854bc10c..d56033ab025 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -30,6 +30,7 @@ struct _db_stack_frame_ { const char *func; /* function name of the previous stack frame */ const char *file; /* filename of the function of previous frame */ uint level; /* this nesting level, highest bit enables tracing */ + int line; /* line of DBUG_RETURN */ struct _db_stack_frame_ *prev; /* pointer to the previous frame */ }; @@ -48,7 +49,7 @@ extern void _db_set_(const char *control); extern void _db_set_init_(const char *control); extern void _db_enter_(const char *_func_, const char *_file_, uint _line_, struct _db_stack_frame_ *_stack_frame_); -extern void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_); +extern void _db_return_(struct _db_stack_frame_ *_stack_frame_); extern void _db_pargs_(uint _line_,const char *keyword); extern void _db_doprnt_(const char *format,...) ATTRIBUTE_FORMAT(printf, 1, 2); @@ -63,12 +64,24 @@ 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); +#define DBUG_LEAVE do { \ + _db_stack_frame_.line= __LINE__; \ + _db_return_ (&_db_stack_frame_); \ + _db_stack_frame_.line= 0; \ + } while(0) + +#ifdef HAVE_ATTRIBUTE_CLEANUP +#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_ __attribute__((cleanup(_db_return_))); \ + _db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_) +#define DBUG_RETURN(a1) do { _db_stack_frame_.line=__LINE__; return(a1);} while(0) +#define DBUG_VOID_RETURN do { _db_stack_frame_.line=__LINE__; return;} while(0) +#else #define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \ _db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_) -#define DBUG_LEAVE _db_return_ (__LINE__, &_db_stack_frame_) - #define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0) #define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0) +#endif + #define DBUG_EXECUTE(keyword,a1) \ do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0) #define DBUG_EXECUTE_IF(keyword,a1) \ |