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 ArgsTranslationTable; 31 class AsyncTrackSetTracker; 32 class AndroidProbesTracker; 33 class ChunkedTraceReader; 34 class ClockTracker; 35 class EventTracker; 36 class ForwardingTraceParser; 37 class FtraceModule; 38 class GlobalArgsTracker; 39 class GlobalStackProfileTracker; 40 class HeapGraphTracker; 41 class HeapProfileTracker; 42 class PerfSampleTracker; 43 class MetadataTracker; 44 class ProtoImporterModule; 45 class ProcessTracker; 46 class SliceTracker; 47 class SliceTranslationTable; 48 class FlowTracker; 49 class TraceParser; 50 class TraceSorter; 51 class TraceStorage; 52 class TrackTracker; 53 class DescriptorPool; 54 55 class TraceProcessorContext { 56 public: 57 TraceProcessorContext(); 58 ~TraceProcessorContext(); 59 60 Config config; 61 62 std::unique_ptr<TraceStorage> storage; 63 64 std::unique_ptr<ChunkedTraceReader> chunk_reader; 65 std::unique_ptr<TraceSorter> sorter; 66 67 // Keep the global tracker before the args tracker as we access the global 68 // tracker in the destructor of the args tracker. Also keep it before other 69 // trackers, as they may own ArgsTrackers themselves. 70 std::unique_ptr<GlobalArgsTracker> global_args_tracker; 71 std::unique_ptr<ArgsTracker> args_tracker; 72 std::unique_ptr<ArgsTranslationTable> args_translation_table; 73 74 std::unique_ptr<TrackTracker> track_tracker; 75 std::unique_ptr<AsyncTrackSetTracker> async_track_set_tracker; 76 std::unique_ptr<SliceTracker> slice_tracker; 77 std::unique_ptr<SliceTranslationTable> slice_translation_table; 78 std::unique_ptr<FlowTracker> flow_tracker; 79 std::unique_ptr<ProcessTracker> process_tracker; 80 std::unique_ptr<EventTracker> event_tracker; 81 std::unique_ptr<ClockTracker> clock_tracker; 82 std::unique_ptr<HeapProfileTracker> heap_profile_tracker; 83 std::unique_ptr<PerfSampleTracker> perf_sample_tracker; 84 std::unique_ptr<GlobalStackProfileTracker> global_stack_profile_tracker; 85 std::unique_ptr<MetadataTracker> metadata_tracker; 86 87 // These fields are stored as pointers to Destructible objects rather than 88 // their actual type (a subclass of Destructible), as the concrete subclass 89 // type is only available in storage_full target. To access these fields use 90 // the GetOrCreate() method on their subclass type, e.g. 91 // SyscallTracker::GetOrCreate(context) 92 std::unique_ptr<Destructible> android_probes_tracker; // AndroidProbesTracker 93 std::unique_ptr<Destructible> syscall_tracker; // SyscallTracker 94 std::unique_ptr<Destructible> sched_tracker; // SchedEventTracker 95 std::unique_ptr<Destructible> binder_tracker; // BinderTracker 96 std::unique_ptr<Destructible> systrace_parser; // SystraceParser 97 std::unique_ptr<Destructible> heap_graph_tracker; // HeapGraphTracker 98 std::unique_ptr<Destructible> system_info_tracker; // SystemInfoTracker 99 100 // These fields are trace readers which will be called by |forwarding_parser| 101 // once the format of the trace is discovered. They are placed here as they 102 // are only available in the storage_full target. 103 std::unique_ptr<ChunkedTraceReader> json_trace_tokenizer; 104 std::unique_ptr<ChunkedTraceReader> fuchsia_trace_tokenizer; 105 std::unique_ptr<ChunkedTraceReader> systrace_trace_parser; 106 std::unique_ptr<ChunkedTraceReader> gzip_trace_parser; 107 108 // These fields are trace parsers which will be called by |forwarding_parser| 109 // once the format of the trace is discovered. They are placed here as they 110 // are only available in the storage_full target. 111 std::unique_ptr<TraceParser> json_trace_parser; 112 std::unique_ptr<TraceParser> fuchsia_trace_parser; 113 114 // This field contains the list of proto descriptors that can be used by 115 // reflection-based parsers. 116 std::unique_ptr<DescriptorPool> descriptor_pool_; 117 118 // The module at the index N is registered to handle field id N in 119 // TracePacket. 120 std::vector<std::vector<ProtoImporterModule*>> modules_by_field; 121 std::vector<std::unique_ptr<ProtoImporterModule>> modules; 122 FtraceModule* ftrace_module = nullptr; 123 124 // Marks whether the uuid was read from the trace. 125 // If the uuid was NOT read, the uuid will be made from the hash of the first 126 // 4KB of the trace. 127 bool uuid_found_in_trace = false; 128 }; 129 130 } // namespace trace_processor 131 } // namespace perfetto 132 133 #endif // SRC_TRACE_PROCESSOR_TYPES_TRACE_PROCESSOR_CONTEXT_H_ 134