Path: blob/main/contrib/llvm-project/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h
39654 views
//===-- ABIMacOSX_i386.h ----------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H9#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H1011#include "Plugins/ABI/X86/ABIX86_i386.h"12#include "lldb/Core/Value.h"13#include "lldb/lldb-private.h"1415class ABIMacOSX_i386 : public ABIX86_i386 {16public:17~ABIMacOSX_i386() override = default;1819size_t GetRedZoneSize() const override;2021bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,22lldb::addr_t func_addr, lldb::addr_t return_addr,23llvm::ArrayRef<lldb::addr_t> args) const override;2425bool GetArgumentValues(lldb_private::Thread &thread,26lldb_private::ValueList &values) const override;2728lldb_private::Status29SetReturnValueObject(lldb::StackFrameSP &frame_sp,30lldb::ValueObjectSP &new_value) override;3132bool33CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;3435bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;3637bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;3839// The Darwin i386 ABI requires that stack frames be 16 byte aligned.40// When there is a trap handler on the stack, e.g. _sigtramp in userland41// code, we've seen that the stack pointer is often not aligned properly42// before the handler is invoked. This means that lldb will stop the unwind43// early -- before the function which caused the trap.44//45// To work around this, we relax that alignment to be just word-size46// (4-bytes).47// Allowing the trap handlers for user space would be easy (_sigtramp) but48// in other environments there can be a large number of different functions49// involved in async traps.50//51// If we were to enforce 16-byte alignment, we also need to relax to 4-byte52// alignment for non-darwin i386 targets.53bool CallFrameAddressIsValid(lldb::addr_t cfa) override {54// Make sure the stack call frame addresses are 4 byte aligned55if (cfa & (4ull - 1ull))56return false; // Not 4 byte aligned57if (cfa == 0)58return false; // Zero is not a valid stack address59return true;60}6162bool CodeAddressIsValid(lldb::addr_t pc) override {63// Just make sure the address is a valid 32 bit address.64return pc <= UINT32_MAX;65}6667// Static Functions6869static void Initialize();7071static void Terminate();7273static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch);7475// PluginInterface protocol7677static llvm::StringRef GetPluginNameStatic() { return "abi.macosx-i386"; }7879llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }8081protected:82lldb::ValueObjectSP83GetReturnValueObjectImpl(lldb_private::Thread &thread,84lldb_private::CompilerType &ast_type) const override;8586bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);8788std::string GetMCName(std::string name) override {89MapRegisterName(name, "stmm", "st");90return name;91}9293private:94using ABIX86_i386::ABIX86_i386; // Call CreateInstance instead.95};9697#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H9899100