forked from OSchip/llvm-project
This patch adds support aarch64-linux-gnu (SysV) abi in lldb.
This code is also an import from MacOSx implementation as SysV abi is similar to what has been implemented for MacOS but may require a few tweaks. http://reviews.llvm.org/D8538 llvm-svn: 236098
This commit is contained in:
parent
52f825bd1c
commit
b78e05fead
|
@ -47,6 +47,7 @@ set( LLDB_USED_LIBS
|
|||
lldbPluginABIMacOSX_arm64
|
||||
lldbPluginABIMacOSX_i386
|
||||
lldbPluginABISysV_arm
|
||||
lldbPluginABISysV_arm64
|
||||
lldbPluginABISysV_x86_64
|
||||
lldbPluginABISysV_hexagon
|
||||
lldbPluginABISysV_ppc
|
||||
|
|
|
@ -36,6 +36,7 @@ USEDLIBS = lldbAPI.a \
|
|||
lldbPluginABIMacOSX_arm64.a \
|
||||
lldbPluginABIMacOSX_i386.a \
|
||||
lldbPluginABISysV_arm.a \
|
||||
lldbPluginABISysV_arm64.a \
|
||||
lldbPluginABISysV_ppc.a \
|
||||
lldbPluginABISysV_ppc64.a \
|
||||
lldbPluginABISysV_x86_64.a \
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
|
||||
#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
|
||||
#include "Plugins/ABI/SysV-arm/ABISysV_arm.h"
|
||||
#include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h"
|
||||
#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
|
||||
#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
|
||||
#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
|
||||
|
@ -237,6 +238,7 @@ SystemInitializerFull::Initialize()
|
|||
ABIMacOSX_arm::Initialize();
|
||||
ABIMacOSX_arm64::Initialize();
|
||||
ABISysV_arm::Initialize();
|
||||
ABISysV_arm64::Initialize();
|
||||
ABISysV_x86_64::Initialize();
|
||||
ABISysV_ppc::Initialize();
|
||||
ABISysV_ppc64::Initialize();
|
||||
|
@ -342,6 +344,7 @@ SystemInitializerFull::Terminate()
|
|||
ABIMacOSX_arm::Terminate();
|
||||
ABIMacOSX_arm64::Terminate();
|
||||
ABISysV_arm::Terminate();
|
||||
ABISysV_arm64::Terminate();
|
||||
ABISysV_x86_64::Terminate();
|
||||
ABISysV_ppc::Terminate();
|
||||
ABISysV_ppc64::Terminate();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
add_subdirectory(SysV-arm)
|
||||
add_subdirectory(SysV-arm64)
|
||||
add_subdirectory(SysV-hexagon)
|
||||
add_subdirectory(SysV-ppc)
|
||||
add_subdirectory(SysV-ppc64)
|
||||
|
|
|
@ -219,12 +219,19 @@ ABISP
|
|||
ABIMacOSX_arm64::CreateInstance (const ArchSpec &arch)
|
||||
{
|
||||
static ABISP g_abi_sp;
|
||||
if (arch.GetTriple().getArch() == llvm::Triple::aarch64)
|
||||
const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
|
||||
const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor();
|
||||
|
||||
if (vendor_type == llvm::Triple::Apple)
|
||||
{
|
||||
if (!g_abi_sp)
|
||||
g_abi_sp.reset (new ABIMacOSX_arm64);
|
||||
return g_abi_sp;
|
||||
if (arch_type == llvm::Triple::aarch64)
|
||||
{
|
||||
if (!g_abi_sp)
|
||||
g_abi_sp.reset (new ABIMacOSX_arm64);
|
||||
return g_abi_sp;
|
||||
}
|
||||
}
|
||||
|
||||
return ABISP();
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,125 @@
|
|||
//===-- ABISysV_arm64.h ---------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef liblldb_ABISysV_arm64_h_
|
||||
#define liblldb_ABISysV_arm64_h_
|
||||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/lldb-private.h"
|
||||
#include "lldb/Target/ABI.h"
|
||||
|
||||
class ABISysV_arm64 : public lldb_private::ABI
|
||||
{
|
||||
public:
|
||||
~ABISysV_arm64() { }
|
||||
|
||||
size_t
|
||||
GetRedZoneSize () const override;
|
||||
|
||||
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;
|
||||
|
||||
bool
|
||||
GetArgumentValues (lldb_private::Thread &thread,
|
||||
lldb_private::ValueList &values) const override;
|
||||
|
||||
lldb_private::Error
|
||||
SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
|
||||
|
||||
protected:
|
||||
lldb::ValueObjectSP
|
||||
GetReturnValueObjectImpl (lldb_private::Thread &thread,
|
||||
lldb_private::ClangASTType &ast_type) const override;
|
||||
|
||||
public:
|
||||
bool
|
||||
CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override;
|
||||
|
||||
bool
|
||||
CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override;
|
||||
|
||||
bool
|
||||
RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info) override;
|
||||
|
||||
// The arm64 ABI requires that stack frames be 16 byte aligned.
|
||||
// When there is a trap handler on the stack, e.g. _sigtramp in userland
|
||||
// code, we've seen that the stack pointer is often not aligned properly
|
||||
// before the handler is invoked. This means that lldb will stop the unwind
|
||||
// early -- before the function which caused the trap.
|
||||
//
|
||||
// To work around this, we relax that alignment to be just word-size (8-bytes).
|
||||
// Whitelisting the trap handlers for user space would be easy (_sigtramp) but
|
||||
// in other environments there can be a large number of different functions
|
||||
// involved in async traps.
|
||||
|
||||
bool
|
||||
CallFrameAddressIsValid (lldb::addr_t cfa) override
|
||||
{
|
||||
// Make sure the stack call frame addresses are are 8 byte aligned
|
||||
if (cfa & (8ull - 1ull))
|
||||
return false; // Not 8 byte aligned
|
||||
if (cfa == 0)
|
||||
return false; // Zero is not a valid stack address
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CodeAddressIsValid (lldb::addr_t pc) override
|
||||
{
|
||||
if (pc & (4ull - 1ull))
|
||||
return false; // Not 4 byte aligned
|
||||
|
||||
// Anything else if fair game..
|
||||
return true;
|
||||
}
|
||||
|
||||
const lldb_private::RegisterInfo *
|
||||
GetRegisterInfoArray (uint32_t &count) override;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Static Functions
|
||||
//------------------------------------------------------------------
|
||||
static void
|
||||
Initialize();
|
||||
|
||||
static void
|
||||
Terminate();
|
||||
|
||||
static lldb::ABISP
|
||||
CreateInstance (const lldb_private::ArchSpec &arch);
|
||||
|
||||
static lldb_private::ConstString
|
||||
GetPluginNameStatic();
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// PluginInterface protocol
|
||||
//------------------------------------------------------------------
|
||||
lldb_private::ConstString
|
||||
GetPluginName() override;
|
||||
|
||||
uint32_t
|
||||
GetPluginVersion() override;
|
||||
|
||||
protected:
|
||||
private:
|
||||
ABISysV_arm64() :
|
||||
lldb_private::ABI()
|
||||
{
|
||||
// Call CreateInstance instead.
|
||||
}
|
||||
};
|
||||
|
||||
#endif // liblldb_ABISysV_arm64_h_
|
|
@ -0,0 +1,5 @@
|
|||
set(LLVM_NO_RTTI 1)
|
||||
|
||||
add_lldb_library(lldbPluginABISysV_arm64
|
||||
ABISysV_arm64.cpp
|
||||
)
|
|
@ -0,0 +1,14 @@
|
|||
##===- source/Plugins/ABI/SysV-arm64/Makefile ------------*- Makefile -*-===##
|
||||
#
|
||||
# The LLVM Compiler Infrastructure
|
||||
#
|
||||
# This file is distributed under the University of Illinois Open Source
|
||||
# License. See LICENSE.TXT for details.
|
||||
#
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
LLDB_LEVEL := ../../../..
|
||||
LIBRARYNAME := lldbPluginABISysV_arm64
|
||||
BUILD_ARCHIVE = 1
|
||||
|
||||
include $(LLDB_LEVEL)/Makefile
|
|
@ -13,7 +13,7 @@ include $(LLDB_LEVEL)/../../Makefile.config
|
|||
|
||||
|
||||
PARALLEL_DIRS := ABI/MacOSX-arm ABI/MacOSX-arm64 ABI/MacOSX-i386 ABI/SysV-x86_64 \
|
||||
ABI/SysV-arm ABI/SysV-hexagon ABI/SysV-ppc ABI/SysV-ppc64 \
|
||||
ABI/SysV-arm ABI/SysV-arm64 ABI/SysV-hexagon ABI/SysV-ppc ABI/SysV-ppc64 \
|
||||
Disassembler/llvm \
|
||||
ObjectContainer/BSD-Archive ObjectFile/ELF ObjectFile/PECOFF \
|
||||
ObjectContainer/Universal-Mach-O ObjectFile/Mach-O \
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "ThreadElfCore.h"
|
||||
#include "ProcessElfCore.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextLinux_arm.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextLinux_arm64.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h"
|
||||
|
@ -136,6 +137,9 @@ ThreadElfCore::CreateRegisterContextForFrame (StackFrame *frame)
|
|||
case llvm::Triple::arm:
|
||||
reg_interface = new RegisterContextLinux_arm(arch);
|
||||
break;
|
||||
case llvm::Triple::aarch64:
|
||||
reg_interface = new RegisterContextLinux_arm64(arch);
|
||||
break;
|
||||
case llvm::Triple::x86_64:
|
||||
reg_interface = new RegisterContextLinux_x86_64(arch);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue