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