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 #include "src/traced/probes/ftrace/ftrace_stats.h" 18 19 #include "protos/perfetto/trace/ftrace/ftrace_stats.pbzero.h" 20 21 namespace perfetto { 22 Write(protos::pbzero::FtraceStats * writer) const23void FtraceStats::Write(protos::pbzero::FtraceStats* writer) const { 24 for (const FtraceCpuStats& cpu_specific_stats : cpu_stats) { 25 cpu_specific_stats.Write(writer->add_cpu_stats()); 26 } 27 writer->set_kernel_symbols_parsed(kernel_symbols_parsed); 28 writer->set_kernel_symbols_mem_kb(kernel_symbols_mem_kb); 29 if (!setup_errors.atrace_errors.empty()) 30 writer->set_atrace_errors(setup_errors.atrace_errors); 31 for (const std::string& err : setup_errors.unknown_ftrace_events) 32 writer->add_unknown_ftrace_events(err); 33 for (const std::string& err : setup_errors.failed_ftrace_events) 34 writer->add_failed_ftrace_events(err); 35 36 if (kprobe_stats.hits || kprobe_stats.misses) { 37 auto* kprobe_stats_pb = writer->set_kprobe_stats(); 38 kprobe_stats_pb->set_hits(kprobe_stats.hits); 39 kprobe_stats_pb->set_misses(kprobe_stats.misses); 40 } 41 } 42 Write(protos::pbzero::FtraceCpuStats * writer) const43void FtraceCpuStats::Write(protos::pbzero::FtraceCpuStats* writer) const { 44 writer->set_cpu(cpu); 45 writer->set_entries(entries); 46 writer->set_overrun(overrun); 47 writer->set_commit_overrun(commit_overrun); 48 writer->set_bytes_read(bytes); 49 writer->set_oldest_event_ts(oldest_event_ts); 50 writer->set_now_ts(now_ts); 51 writer->set_dropped_events(dropped_events); 52 writer->set_read_events(read_events); 53 } 54 55 } // namespace perfetto 56