/* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INCLUDE_PERFETTO_PUBLIC_ABI_TRACK_EVENT_HL_ABI_H_ #define INCLUDE_PERFETTO_PUBLIC_ABI_TRACK_EVENT_HL_ABI_H_ #include <stdbool.h> #include <stdint.h> #include "perfetto/public/abi/track_event_abi.h" // High level ABI to emit track events. // // For each tracepoint, the user must call PerfettoTeHlEmitImpl() once and pass // it all the required data for the event. The function will iterate all enabled // data source instances and serialize the tracing data as protobuf messages. // // This tries to cover the most common cases of track event. When hitting these // we minimize binary size at the trace-event call site, but we trade off the // ability to serialize custom protobuf messages. #ifdef __cplusplus extern "C" { #endif // The type of the proto field. enum PerfettoTeHlProtoFieldType { … }; // Common header for all the proto fields. struct PerfettoTeHlProtoField { … }; // PERFETTO_TE_HL_PROTO_TYPE_CSTR struct PerfettoTeHlProtoFieldCstr { … }; // PERFETTO_TE_HL_PROTO_TYPE_BYTES struct PerfettoTeHlProtoFieldBytes { … }; // PERFETTO_TE_HL_PROTO_TYPE_NESTED struct PerfettoTeHlProtoFieldNested { … }; // PERFETTO_TE_HL_PROTO_TYPE_VARINT struct PerfettoTeHlProtoFieldVarInt { … }; // PERFETTO_TE_HL_PROTO_TYPE_FIXED64 struct PerfettoTeHlProtoFieldFixed64 { … }; // PERFETTO_TE_HL_PROTO_TYPE_FIXED32 struct PerfettoTeHlProtoFieldFixed32 { … }; // PERFETTO_TE_HL_PROTO_TYPE_DOUBLE struct PerfettoTeHlProtoFieldDouble { … }; // PERFETTO_TE_HL_PROTO_TYPE_FLOAT struct PerfettoTeHlProtoFieldFloat { … }; // The type of an event extra parameter. enum PerfettoTeHlExtraType { … }; // An extra event parameter. Each type of parameter should embed this as its // first member. struct PerfettoTeHlExtra { … }; // PERFETTO_TE_HL_EXTRA_TYPE_REGISTERED_TRACK struct PerfettoTeHlExtraRegisteredTrack { … }; // PERFETTO_TE_HL_EXTRA_TYPE_NAMED_TRACK struct PerfettoTeHlExtraNamedTrack { … }; // PERFETTO_TE_HL_EXTRA_TYPE_TIMESTAMP struct PerfettoTeHlExtraTimestamp { … }; // PERFETTO_TE_HL_EXTRA_TYPE_DYNAMIC_CATEGORY struct PerfettoTeHlExtraDynamicCategory { … }; // PERFETTO_TE_HL_EXTRA_TYPE_COUNTER_INT64 struct PerfettoTeHlExtraCounterInt64 { … }; // PERFETTO_TE_HL_EXTRA_TYPE_COUNTER_DOUBLE struct PerfettoTeHlExtraCounterDouble { … }; // PERFETTO_TE_HL_EXTRA_TYPE_DEBUG_ARG_BOOL struct PerfettoTeHlExtraDebugArgBool { … }; // PERFETTO_TE_HL_EXTRA_TYPE_DEBUG_ARG_UINT64 struct PerfettoTeHlExtraDebugArgUint64 { … }; // PERFETTO_TE_HL_EXTRA_TYPE_DEBUG_ARG_INT64 struct PerfettoTeHlExtraDebugArgInt64 { … }; // PERFETTO_TE_HL_EXTRA_TYPE_DEBUG_ARG_DOUBLE struct PerfettoTeHlExtraDebugArgDouble { … }; // PERFETTO_TE_HL_EXTRA_TYPE_DEBUG_ARG_STRING struct PerfettoTeHlExtraDebugArgString { … }; // PERFETTO_TE_HL_EXTRA_TYPE_DEBUG_ARG_POINTER struct PerfettoTeHlExtraDebugArgPointer { … }; // PERFETTO_TE_HL_EXTRA_TYPE_FLOW // PERFETTO_TE_HL_EXTRA_TYPE_TERMINATING_FLOW struct PerfettoTeHlExtraFlow { … }; // PERFETTO_TE_HL_EXTRA_TYPE_PROTO_FIELDS struct PerfettoTeHlExtraProtoFields { … }; // Emits an event on all active instances of the track event data source. // * `cat`: The registered category of the event, it knows on which data source // instances the event should be emitted. Use // `perfetto_te_all_categories` for dynamic categories. // * `type`: the event type (slice begin, slice end, ...). See `enum // PerfettoTeType`. // * `name`: All events (except when PERFETTO_TE_TYPE_SLICE_END) can have an // associated name. It can be nullptr. // * `extra_data`: Optional parameters associated with the events. Array of // pointers to each event. The last pointer should be NULL. PERFETTO_SDK_EXPORT void PerfettoTeHlEmitImpl( struct PerfettoTeCategoryImpl* cat, int32_t type, const char* name, struct PerfettoTeHlExtra* const* extra_data); #ifdef __cplusplus } #endif #endif // INCLUDE_PERFETTO_PUBLIC_ABI_TRACK_EVENT_HL_ABI_H_