• 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 #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_LOCAL = -3,
56     UNWIND_TYPE_CUSTOMIZE = -2,
57     UNWIND_TYPE_LOCAL = -1,
58     UNWIND_TYPE_REMOTE,
59 };
60 
61 enum UnwindDynInfoFormatType {
62     UNW_INFO_FORMAT_TABLE,              /* unw_dyn_table_t */
63     UNW_INFO_FORMAT_REMOTE_TABLE,       /* unw_dyn_remote_table_t */
64     UNW_INFO_FORMAT_ARM_EXIDX,          /* ARM specific unwind info */
65 };
66 
67 /**
68  * @brief Unwind regs type
69  */
70 enum UnwindRegsType {
71     /** Dwarf */
72     REGS_TYPE_DWARF = 0,
73     /** Qut */
74     REGS_TYPE_QUT,
75 };
76 
77 /**
78  * @brief Unwind mode
79  */
80 enum UnwindMode {
81     /** Dwarf unwind */
82     DWARF_UNWIND = 0,
83     /** Frame pointer unwind */
84     FRAMEPOINTER_UNWIND,
85     /** Quick unwind table */
86     MINIMAL_UNWIND,
87     /** Mix unwind table */
88     MIX_UNWIND,
89 };
90 
91 /**
92  * @brief Unwind cache mode
93  */
94 enum UnwindCachingPolicy : uint8_t {
95     /** unwind no cache */
96     UNWIND_CACHE_NONE = 0,
97     /** unwind global cache */
98     UNWIND_CACHE_GLOBAL,
99     /** unwind per-thread cache */
100     UNWIND_CACHE_PER_THREAD,
101 };
102 } // namespace HiviewDFX
103 } // namespace OHOS
104 #endif
105