blob: f92f5555829db8531689ac0c09bdefb098889163 [file] [log] [blame]
Eric Seckler5c7866e2019-10-18 08:38:16 +01001/*
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
Eric Seckleracfe35b2019-10-18 15:50:17 +010017#ifndef SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_FTRACE_TOKENIZER_H_
18#define SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_FTRACE_TOKENIZER_H_
Eric Seckler5c7866e2019-10-18 08:38:16 +010019
Primiano Tucci3264b592021-11-08 18:20:51 +000020#include "perfetto/trace_processor/trace_blob_view.h"
Lalit Maganti5ac1b112021-08-19 15:11:01 +010021#include "src/trace_processor/importers/common/clock_tracker.h"
Lalit Maganti7010b332020-02-07 10:51:15 +000022#include "src/trace_processor/storage/trace_storage.h"
Lalit Maganti0faddc42020-04-10 17:58:24 +010023#include "src/trace_processor/types/trace_processor_context.h"
Eric Seckler5c7866e2019-10-18 08:38:16 +010024
Lalit Magantia4c13072021-11-02 20:23:51 +000025#include "protos/perfetto/trace/ftrace/ftrace_event_bundle.pbzero.h"
26
Eric Seckler5c7866e2019-10-18 08:38:16 +010027namespace perfetto {
28namespace trace_processor {
29
Lalit Maganti24305ca72020-10-15 17:18:32 +010030class PacketSequenceState;
31
Eric Seckler5c7866e2019-10-18 08:38:16 +010032class FtraceTokenizer {
33 public:
34 explicit FtraceTokenizer(TraceProcessorContext* context)
35 : context_(context) {}
36
Lalit Magantia4c13072021-11-02 20:23:51 +000037 base::Status TokenizeFtraceBundle(TraceBlobView bundle,
38 PacketSequenceState*,
39 uint32_t packet_sequence_id);
Eric Seckler5c7866e2019-10-18 08:38:16 +010040
41 private:
Lalit Maganti24305ca72020-10-15 17:18:32 +010042 void TokenizeFtraceEvent(uint32_t cpu,
Lalit Maganti5ac1b112021-08-19 15:11:01 +010043 ClockTracker::ClockId,
Lalit Maganti24305ca72020-10-15 17:18:32 +010044 TraceBlobView event,
Lalit Magantia4c13072021-11-02 20:23:51 +000045 PacketSequenceState* state);
Eric Seckler5c7866e2019-10-18 08:38:16 +010046 void TokenizeFtraceCompactSched(uint32_t cpu,
Lalit Maganti5ac1b112021-08-19 15:11:01 +010047 ClockTracker::ClockId,
48 protozero::ConstBytes);
Ryan Savitskic53ec7e2019-11-07 17:04:50 +000049 void TokenizeFtraceCompactSchedSwitch(
50 uint32_t cpu,
Lalit Maganti5ac1b112021-08-19 15:11:01 +010051 ClockTracker::ClockId,
Ryan Savitskic53ec7e2019-11-07 17:04:50 +000052 const protos::pbzero::FtraceEventBundle::CompactSched::Decoder& compact,
53 const std::vector<StringId>& string_table);
54 void TokenizeFtraceCompactSchedWaking(
55 uint32_t cpu,
Lalit Maganti5ac1b112021-08-19 15:11:01 +010056 ClockTracker::ClockId,
Ryan Savitskic53ec7e2019-11-07 17:04:50 +000057 const protos::pbzero::FtraceEventBundle::CompactSched::Decoder& compact,
58 const std::vector<StringId>& string_table);
Eric Seckler5c7866e2019-10-18 08:38:16 +010059
Lalit Magantia4c13072021-11-02 20:23:51 +000060 void HandleFtraceClockSnapshot(int64_t ftrace_ts,
61 int64_t boot_ts,
62 uint32_t packet_sequence_id);
63
64 int64_t latest_ftrace_clock_snapshot_ts_ = 0;
Eric Seckler5c7866e2019-10-18 08:38:16 +010065 TraceProcessorContext* context_;
66};
67
68} // namespace trace_processor
69} // namespace perfetto
70
Eric Seckleracfe35b2019-10-18 15:50:17 +010071#endif // SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_FTRACE_TOKENIZER_H_