summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-09-25 13:03:04 +0000
committerPavel Labath <pavel@labath.sk>2019-09-25 13:03:04 +0000
commitd0b44dbefd140949fed7916dc33e19f7c86b2cfd (patch)
tree318a6e9e16ef40497b6e766535ecde4bfa6fc796
parent7f9ac3372ccb85fbe652276d4081c9c64dfb3836 (diff)
Have ABI plugins vend llvm MCRegisterInfo data
Summary: I was recently surprised to learn that there is a total of 2 (two) users of the register info definitions contained in the ABI plugins. Yet, the defitions themselves span nearly 10kLOC. The two users are: - dwarf expression pretty printer - the mechanism for augmenting the register info definitions obtained over gdb-remote protocol (AugmentRegisterInfoViaABI) Both of these uses need the DWARF an EH register numbers, which is information that is already available in LLVM. This patch makes it possible to do so. It adds a GetMCRegisterInfo method to the ABI class, which every class is expected to implement. Normally, it should be sufficient to obtain the definitions from the appropriate llvm::Target object (for which I provide a utility function), but the subclasses are free to construct it in any way they deem fit. We should be able to always get the MCRegisterInfo object from llvm, with one important exception: if the relevant llvm target was disabled at compile time. To handle this, I add a mechanism to disable the compilation of ABI plugins based on the value of LLVM_TARGETS_TO_BUILD cmake setting. This ensures all our existing are able to create their MCRegisterInfo objects. The new MCRegisterInfo api is not used yet, but the intention is to make use of it in follow-up patches. Reviewers: jasonmolenda, aprantl, JDevlieghere, tatyana-krasnukha Subscribers: wuzish, nemanjai, mgorny, kbarton, atanasyan, lldb-commits Differential Revision: https://reviews.llvm.org/D67965 llvm-svn: 372862
-rw-r--r--lldb/include/lldb/Target/ABI.h18
-rw-r--r--lldb/source/API/CMakeLists.txt5
-rw-r--r--lldb/source/API/SystemInitializerFull.cpp57
-rw-r--r--lldb/source/Plugins/ABI/CMakeLists.txt42
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp3
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h4
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp3
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h4
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp3
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp3
-rw-r--r--lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp3
-rw-r--r--lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp3
-rw-r--r--lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp3
-rw-r--r--lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp3
-rw-r--r--lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp3
-rw-r--r--lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp3
-rw-r--r--lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp3
-rw-r--r--lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp2
-rw-r--r--lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h4
-rw-r--r--lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp6
-rw-r--r--lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h4
-rw-r--r--lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp3
-rw-r--r--lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h4
-rw-r--r--lldb/source/Target/ABI.cpp19
-rw-r--r--lldb/tools/lldb-test/CMakeLists.txt5
-rw-r--r--lldb/tools/lldb-test/SystemInitializerTest.cpp60
35 files changed, 230 insertions, 76 deletions
diff --git a/lldb/include/lldb/Target/ABI.h b/lldb/include/lldb/Target/ABI.h
index f254839fc975..93378abc2ac2 100644
--- a/lldb/include/lldb/Target/ABI.h
+++ b/lldb/include/lldb/Target/ABI.h
@@ -15,8 +15,8 @@
#include "lldb/lldb-private.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/MC/MCRegisterInfo.h"
-// forward define the llvm::Type class
namespace llvm {
class Type;
}
@@ -124,6 +124,8 @@ public:
return pc;
}
+ llvm::MCRegisterInfo &GetMCRegisterInfo() { return *m_mc_register_info_up; }
+
virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0;
bool GetRegisterInfoByName(ConstString name, RegisterInfo &info);
@@ -136,13 +138,19 @@ public:
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch);
protected:
- // Classes that inherit from ABI can see and modify these
- ABI(lldb::ProcessSP process_sp) {
- if (process_sp.get())
- m_process_wp = process_sp;
+ ABI(lldb::ProcessSP process_sp, std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : m_process_wp(process_sp), m_mc_register_info_up(std::move(info_up)) {
+ assert(m_mc_register_info_up && "ABI must have MCRegisterInfo");
}
+ /// Utility function to construct a MCRegisterInfo using the ArchSpec triple.
+ /// Plugins wishing to customize the construction can construct the
+ /// MCRegisterInfo themselves.
+ static std::unique_ptr<llvm::MCRegisterInfo>
+ MakeMCRegisterInfo(const ArchSpec &arch);
+
lldb::ProcessWP m_process_wp;
+ std::unique_ptr<llvm::MCRegisterInfo> m_mc_register_info_up;
private:
DISALLOW_COPY_AND_ASSIGN(ABI);
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index d93b8b5e381d..ff42cb3c46f1 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -103,6 +103,11 @@ add_lldb_library(liblldb SHARED
${option_install_prefix}
)
+foreach (t ${LLVM_TARGETS_TO_BUILD})
+ set_property(SOURCE SystemInitializerFull.cpp APPEND PROPERTY
+ COMPILE_DEFINITIONS "LLVM_TARGET_${t}_BUILT")
+endforeach()
+
if (MSVC)
set_source_files_properties(SBReproducer.cpp PROPERTIES COMPILE_FLAGS /bigobj)
endif()
diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp
index e7f2206b9a59..f71dd51db1e5 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -174,20 +174,34 @@ llvm::Error SystemInitializerFull::Initialize() {
ClangASTContext::Initialize();
- ABIMacOSX_i386::Initialize();
- ABIMacOSX_arm::Initialize();
+#ifdef LLVM_TARGET_AArch64_BUILT
ABIMacOSX_arm64::Initialize();
- ABISysV_arm::Initialize();
ABISysV_arm64::Initialize();
+#endif
+#ifdef LLVM_TARGET_ARM_BUILT
+ ABIMacOSX_arm::Initialize();
+ ABISysV_arm::Initialize();
+#endif
+#ifdef LLVM_TARGET_Hexagon_BUILT
ABISysV_hexagon::Initialize();
- ABISysV_i386::Initialize();
- ABISysV_x86_64::Initialize();
- ABISysV_ppc::Initialize();
- ABISysV_ppc64::Initialize();
+#endif
+#ifdef LLVM_TARGET_Mips_BUILT
ABISysV_mips::Initialize();
ABISysV_mips64::Initialize();
+#endif
+#ifdef LLVM_TARGET_PowerPC_BUILT
+ ABISysV_ppc::Initialize();
+ ABISysV_ppc64::Initialize();
+#endif
+#ifdef LLVM_TARGET_SystemZ_BUILT
ABISysV_s390x::Initialize();
+#endif
+#ifdef LLVM_TARGET_X86_BUILT
+ ABIMacOSX_i386::Initialize();
+ ABISysV_i386::Initialize();
+ ABISysV_x86_64::Initialize();
ABIWindows_x86_64::Initialize();
+#endif
ArchitectureArm::Initialize();
ArchitectureMips::Initialize();
@@ -288,20 +302,35 @@ void SystemInitializerFull::Terminate() {
ArchitectureMips::Terminate();
ArchitecturePPC64::Terminate();
- ABIMacOSX_i386::Terminate();
- ABIMacOSX_arm::Terminate();
+#ifdef LLVM_TARGET_AArch64_BUILT
ABIMacOSX_arm64::Terminate();
- ABISysV_arm::Terminate();
ABISysV_arm64::Terminate();
+#endif
+#ifdef LLVM_TARGET_ARM_BUILT
+ ABIMacOSX_arm::Terminate();
+ ABISysV_arm::Terminate();
+#endif
+#ifdef LLVM_TARGET_Hexagon_BUILT
ABISysV_hexagon::Terminate();
- ABISysV_i386::Terminate();
- ABISysV_x86_64::Terminate();
- ABISysV_ppc::Terminate();
- ABISysV_ppc64::Terminate();
+#endif
+#ifdef LLVM_TARGET_Mips_BUILT
ABISysV_mips::Terminate();
ABISysV_mips64::Terminate();
+#endif
+#ifdef LLVM_TARGET_PowerPC_BUILT
+ ABISysV_ppc::Terminate();
+ ABISysV_ppc64::Terminate();
+#endif
+#ifdef LLVM_TARGET_SystemZ_BUILT
ABISysV_s390x::Terminate();
+#endif
+#ifdef LLVM_TARGET_X86_BUILT
+ ABIMacOSX_i386::Terminate();
+ ABISysV_i386::Terminate();
+ ABISysV_x86_64::Terminate();
ABIWindows_x86_64::Terminate();
+#endif
+
DisassemblerLLVMC::Terminate();
JITLoaderGDB::Terminate();
diff --git a/lldb/source/Plugins/ABI/CMakeLists.txt b/lldb/source/Plugins/ABI/CMakeLists.txt
index c88affd80637..3d10f96114be 100644
--- a/lldb/source/Plugins/ABI/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/CMakeLists.txt
@@ -1,14 +1,28 @@
-add_subdirectory(SysV-arm)
-add_subdirectory(SysV-arm64)
-add_subdirectory(SysV-hexagon)
-add_subdirectory(SysV-ppc)
-add_subdirectory(SysV-ppc64)
-add_subdirectory(SysV-mips)
-add_subdirectory(SysV-mips64)
-add_subdirectory(SysV-s390x)
-add_subdirectory(SysV-i386)
-add_subdirectory(SysV-x86_64)
-add_subdirectory(MacOSX-i386)
-add_subdirectory(MacOSX-arm)
-add_subdirectory(MacOSX-arm64)
-add_subdirectory(Windows-x86_64)
+if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
+ add_subdirectory(MacOSX-arm64)
+ add_subdirectory(SysV-arm64)
+endif()
+if ("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
+ add_subdirectory(MacOSX-arm)
+ add_subdirectory(SysV-arm)
+endif()
+if ("Hexagon" IN_LIST LLVM_TARGETS_TO_BUILD)
+ add_subdirectory(SysV-hexagon)
+endif()
+if ("Mips" IN_LIST LLVM_TARGETS_TO_BUILD)
+ add_subdirectory(SysV-mips)
+ add_subdirectory(SysV-mips64)
+endif()
+if ("PowerPC" IN_LIST LLVM_TARGETS_TO_BUILD)
+ add_subdirectory(SysV-ppc)
+ add_subdirectory(SysV-ppc64)
+endif()
+if ("SystemZ" IN_LIST LLVM_TARGETS_TO_BUILD)
+ add_subdirectory(SysV-s390x)
+endif()
+if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
+ add_subdirectory(SysV-i386)
+ add_subdirectory(SysV-x86_64)
+ add_subdirectory(MacOSX-i386)
+ add_subdirectory(Windows-x86_64)
+endif()
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
index f2d01dba69de..9dff12bcc748 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
@@ -1326,7 +1326,8 @@ ABIMacOSX_arm::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
if (vendor_type == llvm::Triple::Apple) {
if ((arch_type == llvm::Triple::arm) ||
(arch_type == llvm::Triple::thumb)) {
- return ABISP(new ABIMacOSX_arm(process_sp));
+ return ABISP(
+ new ABIMacOSX_arm(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
}
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
index ac9ba00b9d91..e512651f86e5 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
+++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
@@ -85,7 +85,9 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
- ABIMacOSX_arm(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABIMacOSX_arm(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
index e5c72bd549b6..a9c57dfdb247 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
@@ -1666,7 +1666,8 @@ ABIMacOSX_arm64::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
if (vendor_type == llvm::Triple::Apple) {
if (arch_type == llvm::Triple::aarch64) {
- return ABISP(new ABIMacOSX_arm64(process_sp));
+ return ABISP(
+ new ABIMacOSX_arm64(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
}
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
index bfacbcd54a94..c7a91ba9c468 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
+++ b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
@@ -93,7 +93,9 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
- ABIMacOSX_arm64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABIMacOSX_arm64(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index adb40cf1e7ea..76ebd6476ffd 100644
--- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -710,7 +710,8 @@ ABIMacOSX_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch)
if ((arch.GetTriple().getArch() == llvm::Triple::x86) &&
(arch.GetTriple().isMacOSX() || arch.GetTriple().isiOS() ||
arch.GetTriple().isWatchOS())) {
- return ABISP(new ABIMacOSX_i386(process_sp));
+ return ABISP(
+ new ABIMacOSX_i386(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
index 57def683283f..50062b84d878 100644
--- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
+++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
@@ -92,7 +92,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABIMacOSX_i386(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABIMacOSX_i386(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
index b0747147bfad..b6e8f8806829 100644
--- a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
+++ b/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
@@ -1327,7 +1327,8 @@ ABISysV_arm::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
if (vendor_type != llvm::Triple::Apple) {
if ((arch_type == llvm::Triple::arm) ||
(arch_type == llvm::Triple::thumb)) {
- return ABISP(new ABISysV_arm(process_sp));
+ return ABISP(
+ new ABISysV_arm(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
}
diff --git a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h b/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
index a0f00c8f227d..60fb14be5f7b 100644
--- a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
+++ b/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
@@ -85,7 +85,9 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
- ABISysV_arm(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_arm(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
index beb54031c64d..781d71c6c05d 100644
--- a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
@@ -1669,7 +1669,8 @@ ABISysV_arm64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch)
if (vendor_type != llvm::Triple::Apple) {
if (arch_type == llvm::Triple::aarch64) {
- return ABISP(new ABISysV_arm64(process_sp));
+ return ABISP(
+ new ABISysV_arm64(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
}
diff --git a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
index 1fbdc793ed6e..1bf5773e2db3 100644
--- a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
+++ b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
@@ -92,7 +92,9 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
- ABISysV_arm64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_arm64(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
index ae836851162b..34d9258ccb92 100644
--- a/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
+++ b/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
@@ -1014,7 +1014,8 @@ size_t ABISysV_hexagon::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_hexagon::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
if (arch.GetTriple().getArch() == llvm::Triple::hexagon) {
- return ABISP(new ABISysV_hexagon(process_sp));
+ return ABISP(
+ new ABISysV_hexagon(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h b/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
index 459b6315dba2..bef64a22d95f 100644
--- a/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
+++ b/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
@@ -97,7 +97,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_hexagon(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_hexagon(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
index 41148b7f4261..69e4cff90ebf 100644
--- a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
+++ b/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
@@ -198,7 +198,8 @@ ABISP
ABISysV_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
if (arch.GetTriple().getVendor() != llvm::Triple::Apple) {
if (arch.GetTriple().getArch() == llvm::Triple::x86) {
- return ABISP(new ABISysV_i386(process_sp));
+ return ABISP(
+ new ABISysV_i386(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
}
return ABISP();
diff --git a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.h b/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
index 982bdd676b74..2362e9adda98 100644
--- a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
+++ b/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
@@ -100,7 +100,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_i386(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_i386(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
index df63a31d198d..416db9f5ae87 100644
--- a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
+++ b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
@@ -556,7 +556,8 @@ ABISysV_mips::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
if ((arch_type == llvm::Triple::mips) ||
(arch_type == llvm::Triple::mipsel)) {
- return ABISP(new ABISysV_mips(process_sp));
+ return ABISP(
+ new ABISysV_mips(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.h b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
index 6cd9c19c22ac..8143f552fc4d 100644
--- a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
+++ b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
@@ -87,7 +87,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_mips(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_mips(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
index 7fb1ea243eac..72ec0715b6cd 100644
--- a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
@@ -554,7 +554,8 @@ size_t ABISysV_mips64::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_mips64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
if (arch.GetTriple().isMIPS64())
- return ABISP(new ABISysV_mips64(process_sp));
+ return ABISP(
+ new ABISysV_mips64(std::move(process_sp), MakeMCRegisterInfo(arch)));
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
index 7da71b36b4b7..76c3c5413b92 100644
--- a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
+++ b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
@@ -100,7 +100,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_mips64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_mips64(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
index e37a6ae046a0..857b7fee10e3 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
+++ b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
@@ -218,7 +218,8 @@ size_t ABISysV_ppc::GetRedZoneSize() const { return 224; }
ABISP
ABISysV_ppc::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
if (arch.GetTriple().getArch() == llvm::Triple::ppc) {
- return ABISP(new ABISysV_ppc(process_sp));
+ return ABISP(
+ new ABISysV_ppc(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
index 3b199852c30d..59907c4648ba 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
+++ b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
@@ -96,7 +96,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_ppc(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_ppc(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
index 92d5f9ce08d8..935353c38ca4 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
@@ -70,7 +70,8 @@ ABISP
ABISysV_ppc64::CreateInstance(lldb::ProcessSP process_sp,
const ArchSpec &arch) {
if (arch.GetTriple().isPPC64())
- return ABISP(new ABISysV_ppc64(process_sp));
+ return ABISP(
+ new ABISysV_ppc64(std::move(process_sp), MakeMCRegisterInfo(arch)));
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
index d5fb09eec0d0..1b58975dd9d9 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
+++ b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
@@ -96,7 +96,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_ppc64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_ppc64(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
diff --git a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
index 227925fd9031..f4f803a8277d 100644
--- a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
+++ b/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
@@ -200,7 +200,7 @@ size_t ABISysV_s390x::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_s390x::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
if (arch.GetTriple().getArch() == llvm::Triple::systemz) {
- return ABISP(new ABISysV_s390x(process_sp));
+ return ABISP(new ABISysV_s390x(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h b/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
index 13df477e84bc..671d6a18260e 100644
--- a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
+++ b/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
@@ -88,7 +88,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_s390x(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_s390x(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index 7370e1107221..bf1c48f778e1 100644
--- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -235,7 +235,8 @@ ABISysV_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch)
case llvm::Triple::EnvironmentType::UnknownEnvironment:
// UnknownEnvironment is needed for older compilers that don't
// support the simulator environment.
- return ABISP(new ABISysV_x86_64(process_sp));
+ return ABISP(new ABISysV_x86_64(std::move(process_sp),
+ MakeMCRegisterInfo(arch)));
default:
return ABISP();
}
@@ -246,7 +247,8 @@ ABISysV_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch)
case llvm::Triple::OSType::NetBSD:
case llvm::Triple::OSType::Solaris:
case llvm::Triple::OSType::UnknownOS:
- return ABISP(new ABISysV_x86_64(process_sp));
+ return ABISP(
+ new ABISysV_x86_64(std::move(process_sp), MakeMCRegisterInfo(arch)));
default:
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
index f6704aff348c..d445d8f4142a 100644
--- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
+++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
@@ -98,7 +98,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_x86_64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABISysV_x86_64(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp b/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
index fdd10a602099..ac24426914e1 100644
--- a/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
@@ -1092,7 +1092,8 @@ ABISP
ABIWindows_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
if (arch.GetTriple().getArch() == llvm::Triple::x86_64 &&
arch.GetTriple().isOSWindows()) {
- return ABISP(new ABIWindows_x86_64(process_sp));
+ return ABISP(
+ new ABIWindows_x86_64(std::move(process_sp), MakeMCRegisterInfo(arch)));
}
return ABISP();
}
diff --git a/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h b/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
index 9f6b2ceef299..2366566d7809 100644
--- a/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
+++ b/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
@@ -91,7 +91,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABIWindows_x86_64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ ABIWindows_x86_64(lldb::ProcessSP process_sp,
+ std::unique_ptr<llvm::MCRegisterInfo> info_up)
+ : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
// Call CreateInstance instead.
}
};
diff --git a/lldb/source/Target/ABI.cpp b/lldb/source/Target/ABI.cpp
index 28cd9aec665c..005261e0ddee 100644
--- a/lldb/source/Target/ABI.cpp
+++ b/lldb/source/Target/ABI.cpp
@@ -15,6 +15,8 @@
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/TargetRegistry.h"
using namespace lldb;
using namespace lldb_private;
@@ -210,3 +212,20 @@ bool ABI::GetFallbackRegisterLocation(
return false;
}
+
+std::unique_ptr<llvm::MCRegisterInfo> ABI::MakeMCRegisterInfo(const ArchSpec &arch) {
+ std::string triple = arch.GetTriple().getTriple();
+ std::string lookup_error;
+ const llvm::Target *target =
+ llvm::TargetRegistry::lookupTarget(triple, lookup_error);
+ if (!target) {
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS),
+ "Failed to create an llvm target for {0}: {1}", triple,
+ lookup_error);
+ return nullptr;
+ }
+ std::unique_ptr<llvm::MCRegisterInfo> info_up(
+ target->createMCRegInfo(triple));
+ assert(info_up);
+ return info_up;
+}
diff --git a/lldb/tools/lldb-test/CMakeLists.txt b/lldb/tools/lldb-test/CMakeLists.txt
index 2ab1ceacdcd1..df9d0437bb7b 100644
--- a/lldb/tools/lldb-test/CMakeLists.txt
+++ b/lldb/tools/lldb-test/CMakeLists.txt
@@ -24,4 +24,9 @@ add_lldb_tool(lldb-test
Support
)
+foreach (t ${LLVM_TARGETS_TO_BUILD})
+ set_property(SOURCE SystemInitializerTest.cpp APPEND PROPERTY
+ COMPILE_DEFINITIONS "LLVM_TARGET_${t}_BUILT")
+endforeach()
+
include_directories(${LLDB_SOURCE_DIR}/source)
diff --git a/lldb/tools/lldb-test/SystemInitializerTest.cpp b/lldb/tools/lldb-test/SystemInitializerTest.cpp
index 44b960cca101..51ffb6b382dc 100644
--- a/lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ b/lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -28,6 +28,7 @@
#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
#include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h"
#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
+#include "Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h"
#include "Plugins/Architecture/Arm/ArchitectureArm.h"
#include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
@@ -144,19 +145,34 @@ llvm::Error SystemInitializerTest::Initialize() {
ClangASTContext::Initialize();
- ABIMacOSX_i386::Initialize();
- ABIMacOSX_arm::Initialize();
+#ifdef LLVM_TARGET_AArch64_BUILT
ABIMacOSX_arm64::Initialize();
- ABISysV_arm::Initialize();
ABISysV_arm64::Initialize();
+#endif
+#ifdef LLVM_TARGET_ARM_BUILT
+ ABIMacOSX_arm::Initialize();
+ ABISysV_arm::Initialize();
+#endif
+#ifdef LLVM_TARGET_Hexagon_BUILT
ABISysV_hexagon::Initialize();
- ABISysV_i386::Initialize();
- ABISysV_x86_64::Initialize();
- ABISysV_ppc::Initialize();
- ABISysV_ppc64::Initialize();
+#endif
+#ifdef LLVM_TARGET_Mips_BUILT
ABISysV_mips::Initialize();
ABISysV_mips64::Initialize();
+#endif
+#ifdef LLVM_TARGET_PowerPC_BUILT
+ ABISysV_ppc::Initialize();
+ ABISysV_ppc64::Initialize();
+#endif
+#ifdef LLVM_TARGET_SystemZ_BUILT
ABISysV_s390x::Initialize();
+#endif
+#ifdef LLVM_TARGET_X86_BUILT
+ ABIMacOSX_i386::Initialize();
+ ABISysV_i386::Initialize();
+ ABISysV_x86_64::Initialize();
+ ABIWindows_x86_64::Initialize();
+#endif
ArchitectureArm::Initialize();
ArchitecturePPC64::Initialize();
@@ -246,19 +262,35 @@ void SystemInitializerTest::Terminate() {
ClangASTContext::Terminate();
- ABIMacOSX_i386::Terminate();
- ABIMacOSX_arm::Terminate();
+#ifdef LLVM_TARGET_AArch64_BUILT
ABIMacOSX_arm64::Terminate();
- ABISysV_arm::Terminate();
ABISysV_arm64::Terminate();
+#endif
+#ifdef LLVM_TARGET_ARM_BUILT
+ ABIMacOSX_arm::Terminate();
+ ABISysV_arm::Terminate();
+#endif
+#ifdef LLVM_TARGET_Hexagon_BUILT
ABISysV_hexagon::Terminate();
- ABISysV_i386::Terminate();
- ABISysV_x86_64::Terminate();
- ABISysV_ppc::Terminate();
- ABISysV_ppc64::Terminate();
+#endif
+#ifdef LLVM_TARGET_Mips_BUILT
ABISysV_mips::Terminate();
ABISysV_mips64::Terminate();
+#endif
+#ifdef LLVM_TARGET_PowerPC_BUILT
+ ABISysV_ppc::Terminate();
+ ABISysV_ppc64::Terminate();
+#endif
+#ifdef LLVM_TARGET_SystemZ_BUILT
ABISysV_s390x::Terminate();
+#endif
+#ifdef LLVM_TARGET_X86_BUILT
+ ABIMacOSX_i386::Terminate();
+ ABISysV_i386::Terminate();
+ ABISysV_x86_64::Terminate();
+ ABIWindows_x86_64::Terminate();
+#endif
+
DisassemblerLLVMC::Terminate();
JITLoaderGDB::Terminate();