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