xref: /NextBSD/contrib/llvm/tools/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h (revision 287e3b14e9552995def1802ec9c5034f4adf28ec)
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/lldb-private.h"
18 #include "lldb/Core/ConstString.h"
19 #include "lldb/Target/ABI.h"
20 
21 class ABIMacOSX_arm64 :
22     public lldb_private::ABI
23 {
24 public:
~ABIMacOSX_arm64()25     ~ABIMacOSX_arm64() { }
26 
27     virtual size_t
28     GetRedZoneSize () const;
29 
30     virtual bool
31     PrepareTrivialCall (lldb_private::Thread &thread,
32                         lldb::addr_t sp,
33                         lldb::addr_t functionAddress,
34                         lldb::addr_t returnAddress,
35                         llvm::ArrayRef<lldb::addr_t> args) const;
36 
37     virtual bool
38     GetArgumentValues (lldb_private::Thread &thread,
39                        lldb_private::ValueList &values) const;
40 
41     virtual bool
42     CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
43 
44     virtual bool
45     CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
46 
47     virtual bool
48     RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
49 
50     // The arm64 ABI requires that stack frames be 16 byte aligned.
51     // When there is a trap handler on the stack, e.g. _sigtramp in userland
52     // code, we've seen that the stack pointer is often not aligned properly
53     // before the handler is invoked.  This means that lldb will stop the unwind
54     // early -- before the function which caused the trap.
55     //
56     // To work around this, we relax that alignment to be just word-size (8-bytes).
57     // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
58     // in other environments there can be a large number of different functions
59     // involved in async traps.
60 
61     virtual bool
CallFrameAddressIsValid(lldb::addr_t cfa)62     CallFrameAddressIsValid (lldb::addr_t cfa)
63     {
64         // Make sure the stack call frame addresses are are 8 byte aligned
65         if (cfa & (8ull - 1ull))
66             return false;   // Not 8 byte aligned
67         if (cfa == 0)
68             return false;   // Zero is not a valid stack address
69         return true;
70     }
71 
72     virtual bool
CodeAddressIsValid(lldb::addr_t pc)73     CodeAddressIsValid (lldb::addr_t pc)
74     {
75         if (pc & (4ull - 1ull))
76             return false;   // Not 4 byte aligned
77 
78         // Anything else if fair game..
79         return true;
80     }
81 
82     virtual const lldb_private::RegisterInfo *
83     GetRegisterInfoArray (uint32_t &count);
84 
85     //------------------------------------------------------------------
86     // Static Functions
87     //------------------------------------------------------------------
88     static void
89     Initialize();
90 
91     static void
92     Terminate();
93 
94     static lldb::ABISP
95     CreateInstance (const lldb_private::ArchSpec &arch);
96 
97     //------------------------------------------------------------------
98     // PluginInterface protocol
99     //------------------------------------------------------------------
100     static lldb_private::ConstString
101     GetPluginNameStatic();
102 
103     virtual lldb_private::ConstString
GetPluginName()104     GetPluginName()
105     {
106         return GetPluginNameStatic();
107     }
108 
109     virtual const char *
110     GetShortPluginName();
111 
112     virtual uint32_t
113     GetPluginVersion();
114 
115     virtual lldb_private::Error
116     SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
117 
118 protected:
119     virtual lldb::ValueObjectSP
120     GetReturnValueObjectImpl (lldb_private::Thread &thread,
121                     lldb_private::ClangASTType &ast_type) const;
122 
123 private:
ABIMacOSX_arm64()124     ABIMacOSX_arm64() :
125         lldb_private::ABI()
126     {
127         // Call CreateInstance instead.
128     }
129 };
130 
131 #endif  // liblldb_ABI_h_
132