Index: lldb/trunk/include/lldb/Target/ABI.h =================================================================== --- lldb/trunk/include/lldb/Target/ABI.h +++ lldb/trunk/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 @@ 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 @@ 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 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 + MakeMCRegisterInfo(const ArchSpec &arch); + lldb::ProcessWP m_process_wp; + std::unique_ptr m_mc_register_info_up; private: DISALLOW_COPY_AND_ASSIGN(ABI); Index: lldb/trunk/source/API/CMakeLists.txt =================================================================== --- lldb/trunk/source/API/CMakeLists.txt +++ lldb/trunk/source/API/CMakeLists.txt @@ -103,6 +103,11 @@ ${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() Index: lldb/trunk/source/API/SystemInitializerFull.cpp =================================================================== --- lldb/trunk/source/API/SystemInitializerFull.cpp +++ lldb/trunk/source/API/SystemInitializerFull.cpp @@ -174,20 +174,34 @@ 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 @@ 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(); Index: lldb/trunk/source/Plugins/ABI/CMakeLists.txt =================================================================== --- lldb/trunk/source/Plugins/ABI/CMakeLists.txt +++ lldb/trunk/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() Index: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h @@ -85,7 +85,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -1326,7 +1326,8 @@ 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))); } } Index: lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h @@ -93,7 +93,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -1666,7 +1666,8 @@ 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))); } } Index: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h @@ -92,7 +92,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -710,7 +710,8 @@ 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(); } Index: lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.h +++ lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.h @@ -85,7 +85,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -1327,7 +1327,8 @@ 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))); } } Index: lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h +++ lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h @@ -92,7 +92,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -1669,7 +1669,8 @@ 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))); } } Index: lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h +++ lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h @@ -97,7 +97,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp @@ -1014,7 +1014,8 @@ 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(); } Index: lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.h +++ lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.h @@ -100,7 +100,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -198,7 +198,8 @@ 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(); Index: lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.h +++ lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.h @@ -87,7 +87,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -556,7 +556,8 @@ 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(); } Index: lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h +++ lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h @@ -100,7 +100,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -554,7 +554,8 @@ 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(); } Index: lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h +++ lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h @@ -96,7 +96,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -218,7 +218,8 @@ 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(); } Index: lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h +++ lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h @@ -96,7 +96,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } Index: lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -70,7 +70,8 @@ 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(); } Index: lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h +++ lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h @@ -88,7 +88,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp @@ -200,7 +200,7 @@ 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(); } Index: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h @@ -98,7 +98,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -235,7 +235,8 @@ 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 @@ 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(); } Index: lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h =================================================================== --- lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h +++ lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h @@ -91,7 +91,9 @@ 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 info_up) + : lldb_private::ABI(std::move(process_sp), std::move(info_up)) { // Call CreateInstance instead. } }; Index: lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp +++ lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp @@ -1092,7 +1092,8 @@ 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(); } Index: lldb/trunk/source/Target/ABI.cpp =================================================================== --- lldb/trunk/source/Target/ABI.cpp +++ lldb/trunk/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 @@ return false; } + +std::unique_ptr 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 info_up( + target->createMCRegInfo(triple)); + assert(info_up); + return info_up; +} Index: lldb/trunk/tools/lldb-test/CMakeLists.txt =================================================================== --- lldb/trunk/tools/lldb-test/CMakeLists.txt +++ lldb/trunk/tools/lldb-test/CMakeLists.txt @@ -24,4 +24,9 @@ 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) Index: lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp =================================================================== --- lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp +++ lldb/trunk/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 @@ 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 @@ 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();