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_symbols_detail_parser.h"
16 #include "htrace_event_parser.h"
17 #include "symbols_filter.h"
18 namespace SysTuning {
19 namespace TraceStreamer {
HtraceSymbolsDetailParser(TraceDataCache * dataCache,const TraceStreamerFilters * ctx)20 HtraceSymbolsDetailParser::HtraceSymbolsDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx)
21 : streamFilters_(ctx), traceDataCache_(dataCache)
22 {
23 UNUSED(traceDataCache_);
24 if (!streamFilters_) {
25 TS_LOGF("streamFilters_ should not be null");
26 return;
27 }
28 }
29
30 HtraceSymbolsDetailParser::~HtraceSymbolsDetailParser() = default;
Parse(const TracePluginResult * tracePacket)31 void HtraceSymbolsDetailParser::Parse(const TracePluginResult* tracePacket)
32 {
33 if (!tracePacket->symbols_detail_size()) {
34 return;
35 }
36 for (int i = 0; i < tracePacket->symbols_detail_size(); i++) {
37 auto symbol = const_cast<TracePluginResult*>(tracePacket)->mutable_symbols_detail(i);
38 TS_LOGD("symbol_name:%s, symbol_addr:%lu", symbol->symbol_name().c_str(), symbol->symbol_addr());
39 // symbol
40 streamFilters_->symbolsFilter_->RegisterFunc(symbol->symbol_addr(),
41 traceDataCache_->GetDataIndex(symbol->symbol_name()));
42 }
43 }
44 } // namespace TraceStreamer
45 } // namespace SysTuning
46