1 /* 2 * Copyright (C) 2024 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_PERF_PERF_FILE_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PERF_PERF_FILE_H_ 19 20 #include <cstdint> 21 22 #include "src/trace_processor/importers/perf/perf_event.h" 23 24 namespace perfetto::trace_processor::perf_importer { 25 26 struct PerfFile { 27 static constexpr char kPerfMagic[] = {'P', 'E', 'R', 'F', 'I', 'L', 'E', '2'}; 28 struct Section { 29 uint64_t offset; 30 uint64_t size; endPerfFile::Section31 uint64_t end() const { return offset + size; } 32 }; 33 34 struct AttrsEntry { 35 perf_event_attr attr; 36 Section ids; 37 }; 38 39 struct Header { 40 char magic[8]; 41 uint64_t size; 42 // Size of PerfFileAttr struct and section pointing to ids. 43 uint64_t attr_size; 44 Section attrs; 45 Section data; 46 Section event_types; 47 uint64_t flags; 48 uint64_t flags1[3]; 49 num_attrsPerfFile::Header50 uint64_t num_attrs() const { return attrs.size / attr_size; } 51 }; 52 }; 53 54 } // namespace perfetto::trace_processor::perf_importer 55 56 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PERF_PERF_FILE_H_ 57