]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / source / Plugins / ABI / MacOSX-arm64 / ABIMacOSX_arm64.h
1 //===-- ABIMacOSX_arm64.h ---------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_ABIMacOSX_arm64_h_
11 #define liblldb_ABIMacOSX_arm64_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/ConstString.h"
18 #include "lldb/Target/ABI.h"
19 #include "lldb/lldb-private.h"
20
21 class ABIMacOSX_arm64 : public lldb_private::ABI {
22 public:
23   ~ABIMacOSX_arm64() override = default;
24
25   size_t GetRedZoneSize() const override;
26
27   bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
28                           lldb::addr_t functionAddress,
29                           lldb::addr_t returnAddress,
30                           llvm::ArrayRef<lldb::addr_t> args) const override;
31
32   bool GetArgumentValues(lldb_private::Thread &thread,
33                          lldb_private::ValueList &values) const override;
34
35   bool
36   CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
37
38   bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
39
40   bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
41
42   // The arm64 ABI requires that stack frames be 16 byte aligned.
43   // When there is a trap handler on the stack, e.g. _sigtramp in userland
44   // code, we've seen that the stack pointer is often not aligned properly
45   // before the handler is invoked.  This means that lldb will stop the unwind
46   // early -- before the function which caused the trap.
47   //
48   // To work around this, we relax that alignment to be just word-size
49   // (8-bytes).
50   // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
51   // in other environments there can be a large number of different functions
52   // involved in async traps.
53   bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
54     // Make sure the stack call frame addresses are are 8 byte aligned
55     if (cfa & (8ull - 1ull))
56       return false; // Not 8 byte aligned
57     if (cfa == 0)
58       return false; // Zero is not a valid stack address
59     return true;
60   }
61
62   bool CodeAddressIsValid(lldb::addr_t pc) override {
63     if (pc & (4ull - 1ull))
64       return false; // Not 4 byte aligned
65
66     // Anything else if fair game..
67     return true;
68   }
69
70   const lldb_private::RegisterInfo *
71   GetRegisterInfoArray(uint32_t &count) override;
72
73   //------------------------------------------------------------------
74   // Static Functions
75   //------------------------------------------------------------------
76
77   static void Initialize();
78
79   static void Terminate();
80
81   static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch);
82
83   //------------------------------------------------------------------
84   // PluginInterface protocol
85   //------------------------------------------------------------------
86
87   static lldb_private::ConstString GetPluginNameStatic();
88
89   lldb_private::ConstString GetPluginName() override {
90     return GetPluginNameStatic();
91   }
92
93   uint32_t GetPluginVersion() override;
94
95   lldb_private::Error
96   SetReturnValueObject(lldb::StackFrameSP &frame_sp,
97                        lldb::ValueObjectSP &new_value) override;
98
99 protected:
100   lldb::ValueObjectSP
101   GetReturnValueObjectImpl(lldb_private::Thread &thread,
102                            lldb_private::CompilerType &ast_type) const override;
103
104 private:
105   ABIMacOSX_arm64() : lldb_private::ABI() {
106     // Call CreateInstance instead.
107   }
108 };
109
110 #endif // liblldb_ABIMacOSX_arm64_h_