1278332Semaste//===-- ABISysV_ppc.h ----------------------------------------*- C++ -*-===// 2278332Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6278332Semaste// 7278332Semaste//===----------------------------------------------------------------------===// 8278332Semaste 9278332Semaste#ifndef liblldb_ABISysV_ppc_h_ 10278332Semaste#define liblldb_ABISysV_ppc_h_ 11278332Semaste 12314564Sdim#include "lldb/Target/ABI.h" 13278332Semaste#include "lldb/lldb-private.h" 14278332Semaste 15314564Sdimclass ABISysV_ppc : public lldb_private::ABI { 16278332Semastepublic: 17314564Sdim ~ABISysV_ppc() override = default; 18278332Semaste 19314564Sdim size_t GetRedZoneSize() const override; 20278332Semaste 21314564Sdim bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, 22314564Sdim lldb::addr_t functionAddress, 23314564Sdim lldb::addr_t returnAddress, 24314564Sdim llvm::ArrayRef<lldb::addr_t> args) const override; 25278332Semaste 26314564Sdim bool GetArgumentValues(lldb_private::Thread &thread, 27314564Sdim lldb_private::ValueList &values) const override; 28278332Semaste 29321369Sdim lldb_private::Status 30314564Sdim SetReturnValueObject(lldb::StackFrameSP &frame_sp, 31314564Sdim lldb::ValueObjectSP &new_value) override; 32278332Semaste 33314564Sdim lldb::ValueObjectSP 34314564Sdim GetReturnValueObjectImpl(lldb_private::Thread &thread, 35314564Sdim lldb_private::CompilerType &type) const override; 36278332Semaste 37314564Sdim bool 38314564Sdim CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; 39296417Sdim 40314564Sdim bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; 41278332Semaste 42314564Sdim bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; 43278332Semaste 44314564Sdim // The SysV ppc ABI requires that stack frames be 16 byte aligned. 45314564Sdim // When there is a trap handler on the stack, e.g. _sigtramp in userland 46314564Sdim // code, we've seen that the stack pointer is often not aligned properly 47314564Sdim // before the handler is invoked. This means that lldb will stop the unwind 48314564Sdim // early -- before the function which caused the trap. 49314564Sdim // 50314564Sdim // To work around this, we relax that alignment to be just word-size 51314564Sdim // (8-bytes). 52314564Sdim // Whitelisting the trap handlers for user space would be easy (_sigtramp) but 53314564Sdim // in other environments there can be a large number of different functions 54314564Sdim // involved in async traps. 55314564Sdim bool CallFrameAddressIsValid(lldb::addr_t cfa) override { 56314564Sdim // Make sure the stack call frame addresses are 8 byte aligned 57314564Sdim if (cfa & (8ull - 1ull)) 58314564Sdim return false; // Not 8 byte aligned 59314564Sdim if (cfa == 0) 60314564Sdim return false; // Zero is not a valid stack address 61314564Sdim return true; 62314564Sdim } 63278332Semaste 64314564Sdim bool CodeAddressIsValid(lldb::addr_t pc) override { 65314564Sdim // We have a 64 bit address space, so anything is valid as opcodes 66314564Sdim // aren't fixed width... 67314564Sdim return true; 68314564Sdim } 69278332Semaste 70314564Sdim const lldb_private::RegisterInfo * 71314564Sdim GetRegisterInfoArray(uint32_t &count) override; 72278332Semaste 73314564Sdim // Static Functions 74296417Sdim 75314564Sdim static void Initialize(); 76314564Sdim 77314564Sdim static void Terminate(); 78314564Sdim 79321369Sdim static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); 80314564Sdim 81314564Sdim static lldb_private::ConstString GetPluginNameStatic(); 82314564Sdim 83314564Sdim // PluginInterface protocol 84314564Sdim 85314564Sdim lldb_private::ConstString GetPluginName() override; 86314564Sdim 87314564Sdim uint32_t GetPluginVersion() override; 88314564Sdim 89278332Semasteprotected: 90314564Sdim void CreateRegisterMapIfNeeded(); 91278332Semaste 92314564Sdim lldb::ValueObjectSP 93314564Sdim GetReturnValueObjectSimple(lldb_private::Thread &thread, 94314564Sdim lldb_private::CompilerType &ast_type) const; 95296417Sdim 96314564Sdim bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); 97278332Semaste 98278332Semasteprivate: 99360784Sdim ABISysV_ppc(lldb::ProcessSP process_sp, 100360784Sdim std::unique_ptr<llvm::MCRegisterInfo> info_up) 101360784Sdim : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { 102314564Sdim // Call CreateInstance instead. 103314564Sdim } 104278332Semaste}; 105278332Semaste 106296417Sdim#endif // liblldb_ABISysV_ppc_h_ 107