5#ifndef RUNTIME_VM_PERFETTO_UTILS_H_
6#define RUNTIME_VM_PERFETTO_UTILS_H_
8#if defined(SUPPORT_PERFETTO) && !defined(PRODUCT)
14#include "perfetto/ext/tracing/core/trace_packet.h"
15#include "perfetto/protozero/scattered_heap_buffer.h"
26namespace perfetto_utils {
28inline void SetTrustedPacketSequenceId(
36inline void SetTimestampAndMonotonicClockId(
38 int64_t timestamp_micros) {
48inline void PopulateClockSnapshotPacket(
50 SetTrustedPacketSequenceId(packet);
64inline void PopulateProcessDescriptorPacket(
66 perfetto_utils::SetTrustedPacketSequenceId(packet);
75 process_descriptor.
set_pid(pid);
79inline const std::tuple<std::unique_ptr<const uint8_t[]>, intptr_t>
81 protozero::HeapBuffered<perfetto::protos::pbzero::TracePacket>* packet) {
85 for (
const protozero::ScatteredHeapBuffer::Slice& slice :
86 packet->GetSlices()) {
87 size += slice.size() - slice.unused_bytes();
90 std::unique_ptr<uint8_t[]> preamble =
91 std::make_unique<uint8_t[]>(perfetto::TracePacket::kMaxPreambleBytes);
92 uint8_t* ptr = &preamble[0];
94 const uint8_t tag = protozero::proto_utils::MakeTagLengthDelimited(
95 perfetto::TracePacket::kPacketFieldNumber);
96 static_assert(tag < 0x80,
"TracePacket tag should fit in one byte");
99 ptr = protozero::proto_utils::WriteVarInt(
size, ptr);
100 intptr_t preamble_size =
reinterpret_cast<intptr_t
>(ptr) -
101 reinterpret_cast<intptr_t
>(&preamble[0]);
102 return std::make_tuple(std::move(preamble), preamble_size);
105inline void AppendPacketToJSONBase64String(
106 JSONBase64String* jsonBase64String,
107 protozero::HeapBuffered<perfetto::protos::pbzero::TracePacket>* packet) {
108 ASSERT(jsonBase64String !=
nullptr);
109 ASSERT(packet !=
nullptr);
111 const std::tuple<std::unique_ptr<const uint8_t[]>, intptr_t>& response =
112 perfetto_utils::GetProtoPreamble(packet);
113 const uint8_t* preamble =
std::get<0>(response).get();
114 const intptr_t preamble_length =
std::get<1>(response);
115 jsonBase64String->AppendBytes(preamble, preamble_length);
116 for (
const protozero::ScatteredHeapBuffer::Slice& slice :
117 packet->GetSlices()) {
118 jsonBase64String->AppendBytes(slice.start(),
119 slice.size() - slice.unused_bytes());
static intptr_t ProcessId()
static int64_t GetCurrentMonotonicMicrosForTimeline()
void set_clock_id(uint32_t value)
void set_timestamp(uint64_t value)
void set_primary_trace_clock(::perfetto::protos::pbzero::BuiltinClock value)
void set_pid(int32_t value)
void set_timestamp_clock_id(uint32_t value)
T * set_track_descriptor()
void set_trusted_packet_sequence_id(uint32_t value)
void set_timestamp(uint64_t value)
void set_uuid(uint64_t value)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
const myers::Point & get< 1 >(const myers::Segment &s)
const myers::Point & get< 0 >(const myers::Segment &s)
@ BUILTIN_CLOCK_MONOTONIC