• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "htrace_symbols_detail_parser.h"
16 namespace SysTuning {
17 namespace TraceStreamer {
HtraceSymbolsDetailParser(TraceDataCache * dataCache,const TraceStreamerFilters * ctx)18 HtraceSymbolsDetailParser::HtraceSymbolsDetailParser(TraceDataCache *dataCache, const TraceStreamerFilters *ctx)
19     : streamFilters_(ctx), traceDataCache_(dataCache)
20 {
21     Unused(traceDataCache_);
22     if (!streamFilters_) {
23         TS_LOGF("streamFilters_ should not be null");
24         return;
25     }
26 }
27 
28 HtraceSymbolsDetailParser::~HtraceSymbolsDetailParser() = default;
Parse(ProtoReader::BytesView tracePacket)29 void HtraceSymbolsDetailParser::Parse(ProtoReader::BytesView tracePacket)
30 {
31     if (traceDataCache_->isSplitFile_) {
32         return;
33     }
34     ProtoReader::TracePluginResult_Reader reader((const uint8_t *)(tracePacket.data_), tracePacket.size_);
35     if (!reader.has_symbols_detail()) {
36         return;
37     }
38     for (auto i = reader.symbols_detail(); i; ++i) {
39         ProtoReader::SymbolsDetailMsg_Reader reader(i->ToBytes());
40         traceDataCache_->GetSymbolsData()->UpdateSymbol(
41             reader.symbol_addr(), traceDataCache_->GetDataIndex(reader.symbol_name().ToStdString()));
42     }
43 }
44 } // namespace TraceStreamer
45 } // namespace SysTuning
46