#include "perfetto/tracing/console_interceptor.h"
#include <stdarg.h>
#include <algorithm>
#include <cmath>
#include <optional>
#include <tuple>
#include "perfetto/ext/base/file_utils.h"
#include "perfetto/ext/base/hash.h"
#include "perfetto/ext/base/scoped_file.h"
#include "perfetto/ext/base/string_utils.h"
#include "perfetto/ext/base/utils.h"
#include "perfetto/tracing/internal/track_event_internal.h"
#include "protos/perfetto/common/interceptor_descriptor.gen.h"
#include "protos/perfetto/config/data_source_config.gen.h"
#include "protos/perfetto/config/interceptor_config.gen.h"
#include "protos/perfetto/config/interceptors/console_config.gen.h"
#include "protos/perfetto/trace/interned_data/interned_data.pbzero.h"
#include "protos/perfetto/trace/trace_packet.pbzero.h"
#include "protos/perfetto/trace/trace_packet_defaults.pbzero.h"
#include "protos/perfetto/trace/track_event/process_descriptor.pbzero.h"
#include "protos/perfetto/trace/track_event/thread_descriptor.pbzero.h"
#include "protos/perfetto/trace/track_event/track_descriptor.pbzero.h"
#include "protos/perfetto/trace/track_event/track_event.pbzero.h"
namespace perfetto {
struct ConsoleColor { … };
namespace {
int g_output_fd_for_testing;
constexpr std::array<ConsoleColor, 16> kTurboColors = …;
constexpr size_t kHueBits = …;
constexpr uint32_t kMaxHue = …;
constexpr uint8_t kLightness = …;
constexpr ConsoleColor kWhiteColor{ … };
const char kDim[] = …;
const char kDefault[] = …;
const char kReset[] = …;
#define FMT_RGB_SET …
#define FMT_RGB_SET_BG …
ConsoleColor Mix(ConsoleColor a, ConsoleColor b, uint8_t ratio) { … }
ConsoleColor HueToRGB(uint32_t hue) { … }
uint32_t CounterToHue(uint32_t counter) { … }
}
class ConsoleInterceptor::Delegate : public TrackEventStateTracker::Delegate { … };
ConsoleInterceptor::~ConsoleInterceptor() = default;
ConsoleInterceptor::ThreadLocalState::ThreadLocalState(
ThreadLocalStateArgs& args) { … }
ConsoleInterceptor::ThreadLocalState::~ThreadLocalState() = default;
ConsoleInterceptor::Delegate::Delegate(InterceptorContext& context)
: … { … }
ConsoleInterceptor::Delegate::~Delegate() = default;
TrackEventStateTracker::SessionState*
ConsoleInterceptor::Delegate::GetSessionState() { … }
void ConsoleInterceptor::Delegate::OnTrackUpdated(
TrackEventStateTracker::Track& track) { … }
void ConsoleInterceptor::Delegate::OnTrackEvent(
const TrackEventStateTracker::Track& track,
const TrackEventStateTracker::ParsedTrackEvent& event) { … }
void ConsoleInterceptor::Register() { … }
void ConsoleInterceptor::SetOutputFdForTesting(int fd) { … }
void ConsoleInterceptor::OnSetup(const SetupArgs& args) { … }
void ConsoleInterceptor::OnStart(const StartArgs&) { … }
void ConsoleInterceptor::OnStop(const StopArgs&) { … }
void ConsoleInterceptor::OnTracePacket(InterceptorContext context) { … }
void ConsoleInterceptor::Printf(InterceptorContext& context,
const char* format,
...) { … }
void ConsoleInterceptor::Flush(InterceptorContext& context) { … }
void ConsoleInterceptor::SetColor(InterceptorContext& context,
const ConsoleColor& color) { … }
void ConsoleInterceptor::SetColor(InterceptorContext& context,
const char* color) { … }
void ConsoleInterceptor::PrintDebugAnnotations(
InterceptorContext& context,
const protos::pbzero::TrackEvent_Decoder& track_event,
const ConsoleColor& slice_color,
const ConsoleColor& highlight_color) { … }
void ConsoleInterceptor::PrintDebugAnnotationName(
InterceptorContext& context,
const perfetto::protos::pbzero::DebugAnnotation::Decoder& annotation) { … }
void ConsoleInterceptor::PrintDebugAnnotationValue(
InterceptorContext& context,
const perfetto::protos::pbzero::DebugAnnotation::Decoder& annotation) { … }
}