Enumerations
enum class ProtoWireType : uint32_t
| Name | Value |
|---|---|
| kVarInt | 0 |
| kFixed64 | 1 |
| kLengthDelimited | 2 |
| kFixed32 | 5 |
See https://developers.google.com/protocol-buffers/docs/encoding wire types.
This is a type encoded into the proto that provides just enough info to
find the length of the following value.
Defined at line 45 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
enum class ProtoSchemaType
| Name | Value | Comments |
|---|---|---|
| kUnknown | 0 | -- |
| kDouble | 1 | -- |
| kFloat | 2 | -- |
| kInt64 | 3 | -- |
| kUint64 | 4 | -- |
| kInt32 | 5 | -- |
| kFixed64 | 6 | -- |
| kFixed32 | 7 | -- |
| kBool | 8 | -- |
| kString | 9 | -- |
| kGroup | 10 |
Deprecated (proto2 only) |
| kMessage | 11 | -- |
| kBytes | 12 | -- |
| kUint32 | 13 | -- |
| kEnum | 14 | -- |
| kSfixed32 | 15 | -- |
| kSfixed64 | 16 | -- |
| kSint32 | 17 | -- |
| kSint64 | 18 | -- |
This is the type defined in the proto for each field. This information
is used to decide the translation strategy when writing the trace.
Defined at line 89 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
enum class RepetitionType
| Name | Value |
|---|---|
| kNotRepeated | 0 |
| kRepeatedPacked | 1 |
| kRepeatedNotPacked | 2 |
Defined at line 406 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
Records
Functions
-
const char * ProtoSchemaToString (ProtoSchemaType v)Defined at line 111 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
ProtoWireType ProtoSchemaToWireType (ProtoSchemaType v)Returns the wire type used on the wire to encode a field of the given
schema type. This is the single source of truth for the proto-type ->
wire-type grouping. kGroup is a deprecated proto2-only feature that
protozero does not support and that ProtoWireType cannot represent; it,
like kUnknown, maps to kLengthDelimited as a safe opaque default.
Defined at line 162 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
uint64_t GetTagFieldId (uint64_t tag)Defined at line 206 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
uint64_t GetTagFieldType (uint64_t tag)Defined at line 212 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
uint32_t MakeTagVarInt (uint32_t field_id)Proto types: (int|uint|sint)(32|64), bool, enum.
Defined at line 220 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
template <typename T>uint32_t MakeTagFixed (uint32_t field_id)Proto types: fixed64, sfixed64, fixed32, sfixed32, double, float.
Defined at line 226 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
uint32_t MakeTagLengthDelimited (uint32_t field_id)Proto types: string, bytes, embedded messages.
Defined at line 234 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
uint32_t MakeTagStartGroup (uint32_t field_id)Opens a nested message in the proto group encoding described above.
Defined at line 240 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
template <typename T>typename std::make_unsigned<T>::type ZigZagEncode (T value)Proto types: sint64, sint32.
Defined at line 246 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
template <typename T>typename std::make_signed<T>::type ZigZagDecode (T value)Proto types: sint64, sint32.
Defined at line 267 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
template <typename T>typename std::make_unsigned<typename std::conditional<std::is_unsigned<T>::value, T, int64_t>::type>::type ExtendValueForVarIntSerialization (T value)Defined at line 276 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
template <typename T>uint8_t * WriteVarInt (T value, uint8_t * target)Defined at line 302 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
void WriteRedundantVarInt (uint32_tvalue,uint8_t *buf,size_tsize)Writes a fixed-size redundant encoding of the given |value|. This is
used to backfill fixed-size reservations for the length field using a
non-canonical varint encoding (e.g.
instead of
).
See https://github.com/google/protobuf/issues/1530.
This is used mainly in two cases:
1) At trace writing time, when starting a nested messages. The size of a
nested message is not known until all its field have been written.
|kMessageLengthFieldSize| bytes are reserved to encode the size field and
backfilled at the end.
2) When rewriting a message at trace filtering time, in protozero/filtering.
At that point we know only the upper bound of the length (a filtered
message is
<
= the original one) and we backfill after the message has been
filtered.
Defined at line 326 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
template <uint32_t field_id>void StaticAssertSingleBytePreamble ()Defined at line 337 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
const uint8_t * ParseVarInt (const uint8_t *start,const uint8_t *end,uint64_t *out_value)Parses a VarInt from the encoded buffer [start, end). |end| is STL-style and
points one byte past the end of buffer.
The parsed int value is stored in the output arg |value|. Returns a pointer
to the next unconsumed byte (so start
<
retval
<
= end) or |start| if the
VarInt could not be fully parsed because there was not enough space in the
buffer.
Defined at line 348 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
const uint8_t * ParseVarIntUnrolled (const uint8_t * p, uint64_t * out)Unrolled multi-byte varint decode. Avoids the per-byte bounds-check + loop
branch of ParseVarInt, which matters for long varints (e.g. ftrace
timestamps are 8-10 bytes). The caller must guarantee at least 10 readable
bytes at |p| and that p[0] has the continuation bit set. Returns nullptr on
an overlong (> 10 byte) varint. The 10th byte contributes only its low bit
(matching ParseVarInt).
Defined at line 360 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h
-
const uint8_t * ParseVarIntFast (const uint8_t *pos,const uint8_t *end,uint64_t *out)Decodes a varint at |pos|: single-byte fastpath, then the unrolled decode
when there is enough headroom, then the bounded byte-loop near the end of the
buffer. Returns nullptr on a truncated/overlong varint (note: unlike
ParseVarInt, which returns |pos| on failure).
Prefer ParseVarInt() in non-hot code. This is force-inlined and expands the
unrolled decoder at every call site (~415 vs ~80 bytes for a ParseVarInt call
in our measurements), so widespread use bloats the binary. Use it only inside
perf-critical decode loops.
Defined at line 393 of file ../../third_party/perfetto/include/perfetto/protozero/proto_utils.h