1800b99b8Sopenharmony_ci/* 2800b99b8Sopenharmony_ci * Copyright 2024 Institute of Software, Chinese Academy of Sciences. 3800b99b8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4800b99b8Sopenharmony_ci * you may not use this file except in compliance with the License. 5800b99b8Sopenharmony_ci * You may obtain a copy of the License at 6800b99b8Sopenharmony_ci * 7800b99b8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8800b99b8Sopenharmony_ci * 9800b99b8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10800b99b8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11800b99b8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12800b99b8Sopenharmony_ci * See the License for the specific language governing permissions and 13800b99b8Sopenharmony_ci * limitations under the License. 14800b99b8Sopenharmony_ci */ 15800b99b8Sopenharmony_ci 16800b99b8Sopenharmony_ci#ifndef UNWIND_RISCV64_DEFINE_H 17800b99b8Sopenharmony_ci#define UNWIND_RISCV64_DEFINE_H 18800b99b8Sopenharmony_ci 19800b99b8Sopenharmony_ci#include <cinttypes> 20800b99b8Sopenharmony_ci#include <string> 21800b99b8Sopenharmony_ci#include <vector> 22800b99b8Sopenharmony_ci 23800b99b8Sopenharmony_cinamespace OHOS { 24800b99b8Sopenharmony_cinamespace HiviewDFX { 25800b99b8Sopenharmony_ci#define REGS_PRINT_LEN 1024 26800b99b8Sopenharmony_ci#define DWARF_PRESERVED_REGS_NUM 97 27800b99b8Sopenharmony_ci 28800b99b8Sopenharmony_ci#ifdef REG_SP 29800b99b8Sopenharmony_ci#undef REG_SP 30800b99b8Sopenharmony_ci#endif 31800b99b8Sopenharmony_ci#ifdef REG_PC 32800b99b8Sopenharmony_ci#undef REG_PC 33800b99b8Sopenharmony_ci#endif 34800b99b8Sopenharmony_ci 35800b99b8Sopenharmony_cienum RegsEnumRiscv64 : uint16_t { 36800b99b8Sopenharmony_ci REG_RISCV64_X0 = 0, 37800b99b8Sopenharmony_ci REG_RISCV64_X1, 38800b99b8Sopenharmony_ci REG_RISCV64_X2, 39800b99b8Sopenharmony_ci REG_RISCV64_X3, 40800b99b8Sopenharmony_ci REG_RISCV64_X4, 41800b99b8Sopenharmony_ci REG_RISCV64_X5, 42800b99b8Sopenharmony_ci REG_RISCV64_X6, 43800b99b8Sopenharmony_ci REG_RISCV64_X7, 44800b99b8Sopenharmony_ci REG_RISCV64_X8, 45800b99b8Sopenharmony_ci REG_RISCV64_X9, 46800b99b8Sopenharmony_ci REG_RISCV64_X10, 47800b99b8Sopenharmony_ci REG_RISCV64_X11, 48800b99b8Sopenharmony_ci REG_RISCV64_X12, 49800b99b8Sopenharmony_ci REG_RISCV64_X13, 50800b99b8Sopenharmony_ci REG_RISCV64_X14, 51800b99b8Sopenharmony_ci REG_RISCV64_X15, 52800b99b8Sopenharmony_ci REG_RISCV64_X16, 53800b99b8Sopenharmony_ci REG_RISCV64_X17, 54800b99b8Sopenharmony_ci REG_RISCV64_X18, 55800b99b8Sopenharmony_ci REG_RISCV64_X19, 56800b99b8Sopenharmony_ci REG_RISCV64_X20, 57800b99b8Sopenharmony_ci REG_RISCV64_X21, 58800b99b8Sopenharmony_ci REG_RISCV64_X22, 59800b99b8Sopenharmony_ci REG_RISCV64_X23, 60800b99b8Sopenharmony_ci REG_RISCV64_X24, 61800b99b8Sopenharmony_ci REG_RISCV64_X25, 62800b99b8Sopenharmony_ci REG_RISCV64_X26, 63800b99b8Sopenharmony_ci REG_RISCV64_X27, 64800b99b8Sopenharmony_ci REG_RISCV64_X28, 65800b99b8Sopenharmony_ci REG_RISCV64_X29, 66800b99b8Sopenharmony_ci REG_RISCV64_X30, 67800b99b8Sopenharmony_ci REG_RISCV64_X31, 68800b99b8Sopenharmony_ci REG_RISCV64_PC, 69800b99b8Sopenharmony_ci REG_RISCV64_LAST, 70800b99b8Sopenharmony_ci 71800b99b8Sopenharmony_ci REG_SP = REG_RISCV64_X2, 72800b99b8Sopenharmony_ci REG_LR = REG_RISCV64_X0, 73800b99b8Sopenharmony_ci REG_FP = REG_RISCV64_X8, 74800b99b8Sopenharmony_ci REG_PC = REG_RISCV64_PC, 75800b99b8Sopenharmony_ci REG_EH = REG_RISCV64_X0, 76800b99b8Sopenharmony_ci REG_LAST = REG_RISCV64_LAST, 77800b99b8Sopenharmony_ci}; 78800b99b8Sopenharmony_ci 79800b99b8Sopenharmony_cistatic const std::vector<uint16_t> QUT_REGS { 80800b99b8Sopenharmony_ci REG_RISCV64_X0, 81800b99b8Sopenharmony_ci REG_RISCV64_X31, 82800b99b8Sopenharmony_ci REG_SP, 83800b99b8Sopenharmony_ci REG_PC, 84800b99b8Sopenharmony_ci REG_LR, 85800b99b8Sopenharmony_ci}; 86800b99b8Sopenharmony_ci 87800b99b8Sopenharmony_cistruct RegsUserRiscv64 { 88800b99b8Sopenharmony_ci uint64_t regs[31]; 89800b99b8Sopenharmony_ci uint64_t sp; 90800b99b8Sopenharmony_ci uint64_t pc; 91800b99b8Sopenharmony_ci uint64_t pstate; 92800b99b8Sopenharmony_ci}; 93800b99b8Sopenharmony_ci 94800b99b8Sopenharmony_citypedef struct UnwindUContext { 95800b99b8Sopenharmony_ci RegsUserRiscv64 userRegs; 96800b99b8Sopenharmony_ci} UnwindUContext_t; 97800b99b8Sopenharmony_ci} // namespace HiviewDFX 98800b99b8Sopenharmony_ci} // namespace OHOS 99800b99b8Sopenharmony_ci#endif 100