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