1 /* 2 * Copyright (c) 2023 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_DEFINE_H 16 #define UNWIND_DEFINE_H 17 18 #include <cinttypes> 19 #include <string> 20 #include <unistd.h> 21 #if defined(__arm__) 22 #include "unwind_arm_define.h" 23 #elif defined(__aarch64__) 24 #include "unwind_arm64_define.h" 25 #elif defined(__riscv) && __riscv_xlen == 64 26 #include "unwind_riscv64_define.h" 27 #elif defined(__x86_64__) 28 #include "unwind_x86_64_define.h" 29 #else 30 #error "Unsupported architecture" 31 #endif 32 33 namespace OHOS { 34 namespace HiviewDFX { 35 #define FP_MINI_REGS_SIZE 4 36 #define QUT_MINI_REGS_SIZE 7 37 38 #define ARM_EXIDX_TABLE_SIZE 8 39 40 static const int FRAME_MAX_SIZE = 64; 41 42 /** 43 * @brief chip architecture 44 */ 45 enum ArchType : uint8_t { 46 ARCH_UNKNOWN = 0, 47 ARCH_ARM, 48 ARCH_ARM64, 49 ARCH_RISCV64, 50 ARCH_X86, 51 ARCH_X86_64, 52 }; 53 54 enum UnwindType : int8_t { 55 UNWIND_TYPE_CUSTOMIZE = -2, 56 UNWIND_TYPE_LOCAL = -1, 57 UNWIND_TYPE_REMOTE, 58 }; 59 60 enum UnwindDynInfoFormatType { 61 UNW_INFO_FORMAT_TABLE, /* unw_dyn_table_t */ 62 UNW_INFO_FORMAT_REMOTE_TABLE, /* unw_dyn_remote_table_t */ 63 UNW_INFO_FORMAT_ARM_EXIDX, /* ARM specific unwind info */ 64 }; 65 66 /** 67 * @brief Unwind regs type 68 */ 69 enum UnwindRegsType { 70 /** Dwarf */ 71 REGS_TYPE_DWARF = 0, 72 /** Qut */ 73 REGS_TYPE_QUT, 74 }; 75 76 /** 77 * @brief Unwind mode 78 */ 79 enum UnwindMode { 80 /** Dwarf unwind */ 81 DWARF_UNWIND = 0, 82 /** Frame pointer unwind */ 83 FRAMEPOINTER_UNWIND, 84 /** Quick unwind table */ 85 MINIMAL_UNWIND, 86 /** Mix unwind table */ 87 MIX_UNWIND, 88 }; 89 90 /** 91 * @brief Unwind cache mode 92 */ 93 enum UnwindCachingPolicy : uint8_t { 94 /** unwind no cache */ 95 UNWIND_CACHE_NONE = 0, 96 /** unwind global cache */ 97 UNWIND_CACHE_GLOBAL, 98 /** unwind per-thread cache */ 99 UNWIND_CACHE_PER_THREAD, 100 }; 101 } // namespace HiviewDFX 102 } // namespace OHOS 103 #endif 104