blob: 8dcd8109d9f68b7d382bdacd41d6df7caa0a7147 [file] [log] [blame]
Eric Secklerab0604c2019-10-25 10:12:07 +01001/*
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_PROTO_SYSTEM_PROBES_PARSER_H_
18#define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_SYSTEM_PROBES_PARSER_H_
19
20#include <vector>
21
22#include "perfetto/protozero/field.h"
23#include "src/trace_processor/trace_storage.h"
24
25namespace perfetto {
26namespace trace_processor {
27
28class TraceProcessorContext;
29
Eric Seckler5fbcf6d2019-10-28 15:09:10 +000030class SystemProbesParser {
Eric Secklerab0604c2019-10-25 10:12:07 +010031 public:
32 using ConstBytes = protozero::ConstBytes;
33
Eric Seckler5fbcf6d2019-10-28 15:09:10 +000034 explicit SystemProbesParser(TraceProcessorContext*);
Eric Secklerab0604c2019-10-25 10:12:07 +010035
36 void ParseProcessTree(ConstBytes);
37 void ParseProcessStats(int64_t timestamp, ConstBytes);
38 void ParseSysStats(int64_t ts, ConstBytes);
39 void ParseSystemInfo(ConstBytes);
40
41 private:
42 TraceProcessorContext* const context_;
43
44 const StringId utid_name_id_;
45 const StringId num_forks_name_id_;
46 const StringId num_irq_total_name_id_;
47 const StringId num_softirq_total_name_id_;
48 const StringId num_irq_name_id_;
49 const StringId num_softirq_name_id_;
50 const StringId cpu_times_user_ns_id_;
51 const StringId cpu_times_user_nice_ns_id_;
52 const StringId cpu_times_system_mode_ns_id_;
53 const StringId cpu_times_idle_ns_id_;
54 const StringId cpu_times_io_wait_ns_id_;
55 const StringId cpu_times_irq_ns_id_;
56 const StringId cpu_times_softirq_ns_id_;
57 const StringId oom_score_adj_id_;
58 std::vector<StringId> meminfo_strs_id_;
59 std::vector<StringId> vmstat_strs_id_;
60
61 // Maps a proto field number for memcounters in ProcessStats::Process to
62 // their StringId. Keep kProcStatsProcessSize equal to 1 + max proto field
63 // id of ProcessStats::Process.
64 static constexpr size_t kProcStatsProcessSize = 11;
65 std::array<StringId, kProcStatsProcessSize> proc_stats_process_names_{};
66};
67} // namespace trace_processor
68} // namespace perfetto
69
70#endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_SYSTEM_PROBES_PARSER_H_