1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_FTRACE_TOKENIZER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_FTRACE_TOKENIZER_H_ 19 20 #include <vector> 21 22 #include "perfetto/trace_processor/trace_blob_view.h" 23 #include "src/trace_processor/importers/common/clock_tracker.h" 24 #include "src/trace_processor/importers/proto/packet_sequence_state_generation.h" 25 #include "src/trace_processor/storage/trace_storage.h" 26 #include "src/trace_processor/types/trace_processor_context.h" 27 28 #include "protos/perfetto/trace/ftrace/ftrace_event_bundle.pbzero.h" 29 30 namespace perfetto { 31 namespace trace_processor { 32 33 class FtraceTokenizer { 34 public: FtraceTokenizer(TraceProcessorContext * context)35 explicit FtraceTokenizer(TraceProcessorContext* context) 36 : context_(context) {} 37 38 base::Status TokenizeFtraceBundle(TraceBlobView bundle, 39 RefPtr<PacketSequenceStateGeneration>, 40 uint32_t packet_sequence_id); 41 42 private: 43 void TokenizeFtraceEvent(uint32_t cpu, 44 ClockTracker::ClockId, 45 TraceBlobView event, 46 RefPtr<PacketSequenceStateGeneration> state); 47 void TokenizeFtraceCompactSched(uint32_t cpu, 48 ClockTracker::ClockId, 49 protozero::ConstBytes); 50 void TokenizeFtraceCompactSchedSwitch( 51 uint32_t cpu, 52 ClockTracker::ClockId, 53 const protos::pbzero::FtraceEventBundle::CompactSched::Decoder& compact, 54 const std::vector<StringId>& string_table); 55 void TokenizeFtraceCompactSchedWaking( 56 uint32_t cpu, 57 ClockTracker::ClockId, 58 const protos::pbzero::FtraceEventBundle::CompactSched::Decoder& compact, 59 const std::vector<StringId>& string_table); 60 61 void HandleFtraceClockSnapshot(int64_t ftrace_ts, 62 int64_t boot_ts, 63 uint32_t packet_sequence_id); 64 void TokenizeFtraceGpuWorkPeriod(uint32_t cpu, 65 TraceBlobView event, 66 RefPtr<PacketSequenceStateGeneration> state); 67 void TokenizeFtraceThermalExynosAcpmBulk( 68 uint32_t cpu, 69 TraceBlobView event, 70 RefPtr<PacketSequenceStateGeneration> state); 71 DlogWithLimit(const base::Status & status)72 void DlogWithLimit(const base::Status& status) { 73 static std::atomic<uint32_t> dlog_count(0); 74 if (dlog_count++ < 10) 75 PERFETTO_DLOG("%s", status.c_message()); 76 } 77 78 int64_t latest_ftrace_clock_snapshot_ts_ = 0; 79 std::vector<bool> per_cpu_seen_first_bundle_; 80 TraceProcessorContext* context_; 81 }; 82 83 } // namespace trace_processor 84 } // namespace perfetto 85 86 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_FTRACE_TOKENIZER_H_ 87