• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "perfetto/trace_processor/trace_blob_view.h"
21 #include "src/trace_processor/importers/common/clock_tracker.h"
22 #include "src/trace_processor/storage/trace_storage.h"
23 #include "src/trace_processor/types/trace_processor_context.h"
24 
25 #include "protos/perfetto/trace/ftrace/ftrace_event_bundle.pbzero.h"
26 
27 namespace perfetto {
28 namespace trace_processor {
29 
30 class PacketSequenceState;
31 
32 class FtraceTokenizer {
33  public:
FtraceTokenizer(TraceProcessorContext * context)34   explicit FtraceTokenizer(TraceProcessorContext* context)
35       : context_(context) {}
36 
37   base::Status TokenizeFtraceBundle(TraceBlobView bundle,
38                                     PacketSequenceState*,
39                                     uint32_t packet_sequence_id);
40 
41  private:
42   void TokenizeFtraceEvent(uint32_t cpu,
43                            ClockTracker::ClockId,
44                            TraceBlobView event,
45                            PacketSequenceState* state);
46   void TokenizeFtraceCompactSched(uint32_t cpu,
47                                   ClockTracker::ClockId,
48                                   protozero::ConstBytes);
49   void TokenizeFtraceCompactSchedSwitch(
50       uint32_t cpu,
51       ClockTracker::ClockId,
52       const protos::pbzero::FtraceEventBundle::CompactSched::Decoder& compact,
53       const std::vector<StringId>& string_table);
54   void TokenizeFtraceCompactSchedWaking(
55       uint32_t cpu,
56       ClockTracker::ClockId,
57       const protos::pbzero::FtraceEventBundle::CompactSched::Decoder& compact,
58       const std::vector<StringId>& string_table);
59 
60   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;
65   TraceProcessorContext* context_;
66 };
67 
68 }  // namespace trace_processor
69 }  // namespace perfetto
70 
71 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_FTRACE_TOKENIZER_H_
72