Namespaces

Enumerations

enum BackendType : uint32_t
Name Value Comments
kUnspecifiedBackend 0 --
kInProcessBackend 1 << 0

Connects to a previously-initialized perfetto tracing backend for
in-process. If the in-process backend has not been previously initialized
it will do so and create the tracing service on a dedicated thread.

kSystemBackend 1 << 1

Connects to the system tracing service (e.g. on Linux/Android/Mac uses a
named UNIX socket).

kCustomBackend 1 << 2

Used to provide a custom IPC transport to connect to the service.
TracingInitArgs::custom_backend must be non-null and point to an
indefinitely lived instance.

Defined at line 24 of file ../../third_party/perfetto/include/perfetto/tracing/backend_type.h

enum class BufferExhaustedPolicy
Name Value Comments
kStall 0

SharedMemoryArbiterImpl::GetNewChunk() will stall if no free SMB chunk is
available and wait for the tracing service to free one. Note that this
requires that messages the arbiter sends to the tracing service (from any
TraceWriter thread) will be received by it, even if all TraceWriter threads
are stalled. If no free SMB chunk becomes available after a few seconds,
the process will be aborted.

kDrop 1

SharedMemoryArbiterImpl::GetNewChunk() will return an invalid chunk if no
free SMB chunk is available. In this case, the TraceWriter will fall back
to a garbage chunk and drop written data until acquiring a future chunk
succeeds again.

kStallThenDrop 2

SharedMemoryArbiterImpl::GetNewChunk() will stall if no free SMB chunk is
available and wait for the tracing service to free one. Note that this
requires that messages the arbiter sends to the tracing service (from any
TraceWriter thread) will be received by it, even if all TraceWriter threads
are stalled. If no free SMB chunk becomes available after a few seconds,
SharedMemoryArbiterImpl::GetNewChunk() will return an invalid chunk and
data will be lost.

kDefault kStall

Deprecated alias. Do not use.

Determines how SharedMemoryArbiterImpl::GetNewChunk() behaves when no free

chunks are available.

Defined at line 24 of file ../../third_party/perfetto/include/perfetto/tracing/buffer_exhausted_policy.h

enum ProtocolAbiVersion : uint32_t
Name Value Comments
kProtocolAbiV1 1 << 0

The original protocol.
- The producer and the service share one shared memory buffer (SMB) of
pages and chunks.
- Writers fill chunks. The producer tells the service which chunks are
complete with CommitData() IPCs.
- Lengths of nested messages that cross a chunk are patched later, usually
through CommitData().
Layout: include/perfetto/ext/tracing/core/shared_memory_abi.h.
Docs: https://perfetto.dev/docs/design-docs/api-and-abi#shmem-abi.

kProtocolAbiV2 1 << 1

Tracing v2. It is still under development and its ABI is not stable yet.

The producer allocates a ring buffer:
- AttachV2RingBuffer() shares it with the service, once.
- Writers append chunks and never patch them. Nested messages use proto
group encoding, so no length needs a patch.
- DrainV2RingBuffer() asks the service to read it. There is no CommitData()
for these chunks.
A connection can use both writer types only if both versions are in the
common mask. A writer sequence must use one format throughout its life.
Layout: src/tracing/v2/shared_ring_buffer_abi.h.
Design: RFC-0014, https://github.com/google/perfetto/discussions/4508.
Ring buffer ABI: RFC-0046,
https://github.com/google/perfetto/discussions/7120.

A shared memory layout and the operations that send its data to the service.

Each version is independent. Support for v2 does not imply support for v1.

Each value is a single bit. Peers exchange and store a set of versions as a

uint32_t mask, e.g. kProtocolAbiV1 | kProtocolAbiV2.

A new version must take the next unused bit: 1

<

<

2, then 1

<

<

3.

At connection setup:

- The producer sends the mask of versions it supports in

InitializeConnection.

- The service returns the mask of versions that both sides support.

- An old peer sends no mask. This means v1 only.

- No common version means the connection fails.

The proto enum in protos/perfetto/ipc/producer_port.proto has the same

values.

The common mask stays fixed for the connection. A writer must use one of

these versions that its data source config and target buffer permit.

A layout change that an old peer cannot read needs a new version.

Defined at line 72 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/tracing_service.h

Records

Functions

  • const char * GetConsumerSocket ()
  • TraceConfig::TriggerConfig::TriggerMode GetTriggerMode (const TraceConfig & cfg)

    Defined at line 30 of file ../../third_party/perfetto/include/perfetto/tracing/core/trace_config.h

  • ProducerAndWriterID MkProducerAndWriterID (ProducerID p, WriterID w)

    Defined at line 48 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/basic_types.h

  • void GetProducerAndWriterID (ProducerAndWriterID x, ProducerID * p, WriterID * w)

    Defined at line 55 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/basic_types.h

  • std::vector<std::string> TokenizeProducerSockets (const char * producer_socket_names)

    This function is used for tokenize the |producer_socket_names| string into

    multiple producer socket names.

  • const char * GetProducerSocket ()
  • std::string GetRelaySocket ()

    Optionally returns the relay socket name. The relay socket is used

    for forwarding the IPC messages between the local producers and the remote

    tracing service.

  • template <typename MessageType, typename FieldMetadataType, typename ValueType>
    void WriteTracedProtoField (TracedProto<MessageType> & message, FieldMetadataType , ValueType && value)

    Defined at line 398 of file ../../third_party/perfetto/include/perfetto/tracing/traced_proto.h

  • template <typename T>
    void WriteIntoTracedValue (TracedValue context, T && value)

    A type T is writable into a trace if one of the following is defined:

    - T::WriteIntoTracedValue(TracedValue) const

    - T::WriteIntoTrace(TracedValue) const

    - perfetto::TraceFormatTraits

    <T

    >::WriteIntoTracedValue(TracedValue, const T

    &

    )

    - perfetto::TraceFormatTraits

    <T

    >::WriteIntoTrace(TracedValue, const T

    &

    )

    The member forms are preferred for code that can depend on perfetto directly;

    the TraceFormatTraits forms are for types owned by code that cannot. See the

    examples at the top of this file. Primitives, strings, pointers, STL

    containers and protozero enums are supported out of the box.

    If the static_assert below fires, the most common causes are:

    - No conversion is defined for T.

    - The conversion method is not const, or does not take TracedValue by value.

    - The method name is misspelled: only WriteIntoTrace and WriteIntoTracedValue

    are recognised.

    - The TraceFormatTraits

    <T

    > specialisation is not in the perfetto namespace.

    - The header defining the conversion is not included at the TRACE_EVENT call

    site.

    - T is a pointer or smart pointer to a type that is itself not writable.

    - T is a plain enum with no conversion (only protozero enums are automatic).

    Defined at line 497 of file ../../third_party/perfetto/include/perfetto/tracing/traced_value.h

  • template <typename MessageType, typename T>
    void WriteIntoTracedProto (TracedProto<MessageType> context, T && value)

    Defined at line 382 of file ../../third_party/perfetto/include/perfetto/tracing/traced_proto.h

  • template <typename T>
    typename std::enable_if<internal::has_traced_value_support<T>::value>::type WriteIntoTracedValueWithFallback (TracedValue context, T && value, const std::string & )

    Helpers to write a given value into TracedValue even if the given type

    doesn't support conversion (in which case the provided fallback should be

    used). Useful for automatically generating conversions for autogenerated

    code, but otherwise shouldn't be used as non-autogenerated code is expected

    to define WriteIntoTracedValue convertor.

    See WriteWithFallback test in traced_value_unittest.cc for a concrete

    example.

    Defined at line 519 of file ../../third_party/perfetto/include/perfetto/tracing/traced_value.h

  • template <typename T>
    typename std::enable_if<!internal::has_traced_value_support<T>::value>::type WriteIntoTracedValueWithFallback (TracedValue context, T && , const std::string & fallback)

    Defined at line 527 of file ../../third_party/perfetto/include/perfetto/tracing/traced_value.h