ABIMacOSX_i386.h revision 263363
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 21class ABIMacOSX_i386 : 22 public lldb_private::ABI 23{ 24public: 25 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 57protected: 58 virtual lldb::ValueObjectSP 59 GetReturnValueObjectImpl (lldb_private::Thread &thread, 60 lldb_private::ClangASTType &ast_type) const; 61 62public: 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 74 StackUsesFrames () 75 { 76 return true; 77 } 78 79 virtual bool 80 CallFrameAddressIsValid (lldb::addr_t cfa) 81 { 82 // Darwin call frame addresses must be 16-byte aligned, but other OS's 83 // only need 4-byte alignment. Otherwise the ABI matches, so we have 84 // this one minor override here. 85 if (target_is_darwin) 86 { 87 // Make sure the stack call frame addresses are are 16 byte aligned 88 if (cfa & (16ull - 1ull)) 89 return false; // Not 16 byte aligned 90 } 91 else 92 { 93 // Make sure the stack call frame addresses are are 4 byte aligned 94 if (cfa & (4ull - 1ull)) 95 return false; // Not 4 byte aligned 96 } 97 if (cfa == 0) 98 return false; // Zero is not a valid stack address 99 return true; 100 } 101 102 virtual bool 103 CodeAddressIsValid (lldb::addr_t pc) 104 { 105 // Just make sure the address is a valid 32 bit address. 106 return pc <= UINT32_MAX; 107 } 108 109 virtual bool 110 FunctionCallsChangeCFA () 111 { 112 return true; 113 } 114 115 virtual const lldb_private::RegisterInfo * 116 GetRegisterInfoArray (uint32_t &count); 117 118 //------------------------------------------------------------------ 119 // Static Functions 120 //------------------------------------------------------------------ 121 static void 122 Initialize(); 123 124 static void 125 Terminate(); 126 127 static lldb::ABISP 128 CreateInstance (const lldb_private::ArchSpec &arch); 129 130 //------------------------------------------------------------------ 131 // PluginInterface protocol 132 //------------------------------------------------------------------ 133 static lldb_private::ConstString 134 GetPluginNameStatic (); 135 136 virtual lldb_private::ConstString 137 GetPluginName(); 138 139 virtual uint32_t 140 GetPluginVersion(); 141 142protected: 143 bool 144 RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); 145 146private: 147 ABIMacOSX_i386(bool is_darwin) : lldb_private::ABI(), 148 target_is_darwin(is_darwin) 149 { } // Call CreateInstance instead. 150 151 bool target_is_darwin; 152}; 153 154 155#endif // liblldb_ABI_h_ 156