/* * Copyright (C) 2017 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_EXT_TRACING_CORE_BASIC_TYPES_H_ #define INCLUDE_PERFETTO_EXT_TRACING_CORE_BASIC_TYPES_H_ #include <stddef.h> #include <stdint.h> #include "perfetto/ext/base/sys_types.h" namespace perfetto { // Unique within the scope of the tracing service. TracingSessionID; // Unique within the scope of the tracing service. ProducerID; // Unique within the scope of the tracing service. DataSourceInstanceID; // Unique within the scope of a Producer. WriterID; // Unique within the scope of the tracing service. FlushRequestID; // Combines Producer and Writer ID in one word which can be used as key for // hashtables and other data structures. ProducerAndWriterID; inline ProducerAndWriterID MkProducerAndWriterID(ProducerID p, WriterID w) { … } inline void GetProducerAndWriterID(ProducerAndWriterID x, ProducerID* p, WriterID* w) { … } // We need one FD per producer and we are not going to be able to keep > 64k FDs // open in the service. static constexpr ProducerID kMaxProducerID = …; // 1024 Writers per producer seems a resonable bound. This reduces the ability // to memory-DoS the service by having to keep track of too many writer IDs. static constexpr WriterID kMaxWriterID = …; // Unique within the scope of a {ProducerID, WriterID} tuple. ChunkID; static constexpr ChunkID kMaxChunkID = …; // Unique within the scope of the tracing service. BufferID; // Target buffer ID for SharedMemoryArbiter. Values up to max uint16_t are // equivalent to a bound BufferID. Values above max uint16_t are reservation IDs // for the target buffer of a startup trace writer. Reservation IDs will be // translated to actual BufferIDs after they are bound by // SharedMemoryArbiter::BindStartupTargetBuffer(). // TODO(mohitms): Delete this type and use `struct {uint16 ; uint16;}` instead. MaybeUnboundBufferID; // Keep this in sync with SharedMemoryABI::PageHeader::target_buffer. static constexpr BufferID kMaxTraceBufferID = …; // Unique within the scope of a tracing session. PacketSequenceID; // Used for extra packets emitted by the service, such as statistics. static constexpr PacketSequenceID kServicePacketSequenceID = …; static constexpr PacketSequenceID kMaxPacketSequenceID = …; constexpr uint32_t kDefaultFlushTimeoutMs = …; // The special id 0xffff..ffff represents the tracing session with the highest // bugreport score. This is used for CloneSession(kBugreportSessionId). constexpr TracingSessionID kBugreportSessionId = …; // The ID of a machine in a multi-machine tracing session. MachineID; constexpr MachineID kDefaultMachineID = …; } // namespace perfetto #endif // INCLUDE_PERFETTO_EXT_TRACING_CORE_BASIC_TYPES_H_