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