1 /* 2 * Copyright (c) 2023-2024 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 DFX_ERRORS_H 16 #define DFX_ERRORS_H 17 18 #include <cinttypes> 19 20 namespace OHOS { 21 namespace HiviewDFX { 22 /** 23 * @brief Unwind error code 24 */ 25 enum UnwindErrorCode : uint16_t { 26 /** No error */ 27 UNW_ERROR_NONE = 0, 28 /** No unwind info */ 29 UNW_ERROR_NO_UNWIND_INFO, 30 /** Pc Not in unwind info */ 31 UNW_ERROR_PC_NOT_IN_UNWIND_INFO, 32 /** Invalid unwind context */ 33 UNW_ERROR_INVALID_CONTEXT, 34 /** Invalid unwind memory */ 35 UNW_ERROR_INVALID_MEMORY, 36 /** Invalid unwind regs */ 37 UNW_ERROR_INVALID_REGS, 38 /** Invalid unwind map */ 39 UNW_ERROR_INVALID_MAP, 40 /** Invalid unwind elf */ 41 UNW_ERROR_INVALID_ELF, 42 /** Invalid unwind pid */ 43 UNW_ERROR_INVALID_PID, 44 /** Reserved value */ 45 UNW_ERROR_RESERVED_VALUE, 46 /** Illegal value */ 47 UNW_ERROR_ILLEGAL_VALUE, 48 /** Illegal state */ 49 UNW_ERROR_ILLEGAL_STATE, 50 /** unreadable sp */ 51 UNW_ERROR_UNREADABLE_SP, 52 /** The last frame has the same pc/sp as the next frame */ 53 UNW_ERROR_REPEATED_FRAME, 54 /** The last return address has the same */ 55 UNW_ERROR_RETURN_ADDRESS_SAME, 56 /** The last return address undefined */ 57 UNW_ERROR_RETURN_ADDRESS_UNDEFINED, 58 /** The number of frames exceed the total allowed */ 59 UNW_ERROR_MAX_FRAMES_EXCEEDED, 60 /** arm exidx invalid alignment */ 61 UNW_ERROR_INVALID_ALIGNMENT, 62 /** arm exidx invalid personality */ 63 UNW_ERROR_INVALID_PERSONALITY, 64 /** arm exidx cant unwind */ 65 UNW_ERROR_CANT_UNWIND, 66 /** arm exidx spare */ 67 UNW_ERROR_ARM_EXIDX_SPARE, 68 /** arm exidx finish */ 69 UNW_ERROR_ARM_EXIDX_FINISH, 70 /** Dwarf cfa invalid */ 71 UNW_ERROR_DWARF_INVALID_CFA, 72 /** Dwarf fde invalid */ 73 UNW_ERROR_DWARF_INVALID_FDE, 74 /** Dwarf instr invalid */ 75 UNW_ERROR_DWARF_INVALID_INSTR, 76 /** step ark frame error */ 77 UNW_ERROR_STEP_ARK_FRAME, 78 /** Unknown ark map */ 79 UNW_ERROR_UNKNOWN_ARK_MAP, 80 /** Unsupported qut reg */ 81 UNW_ERROR_UNSUPPORTED_QUT_REG, 82 /** Unsupported version */ 83 UNW_ERROR_UNSUPPORTED_VERSION, 84 /** Not support */ 85 UNW_ERROR_NOT_SUPPORT, 86 }; 87 88 /** 89 * @brief Unwind error data 90 */ 91 class UnwindErrorData { 92 public: GetCode()93 uint16_t GetCode() const { return code_; } GetAddr()94 uint64_t GetAddr() const { return addr_; } 95 SetAddrAndCode(uintptr_t addr,uint16_t code)96 void SetAddrAndCode(uintptr_t addr, uint16_t code) 97 { 98 addr_ = addr; 99 code_ = code; 100 } 101 SetCode(uint16_t code)102 void SetCode(uint16_t code) 103 { 104 code_ = code; 105 } 106 SetAddr(uintptr_t addr)107 void SetAddr(uintptr_t addr) 108 { 109 addr_ = addr; 110 } 111 private: 112 uint16_t code_ = 0; 113 uintptr_t addr_ = 0; 114 }; 115 } // namespace HiviewDFX 116 } // namespace OHOS 117 #endif 118