1 //===-- ABIMacOSX_i386.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_i386_h_
11 #define liblldb_ABIMacOSX_i386_h_
15 // Other libraries and framework includes
17 #include "lldb/lldb-private.h"
18 #include "lldb/Target/ABI.h"
19 #include "lldb/Core/Value.h"
21 class ABIMacOSX_i386 :
22 public lldb_private::ABI
29 GetRedZoneSize () const;
32 PrepareTrivialCall (lldb_private::Thread &thread,
34 lldb::addr_t func_addr,
35 lldb::addr_t return_addr,
36 llvm::ArrayRef<lldb::addr_t> args) const;
39 PrepareNormalCall (lldb_private::Thread &thread,
41 lldb::addr_t func_addr,
42 lldb::addr_t return_addr,
43 lldb_private::ValueList &args) const;
46 GetArgumentValues (lldb_private::Thread &thread,
47 lldb_private::ValueList &values) const;
49 virtual lldb_private::Error
50 SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
53 virtual lldb::ValueObjectSP
54 GetReturnValueObjectImpl (lldb_private::Thread &thread,
55 lldb_private::ClangASTType &ast_type) const;
60 CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
63 CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
66 RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
74 // The Darwin i386 ABI requires that stack frames be 16 byte aligned.
75 // When there is a trap handler on the stack, e.g. _sigtramp in userland
76 // code, we've seen that the stack pointer is often not aligned properly
77 // before the handler is invoked. This means that lldb will stop the unwind
78 // early -- before the function which caused the trap.
80 // To work around this, we relax that alignment to be just word-size (4-bytes).
81 // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
82 // in other environments there can be a large number of different functions
83 // involved in async traps.
85 // If we were to enforce 16-byte alignment, we also need to relax to 4-byte
86 // alignment for non-darwin i386 targets.
88 CallFrameAddressIsValid (lldb::addr_t cfa)
90 // Make sure the stack call frame addresses are are 4 byte aligned
91 if (cfa & (4ull - 1ull))
92 return false; // Not 4 byte aligned
94 return false; // Zero is not a valid stack address
99 CodeAddressIsValid (lldb::addr_t pc)
101 // Just make sure the address is a valid 32 bit address.
102 return pc <= UINT32_MAX;
106 FunctionCallsChangeCFA ()
111 virtual const lldb_private::RegisterInfo *
112 GetRegisterInfoArray (uint32_t &count);
114 //------------------------------------------------------------------
116 //------------------------------------------------------------------
124 CreateInstance (const lldb_private::ArchSpec &arch);
126 //------------------------------------------------------------------
127 // PluginInterface protocol
128 //------------------------------------------------------------------
129 static lldb_private::ConstString
130 GetPluginNameStatic ();
132 virtual lldb_private::ConstString
140 RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info);
143 ABIMacOSX_i386() : lldb_private::ABI() { } // Call CreateInstance instead.
147 #endif // liblldb_ABI_h_