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_INSTRUMENTS_ROW_PARSER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_INSTRUMENTS_ROW_PARSER_H_ 19 20 #include "perfetto/ext/base/flat_hash_map.h" 21 #include "src/trace_processor/importers/common/trace_parser.h" 22 #include "src/trace_processor/importers/common/virtual_memory_mapping.h" 23 #include "src/trace_processor/importers/instruments/row.h" 24 #include "src/trace_processor/storage/trace_storage.h" 25 #include "src/trace_processor/types/trace_processor_context.h" 26 27 namespace perfetto::trace_processor::instruments_importer { 28 29 class RowDataTracker; 30 31 class RowParser : public InstrumentsRowParser { 32 public: 33 explicit RowParser(TraceProcessorContext*); 34 ~RowParser() override = default; 35 36 void ParseInstrumentsRow(int64_t, instruments_importer::Row) override; 37 38 private: 39 DummyMemoryMapping* GetDummyMapping(UniquePid upid); 40 41 TraceProcessorContext* context_; 42 RowDataTracker& data_; 43 44 // Cache FrameId and binary mappings by instruments frame and binary 45 // pointers, respectively. These are already de-duplicated in the 46 // instruments XML parsing. 47 base::FlatHashMap<BacktraceFrameId, FrameId> frame_to_frame_id_; 48 base::FlatHashMap<BinaryId, VirtualMemoryMapping*> binary_to_mapping_; 49 base::FlatHashMap<UniquePid, DummyMemoryMapping*> dummy_mappings_; 50 }; 51 52 } // namespace perfetto::trace_processor::instruments_importer 53 54 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_INSTRUMENTS_ROW_PARSER_H_ 55