aboutsummaryrefslogtreecommitdiff
path: root/src/trace_processor/types/trace_processor_context.h
blob: 2f188ada5d1f645f5dd2f50028d7daf5376531a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SRC_TRACE_PROCESSOR_TYPES_TRACE_PROCESSOR_CONTEXT_H_
#define SRC_TRACE_PROCESSOR_TYPES_TRACE_PROCESSOR_CONTEXT_H_

#include <memory>
#include <vector>

#include "perfetto/trace_processor/basic_types.h"
#include "src/trace_processor/types/destructible.h"

namespace perfetto {
namespace trace_processor {

class ArgsTracker;
class AndroidProbesTracker;
class ChunkedTraceReader;
class ClockTracker;
class EventTracker;
class ForwardingTraceParser;
class FtraceModule;
class GlobalArgsTracker;
class HeapGraphTracker;
class HeapProfileTracker;
class MetadataTracker;
class PerfSampleTracker;
class ProtoImporterModule;
class ProcessTracker;
class SliceTracker;
class TraceParser;
class TraceSorter;
class TraceStorage;
class TrackTracker;
class JsonTracker;

class TraceProcessorContext {
 public:
  TraceProcessorContext();
  ~TraceProcessorContext();

  Config config;

  std::unique_ptr<TraceStorage> storage;

  std::unique_ptr<ChunkedTraceReader> chunk_reader;
  std::unique_ptr<TraceSorter> sorter;

  // Keep the global tracker before the args tracker as we access the global
  // tracker in the destructor of the args tracker. Also keep it before other
  // trackers, as they may own ArgsTrackers themselves.
  std::unique_ptr<GlobalArgsTracker> global_args_tracker;
  std::unique_ptr<ArgsTracker> args_tracker;

  std::unique_ptr<TrackTracker> track_tracker;
  std::unique_ptr<SliceTracker> slice_tracker;
  std::unique_ptr<ProcessTracker> process_tracker;
  std::unique_ptr<EventTracker> event_tracker;
  std::unique_ptr<ClockTracker> clock_tracker;
  std::unique_ptr<HeapProfileTracker> heap_profile_tracker;
  std::unique_ptr<MetadataTracker> metadata_tracker;
  std::unique_ptr<PerfSampleTracker> perf_sample_tracker;

  // These fields are stored as pointers to Destructible objects rather than
  // their actual type (a subclass of Destructible), as the concrete subclass
  // type is only available in storage_full target. To access these fields use
  // the GetOrCreate() method on their subclass type, e.g.
  // SyscallTracker::GetOrCreate(context)
  std::unique_ptr<Destructible> android_probes_tracker;  // AndroidProbesTracker
  std::unique_ptr<Destructible> syscall_tracker;         // SyscallTracker
  std::unique_ptr<Destructible> sched_tracker;           // SchedEventTracker
  std::unique_ptr<Destructible> binder_tracker;          // BinderTracker
  std::unique_ptr<Destructible> systrace_parser;         // SystraceParser
  std::unique_ptr<Destructible> heap_graph_tracker;      // HeapGraphTracker
  std::unique_ptr<Destructible> json_tracker;            // JsonTracker
  std::unique_ptr<Destructible> system_info_tracker;     // SystemInfoTracker

  // These fields are trace readers which will be called by |forwarding_parser|
  // once the format of the trace is discovered. They are placed here as they
  // are only available in the storage_full target.
  std::unique_ptr<ChunkedTraceReader> json_trace_tokenizer;
  std::unique_ptr<ChunkedTraceReader> fuchsia_trace_tokenizer;
  std::unique_ptr<ChunkedTraceReader> systrace_trace_parser;
  std::unique_ptr<ChunkedTraceReader> gzip_trace_parser;

  // These fields are trace parsers which will be called by |forwarding_parser|
  // once the format of the trace is discovered. They are placed here as they
  // are only available in the storage_full target.
  std::unique_ptr<TraceParser> json_trace_parser;
  std::unique_ptr<TraceParser> fuchsia_trace_parser;

  // The module at the index N is registered to handle field id N in
  // TracePacket.
  std::vector<ProtoImporterModule*> modules_by_field;
  std::vector<std::unique_ptr<ProtoImporterModule>> modules;
  FtraceModule* ftrace_module = nullptr;
};

}  // namespace trace_processor
}  // namespace perfetto

#endif  // SRC_TRACE_PROCESSOR_TYPES_TRACE_PROCESSOR_CONTEXT_H_