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 constexpr int FLAG_SHIFT_LEFT = 63; 28 class PerfDataFilter : private FilterBase { 29 public: 30 PerfDataFilter(TraceDataCache*, const TraceStreamerFilters*); 31 PerfDataFilter(const PerfDataFilter&) = delete; 32 PerfDataFilter& operator=(const PerfDataFilter&) = delete; 33 ~PerfDataFilter() override; 34 35 public: 36 size_t AppendPerfFiles(uint64_t fileId, uint32_t serial, DataIndex symbols, DataIndex filePath); 37 void AppendPerfCallChain(uint32_t callChainId, 38 uint32_t depth, 39 uint64_t ip, 40 uint64_t vaddrInFile, 41 uint64_t fileId, 42 uint64_t symbolId); 43 void Finish(); 44 void BeforeReload(); 45 46 private: 47 DoubleMap<uint64_t, uint32_t, uint64_t> fileIdToRowInFileTable_; 48 std::set<uint64_t> fileIds_; 49 std::map<uint64_t, uint64_t> fileIdToRow_{}; 50 }; 51 } // namespace TraceStreamer 52 } // namespace SysTuning 53 54 #endif // PERF_DATA_FILTER_H 55