• 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  #ifndef HTRACE_NATIVE_HOOK_PARSER_H
16  #define HTRACE_NATIVE_HOOK_PARSER_H
17  #include <cstdint>
18  #include <map>
19  #include <set>
20  #include <string>
21  #include "common_types.h"
22  #include "event_parser_base.h"
23  #include "htrace_event_parser.h"
24  #include "htrace_plugin_time_parser.h"
25  #include "native_hook_filter.h"
26  #include "offline_symbolization_filter.h"
27  #include "trace_streamer_config.h"
28  #include "trace_streamer_filters.h"
29  namespace SysTuning {
30  namespace TraceStreamer {
31  class HtraceNativeHookParser : public EventParserBase, public HtracePluginTimeParser {
32  public:
33      HtraceNativeHookParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx);
34      ~HtraceNativeHookParser();
35      void ParseConfigInfo(HtraceDataSegment& dataSeg);
36      void Parse(HtraceDataSegment& dataSeg, bool& haveSplitSeg);
37      void FinishSplitNativeHook();
38      void FinishParseNativeHookData();
39      void Finish();
NativeHookReloadElfSymbolTable(const std::vector<std::unique_ptr<SymbolsFile>> & symbolsFile)40      bool NativeHookReloadElfSymbolTable(const std::vector<std::unique_ptr<SymbolsFile>>& symbolsFile)
41      {
42          return nativeHookFilter_->NativeHookReloadElfSymbolTable(symbolsFile);
43      }
44  
45  private:
46      void ParseNativeHookAuxiliaryEvent(std::unique_ptr<NativeHookMetaData>& nativeHookMetaData);
47      void ParseFileEvent(const ProtoReader::BytesView& bytesView);
48      void ParseSymbolEvent(const ProtoReader::BytesView& bytesView);
49      void ParseThreadEvent(const ProtoReader::BytesView& bytesView);
50      void ParseFrameMap(std::unique_ptr<NativeHookMetaData>& nativeHookMetaData);
51      bool ParseStackMap(const ProtoReader::BytesView& bytesView);
52      void SplitHookData(std::unique_ptr<NativeHookMetaData>& nativeHookMetaData, bool& haveSplitSeg);
53  
54  private:
55      std::vector<std::shared_ptr<const std::string>> segs_ = {};
56      std::unique_ptr<NativeHookFilter> nativeHookFilter_;
57      uint64_t hookBootTime_ = 0;
58      bool isCommData_ = false;
59  };
60  } // namespace TraceStreamer
61  } // namespace SysTuning
62  
63  #endif // HTRACE_NATIVE_HOOK_PARSER_H
64