From 4c694864b8dba716cde0d3933145f3ffab346cdb Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Thu, 25 Nov 2010 22:44:08 -0500 Subject: Fixing trace macros One of the macros did not work, when I turned on tracing. The issue is that __FUNCTION__ should be treated as a variable and not as macro. This patch addressed the issue. --- trace/trace.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'trace') diff --git a/trace/trace.h b/trace/trace.h index d42d3ac..59d86a8 100644 --- a/trace/trace.h +++ b/trace/trace.h @@ -112,6 +112,14 @@ extern unsigned trace_level; } \ } while(0) +#define TRACE_RETURN(flow, val) \ + do { \ + char mstr[200]; \ + sprintf(mstr, "%s returning:", __FUNCTION__); \ + flow(mstr, val); \ + } while(0) + + /* Assertion */ #define TRACE_ASSERT(expression) expression ? : printf("ASSERTION FAILED\n") #else /* HAVE_TRACE */ @@ -123,6 +131,7 @@ extern unsigned trace_level; #define TRACE_LNUMBER(level, msg, num) #define TRACE_SLNUMBER(level, msg, num) #define TRACE_DOUBLE(level, msg, num) +#define TRACE_RETURN(flow, val) #endif /* HAVE_TRACE */ @@ -159,8 +168,7 @@ extern unsigned trace_level; /* Some other nice wrappers for function entry and exit */ #define TRACE_FLOW_ENTRY() TRACE_FLOW_STRING(__FUNCTION__, "Entry") #define TRACE_FLOW_EXIT() TRACE_FLOW_STRING(__FUNCTION__, "Exit") -#define TRACE_FLOW_RETURN(val) \ - TRACE_FLOW_NUMBER(__FUNCTION__ " returning:", val) +#define TRACE_FLOW_RETURN(val) TRACE_RETURN(TRACE_FLOW_NUMBER, val) #endif /* COMMON_TRACE_H */ -- cgit