LLDB  mainline
ABISysV_x86_64.h
Go to the documentation of this file.
1 //===-- ABISysV_x86_64.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H
10 #define LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H
11 
13 
14 class ABISysV_x86_64 : public ABIX86_64 {
15 public:
16  ~ABISysV_x86_64() override = default;
17 
18  size_t GetRedZoneSize() const override;
19 
21  lldb::addr_t functionAddress,
22  lldb::addr_t returnAddress,
23  llvm::ArrayRef<lldb::addr_t> args) const override;
24 
26  lldb_private::ValueList &values) const override;
27 
29  SetReturnValueObject(lldb::StackFrameSP &frame_sp,
30  lldb::ValueObjectSP &new_value) override;
31 
32  lldb::ValueObjectSP
34  lldb_private::CompilerType &type) const override;
35 
36  bool
38 
39  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
40 
41  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
42 
43  // The SysV x86_64 ABI requires that stack frames be 16 byte aligned.
44  // When there is a trap handler on the stack, e.g. _sigtramp in userland
45  // code, we've seen that the stack pointer is often not aligned properly
46  // before the handler is invoked. This means that lldb will stop the unwind
47  // early -- before the function which caused the trap.
48  //
49  // To work around this, we relax that alignment to be just word-size
50  // (8-bytes).
51  // Allowing the trap handlers for user space would be easy (_sigtramp) but
52  // in other environments there can be a large number of different functions
53  // involved in async traps.
55  // Make sure the stack call frame addresses are 8 byte aligned
56  if (cfa & (8ull - 1ull))
57  return false; // Not 8 byte aligned
58  if (cfa == 0)
59  return false; // Zero is not a valid stack address
60  return true;
61  }
62 
64  // We have a 64 bit address space, so anything is valid as opcodes
65  // aren't fixed width...
66  return true;
67  }
68 
69  bool GetPointerReturnRegister(const char *&name) override;
70 
71  // Static Functions
72 
73  static void Initialize();
74 
75  static void Terminate();
76 
77  static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch);
78 
79  static llvm::StringRef GetPluginNameStatic() { return "sysv-x86_64"; }
80 
81  // PluginInterface protocol
82  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
83 
84 protected:
86 
87  lldb::ValueObjectSP
89  lldb_private::CompilerType &ast_type) const;
90 
91  bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
92  uint32_t GetGenericNum(llvm::StringRef reg) override;
93 
94 private:
95  using ABIX86_64::ABIX86_64; // Call CreateInstance instead.
96 };
97 
98 #endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H
lldb_private::ArchSpec
Definition: ArchSpec.h:33
ABIX86_64.h
ABISysV_x86_64::GetGenericNum
uint32_t GetGenericNum(llvm::StringRef reg) override
Return the generic number of the given register.
Definition: ABISysV_x86_64.cpp:930
ABISysV_x86_64::Terminate
static void Terminate()
Definition: ABISysV_x86_64.cpp:952
ABISysV_x86_64::Initialize
static void Initialize()
Definition: ABISysV_x86_64.cpp:947
lldb_private::ValueList
Definition: Value.h:157
ABISysV_x86_64::RegisterIsCalleeSaved
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info)
Definition: ABISysV_x86_64.cpp:917
ABISysV_x86_64::PrepareTrivialCall
bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, llvm::ArrayRef< lldb::addr_t > args) const override
Definition: ABISysV_x86_64.cpp:107
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
pc
@ pc
Definition: CompactUnwindInfo.cpp:1250
ABISysV_x86_64::GetPointerReturnRegister
bool GetPointerReturnRegister(const char *&name) override
Definition: ABISysV_x86_64.cpp:60
ABISysV_x86_64::CreateRegisterMapIfNeeded
void CreateRegisterMapIfNeeded()
ABISysV_x86_64::CreateDefaultUnwindPlan
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
Definition: ABISysV_x86_64.cpp:877
lldb_private::Thread
Definition: Thread.h:60
ABISysV_x86_64
Definition: ABISysV_x86_64.h:14
sp
@ sp
Definition: CompactUnwindInfo.cpp:1249
ABISysV_x86_64::GetReturnValueObjectSimple
lldb::ValueObjectSP GetReturnValueObjectSimple(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const
Definition: ABISysV_x86_64.cpp:385
ABISysV_x86_64::CallFrameAddressIsValid
bool CallFrameAddressIsValid(lldb::addr_t cfa) override
Definition: ABISysV_x86_64.h:54
ABIX86_64
Definition: ABIX86_64.h:14
ABISysV_x86_64::CreateFunctionEntryUnwindPlan
bool CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
Definition: ABISysV_x86_64.cpp:855
ABISysV_x86_64::SetReturnValueObject
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
Definition: ABISysV_x86_64.cpp:288
lldb_private::Status
Definition: Status.h:44
ABISysV_x86_64::CreateInstance
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
Definition: ABISysV_x86_64.cpp:70
ABISysV_x86_64::RegisterIsVolatile
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
Definition: ABISysV_x86_64.cpp:904
uint32_t
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
ABISysV_x86_64::CodeAddressIsValid
bool CodeAddressIsValid(lldb::addr_t pc) override
Definition: ABISysV_x86_64.h:63
ABISysV_x86_64::GetRedZoneSize
size_t GetRedZoneSize() const override
Definition: ABISysV_x86_64.cpp:65
ABISysV_x86_64::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: ABISysV_x86_64.h:79
lldb_private::UnwindPlan
Definition: UnwindPlan.h:53
ABISysV_x86_64::GetArgumentValues
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override
Definition: ABISysV_x86_64.cpp:215
ABISysV_x86_64::GetPluginName
llvm::StringRef GetPluginName() override
Definition: ABISysV_x86_64.h:82
ABISysV_x86_64::~ABISysV_x86_64
~ABISysV_x86_64() override=default
ABISysV_x86_64::GetReturnValueObjectImpl
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &type) const override
Definition: ABISysV_x86_64.cpp:616