1 //===-- ABISysV_x86_64.h ----------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H
10 #define LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H
12 #include "Plugins/ABI/X86/ABIX86_64.h"
14 class ABISysV_x86_64
: public ABIX86_64
{
16 ~ABISysV_x86_64() override
= default;
18 size_t GetRedZoneSize() const override
;
20 bool PrepareTrivialCall(lldb_private::Thread
&thread
, lldb::addr_t sp
,
21 lldb::addr_t functionAddress
,
22 lldb::addr_t returnAddress
,
23 llvm::ArrayRef
<lldb::addr_t
> args
) const override
;
25 bool GetArgumentValues(lldb_private::Thread
&thread
,
26 lldb_private::ValueList
&values
) const override
;
29 SetReturnValueObject(lldb::StackFrameSP
&frame_sp
,
30 lldb::ValueObjectSP
&new_value
) override
;
33 GetReturnValueObjectImpl(lldb_private::Thread
&thread
,
34 lldb_private::CompilerType
&type
) const override
;
37 CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan
&unwind_plan
) override
;
39 bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan
&unwind_plan
) override
;
41 bool RegisterIsVolatile(const lldb_private::RegisterInfo
*reg_info
) override
;
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.
49 // To work around this, we relax that alignment to be just word-size
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.
54 bool CallFrameAddressIsValid(lldb::addr_t cfa
) override
{
55 // Make sure the stack call frame addresses are 8 byte aligned
56 if (cfa
& (8ull - 1ull))
57 return false; // Not 8 byte aligned
59 return false; // Zero is not a valid stack address
63 bool CodeAddressIsValid(lldb::addr_t pc
) override
{
64 // We have a 64 bit address space, so anything is valid as opcodes
65 // aren't fixed width...
69 bool GetPointerReturnRegister(const char *&name
) override
;
73 static void Initialize();
75 static void Terminate();
77 static lldb::ABISP
CreateInstance(lldb::ProcessSP process_sp
, const lldb_private::ArchSpec
&arch
);
79 static llvm::StringRef
GetPluginNameStatic() { return "sysv-x86_64"; }
81 // PluginInterface protocol
82 llvm::StringRef
GetPluginName() override
{ return GetPluginNameStatic(); }
85 void CreateRegisterMapIfNeeded();
88 GetReturnValueObjectSimple(lldb_private::Thread
&thread
,
89 lldb_private::CompilerType
&ast_type
) const;
91 bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo
*reg_info
);
92 uint32_t GetGenericNum(llvm::StringRef reg
) override
;
95 using ABIX86_64::ABIX86_64
; // Call CreateInstance instead.
98 #endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H