JDevlieghere created this revision. JDevlieghere added a reviewer: LLDB. Herald added subscribers: jdoerfert, MaskRay, arichardson, mgorny, emaste. Herald added a reviewer: espindola. Herald added a project: LLDB.
Yesterday I stumbled upon the initialization code for the "Kalimba" platform. It looks like this was added in 2014 and never had any tests. If nobody is relying on this platform, I propose to remove it. Repository: rLLDB LLDB https://reviews.llvm.org/D59850 Files: lldb/include/lldb/Utility/ArchSpec.h lldb/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py lldb/source/API/SystemInitializerFull.cpp lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Plugins/Platform/CMakeLists.txt lldb/source/Plugins/Platform/Kalimba/CMakeLists.txt lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.h lldb/source/Utility/ArchSpec.cpp lldb/tools/lldb-test/SystemInitializerTest.cpp
Index: lldb/tools/lldb-test/SystemInitializerTest.cpp =================================================================== --- lldb/tools/lldb-test/SystemInitializerTest.cpp +++ lldb/tools/lldb-test/SystemInitializerTest.cpp @@ -57,7 +57,6 @@ #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" #include "Plugins/Platform/Android/PlatformAndroid.h" #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" -#include "Plugins/Platform/Kalimba/PlatformKalimba.h" #include "Plugins/Platform/Linux/PlatformLinux.h" #include "Plugins/Platform/MacOSX/PlatformMacOSX.h" #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" @@ -129,7 +128,6 @@ platform_netbsd::PlatformNetBSD::Initialize(); platform_openbsd::PlatformOpenBSD::Initialize(); PlatformWindows::Initialize(); - PlatformKalimba::Initialize(); platform_android::PlatformAndroid::Initialize(); PlatformRemoteiOS::Initialize(); PlatformMacOSX::Initialize(); @@ -325,7 +323,6 @@ platform_netbsd::PlatformNetBSD::Terminate(); platform_openbsd::PlatformOpenBSD::Terminate(); PlatformWindows::Terminate(); - PlatformKalimba::Terminate(); platform_android::PlatformAndroid::Terminate(); PlatformMacOSX::Terminate(); PlatformRemoteiOS::Terminate(); Index: lldb/source/Utility/ArchSpec.cpp =================================================================== --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -214,13 +214,7 @@ ArchSpec::eCore_uknownMach32, "unknown-mach-32"}, {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch, ArchSpec::eCore_uknownMach64, "unknown-mach-64"}, - - {eByteOrderBig, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba3, - "kalimba3"}, - {eByteOrderLittle, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba4, - "kalimba4"}, - {eByteOrderLittle, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba5, - "kalimba5"}}; +}; // Ensure that we have an entry in the g_core_definitions for each core. If you // comment out an entry above, you will need to comment out the corresponding @@ -452,12 +446,6 @@ ArchSpec::eMIPSSubType_mips64r6el, 0xFFFFFFFFu, 0xFFFFFFFFu}, // mips64r6el {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}, // HEXAGON - {ArchSpec::eCore_kalimba3, llvm::ELF::EM_CSR_KALIMBA, - llvm::Triple::KalimbaSubArch_v3, 0xFFFFFFFFu, 0xFFFFFFFFu}, // KALIMBA - {ArchSpec::eCore_kalimba4, llvm::ELF::EM_CSR_KALIMBA, - llvm::Triple::KalimbaSubArch_v4, 0xFFFFFFFFu, 0xFFFFFFFFu}, // KALIMBA - {ArchSpec::eCore_kalimba5, llvm::ELF::EM_CSR_KALIMBA, - llvm::Triple::KalimbaSubArch_v5, 0xFFFFFFFFu, 0xFFFFFFFFu} // KALIMBA }; static const ArchDefinition g_elf_arch_def = { @@ -728,30 +716,10 @@ } uint32_t ArchSpec::GetDataByteSize() const { - switch (m_core) { - case eCore_kalimba3: - return 4; - case eCore_kalimba4: - return 1; - case eCore_kalimba5: - return 4; - default: - return 1; - } return 1; } uint32_t ArchSpec::GetCodeByteSize() const { - switch (m_core) { - case eCore_kalimba3: - return 4; - case eCore_kalimba4: - return 1; - case eCore_kalimba5: - return 1; - default: - return 1; - } return 1; } @@ -942,13 +910,13 @@ m_triple.setVendor(llvm::Triple::Apple); // Don't set the OS. It could be simulator, macosx, ios, watchos, - // tvos, bridgeos. We could get close with the cpu type - but we - // can't get it right all of the time. Better to leave this unset - // so other sections of code will set it when they have more - // information. NB: don't call m_triple.setOS (llvm::Triple::UnknownOS). - // That sets the OSName to "unknown" and the - // ArchSpec::TripleVendorWasSpecified() method says that any OSName - // setting means it was specified. + // tvos, bridgeos. We could get close with the cpu type - but we + // can't get it right all of the time. Better to leave this unset + // so other sections of code will set it when they have more + // information. NB: don't call m_triple.setOS + // (llvm::Triple::UnknownOS). That sets the OSName to "unknown" and + // the ArchSpec::TripleVendorWasSpecified() method says that any + // OSName setting means it was specified. } else if (arch_type == eArchTypeELF) { switch (os) { case llvm::ELF::ELFOSABI_AIX: Index: lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.h =================================================================== --- lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.h +++ /dev/null @@ -1,78 +0,0 @@ -//===-- PlatformKalimba.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_PlatformKalimba_h_ -#define liblldb_PlatformKalimba_h_ - -#include "lldb/Target/Platform.h" - -namespace lldb_private { - -class PlatformKalimba : public Platform { -public: - PlatformKalimba(bool is_host); - - ~PlatformKalimba() override; - - static void Initialize(); - - static void Terminate(); - - //------------------------------------------------------------ - // lldb_private::PluginInterface functions - //------------------------------------------------------------ - static lldb::PlatformSP CreateInstance(bool force, - const lldb_private::ArchSpec *arch); - - static lldb_private::ConstString GetPluginNameStatic(bool is_host); - - static const char *GetPluginDescriptionStatic(bool is_host); - - lldb_private::ConstString GetPluginName() override; - - uint32_t GetPluginVersion() override { return 1; } - - //------------------------------------------------------------ - // lldb_private::Platform functions - //------------------------------------------------------------ - const char *GetDescription() override { - return GetPluginDescriptionStatic(IsHost()); - } - - void GetStatus(Stream &strm) override; - - bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override; - - size_t GetSoftwareBreakpointTrapOpcode(Target &target, - BreakpointSite *bp_site) override; - - lldb_private::Status - LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override; - - lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, - Target *target, Status &error) override; - - // Kalimba processes can not be launched by spawning and attaching. - bool CanDebugProcess() override { return false; } - - void CalculateTrapHandlerSymbolNames() override; - - UserIDResolver &GetUserIDResolver() override { - return UserIDResolver::GetNoopResolver(); - } - -protected: - lldb::PlatformSP m_remote_platform_sp; - -private: - DISALLOW_COPY_AND_ASSIGN(PlatformKalimba); -}; - -} // namespace lldb_private - -#endif // liblldb_PlatformKalimba_h_ Index: lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp =================================================================== --- lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp +++ /dev/null @@ -1,153 +0,0 @@ -//===-- PlatformKalimba.cpp ---------------------------------------*- C++ -//-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "PlatformKalimba.h" -#include "lldb/Host/Config.h" - -#include "lldb/Core/Debugger.h" -#include "lldb/Core/Module.h" -#include "lldb/Core/ModuleList.h" -#include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Host/HostInfo.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Status.h" -#include "lldb/Utility/StreamString.h" - -using namespace lldb; -using namespace lldb_private; - -static uint32_t g_initialize_count = 0; - -PlatformSP PlatformKalimba::CreateInstance(bool force, const ArchSpec *arch) { - bool create = force; - if (!create && arch && arch->IsValid()) { - const llvm::Triple &triple = arch->GetTriple(); - switch (triple.getVendor()) { - case llvm::Triple::CSR: - create = true; - break; - - default: - break; - } - } - if (create) - return PlatformSP(new PlatformKalimba(false)); - return PlatformSP(); -} - -lldb_private::ConstString -PlatformKalimba::GetPluginNameStatic(bool /*is_host*/) { - static ConstString g_remote_name("kalimba"); - return g_remote_name; -} - -const char *PlatformKalimba::GetPluginDescriptionStatic(bool /*is_host*/) { - return "Kalimba user platform plug-in."; -} - -lldb_private::ConstString PlatformKalimba::GetPluginName() { - return GetPluginNameStatic(false); -} - -void PlatformKalimba::Initialize() { - Platform::Initialize(); - - if (g_initialize_count++ == 0) { - PluginManager::RegisterPlugin( - PlatformKalimba::GetPluginNameStatic(false), - PlatformKalimba::GetPluginDescriptionStatic(false), - PlatformKalimba::CreateInstance); - } -} - -void PlatformKalimba::Terminate() { - if (g_initialize_count > 0) { - if (--g_initialize_count == 0) { - PluginManager::UnregisterPlugin(PlatformKalimba::CreateInstance); - } - } - - Platform::Terminate(); -} - -//------------------------------------------------------------------ -/// Default Constructor -//------------------------------------------------------------------ -PlatformKalimba::PlatformKalimba(bool is_host) - : Platform(is_host), // This is the local host platform - m_remote_platform_sp() {} - -//------------------------------------------------------------------ -/// Destructor. -/// -/// The destructor is virtual since this class is designed to be -/// inherited from by the plug-in instance. -//------------------------------------------------------------------ -PlatformKalimba::~PlatformKalimba() {} - -bool PlatformKalimba::GetSupportedArchitectureAtIndex(uint32_t idx, - ArchSpec &arch) { - if (idx == 0) { - arch = ArchSpec("kalimba3-csr-unknown"); - return true; - } - if (idx == 1) { - arch = ArchSpec("kalimba4-csr-unknown"); - return true; - } - if (idx == 2) { - arch = ArchSpec("kalimba5-csr-unknown"); - return true; - } - return false; -} - -void PlatformKalimba::GetStatus(Stream &strm) { Platform::GetStatus(strm); } - -size_t -PlatformKalimba::GetSoftwareBreakpointTrapOpcode(Target & /*target*/, - BreakpointSite * /*bp_site*/) { - // the target hardware does not support software breakpoints - return 0; -} - -Status PlatformKalimba::LaunchProcess(ProcessLaunchInfo &launch_info) { - Status error; - - if (IsHost()) { - error.SetErrorString("native execution is not possible"); - } else { - error.SetErrorString("the platform is not currently connected"); - } - return error; -} - -lldb::ProcessSP PlatformKalimba::Attach(ProcessAttachInfo &attach_info, - Debugger &debugger, Target *target, - Status &error) { - lldb::ProcessSP process_sp; - if (IsHost()) { - error.SetErrorString("native execution is not possible"); - } else { - if (m_remote_platform_sp) - process_sp = - m_remote_platform_sp->Attach(attach_info, debugger, target, error); - else - error.SetErrorString("the platform is not currently connected"); - } - return process_sp; -} - -void PlatformKalimba::CalculateTrapHandlerSymbolNames() { - // TODO Research this sometime. -} Index: lldb/source/Plugins/Platform/Kalimba/CMakeLists.txt =================================================================== --- lldb/source/Plugins/Platform/Kalimba/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -add_lldb_library(lldbPluginPlatformKalimba PLUGIN - PlatformKalimba.cpp - - LINK_LIBS - lldbCore - lldbHost - lldbTarget - ) Index: lldb/source/Plugins/Platform/CMakeLists.txt =================================================================== --- lldb/source/Plugins/Platform/CMakeLists.txt +++ lldb/source/Plugins/Platform/CMakeLists.txt @@ -14,5 +14,4 @@ add_subdirectory(POSIX) add_subdirectory(gdb-server) -add_subdirectory(Kalimba) add_subdirectory(Android) Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -57,7 +57,6 @@ const char *const LLDB_NT_OWNER_NETBSD = "NetBSD"; const char *const LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE"; const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD"; -const char *const LLDB_NT_OWNER_CSR = "csr"; const char *const LLDB_NT_OWNER_ANDROID = "Android"; const char *const LLDB_NT_OWNER_CORE = "CORE"; const char *const LLDB_NT_OWNER_LINUX = "LINUX"; @@ -274,27 +273,6 @@ return true; } -static uint32_t kalimbaVariantFromElfFlags(const elf::elf_word e_flags) { - const uint32_t dsp_rev = e_flags & 0xFF; - uint32_t kal_arch_variant = LLDB_INVALID_CPUTYPE; - switch (dsp_rev) { - // TODO(mg11) Support more variants - case 10: - kal_arch_variant = llvm::Triple::KalimbaSubArch_v3; - break; - case 14: - kal_arch_variant = llvm::Triple::KalimbaSubArch_v4; - break; - case 17: - case 20: - kal_arch_variant = llvm::Triple::KalimbaSubArch_v5; - break; - default: - break; - } - return kal_arch_variant; -} - static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) { const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH; uint32_t endian = header.e_ident[EI_DATA]; @@ -352,32 +330,7 @@ if (header.e_machine == llvm::ELF::EM_MIPS) return mipsVariantFromElfFlags(header); - return llvm::ELF::EM_CSR_KALIMBA == header.e_machine - ? kalimbaVariantFromElfFlags(header.e_flags) - : LLDB_INVALID_CPUTYPE; -} - -//! The kalimba toolchain identifies a code section as being -//! one with the SHT_PROGBITS set in the section sh_type and the top -//! bit in the 32-bit address field set. -static lldb::SectionType -kalimbaSectionType(const elf::ELFHeader &header, - const elf::ELFSectionHeader §_hdr) { - if (llvm::ELF::EM_CSR_KALIMBA != header.e_machine) { - return eSectionTypeOther; - } - - if (llvm::ELF::SHT_NOBITS == sect_hdr.sh_type) { - return eSectionTypeZeroFill; - } - - if (llvm::ELF::SHT_PROGBITS == sect_hdr.sh_type) { - const lldb::addr_t KAL_CODE_BIT = 1 << 31; - return KAL_CODE_BIT & sect_hdr.sh_addr ? eSectionTypeCode - : eSectionTypeData; - } - - return eSectionTypeOther; + return LLDB_INVALID_CPUTYPE; } // Arbitrary constant used as UUID prefix for core files. @@ -1336,21 +1289,6 @@ // Set the elf OS version to OpenBSD. Also clear the vendor. arch_spec.GetTriple().setOS(llvm::Triple::OSType::OpenBSD); arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor); - } - // Process CSR kalimba notes - else if ((note.n_type == LLDB_NT_GNU_ABI_TAG) && - (note.n_name == LLDB_NT_OWNER_CSR)) { - arch_spec.GetTriple().setOS(llvm::Triple::OSType::UnknownOS); - arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::CSR); - - // TODO At some point the description string could be processed. - // It could provide a steer towards the kalimba variant which this ELF - // targets. - if (note.n_descsz) { - const char *cstr = - data.GetCStr(&offset, llvm::alignTo(note.n_descsz, 4)); - (void)cstr; - } } else if (note.n_name == LLDB_NT_OWNER_ANDROID) { arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); arch_spec.GetTriple().setEnvironment( @@ -1808,14 +1746,7 @@ case SHT_DYNAMIC: return eSectionTypeELFDynamicLinkInfo; } - SectionType Type = GetSectionTypeFromName(H.section_name.GetStringRef()); - if (Type == eSectionTypeOther) { - // the kalimba toolchain assumes that ELF section names are free-form. - // It does support linkscripts which (can) give rise to various - // arbitrarily named sections being "Code" or "Data". - Type = kalimbaSectionType(m_header, H); - } - return Type; + return GetSectionTypeFromName(H.section_name.GetStringRef()); } static uint32_t GetTargetByteSize(SectionType Type, const ArchSpec &arch) { Index: lldb/source/API/SystemInitializerFull.cpp =================================================================== --- lldb/source/API/SystemInitializerFull.cpp +++ lldb/source/API/SystemInitializerFull.cpp @@ -69,7 +69,6 @@ #include "Plugins/OperatingSystem/Python/OperatingSystemPython.h" #include "Plugins/Platform/Android/PlatformAndroid.h" #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" -#include "Plugins/Platform/Kalimba/PlatformKalimba.h" #include "Plugins/Platform/Linux/PlatformLinux.h" #include "Plugins/Platform/MacOSX/PlatformMacOSX.h" #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" @@ -150,7 +149,6 @@ platform_netbsd::PlatformNetBSD::Initialize(); platform_openbsd::PlatformOpenBSD::Initialize(); PlatformWindows::Initialize(); - PlatformKalimba::Initialize(); platform_android::PlatformAndroid::Initialize(); PlatformRemoteiOS::Initialize(); PlatformMacOSX::Initialize(); @@ -356,7 +354,6 @@ platform_netbsd::PlatformNetBSD::Terminate(); platform_openbsd::PlatformOpenBSD::Terminate(); PlatformWindows::Terminate(); - PlatformKalimba::Terminate(); platform_android::PlatformAndroid::Terminate(); PlatformMacOSX::Terminate(); PlatformRemoteiOS::Terminate(); Index: lldb/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py =================================================================== --- lldb/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py +++ lldb/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py @@ -30,8 +30,6 @@ "hello-netbsd-6.1-x86_64-gcc-4.5.3": re.compile(r"x86_64-(\*)?-netbsd6.1.4(-unknown)? x86_64"), "hello-ubuntu-14.04-x86_64-gcc-4.8.2": re.compile(r"x86_64-(\*)?-linux(-unknown)? x86_64"), "hello-ubuntu-14.04-x86_64-clang-3.5pre": re.compile(r"x86_64-(\*)?-linux(-unknown)? x86_64"), - "hello-unknown-kalimba_arch4-kcc-36": re.compile(r"kalimba4-csr-(unknown|\*)(-unknown)? kalimba"), - "hello-unknown-kalimba_arch5-kcc-39": re.compile(r"kalimba5-csr-(unknown|\*)(-unknown)? kalimba"), } for image_name in images: Index: lldb/include/lldb/Utility/ArchSpec.h =================================================================== --- lldb/include/lldb/Utility/ArchSpec.h +++ lldb/include/lldb/Utility/ArchSpec.h @@ -185,10 +185,6 @@ eCore_uknownMach32, eCore_uknownMach64, - eCore_kalimba3, - eCore_kalimba4, - eCore_kalimba5, - kNumCores, kCore_invalid, @@ -222,9 +218,6 @@ kCore_hexagon_first = eCore_hexagon_generic, kCore_hexagon_last = eCore_hexagon_hexagonv5, - kCore_kalimba_first = eCore_kalimba3, - kCore_kalimba_last = eCore_kalimba5, - kCore_mips32_first = eCore_mips32, kCore_mips32_last = eCore_mips32r6,
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits