1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PERF_DATA_FILTER_H 17 #define PERF_DATA_FILTER_H 18 #include <map> 19 #include <set> 20 #include <unordered_set> 21 #include "double_map.h" 22 #include "filter_base.h" 23 #include "trace_data_cache.h" 24 #include "trace_streamer_filters.h" 25 namespace SysTuning { 26 namespace TraceStreamer { 27 class PerfDataFilter : private FilterBase { 28 public: 29 PerfDataFilter(TraceDataCache*, const TraceStreamerFilters*); 30 PerfDataFilter(const PerfDataFilter&) = delete; 31 PerfDataFilter& operator=(const PerfDataFilter&) = delete; 32 ~PerfDataFilter() override; 33 34 public: 35 size_t AppendPerfFiles(uint64_t fileId, uint32_t serial, DataIndex symbols, DataIndex filePath); 36 size_t AppendPerfCallChain(uint64_t sampleId, 37 uint64_t callChainId, 38 uint64_t vaddrInFile, 39 uint64_t fileId, 40 uint64_t symbolId); 41 void Finish(); 42 43 private: 44 DoubleMap<uint64_t, uint32_t, uint64_t> fileIdToRowInFileTable_; 45 DoubleMap<uint64_t, uint64_t, uint64_t> fileIdToRowInChainTable_; 46 std::set<uint64_t> fileIds_; 47 std::map<uint64_t, uint64_t> fileIdToRow_{}; 48 }; 49 } // namespace TraceStreamer 50 } // namespace SysTuning 51 52 #endif // PERF_DATA_FILTER_H 53