class TracePacket
Defined at line 39 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/trace_packet.h
A wrapper around a byte buffer that contains a protobuf-encoded TracePacket
(see trace_packet.proto). The TracePacket is decoded only if the Consumer
requests that. This is to allow Consumer(s) to just stream the packet over
the network or save it to a file without wasting time decoding it and without
needing to depend on libprotobuf or the trace_packet.pb.h header.
If the packets are saved / streamed and not just consumed locally, consumers
should ensure to preserve the unknown fields in the proto. A consumer, in
fact, might have an older version .proto which is newer on the producer.
Public Members
static const uint32_t kPacketFieldNumber
static const size_t kMaxPreambleBytes
Public Methods
void TracePacket ()
void ~TracePacket ()
void TracePacket (TracePacket && )
TracePacket & operator= (TracePacket && )
void AddSlice (Slice )
Mutator, used only by the service and tests.
void AddSlice (const void * start, size_t size)
Does not copy / take ownership of the memory of the slice. The TracePacket
will be valid only as long as the original buffer is valid.
std::tuple<char *, size_t> GetProtoPreamble ()
Generates a protobuf preamble suitable to represent this packet as a
repeated field within a root trace.proto message.
Returns a pointer to a buffer, owned by this class, containing the preamble
and its size.
std::string GetRawBytesForTesting ()
Returns the raw protobuf bytes of the slices, all stitched together into
a string. Only for testing.
const Slices & slices ()
Accesses all the raw slices in the packet, for saving them to file/network.
Defined at line 55 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/trace_packet.h
size_t size ()
Total size of all slices.
Defined at line 65 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/trace_packet.h
std::optional<uint32_t> buffer_index_for_stats ()
Remembers the buffer index where this packet was taken from. This is
usually populated for packets from a TraceBuffer, not synthetic ones.
Defined at line 79 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/trace_packet.h
void set_buffer_index_for_stats (uint32_t v)
Defined at line 84 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/trace_packet.h