1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 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 PBREADER_FFRT_PARSER_H 17 #define PBREADER_FFRT_PARSER_H 18 19 #include "common_types.h" 20 #include "double_map.h" 21 #include "ffrt_profiler_result.pbreader.h" 22 #include "event_parser_base.h" 23 #include "htrace_event_parser.h" 24 25 namespace SysTuning { 26 namespace TraceStreamer { 27 class PbreaderFfrtDetailParser : public EventParserBase { 28 public: 29 PbreaderFfrtDetailParser(TraceDataCache *dataCache, 30 const TraceStreamerFilters *ctx, 31 HtraceEventParser *eventParser); 32 ~PbreaderFfrtDetailParser(); 33 void Parser(const PbreaderDataSegment &dataSeg, bool &haveSplitSeg); 34 void SetFfrtSrcClockid(PbreaderDataSegment &dataSeg); 35 void FilterAllEventsReader(); 36 37 private: 38 void PaserCommData(bool &haveSplitSeg, std::unique_ptr<ProtoReader::FfrtProfilerEvent_Reader> &ffrtEventPtr); 39 void ParserFfrtTrace(const PbreaderDataSegment &dataSeg, 40 bool &haveSplitSeg, 41 std::unique_ptr<ProtoReader::FfrtProfilerEvent_Reader> &ffrtEventPtr); 42 43 private: 44 HtraceEventParser *eventParser_; 45 ClockId ffrtClockid_ = TS_CLOCK_UNKNOW; 46 // tid, pid, taskname 47 DoubleMap<int32_t, int32_t, DataIndex> taskNameIndexMap_; 48 }; 49 } // namespace TraceStreamer 50 } // namespace SysTuning 51 #endif // PBREADER_FFRT_PARSER_H 52