From 01937ee2b9ad00ac72162c92d838f2520ab5ae8d Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Tue, 29 Nov 2016 10:49:23 -0800 Subject: [PATCH] libutils: allow multiple ATRACE_NAMEs in a scope. Bug: http://b/31289465 Test: m Change-Id: Iabd97439fa55ea285ce0501dbb4fd9d07149ae61 --- include/utils/Trace.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/utils/Trace.h b/include/utils/Trace.h index 6ba68f61c..eeba40d65 100644 --- a/include/utils/Trace.h +++ b/include/utils/Trace.h @@ -33,10 +33,10 @@ // See for more ATRACE_* macros. -// ATRACE_NAME traces the beginning and end of the current scope. To trace -// the correct start and end times this macro should be declared first in the -// scope body. -#define ATRACE_NAME(name) android::ScopedTrace ___tracer(ATRACE_TAG, name) +// ATRACE_NAME traces from its location until the end of its enclosing scope. +#define _PASTE(x, y) x ## y +#define PASTE(x, y) _PASTE(x,y) +#define ATRACE_NAME(name) android::ScopedTrace PASTE(___tracer, __LINE__) (ATRACE_TAG, name) // ATRACE_CALL is an ATRACE_NAME that uses the current function name. #define ATRACE_CALL() ATRACE_NAME(__FUNCTION__)