#include "perfetto/tracing/internal/track_event_internal.h"
#include "perfetto/base/proc_utils.h"
#include "perfetto/base/time.h"
#include "perfetto/tracing/core/data_source_config.h"
#include "perfetto/tracing/internal/track_event_interned_fields.h"
#include "perfetto/tracing/track_event.h"
#include "perfetto/tracing/track_event_category_registry.h"
#include "perfetto/tracing/track_event_interned_data_index.h"
#include "protos/perfetto/common/data_source_descriptor.gen.h"
#include "protos/perfetto/common/track_event_descriptor.pbzero.h"
#include "protos/perfetto/trace/clock_snapshot.pbzero.h"
#include "protos/perfetto/trace/interned_data/interned_data.pbzero.h"
#include "protos/perfetto/trace/trace_packet_defaults.pbzero.h"
#include "protos/perfetto/trace/track_event/debug_annotation.pbzero.h"
#include "protos/perfetto/trace/track_event/track_descriptor.pbzero.h"
#if PERFETTO_BUILDFLAG(PERFETTO_OS_MAC)
#include <os/signpost.h>
#endif
ClockSnapshot;
namespace perfetto {
TrackEventSessionObserver::~TrackEventSessionObserver() = default;
void TrackEventSessionObserver::OnSetup(const DataSourceBase::SetupArgs&) { … }
void TrackEventSessionObserver::OnStart(const DataSourceBase::StartArgs&) { … }
void TrackEventSessionObserver::OnStop(const DataSourceBase::StopArgs&) { … }
void TrackEventSessionObserver::WillClearIncrementalState(
const DataSourceBase::ClearIncrementalStateArgs&) { … }
TrackEventTlsStateUserData::~TrackEventTlsStateUserData() = default;
namespace internal {
BaseTrackEventInternedDataIndex::~BaseTrackEventInternedDataIndex() = default;
namespace {
static constexpr const char kLegacySlowPrefix[] = …;
static constexpr const char kSlowTag[] = …;
static constexpr const char kDebugTag[] = …;
static constexpr const char kFilteredEventName[] = …;
constexpr auto kClockIdIncremental = …;
constexpr auto kClockIdAbsolute = …;
class TrackEventSessionObserverRegistry { … };
enum class MatchType { … };
bool NameMatchesPattern(const std::string& pattern,
const std::string& name,
MatchType match_type) { … }
bool NameMatchesPatternList(const std::vector<std::string>& patterns,
const std::string& name,
MatchType match_type) { … }
}
const Track TrackEventInternal::kDefaultTrack{ … };
std::atomic<int> TrackEventInternal::session_count_{ … };
bool TrackEventInternal::Initialize(
const TrackEventCategoryRegistry& registry,
bool (*register_data_source)(const DataSourceDescriptor&)) { … }
bool TrackEventInternal::AddSessionObserver(
const TrackEventCategoryRegistry& registry,
TrackEventSessionObserver* observer) { … }
void TrackEventInternal::RemoveSessionObserver(
const TrackEventCategoryRegistry& registry,
TrackEventSessionObserver* observer) { … }
#if !PERFETTO_BUILDFLAG(PERFETTO_OS_APPLE) && \
!PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
static constexpr protos::pbzero::BuiltinClock kDefaultTraceClock = …;
#else
static constexpr protos::pbzero::BuiltinClock kDefaultTraceClock =
protos::pbzero::BUILTIN_CLOCK_MONOTONIC;
#endif
protos::pbzero::BuiltinClock TrackEventInternal::clock_ = …;
bool TrackEventInternal::disallow_merging_with_system_tracks_ = …;
void TrackEventInternal::EnableTracing(
const TrackEventCategoryRegistry& registry,
const protos::gen::TrackEventConfig& config,
const DataSourceBase::SetupArgs& args) { … }
void TrackEventInternal::OnStart(const TrackEventCategoryRegistry& registry,
const DataSourceBase::StartArgs& args) { … }
void TrackEventInternal::OnStop(const TrackEventCategoryRegistry& registry,
const DataSourceBase::StopArgs& args) { … }
void TrackEventInternal::DisableTracing(
const TrackEventCategoryRegistry& registry,
uint32_t internal_instance_index) { … }
void TrackEventInternal::WillClearIncrementalState(
const TrackEventCategoryRegistry& registry,
const DataSourceBase::ClearIncrementalStateArgs& args) { … }
bool TrackEventInternal::IsCategoryEnabled(
const TrackEventCategoryRegistry& registry,
const protos::gen::TrackEventConfig& config,
const Category& category) { … }
uint64_t TrackEventInternal::GetTimeNs() { … }
TraceTimestamp TrackEventInternal::GetTraceTime() { … }
int TrackEventInternal::GetSessionCount() { … }
void TrackEventInternal::ResetIncrementalState(
TraceWriterBase* trace_writer,
TrackEventIncrementalState* incr_state,
const TrackEventTlsState& tls_state,
const TraceTimestamp& timestamp) { … }
protozero::MessageHandle<protos::pbzero::TracePacket>
TrackEventInternal::NewTracePacket(TraceWriterBase* trace_writer,
TrackEventIncrementalState* incr_state,
const TrackEventTlsState& tls_state,
TraceTimestamp timestamp,
uint32_t seq_flags) { … }
void TrackEventInternal::WriteEventName(StaticString event_name,
perfetto::EventContext& event_ctx,
const TrackEventTlsState&) { … }
void TrackEventInternal::WriteEventName(perfetto::DynamicString event_name,
perfetto::EventContext& event_ctx,
const TrackEventTlsState& tls_state) { … }
EventContext TrackEventInternal::WriteEvent(
TraceWriterBase* trace_writer,
TrackEventIncrementalState* incr_state,
TrackEventTlsState& tls_state,
const Category* category,
perfetto::protos::pbzero::TrackEvent::Type type,
const TraceTimestamp& timestamp,
bool on_current_thread_track) { … }
protos::pbzero::DebugAnnotation* TrackEventInternal::AddDebugAnnotation(
perfetto::EventContext* event_ctx,
const char* name) { … }
protos::pbzero::DebugAnnotation* TrackEventInternal::AddDebugAnnotation(
perfetto::EventContext* event_ctx,
perfetto::DynamicString name) { … }
}
}