1 //===-- ABIMacOSX_arm64.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ABIMacOSX_arm64_h_
11 #define liblldb_ABIMacOSX_arm64_h_
15 // Other libraries and framework includes
17 #include "lldb/Core/ConstString.h"
18 #include "lldb/Target/ABI.h"
19 #include "lldb/lldb-private.h"
21 class ABIMacOSX_arm64 : public lldb_private::ABI {
23 ~ABIMacOSX_arm64() override = default;
25 size_t GetRedZoneSize() const override;
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;
32 bool GetArgumentValues(lldb_private::Thread &thread,
33 lldb_private::ValueList &values) const override;
36 CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
38 bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
40 bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
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.
48 // To work around this, we relax that alignment to be just word-size
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
58 return false; // Zero is not a valid stack address
62 bool CodeAddressIsValid(lldb::addr_t pc) override {
63 if (pc & (4ull - 1ull))
64 return false; // Not 4 byte aligned
66 // Anything else if fair game..
70 const lldb_private::RegisterInfo *
71 GetRegisterInfoArray(uint32_t &count) override;
73 //------------------------------------------------------------------
75 //------------------------------------------------------------------
77 static void Initialize();
79 static void Terminate();
81 static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch);
83 //------------------------------------------------------------------
84 // PluginInterface protocol
85 //------------------------------------------------------------------
87 static lldb_private::ConstString GetPluginNameStatic();
89 lldb_private::ConstString GetPluginName() override {
90 return GetPluginNameStatic();
93 uint32_t GetPluginVersion() override;
96 SetReturnValueObject(lldb::StackFrameSP &frame_sp,
97 lldb::ValueObjectSP &new_value) override;
101 GetReturnValueObjectImpl(lldb_private::Thread &thread,
102 lldb_private::CompilerType &ast_type) const override;
105 ABIMacOSX_arm64() : lldb_private::ABI() {
106 // Call CreateInstance instead.
110 #endif // liblldb_ABIMacOSX_arm64_h_