1 /* 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 <cstddef> 21 #include <cstdint> 22 #include <vector> 23 24 #include "perfetto/protozero/field.h" 25 #include "src/trace_processor/storage/trace_storage.h" 26 27 namespace perfetto::trace_processor { 28 29 class TraceProcessorContext; 30 31 class SystemProbesParser { 32 public: 33 using ConstBytes = protozero::ConstBytes; 34 using ConstChars = protozero::ConstChars; 35 36 explicit SystemProbesParser(TraceProcessorContext*); 37 38 void ParseProcessTree(ConstBytes); 39 void ParseProcessStats(int64_t ts, ConstBytes); 40 void ParseSysStats(int64_t ts, ConstBytes); 41 void ParseSystemInfo(ConstBytes); 42 void ParseCpuInfo(ConstBytes); 43 44 private: 45 void ParseThreadStats(int64_t timestamp, uint32_t pid, ConstBytes); 46 void ParseDiskStats(int64_t ts, ConstBytes blob); 47 void ParseProcessFds(int64_t ts, uint32_t pid, ConstBytes); 48 void ParseCpuIdleStats(int64_t ts, ConstBytes); 49 50 TraceProcessorContext* const context_; 51 52 const StringId utid_name_id_; 53 54 // Arm CPU identifier string IDs 55 const StringId arm_cpu_implementer; 56 const StringId arm_cpu_architecture; 57 const StringId arm_cpu_variant; 58 const StringId arm_cpu_part; 59 const StringId arm_cpu_revision; 60 61 std::vector<const char*> meminfo_strs_; 62 std::vector<const char*> vmstat_strs_; 63 64 uint32_t page_size_ = 0; 65 66 int64_t prev_read_amount = -1; 67 int64_t prev_write_amount = -1; 68 int64_t prev_discard_amount = -1; 69 int64_t prev_flush_count = -1; 70 int64_t prev_read_time = -1; 71 int64_t prev_write_time = -1; 72 int64_t prev_discard_time = -1; 73 int64_t prev_flush_time = -1; 74 }; 75 76 } // namespace perfetto::trace_processor 77 78 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_SYSTEM_PROBES_PARSER_H_ 79