1 //===-- ABIMacOSX_arm.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_arm_h_
11 #define liblldb_ABIMacOSX_arm_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/Target/ABI.h"
19 
20 class ABIMacOSX_arm : public lldb_private::ABI
21 {
22 public:
~ABIMacOSX_arm()23     ~ABIMacOSX_arm() { }
24 
25     virtual size_t
26     GetRedZoneSize () const;
27 
28     virtual bool
29     PrepareTrivialCall (lldb_private::Thread &thread,
30                         lldb::addr_t sp,
31                         lldb::addr_t func_addr,
32                         lldb::addr_t returnAddress,
33                         lldb::addr_t *arg1_ptr = NULL,
34                         lldb::addr_t *arg2_ptr = NULL,
35                         lldb::addr_t *arg3_ptr = NULL,
36                         lldb::addr_t *arg4_ptr = NULL,
37                         lldb::addr_t *arg5_ptr = NULL,
38                         lldb::addr_t *arg6_ptr = NULL) const;
39 
40     virtual bool
41     GetArgumentValues (lldb_private::Thread &thread,
42                        lldb_private::ValueList &values) const;
43 
44     virtual lldb_private::Error
45     SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
46 
47 protected:
48     virtual lldb::ValueObjectSP
49     GetReturnValueObjectImpl (lldb_private::Thread &thread,
50                     lldb_private::ClangASTType &ast_type) const;
51 
52 public:
53     virtual bool
54     CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
55 
56     virtual bool
57     CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
58 
59     virtual bool
60     RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
61 
62     virtual bool
StackUsesFrames()63     StackUsesFrames ()
64     {
65         return true;
66     }
67 
68     virtual bool
CallFrameAddressIsValid(lldb::addr_t cfa)69     CallFrameAddressIsValid (lldb::addr_t cfa)
70     {
71         // Make sure the stack call frame addresses are are 4 byte aligned
72         if (cfa & (4ull - 1ull))
73             return false;   // Not 4 byte aligned
74         if (cfa == 0)
75             return false;   // Zero is not a valid stack address
76         return true;
77     }
78 
79     virtual bool
CodeAddressIsValid(lldb::addr_t pc)80     CodeAddressIsValid (lldb::addr_t pc)
81     {
82         // Just make sure the address is a valid 32 bit address. Bit zero
83         // might be set due to Thumb function calls, so don't enforce 2 byte
84         // alignment
85         return pc <= UINT32_MAX;
86     }
87 
88     virtual lldb::addr_t
FixCodeAddress(lldb::addr_t pc)89     FixCodeAddress (lldb::addr_t pc)
90     {
91         // ARM uses bit zero to signify a code address is thumb, so we must
92         // strip bit zero in any code addresses.
93         return pc & ~(lldb::addr_t)1;
94     }
95 
96     virtual bool
FunctionCallsChangeCFA()97     FunctionCallsChangeCFA ()
98     {
99         return false;
100     }
101 
102     virtual const lldb_private::RegisterInfo *
103     GetRegisterInfoArray (uint32_t &count);
104 
105     //------------------------------------------------------------------
106     // Static Functions
107     //------------------------------------------------------------------
108     static void
109     Initialize();
110 
111     static void
112     Terminate();
113 
114     static lldb::ABISP
115     CreateInstance (const lldb_private::ArchSpec &arch);
116 
117     static lldb_private::ConstString
118     GetPluginNameStatic();
119 
120     //------------------------------------------------------------------
121     // PluginInterface protocol
122     //------------------------------------------------------------------
123     virtual lldb_private::ConstString
124     GetPluginName();
125 
126     virtual uint32_t
127     GetPluginVersion();
128 
129 protected:
130 private:
ABIMacOSX_arm()131     ABIMacOSX_arm() :
132         lldb_private::ABI()
133     {
134          // Call CreateInstance instead.
135     }
136 };
137 
138 #endif  // liblldb_ABIMacOSX_arm_h_
139