• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "htrace_cpu_detail_parser.h"
16 #include "htrace_event_parser.h"
17 #include "stat_filter.h"
18 namespace SysTuning {
19 namespace TraceStreamer {
HtraceCpuDetailParser(TraceDataCache * dataCache,const TraceStreamerFilters * ctx)20 HtraceCpuDetailParser::HtraceCpuDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx)
21     : eventParser_(std::make_unique<HtraceEventParser>(dataCache, ctx))
22 {
23 }
24 
25 HtraceCpuDetailParser::~HtraceCpuDetailParser() = default;
Parse(TracePluginResult * tracePacket,BuiltinClocks clock)26 void HtraceCpuDetailParser::Parse(TracePluginResult* tracePacket, BuiltinClocks clock)
27 {
28     if (!tracePacket->ftrace_cpu_detail_size()) {
29         return;
30     }
31 
32     for (int i = 0; i < tracePacket->ftrace_cpu_detail_size(); i++) {
33         FtraceCpuDetailMsg* cpuDetail = tracePacket->mutable_ftrace_cpu_detail(i);
34         eventParser_->ParseDataItem(cpuDetail, clock);
35     }
36 }
FilterAllEvents()37 void HtraceCpuDetailParser::FilterAllEvents()
38 {
39     eventParser_->FilterAllEvents();
40     eventParser_->Clear();
41 }
42 } // namespace TraceStreamer
43 } // namespace SysTuning
44