• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #include <functional>
15 #include <cstdint>
16 
17 // Convenient declspec dllexport macro for android-emu-shared on Windows
18 #ifndef PERFETTO_TRACING_ONLY_EXPORT
19     #ifdef _MSC_VER
20         #define PERFETTO_TRACING_ONLY_EXPORT __declspec(dllexport)
21     #else // _MSC_VER
22         #define PERFETTO_TRACING_ONLY_EXPORT __attribute__((visibility("default")))
23     #endif // !_MSC_VER
24 #endif // !PERFETTO_TRACING_ONLY_EXPORT
25 
26 namespace virtualdeviceperfetto {
27 
28 struct VirtualDeviceTraceConfig {
29     bool initialized;
30     bool tracingDisabled;
31     uint32_t packetsWritten;
32     bool sequenceIdWritten;
33     uint32_t currentInterningId;
34     uint32_t currentThreadId;
35     const char* hostFilename;
36     const char* guestFilename;
37     const char* combinedFilename;
38     uint64_t hostStartTime;
39     uint64_t guestStartTime;
40     uint64_t guestTimeDiff;
41     uint32_t perThreadStorageMb;
42 };
43 
44 PERFETTO_TRACING_ONLY_EXPORT void setTraceConfig(std::function<void(VirtualDeviceTraceConfig&)>);
45 PERFETTO_TRACING_ONLY_EXPORT VirtualDeviceTraceConfig queryTraceConfig();
46 
47 // An optimization to have faster queries of whether tracing is enabled.
48 PERFETTO_TRACING_ONLY_EXPORT void initialize(const bool** tracingDisabledPtr);
49 
50 PERFETTO_TRACING_ONLY_EXPORT void enableTracing();
51 PERFETTO_TRACING_ONLY_EXPORT void disableTracing();
52 
53 PERFETTO_TRACING_ONLY_EXPORT void beginTrace(const char* eventName);
54 PERFETTO_TRACING_ONLY_EXPORT void endTrace();
55 PERFETTO_TRACING_ONLY_EXPORT void traceCounter(const char* name, int64_t value);
56 
57 PERFETTO_TRACING_ONLY_EXPORT void setGuestTime(uint64_t guestTime);
58 
59 } // namespace virtualdeviceperfetto
60