1 // Copyright (C) 2019 The Android Open Source Project
2 // Copyright (C) 2019 Google Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 #pragma once
16 
17 // Library to perform tracing. Talks to platform-specific
18 // tracing libraries.
19 
20 namespace gfxstream {
21 namespace guest {
22 
23 bool isTracingEnabled();
24 
25 class ScopedTraceGuest {
26 public:
ScopedTraceGuest(const char * name)27     ScopedTraceGuest(const char* name) : name_(name) {
28         beginTraceImpl(name_);
29     }
30 
~ScopedTraceGuest()31     ~ScopedTraceGuest() {
32         endTraceImpl(name_);
33     }
34 private:
35     void beginTraceImpl(const char* name);
36     void endTraceImpl(const char* name);
37 
38     const char* const name_;
39 };
40 
41 } // namespace base
42 } // namespace android
43 
44 #define __AEMU_GENSYM2(x,y) x##y
45 #define __AEMU_GENSYM1(x,y) __AEMU_GENSYM2(x,y)
46 #define AEMU_GENSYM(x) __AEMU_GENSYM1(x,__COUNTER__)
47 
48 #define AEMU_SCOPED_TRACE(tag) __attribute__ ((unused)) gfxstream::guest::ScopedTraceGuest AEMU_GENSYM(aemuScopedTrace_)(tag)
49