• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 INCLUDE_PERFETTO_PUBLIC_ABI_TRACING_SESSION_ABI_H_
18 #define INCLUDE_PERFETTO_PUBLIC_ABI_TRACING_SESSION_ABI_H_
19 
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include <stdint.h>
23 
24 #include "perfetto/public/abi/export.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 // Opaque pointer to the internal representation of a tracing session.
31 struct PerfettoTracingSessionImpl;
32 
33 PERFETTO_SDK_EXPORT struct PerfettoTracingSessionImpl*
34 PerfettoTracingSessionSystemCreate(void);
35 
36 PERFETTO_SDK_EXPORT struct PerfettoTracingSessionImpl*
37 PerfettoTracingSessionInProcessCreate(void);
38 
39 PERFETTO_SDK_EXPORT void PerfettoTracingSessionSetup(
40     struct PerfettoTracingSessionImpl*,
41     void* cfg_begin,
42     size_t cfg_len);
43 
44 PERFETTO_SDK_EXPORT void PerfettoTracingSessionStartAsync(
45     struct PerfettoTracingSessionImpl*);
46 
47 PERFETTO_SDK_EXPORT void PerfettoTracingSessionStartBlocking(
48     struct PerfettoTracingSessionImpl*);
49 
50 PERFETTO_SDK_EXPORT void PerfettoTracingSessionStopAsync(
51     struct PerfettoTracingSessionImpl*);
52 
53 PERFETTO_SDK_EXPORT void PerfettoTracingSessionStopBlocking(
54     struct PerfettoTracingSessionImpl*);
55 
56 // Called back to read pieces of tracing data. `data` points to a chunk of trace
57 // data, `size` bytes long. `has_more` is true if there is more tracing data and
58 // the callback will be invoked again.
59 typedef void (*PerfettoTracingSessionReadCb)(struct PerfettoTracingSessionImpl*,
60                                              const void* data,
61                                              size_t size,
62                                              bool has_more,
63                                              void* user_arg);
64 
65 // Repeatedly calls cb with data from the tracing session. `user_arg` is passed
66 // as is to the callback.
67 PERFETTO_SDK_EXPORT void PerfettoTracingSessionReadTraceBlocking(
68     struct PerfettoTracingSessionImpl*,
69     PerfettoTracingSessionReadCb cb,
70     void* user_arg);
71 
72 PERFETTO_SDK_EXPORT void PerfettoTracingSessionDestroy(
73     struct PerfettoTracingSessionImpl*);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif  // INCLUDE_PERFETTO_PUBLIC_ABI_TRACING_SESSION_ABI_H_
80