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