• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 UNWIND_ENTRY_PARSER_H
16 #define UNWIND_ENTRY_PARSER_H
17 
18 #include <cinttypes>
19 #include <memory>
20 #include <securec.h>
21 
22 #include "dfx_memory.h"
23 #include "unwind_context.h"
24 
25 namespace OHOS {
26 namespace HiviewDFX {
27 class UnwindEntryParser {
28 public:
UnwindEntryParser(const std::shared_ptr<DfxMemory> & memory)29     explicit UnwindEntryParser(const std::shared_ptr<DfxMemory>& memory) : memory_(memory) {}
30     virtual ~UnwindEntryParser() = default;
31     virtual bool Step(uintptr_t pc, const UnwindTableInfo& uti, std::shared_ptr<RegLocState> rs) = 0;
GetLastErrorCode()32     uint16_t GetLastErrorCode() { return lastErrorData_.GetCode(); }
GetLastErrorAddr()33     uint64_t GetLastErrorAddr() { return lastErrorData_.GetAddr(); }
34 protected:
35     virtual bool SearchEntry(uintptr_t pc, const UnwindTableInfo& uti, UnwindEntryInfo& uei) = 0;
36     UnwindErrorData lastErrorData_ {};
37     std::shared_ptr<DfxMemory> memory_ = nullptr;
38 };
39 } // nameapace HiviewDFX
40 } // nameapace OHOS
41 #endif
42