• 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_CONTEXT_H
16 #define UNWIND_CONTEXT_H
17 
18 #include <memory>
19 #if is_ohos
20 #include <ucontext.h>
21 #endif
22 
23 #include "byte_order.h"
24 #include "dfx_errors.h"
25 #include "unwind_define.h"
26 #include "unwind_loc.h"
27 
28 namespace OHOS {
29 namespace HiviewDFX {
30 class DfxMap;
31 class DfxRegs;
32 
33 struct UnwindTableInfo {
34     uintptr_t startPc = 0;
35     uintptr_t endPc = 0;
36     uintptr_t gp = 0; /* global-pointer in effect for this entry */
37     int format = -1;
38     bool isLinear = false;
39     uintptr_t namePtr = 0;
40     uintptr_t segbase = 0;
41     uintptr_t tableLen = 0;
42     uintptr_t tableData = 0;
43 };
44 
45 struct UnwindEntryInfo {
46     uintptr_t startPc;
47     uintptr_t endPc;
48     uintptr_t lsda;
49     uintptr_t handler;
50     uintptr_t gp;
51     int format = -1;
52     int unwindInfoSize;
53     void *unwindInfo;
54 };
55 
56 struct UnwindAccessors {
57     int (*FindUnwindTable)(uintptr_t, UnwindTableInfo &, void *);
58     int (*AccessMem)(uintptr_t, uintptr_t *, void *);
59     int (*AccessReg)(int, uintptr_t *, void *);
60 };
61 
62 struct UnwindContext {
63     bool stackCheck = false;
64     uintptr_t stackBottom = 0;
65     uintptr_t stackTop = 0;
66     int pid;
67     std::shared_ptr<DfxRegs> regs = nullptr;
68     std::shared_ptr<DfxMap> map = nullptr;
69     struct UnwindTableInfo di;
70 };
71 } // namespace HiviewDFX
72 } // namespace OHOS
73 #endif
74