1 /* 2 * Copyright 2024 Institute of Software, Chinese Academy of Sciences. 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_LOONGARCH64_DEFINE_H 16 #define UNWIND_LOONGARCH64_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 RegsEnumLoongArch64 : uint16_t { 28 REG_LOONGARCH64_R0 = 0, 29 REG_LOONGARCH64_R1, 30 REG_LOONGARCH64_R2, 31 REG_LOONGARCH64_R3, 32 REG_LOONGARCH64_R4, 33 REG_LOONGARCH64_R5, 34 REG_LOONGARCH64_R6, 35 REG_LOONGARCH64_R7, 36 REG_LOONGARCH64_R8, 37 REG_LOONGARCH64_R9, 38 REG_LOONGARCH64_R10, 39 REG_LOONGARCH64_R11, 40 REG_LOONGARCH64_R12, 41 REG_LOONGARCH64_R13, 42 REG_LOONGARCH64_R14, 43 REG_LOONGARCH64_R15, 44 REG_LOONGARCH64_R16, 45 REG_LOONGARCH64_R17, 46 REG_LOONGARCH64_R18, 47 REG_LOONGARCH64_R19, 48 REG_LOONGARCH64_R20, 49 REG_LOONGARCH64_R21, 50 REG_LOONGARCH64_R22, 51 REG_LOONGARCH64_R23, 52 REG_LOONGARCH64_R24, 53 REG_LOONGARCH64_R25, 54 REG_LOONGARCH64_R26, 55 REG_LOONGARCH64_R27, 56 REG_LOONGARCH64_R28, 57 REG_LOONGARCH64_R29, 58 REG_LOONGARCH64_R30, 59 REG_LOONGARCH64_R31, 60 REG_LOONGARCH64_PC, 61 REG_LOONGARCH64_LAST, 62 63 REG_SP = REG_LOONGARCH64_R3, 64 REG_LR = REG_LOONGARCH64_R1, 65 REG_FP = REG_LOONGARCH64_R22, 66 REG_PC = REG_LOONGARCH64_PC, 67 REG_EH = REG_LOONGARCH64_R0, 68 REG_LAST = REG_LOONGARCH64_LAST, 69 }; 70 71 static const std::vector<uint16_t> QUT_REGS { 72 REG_LOONGARCH64_R0, 73 REG_LOONGARCH64_R31, 74 REG_SP, 75 REG_PC, 76 REG_LR, 77 }; 78 79 struct RegsUserLoongArch64 { 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 RegsUserLoongArch64 userRegs; 88 } UnwindUContext_t; 89 } // namespace HiviewDFX 90 } // namespace OHOS 91 #endif 92