]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
Merge ^/head r275262 through r275363.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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/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:
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     
51     virtual bool
52     StackUsesFrames ()
53     {
54         // MacOSX uses frame pointers.
55         return true;
56     }
57     
58     // The arm64 ABI requires that stack frames be 16 byte aligned.
59     // When there is a trap handler on the stack, e.g. _sigtramp in userland
60     // code, we've seen that the stack pointer is often not aligned properly
61     // before the handler is invoked.  This means that lldb will stop the unwind
62     // early -- before the function which caused the trap.
63     //
64     // To work around this, we relax that alignment to be just word-size (8-bytes).
65     // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
66     // in other environments there can be a large number of different functions
67     // involved in async traps.
68
69     virtual bool
70     CallFrameAddressIsValid (lldb::addr_t cfa)
71     {
72         // Make sure the stack call frame addresses are are 8 byte aligned
73         if (cfa & (8ull - 1ull))
74             return false;   // Not 8 byte aligned
75         if (cfa == 0)
76             return false;   // Zero is not a valid stack address
77         return true;
78     }
79     
80     virtual bool
81     CodeAddressIsValid (lldb::addr_t pc)
82     {
83         if (pc & (4ull - 1ull))
84             return false;   // Not 4 byte aligned
85         
86         // Anything else if fair game..
87         return true;
88     }
89
90     virtual bool
91     FunctionCallsChangeCFA ()
92     {
93         return false;
94     }
95
96     virtual const lldb_private::RegisterInfo *
97     GetRegisterInfoArray (uint32_t &count);
98
99     //------------------------------------------------------------------
100     // Static Functions
101     //------------------------------------------------------------------
102     static void
103     Initialize();
104     
105     static void
106     Terminate();
107     
108     static lldb::ABISP
109     CreateInstance (const lldb_private::ArchSpec &arch);
110     
111     //------------------------------------------------------------------
112     // PluginInterface protocol
113     //------------------------------------------------------------------
114     static lldb_private::ConstString
115     GetPluginNameStatic();
116
117     virtual lldb_private::ConstString
118     GetPluginName()
119     {
120         return GetPluginNameStatic();
121     }
122
123     virtual const char *
124     GetShortPluginName();
125     
126     virtual uint32_t
127     GetPluginVersion();
128     
129     virtual lldb_private::Error
130     SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
131
132 protected:
133     virtual lldb::ValueObjectSP
134     GetReturnValueObjectImpl (lldb_private::Thread &thread,
135                     lldb_private::ClangASTType &ast_type) const;
136
137 private:
138     ABIMacOSX_arm64() : 
139         lldb_private::ABI() 
140     {
141         // Call CreateInstance instead.  
142     } 
143 };
144
145 #endif  // liblldb_ABI_h_