1 /* 2 * Copyright (C) 2018 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_TYPES_TRACE_PROCESSOR_CONTEXT_H_ 18 #define SRC_TRACE_PROCESSOR_TYPES_TRACE_PROCESSOR_CONTEXT_H_ 19 20 #include <memory> 21 #include <vector> 22 23 #include "perfetto/trace_processor/basic_types.h" 24 #include "src/trace_processor/types/destructible.h" 25 26 namespace perfetto { 27 namespace trace_processor { 28 29 class ArgsTracker; 30 class AndroidProbesTracker; 31 class ChunkedTraceReader; 32 class ClockTracker; 33 class EventTracker; 34 class ForwardingTraceParser; 35 class FtraceModule; 36 class GlobalArgsTracker; 37 class HeapGraphTracker; 38 class HeapProfileTracker; 39 class MetadataTracker; 40 class PerfSampleTracker; 41 class ProtoImporterModule; 42 class ProcessTracker; 43 class SliceTracker; 44 class TraceParser; 45 class TraceSorter; 46 class TraceStorage; 47 class TrackTracker; 48 class JsonTracker; 49 50 class TraceProcessorContext { 51 public: 52 TraceProcessorContext(); 53 ~TraceProcessorContext(); 54 55 Config config; 56 57 std::unique_ptr<TraceStorage> storage; 58 59 std::unique_ptr<ChunkedTraceReader> chunk_reader; 60 std::unique_ptr<TraceSorter> sorter; 61 62 // Keep the global tracker before the args tracker as we access the global 63 // tracker in the destructor of the args tracker. Also keep it before other 64 // trackers, as they may own ArgsTrackers themselves. 65 std::unique_ptr<GlobalArgsTracker> global_args_tracker; 66 std::unique_ptr<ArgsTracker> args_tracker; 67 68 std::unique_ptr<TrackTracker> track_tracker; 69 std::unique_ptr<SliceTracker> slice_tracker; 70 std::unique_ptr<ProcessTracker> process_tracker; 71 std::unique_ptr<EventTracker> event_tracker; 72 std::unique_ptr<ClockTracker> clock_tracker; 73 std::unique_ptr<HeapProfileTracker> heap_profile_tracker; 74 std::unique_ptr<MetadataTracker> metadata_tracker; 75 std::unique_ptr<PerfSampleTracker> perf_sample_tracker; 76 77 // These fields are stored as pointers to Destructible objects rather than 78 // their actual type (a subclass of Destructible), as the concrete subclass 79 // type is only available in storage_full target. To access these fields use 80 // the GetOrCreate() method on their subclass type, e.g. 81 // SyscallTracker::GetOrCreate(context) 82 std::unique_ptr<Destructible> android_probes_tracker; // AndroidProbesTracker 83 std::unique_ptr<Destructible> syscall_tracker; // SyscallTracker 84 std::unique_ptr<Destructible> sched_tracker; // SchedEventTracker 85 std::unique_ptr<Destructible> binder_tracker; // BinderTracker 86 std::unique_ptr<Destructible> systrace_parser; // SystraceParser 87 std::unique_ptr<Destructible> heap_graph_tracker; // HeapGraphTracker 88 std::unique_ptr<Destructible> json_tracker; // JsonTracker 89 std::unique_ptr<Destructible> system_info_tracker; // SystemInfoTracker 90 91 // These fields are trace readers which will be called by |forwarding_parser| 92 // once the format of the trace is discovered. They are placed here as they 93 // are only available in the storage_full target. 94 std::unique_ptr<ChunkedTraceReader> json_trace_tokenizer; 95 std::unique_ptr<ChunkedTraceReader> fuchsia_trace_tokenizer; 96 std::unique_ptr<ChunkedTraceReader> systrace_trace_parser; 97 std::unique_ptr<ChunkedTraceReader> gzip_trace_parser; 98 99 // These fields are trace parsers which will be called by |forwarding_parser| 100 // once the format of the trace is discovered. They are placed here as they 101 // are only available in the storage_full target. 102 std::unique_ptr<TraceParser> json_trace_parser; 103 std::unique_ptr<TraceParser> fuchsia_trace_parser; 104 105 // The module at the index N is registered to handle field id N in 106 // TracePacket. 107 std::vector<ProtoImporterModule*> modules_by_field; 108 std::vector<std::unique_ptr<ProtoImporterModule>> modules; 109 FtraceModule* ftrace_module = nullptr; 110 }; 111 112 } // namespace trace_processor 113 } // namespace perfetto 114 115 #endif // SRC_TRACE_PROCESSOR_TYPES_TRACE_PROCESSOR_CONTEXT_H_ 116