1 //===-- ABISysV_ppc64.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_ABISysV_ppc64_h_ 11 #define liblldb_ABISysV_ppc64_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 ABISysV_ppc64 : 21 public lldb_private::ABI 22 { 23 public: 24 ~ABISysV_ppc64()25 ~ABISysV_ppc64() 26 { 27 } 28 29 virtual size_t 30 GetRedZoneSize () const; 31 32 virtual bool 33 PrepareTrivialCall (lldb_private::Thread &thread, 34 lldb::addr_t sp, 35 lldb::addr_t functionAddress, 36 lldb::addr_t returnAddress, 37 llvm::ArrayRef<lldb::addr_t> args) const; 38 39 virtual bool 40 GetArgumentValues (lldb_private::Thread &thread, 41 lldb_private::ValueList &values) const; 42 43 virtual lldb_private::Error 44 SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value); 45 46 protected: 47 lldb::ValueObjectSP 48 GetReturnValueObjectSimple (lldb_private::Thread &thread, 49 lldb_private::ClangASTType &ast_type) const; 50 51 public: 52 virtual lldb::ValueObjectSP 53 GetReturnValueObjectImpl (lldb_private::Thread &thread, 54 lldb_private::ClangASTType &type) const; 55 56 virtual bool 57 CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan); 58 59 virtual bool 60 CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan); 61 62 virtual bool 63 RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info); 64 65 virtual bool StackUsesFrames()66 StackUsesFrames () 67 { 68 return true; 69 } 70 71 // The SysV ppc64 ABI requires that stack frames be 16 byte aligned. 72 // When there is a trap handler on the stack, e.g. _sigtramp in userland 73 // code, we've seen that the stack pointer is often not aligned properly 74 // before the handler is invoked. This means that lldb will stop the unwind 75 // early -- before the function which caused the trap. 76 // 77 // To work around this, we relax that alignment to be just word-size (8-bytes). 78 // Whitelisting the trap handlers for user space would be easy (_sigtramp) but 79 // in other environments there can be a large number of different functions 80 // involved in async traps. 81 virtual bool CallFrameAddressIsValid(lldb::addr_t cfa)82 CallFrameAddressIsValid (lldb::addr_t cfa) 83 { 84 // Make sure the stack call frame addresses are 8 byte aligned 85 if (cfa & (8ull - 1ull)) 86 return false; // Not 8 byte aligned 87 if (cfa == 0) 88 return false; // Zero is not a valid stack address 89 return true; 90 } 91 92 virtual bool CodeAddressIsValid(lldb::addr_t pc)93 CodeAddressIsValid (lldb::addr_t pc) 94 { 95 // We have a 64 bit address space, so anything is valid as opcodes 96 // aren't fixed width... 97 return true; 98 } 99 100 virtual bool FunctionCallsChangeCFA()101 FunctionCallsChangeCFA () 102 { 103 return true; 104 } 105 106 virtual const lldb_private::RegisterInfo * 107 GetRegisterInfoArray (uint32_t &count); 108 //------------------------------------------------------------------ 109 // Static Functions 110 //------------------------------------------------------------------ 111 static void 112 Initialize(); 113 114 static void 115 Terminate(); 116 117 static lldb::ABISP 118 CreateInstance (const lldb_private::ArchSpec &arch); 119 120 static lldb_private::ConstString 121 GetPluginNameStatic(); 122 123 //------------------------------------------------------------------ 124 // PluginInterface protocol 125 //------------------------------------------------------------------ 126 virtual lldb_private::ConstString 127 GetPluginName(); 128 129 virtual uint32_t 130 GetPluginVersion(); 131 132 protected: 133 void 134 CreateRegisterMapIfNeeded (); 135 136 bool 137 RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); 138 139 private: ABISysV_ppc64()140 ABISysV_ppc64() : lldb_private::ABI() { } // Call CreateInstance instead. 141 }; 142 143 #endif // liblldb_ABI_h_ 144