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_PRODUCER_ABI_H_ 18 #define INCLUDE_PERFETTO_PUBLIC_ABI_PRODUCER_ABI_H_ 19 20 #include <stdint.h> 21 22 #include "perfetto/public/abi/export.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 // Opaque pointer to an object that stores the initialization params. 29 struct PerfettoProducerBackendInitArgs; 30 31 // Creates an object to store the configuration params for initializing a 32 // backend. 33 PERFETTO_SDK_EXPORT struct PerfettoProducerBackendInitArgs* 34 PerfettoProducerBackendInitArgsCreate(void); 35 36 // Tunes the size of the shared memory buffer between the current 37 // process and the service backend(s). This is a trade-off between memory 38 // footprint and the ability to sustain bursts of trace writes (see comments 39 // in shared_memory_abi.h). 40 // If set, the value must be a multiple of 4KB. The value can be ignored if 41 // larger than kMaxShmSize (32MB) or not a multiple of 4KB 42 PERFETTO_SDK_EXPORT void PerfettoProducerBackendInitArgsSetShmemSizeHintKb( 43 struct PerfettoProducerBackendInitArgs*, 44 uint32_t size); 45 46 PERFETTO_SDK_EXPORT void PerfettoProducerBackendInitArgsDestroy( 47 struct PerfettoProducerBackendInitArgs*); 48 49 // Initializes the global system perfetto producer. 50 // 51 // It's ok to call this function multiple times, but if the producer was 52 // already initialized, most of `args` would be ignored. 53 // 54 // Does not take ownership of `args`. `args` can be destroyed immediately 55 // after this call returns. 56 PERFETTO_SDK_EXPORT void PerfettoProducerSystemInit( 57 const struct PerfettoProducerBackendInitArgs* args); 58 59 // Initializes the global in-process perfetto producer. 60 // 61 // It's ok to call this function multiple times, but if the producer was 62 // already initialized, most of `args` would be ignored. 63 // 64 // Does not take ownership of `args`. `args` can be destroyed immediately 65 // after this call returns. 66 PERFETTO_SDK_EXPORT void PerfettoProducerInProcessInit( 67 const struct PerfettoProducerBackendInitArgs* args); 68 69 // Informs the tracing services to activate any of these triggers if any tracing 70 // session was waiting for them. 71 // 72 // `trigger_names` is an array of `const char*` (zero terminated strings). The 73 // last pointer in the array must be NULL. 74 // 75 // Sends the trigger signal to all the initialized backends that are currently 76 // connected and that connect in the next `ttl_ms` milliseconds (but 77 // returns immediately anyway). 78 PERFETTO_SDK_EXPORT void PerfettoProducerActivateTriggers( 79 const char* trigger_names[], 80 uint32_t ttl_ms); 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif // INCLUDE_PERFETTO_PUBLIC_ABI_PRODUCER_ABI_H_ 87