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 #include "src/trace_processor/importers/perf/itrace_start_record.h" 18 19 #include "src/trace_processor/importers/perf/reader.h" 20 21 namespace perfetto::trace_processor::perf_importer { 22 Parse(const Record & record)23base::Status ItraceStartRecord::Parse(const Record& record) { 24 attr = record.attr; 25 Reader reader(record.payload.copy()); 26 27 if (!reader.Read(pid) || !reader.Read(tid)) { 28 return base::ErrStatus("Failed to parse PERF_RECORD_ITRACE_START"); 29 } 30 31 if (!record.has_trailing_sample_id()) { 32 sample_id.reset(); 33 return base::OkStatus(); 34 } 35 36 sample_id.emplace(); 37 return sample_id->ParseFromRecord(record); 38 } 39 40 } // namespace perfetto::trace_processor::perf_importer 41