xref: /aosp_15_r20/frameworks/native/libs/tracing_perfetto/tracing_perfetto_internal.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
2  * Copyright 2024 The Android Open Source Project
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  */
16 
17 #ifndef TRACING_PERFETTO_INTERNAL_H
18 #define TRACING_PERFETTO_INTERNAL_H
19 
20 #include <stdint.h>
21 
22 #include "perfetto/public/te_category_macros.h"
23 
24 namespace tracing_perfetto {
25 
26 namespace internal {
27 
28 bool isPerfettoRegistered();
29 
30 struct PerfettoTeCategory* toPerfettoCategory(uint64_t category);
31 
32 void registerWithPerfetto(bool test = false);
33 
34 void perfettoTraceBegin(const struct PerfettoTeCategory& category, const char* name);
35 
36 void perfettoTraceEnd(const struct PerfettoTeCategory& category);
37 
38 void perfettoTraceAsyncBegin(const struct PerfettoTeCategory& category, const char* name,
39                                uint64_t cookie);
40 
41 void perfettoTraceAsyncEnd(const struct PerfettoTeCategory& category, const char* name,
42                              uint64_t cookie);
43 
44 void perfettoTraceAsyncBeginForTrack(const struct PerfettoTeCategory& category, const char* name,
45                                        const char* trackName, uint64_t cookie);
46 
47 void perfettoTraceAsyncEndForTrack(const struct PerfettoTeCategory& category,
48                                      const char* trackName, uint64_t cookie);
49 
50 void perfettoTraceInstant(const struct PerfettoTeCategory& category, const char* name);
51 
52 void perfettoTraceInstantForTrack(const struct PerfettoTeCategory& category,
53                                     const char* trackName, const char* name);
54 
55 void perfettoTraceCounter(const struct PerfettoTeCategory& category, const char* name,
56                             int64_t value);
57 
58 bool isPerfettoCategoryEnabled(PerfettoTeCategory *perfettoTeCategory);
59 
60 bool shouldPreferAtrace(PerfettoTeCategory *perfettoTeCategory, uint64_t category);
61 
62 }  // namespace internal
63 
64 }  // namespace tracing_perfetto
65 
66 #endif  // TRACING_PERFETTO_INTERNAL_H
67