• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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_EXT_TRACING_CORE_BASIC_TYPES_H_
18 #define INCLUDE_PERFETTO_EXT_TRACING_CORE_BASIC_TYPES_H_
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 
23 #include "perfetto/ext/base/sys_types.h"
24 
25 namespace perfetto {
26 
27 // Unique within the scope of the tracing service.
28 using TracingSessionID = uint64_t;
29 
30 // Unique within the scope of the tracing service.
31 using ProducerID = uint16_t;
32 
33 // Unique within the scope of the tracing service.
34 using DataSourceInstanceID = uint64_t;
35 
36 // Unique within the scope of a Producer.
37 using WriterID = uint16_t;
38 
39 // Unique within the scope of the tracing service.
40 using FlushRequestID = uint64_t;
41 
42 // We need one FD per producer and we are not going to be able to keep > 64k FDs
43 // open in the service.
44 static constexpr ProducerID kMaxProducerID = static_cast<ProducerID>(-1);
45 
46 // 1024 Writers per producer seems a resonable bound. This reduces the ability
47 // to memory-DoS the service by having to keep track of too many writer IDs.
48 static constexpr WriterID kMaxWriterID = static_cast<WriterID>((1 << 10) - 1);
49 
50 // Unique within the scope of a {ProducerID, WriterID} tuple.
51 using ChunkID = uint32_t;
52 static constexpr ChunkID kMaxChunkID = static_cast<ChunkID>(-1);
53 
54 // Unique within the scope of the tracing service.
55 using BufferID = uint16_t;
56 
57 // Target buffer ID for SharedMemoryArbiter. Values up to max uint16_t are
58 // equivalent to a bound BufferID. Values above max uint16_t are reservation IDs
59 // for the target buffer of a startup trace writer. Reservation IDs will be
60 // translated to actual BufferIDs after they are bound by
61 // SharedMemoryArbiter::BindStartupTargetBuffer().
62 using MaybeUnboundBufferID = uint32_t;
63 
64 // Keep this in sync with SharedMemoryABI::PageHeader::target_buffer.
65 static constexpr BufferID kMaxTraceBufferID = static_cast<BufferID>(-1);
66 
67 // Unique within the scope of a tracing session.
68 using PacketSequenceID = uint32_t;
69 // Used for extra packets emitted by the service, such as statistics.
70 static constexpr PacketSequenceID kServicePacketSequenceID = 1;
71 static constexpr PacketSequenceID kMaxPacketSequenceID =
72     static_cast<PacketSequenceID>(-1);
73 
74 constexpr uid_t kInvalidUid = ::perfetto::base::kInvalidUid;
75 
76 constexpr uint32_t kDefaultFlushTimeoutMs = 5000;
77 
78 }  // namespace perfetto
79 
80 #endif  // INCLUDE_PERFETTO_EXT_TRACING_CORE_BASIC_TYPES_H_
81