summaryrefslogtreecommitdiff
path: root/dbug
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-11-10 16:57:15 +0100
committerSergei Golubchik <serg@mariadb.org>2015-11-16 07:55:55 +0100
commit29dd634a4c0b9c3579cf9d318ed64d748d848b1d (patch)
tree83968b769967aba2ca8236c9b2434f00b34674c6 /dbug
parent8f60656fd58610a7ed0b65321d229b44ab618f9a (diff)
downloadmariadb-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 'dbug')
-rw-r--r--dbug/dbug.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c
index dffd7a44cd8..b2b298beb09 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -1106,6 +1106,7 @@ void _db_enter_(const char *_func_, const char *_file_,
}
save_errno= errno;
+ _stack_frame_->line= -1;
_stack_frame_->func= cs->func;
_stack_frame_->file= cs->file;
cs->func= _func_;
@@ -1161,14 +1162,17 @@ void _db_enter_(const char *_func_, const char *_file_,
*
*/
-void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
+void _db_return_(struct _db_stack_frame_ *_stack_frame_)
{
int save_errno=errno;
uint _slevel_= _stack_frame_->level & ~TRACE_ON;
CODE_STATE *cs;
get_code_state_or_return;
- if (cs->framep != _stack_frame_)
+ if (_stack_frame_->line == 0)
+ return;
+
+ if (_stack_frame_->line == -1 || cs->framep != _stack_frame_)
{
char buf[512];
my_snprintf(buf, sizeof(buf), ERR_MISSING_RETURN, cs->func);
@@ -1183,7 +1187,7 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
{
if (!cs->locked)
pthread_mutex_lock(&THR_LOCK_dbug);
- DoPrefix(cs, _line_);
+ DoPrefix(cs, _stack_frame_->line);
Indent(cs, cs->level);
(void) fprintf(cs->stack->out_file->file, "<%s\n", cs->func);
DbugFlush(cs);