michael@0: /* michael@0: * Copyright (C) 2012 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef ANDROID_TRACE_H michael@0: #define ANDROID_TRACE_H michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include michael@0: #include michael@0: #include "cutils_trace.h" michael@0: michael@0: // See for more ATRACE_* macros. michael@0: michael@0: // ATRACE_NAME traces the beginning and end of the current scope. To trace michael@0: // the correct start and end times this macro should be declared first in the michael@0: // scope body. michael@0: #define ATRACE_NAME(name) android::ScopedTrace ___tracer(ATRACE_TAG, name) michael@0: // ATRACE_CALL is an ATRACE_NAME that uses the current function name. michael@0: #define ATRACE_CALL() ATRACE_NAME(__FUNCTION__) michael@0: michael@0: namespace android { michael@0: michael@0: class ScopedTrace { michael@0: public: michael@0: inline ScopedTrace(uint64_t tag, const char* name) michael@0: : mTag(tag) { michael@0: #ifdef HAVE_ANDROID_OS michael@0: atrace_begin(mTag,name); michael@0: #endif michael@0: } michael@0: michael@0: inline ~ScopedTrace() { michael@0: #ifdef HAVE_ANDROID_OS michael@0: atrace_end(mTag); michael@0: #endif michael@0: } michael@0: michael@0: private: michael@0: uint64_t mTag; michael@0: }; michael@0: michael@0: }; // namespace android michael@0: michael@0: #endif // ANDROID_TRACE_H