• 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_TRACING_CORE_BASIC_TYPES_H_
18 #define INCLUDE_PERFETTO_TRACING_CORE_BASIC_TYPES_H_
19 
20 #include "perfetto/base/build_config.h"
21 
22 #include <stddef.h>
23 #include <stdint.h>
24 #include <sys/types.h>
25 
26 #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
27 using uid_t = unsigned int;
28 #endif
29 
30 namespace perfetto {
31 
32 // Unique within the scope of the tracing service.
33 using TracingSessionID = uint64_t;
34 
35 // Unique within the scope of the tracing service.
36 using ProducerID = uint16_t;
37 
38 // Unique within the scope of the tracing service.
39 using DataSourceInstanceID = uint64_t;
40 
41 // Unique within the scope of a Producer.
42 using WriterID = uint16_t;
43 
44 // Unique within the scope of the tracing service.
45 using FlushRequestID = uint64_t;
46 
47 // We need one FD per producer and we are not going to be able to keep > 64k FDs
48 // open in the service.
49 static constexpr ProducerID kMaxProducerID = static_cast<ProducerID>(-1);
50 
51 // 1024 Writers per producer seems a resonable bound. This reduces the ability
52 // to memory-DoS the service by having to keep track of too many writer IDs.
53 static constexpr WriterID kMaxWriterID = static_cast<WriterID>((1 << 10) - 1);
54 
55 // Unique within the scope of a {ProducerID, WriterID} tuple.
56 using ChunkID = uint32_t;
57 static constexpr ChunkID kMaxChunkID = static_cast<ChunkID>(-1);
58 
59 // Unique within the scope of the tracing service.
60 using BufferID = uint16_t;
61 
62 // Keep this in sync with SharedMemoryABI::PageHeader::target_buffer.
63 static constexpr BufferID kMaxTraceBufferID = static_cast<BufferID>(-1);
64 
65 // Unique within the scope of a tracing session.
66 using PacketSequenceID = uint32_t;
67 // Used for extra packets emitted by the service, such as statistics.
68 static constexpr PacketSequenceID kInvalidPacketSequenceID = 0;
69 static constexpr PacketSequenceID kServicePacketSequenceID = 1;
70 static constexpr PacketSequenceID kMaxPacketSequenceID =
71     static_cast<PacketSequenceID>(-1);
72 
73 // TODO(primiano): temporary. The buffer page size should be configurable by
74 // consumers.
75 static constexpr size_t kBufferPageSize = 8192;
76 
77 constexpr uid_t kInvalidUid = static_cast<uid_t>(-1);
78 
79 constexpr uint32_t kDefaultFlushTimeoutMs = 5000;
80 
81 }  // namespace perfetto
82 
83 #endif  // INCLUDE_PERFETTO_TRACING_CORE_BASIC_TYPES_H_
84