#include "src/trace_processor/importers/ftrace/ftrace_parser.h"
#include <optional>
#include "perfetto/base/logging.h"
#include "perfetto/base/status.h"
#include "perfetto/ext/base/string_utils.h"
#include "perfetto/ext/base/string_view.h"
#include "perfetto/protozero/proto_decoder.h"
#include "perfetto/trace_processor/basic_types.h"
#include "src/trace_processor/importers/common/args_tracker.h"
#include "src/trace_processor/importers/common/async_track_set_tracker.h"
#include "src/trace_processor/importers/common/cpu_tracker.h"
#include "src/trace_processor/importers/common/metadata_tracker.h"
#include "src/trace_processor/importers/common/parser_types.h"
#include "src/trace_processor/importers/common/process_tracker.h"
#include "src/trace_processor/importers/common/system_info_tracker.h"
#include "src/trace_processor/importers/common/thread_state_tracker.h"
#include "src/trace_processor/importers/common/track_tracker.h"
#include "src/trace_processor/importers/ftrace/binder_tracker.h"
#include "src/trace_processor/importers/ftrace/ftrace_sched_event_tracker.h"
#include "src/trace_processor/importers/ftrace/v4l2_tracker.h"
#include "src/trace_processor/importers/ftrace/virtio_video_tracker.h"
#include "src/trace_processor/importers/i2c/i2c_tracker.h"
#include "src/trace_processor/importers/proto/packet_sequence_state_generation.h"
#include "src/trace_processor/importers/syscalls/syscall_tracker.h"
#include "src/trace_processor/importers/systrace/systrace_parser.h"
#include "src/trace_processor/storage/metadata.h"
#include "src/trace_processor/storage/stats.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/types/softirq_action.h"
#include "src/trace_processor/types/tcp_state.h"
#include "protos/perfetto/common/gpu_counter_descriptor.pbzero.h"
#include "protos/perfetto/trace/ftrace/android_fs.pbzero.h"
#include "protos/perfetto/trace/ftrace/bcl_exynos.pbzero.h"
#include "protos/perfetto/trace/ftrace/binder.pbzero.h"
#include "protos/perfetto/trace/ftrace/cma.pbzero.h"
#include "protos/perfetto/trace/ftrace/cpuhp.pbzero.h"
#include "protos/perfetto/trace/ftrace/cros_ec.pbzero.h"
#include "protos/perfetto/trace/ftrace/dcvsh.pbzero.h"
#include "protos/perfetto/trace/ftrace/dmabuf_heap.pbzero.h"
#include "protos/perfetto/trace/ftrace/dpu.pbzero.h"
#include "protos/perfetto/trace/ftrace/fastrpc.pbzero.h"
#include "protos/perfetto/trace/ftrace/ftrace.pbzero.h"
#include "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h"
#include "protos/perfetto/trace/ftrace/ftrace_stats.pbzero.h"
#include "protos/perfetto/trace/ftrace/g2d.pbzero.h"
#include "protos/perfetto/trace/ftrace/generic.pbzero.h"
#include "protos/perfetto/trace/ftrace/google_icc_trace.pbzero.h"
#include "protos/perfetto/trace/ftrace/google_irm_trace.pbzero.h"
#include "protos/perfetto/trace/ftrace/gpu_mem.pbzero.h"
#include "protos/perfetto/trace/ftrace/i2c.pbzero.h"
#include "protos/perfetto/trace/ftrace/ion.pbzero.h"
#include "protos/perfetto/trace/ftrace/irq.pbzero.h"
#include "protos/perfetto/trace/ftrace/kgsl.pbzero.h"
#include "protos/perfetto/trace/ftrace/kmem.pbzero.h"
#include "protos/perfetto/trace/ftrace/lwis.pbzero.h"
#include "protos/perfetto/trace/ftrace/mali.pbzero.h"
#include "protos/perfetto/trace/ftrace/mdss.pbzero.h"
#include "protos/perfetto/trace/ftrace/mm_event.pbzero.h"
#include "protos/perfetto/trace/ftrace/net.pbzero.h"
#include "protos/perfetto/trace/ftrace/oom.pbzero.h"
#include "protos/perfetto/trace/ftrace/panel.pbzero.h"
#include "protos/perfetto/trace/ftrace/power.pbzero.h"
#include "protos/perfetto/trace/ftrace/raw_syscalls.pbzero.h"
#include "protos/perfetto/trace/ftrace/rpm.pbzero.h"
#include "protos/perfetto/trace/ftrace/samsung.pbzero.h"
#include "protos/perfetto/trace/ftrace/sched.pbzero.h"
#include "protos/perfetto/trace/ftrace/scm.pbzero.h"
#include "protos/perfetto/trace/ftrace/sde.pbzero.h"
#include "protos/perfetto/trace/ftrace/signal.pbzero.h"
#include "protos/perfetto/trace/ftrace/skb.pbzero.h"
#include "protos/perfetto/trace/ftrace/sock.pbzero.h"
#include "protos/perfetto/trace/ftrace/synthetic.pbzero.h"
#include "protos/perfetto/trace/ftrace/systrace.pbzero.h"
#include "protos/perfetto/trace/ftrace/task.pbzero.h"
#include "protos/perfetto/trace/ftrace/tcp.pbzero.h"
#include "protos/perfetto/trace/ftrace/trusty.pbzero.h"
#include "protos/perfetto/trace/ftrace/ufs.pbzero.h"
#include "protos/perfetto/trace/ftrace/vmscan.pbzero.h"
#include "protos/perfetto/trace/ftrace/workqueue.pbzero.h"
#include "protos/perfetto/trace/interned_data/interned_data.pbzero.h"
#include "protos/perfetto/trace/profiling/profile_common.pbzero.h"
namespace perfetto::trace_processor {
namespace {
ConstBytes;
ProtoDecoder;
struct FtraceEventAndFieldId { … };
constexpr auto kKernelFunctionFields = …;
std::string GetUfsCmdString(uint32_t ufsopcode, uint32_t gid) { … }
enum RpmStatus { … };
std::string GetDpmCallbackEventString(int64_t event) { … }
bool StrStartsWith(const std::string& str, const std::string& prefix) { … }
std::string ConstructDpmCallbackSliceName(const std::string& driver_name,
const std::string& device_name,
const std::string& pm_ops,
const std::string& event_type) { … }
}
FtraceParser::FtraceParser(TraceProcessorContext* context)
: … { … }
base::Status FtraceParser::ParseFtraceStats(ConstBytes blob,
uint32_t packet_sequence_id) { … }
base::Status FtraceParser::ParseFtraceEvent(uint32_t cpu,
int64_t ts,
const TracePacketData& data) { … }
base::Status FtraceParser::ParseInlineSchedSwitch(
uint32_t cpu,
int64_t ts,
const InlineSchedSwitch& data) { … }
base::Status FtraceParser::ParseInlineSchedWaking(
uint32_t cpu,
int64_t ts,
const InlineSchedWaking& data) { … }
void FtraceParser::MaybeOnFirstFtraceEvent() { … }
void FtraceParser::ParseGenericFtrace(int64_t ts,
uint32_t cpu,
uint32_t tid,
ConstBytes blob) { … }
void FtraceParser::ParseTypedFtraceToRaw(
uint32_t ftrace_id,
int64_t timestamp,
uint32_t cpu,
uint32_t tid,
ConstBytes blob,
PacketSequenceStateGeneration* seq_state) { … }
PERFETTO_ALWAYS_INLINE
void FtraceParser::ParseSchedSwitch(uint32_t cpu,
int64_t timestamp,
ConstBytes blob) { … }
void FtraceParser::ParseSchedWaking(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseSchedProcessFree(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseCpuFreq(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseCpuFreqThrottle(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseGpuFreq(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseKgslGpuFreq(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseCpuIdle(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParsePrint(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseZero(int64_t timestamp, uint32_t pid, ConstBytes blob) { … }
void FtraceParser::ParseMdssTracingMarkWrite(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseSdeTracingMarkWrite(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseSamsungTracingMarkWrite(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseDpuTracingMarkWrite(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseG2dTracingMarkWrite(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseMaliTracingMarkWrite(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseLwisTracingMarkWrite(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseGoogleIccEvent(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseGoogleIrmEvent(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseIonHeapGrowOrShrink(int64_t timestamp,
uint32_t pid,
ConstBytes blob,
bool grow) { … }
void FtraceParser::ParseIonStat(int64_t timestamp,
uint32_t pid,
protozero::ConstBytes data) { … }
void FtraceParser::ParseBclIrq(int64_t ts, protozero::ConstBytes data) { … }
void FtraceParser::ParseDmaHeapStat(int64_t timestamp,
uint32_t pid,
protozero::ConstBytes data) { … }
void FtraceParser::ParseSignalGenerate(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseSignalDeliver(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseOOMScoreAdjUpdate(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseOOMKill(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseMmEventRecord(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseSysEnterEvent(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseSysExitEvent(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseI2cReadEvent(int64_t timestamp,
uint32_t pid,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseI2cWriteEvent(int64_t timestamp,
uint32_t pid,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseI2cResultEvent(int64_t timestamp,
uint32_t pid,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTaskNewTask(int64_t timestamp,
uint32_t source_tid,
ConstBytes blob) { … }
void FtraceParser::ParseTaskRename(ConstBytes blob) { … }
void FtraceParser::ParseBinderTransaction(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseBinderTransactionReceived(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseBinderCommand(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseBinderReturn(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseBinderTransactionAllocBuf(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseBinderLocked(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseBinderLock(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseBinderUnlock(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseClockSetRate(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseClockEnable(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ParseClockDisable(int64_t timestamp, ConstBytes blob) { … }
void FtraceParser::ClockRate(int64_t timestamp,
base::StringView clock_name,
base::StringView subtitle,
uint64_t rate) { … }
void FtraceParser::ParseScmCallStart(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseScmCallEnd(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseCmaAllocStart(int64_t timestamp, uint32_t pid) { … }
void FtraceParser::ParseCmaAllocInfo(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseDirectReclaimBegin(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseDirectReclaimEnd(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseShrinkSlabStart(
int64_t timestamp,
uint32_t pid,
ConstBytes blob,
PacketSequenceStateGeneration* seq_state) { … }
void FtraceParser::ParseShrinkSlabEnd(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseWorkqueueExecuteStart(
uint32_t cpu,
int64_t timestamp,
uint32_t pid,
ConstBytes blob,
PacketSequenceStateGeneration* seq_state) { … }
void FtraceParser::ParseWorkqueueExecuteEnd(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
void FtraceParser::ParseIrqHandlerEntry(uint32_t cpu,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseIrqHandlerExit(uint32_t cpu,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseSoftIrqEntry(uint32_t cpu,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseSoftIrqExit(uint32_t cpu,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseGpuMemTotal(int64_t timestamp,
protozero::ConstBytes data) { … }
void FtraceParser::ParseSchedBlockedReason(
protozero::ConstBytes blob,
PacketSequenceStateGeneration* seq_state) { … }
void FtraceParser::ParseFastRpcDmaStat(int64_t timestamp,
uint32_t pid,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseCpuhpPause(int64_t,
uint32_t,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseNetifReceiveSkb(uint32_t cpu,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseNetDevXmit(uint32_t cpu,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseInetSockSetState(int64_t timestamp,
uint32_t pid,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTcpRetransmitSkb(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseNapiGroReceiveEntry(uint32_t cpu,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseNapiGroReceiveExit(uint32_t cpu,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseCpuFrequencyLimits(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseKfreeSkb(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseCrosEcSensorhubData(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseUfshcdClkGating(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustySmc(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustySmcDone(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyStdCall32(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyStdCall32Done(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyShareMemory(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyShareMemoryDone(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyReclaimMemory(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyReclaimMemoryDone(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIrq(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIpcHandleEvent(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyEnqueueNop(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIpcConnect(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIpcConnectEnd(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIpcWrite(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIpcRead(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIpcReadEnd(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIpcPoll(uint32_t pid,
int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseTrustyIpcRx(uint32_t pid,
int64_t ts,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseUfshcdCommand(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseWakeSourceActivate(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseWakeSourceDeactivate(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseSuspendResume(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseSuspendResumeMinimal(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseSchedCpuUtilCfs(int64_t timestamp,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseFuncgraphEntry(
int64_t timestamp,
uint32_t cpu,
uint32_t pid,
protozero::ConstBytes blob,
PacketSequenceStateGeneration* seq_state) { … }
void FtraceParser::ParseFuncgraphExit(
int64_t timestamp,
uint32_t cpu,
uint32_t pid,
protozero::ConstBytes blob,
PacketSequenceStateGeneration* seq_state) { … }
void FtraceParser::ParseAndroidFsDatareadStart(int64_t ts,
uint32_t pid,
ConstBytes data) { … }
void FtraceParser::ParseAndroidFsDatareadEnd(int64_t ts, ConstBytes data) { … }
StringId FtraceParser::GetRpmStatusStringId(int32_t rpm_status_val) { … }
void FtraceParser::ParseRpmStatus(int64_t ts, protozero::ConstBytes blob) { … }
void FtraceParser::ParseDevicePmCallbackStart(int64_t ts,
protozero::ConstBytes blob) { … }
void FtraceParser::ParseDevicePmCallbackEnd(int64_t ts,
protozero::ConstBytes blob) { … }
void FtraceParser::ParsePanelWriteGeneric(int64_t timestamp,
uint32_t pid,
ConstBytes blob) { … }
StringId FtraceParser::InternedKernelSymbolOrFallback(
uint64_t key,
PacketSequenceStateGeneration* seq_state) { … }
}