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_ARM64_DEFINE_H 16 #define UNWIND_ARM64_DEFINE_H 17 18 #include <cinttypes> 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace HiviewDFX { 24 #define REGS_PRINT_LEN 1024 25 #define DWARF_PRESERVED_REGS_NUM 97 26 27 enum RegsEnumArm64 : uint16_t { 28 REG_AARCH64_X0 = 0, 29 REG_AARCH64_X1, 30 REG_AARCH64_X2, 31 REG_AARCH64_X3, 32 REG_AARCH64_X4, 33 REG_AARCH64_X5, 34 REG_AARCH64_X6, 35 REG_AARCH64_X7, 36 REG_AARCH64_X8, 37 REG_AARCH64_X9, 38 REG_AARCH64_X10, 39 REG_AARCH64_X11, 40 REG_AARCH64_X12, 41 REG_AARCH64_X13, 42 REG_AARCH64_X14, 43 REG_AARCH64_X15, 44 REG_AARCH64_X16, 45 REG_AARCH64_X17, 46 REG_AARCH64_X18, 47 REG_AARCH64_X19, 48 REG_AARCH64_X20, 49 REG_AARCH64_X21, 50 REG_AARCH64_X22, 51 REG_AARCH64_X23, 52 REG_AARCH64_X24, 53 REG_AARCH64_X25, 54 REG_AARCH64_X26, 55 REG_AARCH64_X27, 56 REG_AARCH64_X28, 57 REG_AARCH64_X29, 58 REG_AARCH64_X30, 59 REG_AARCH64_X31, 60 REG_AARCH64_PC, 61 REG_AARCH64_LAST, 62 63 REG_SP = REG_AARCH64_X31, 64 REG_LR = REG_AARCH64_X30, 65 REG_FP = REG_AARCH64_X29, 66 REG_PC = REG_AARCH64_PC, 67 REG_EH = REG_AARCH64_X0, 68 REG_LAST = REG_AARCH64_LAST, 69 }; 70 71 static const std::vector<uint16_t> QUT_REGS { 72 REG_AARCH64_X0, 73 REG_AARCH64_X29, 74 REG_SP, 75 REG_PC, 76 REG_LR, 77 }; 78 79 struct RegsUserArm64 { 80 uint64_t regs[31]; // 31 81 uint64_t sp; 82 uint64_t pc; 83 uint64_t pstate; 84 }; 85 86 typedef struct UnwindUContext { 87 RegsUserArm64 userRegs; 88 } UnwindUContext_t; 89 } // namespace HiviewDFX 90 } // namespace OHOS 91 #endif 92