diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -619,10 +619,12 @@ return 1; } - virtual const lldb::UnixSignalsSP &GetRemoteUnixSignals(); + virtual lldb::UnixSignalsSP GetRemoteUnixSignals(); lldb::UnixSignalsSP GetUnixSignals(); + virtual lldb::UnixSignalsSP CreateUnixSignals() = 0; + /// Locate a queue name given a thread's qaddr /// /// On a system using libdispatch ("Grand Central Dispatch") style queues, a diff --git a/lldb/include/lldb/Target/UnixSignals.h b/lldb/include/lldb/Target/UnixSignals.h --- a/lldb/include/lldb/Target/UnixSignals.h +++ b/lldb/include/lldb/Target/UnixSignals.h @@ -22,7 +22,6 @@ class UnixSignals { public: - static lldb::UnixSignalsSP Create(const ArchSpec &arch); static lldb::UnixSignalsSP CreateForHost(); // Constructors and Destructors diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt @@ -19,6 +19,7 @@ lldbUtility lldbPluginExpressionParserClang lldbPluginCPPRuntime + lldbPluginProcessUtility lldbPluginTypeSystemClang CLANG_LIBS clangAST diff --git a/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt b/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt --- a/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt +++ b/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt @@ -1,4 +1,5 @@ add_lldb_library(lldbPluginPlatformFreeBSD PLUGIN + FreeBSDSignals.cpp PlatformFreeBSD.cpp LINK_LIBS diff --git a/lldb/source/Plugins/Process/Utility/FreeBSDSignals.h b/lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.h rename from lldb/source/Plugins/Process/Utility/FreeBSDSignals.h rename to lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.h diff --git a/lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp b/lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.cpp rename from lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp rename to lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.cpp diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -59,6 +59,8 @@ std::vector m_supported_architectures; + lldb::UnixSignalsSP CreateUnixSignals() override; + private: std::mutex m_mutex; std::shared_ptr m_type_system; diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "PlatformFreeBSD.h" +#include "FreeBSDSignals.h" #include "lldb/Host/Config.h" #include @@ -282,3 +283,7 @@ ast->CompleteTagDeclarationDefinition(siginfo_type); return siginfo_type; } + +lldb::UnixSignalsSP PlatformFreeBSD::CreateUnixSignals() { + return std::make_shared(); +} diff --git a/lldb/source/Plugins/Platform/Linux/CMakeLists.txt b/lldb/source/Plugins/Platform/Linux/CMakeLists.txt --- a/lldb/source/Plugins/Platform/Linux/CMakeLists.txt +++ b/lldb/source/Plugins/Platform/Linux/CMakeLists.txt @@ -1,4 +1,5 @@ add_lldb_library(lldbPluginPlatformLinux PLUGIN + LinuxSignals.cpp PlatformLinux.cpp LINK_LIBS diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.h b/lldb/source/Plugins/Platform/Linux/LinuxSignals.h rename from lldb/source/Plugins/Process/Utility/LinuxSignals.h rename to lldb/source/Plugins/Platform/Linux/LinuxSignals.h diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp b/lldb/source/Plugins/Platform/Linux/LinuxSignals.cpp rename from lldb/source/Plugins/Process/Utility/LinuxSignals.cpp rename to lldb/source/Plugins/Platform/Linux/LinuxSignals.cpp diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h @@ -64,6 +64,8 @@ std::vector m_supported_architectures; + lldb::UnixSignalsSP CreateUnixSignals() override; + private: std::mutex m_mutex; std::shared_ptr m_type_system; diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "PlatformLinux.h" +#include "LinuxSignals.h" #include "lldb/Host/Config.h" #include @@ -480,3 +481,7 @@ ast->CompleteTagDeclarationDefinition(siginfo_type); return siginfo_type; } + +lldb::UnixSignalsSP PlatformLinux::CreateUnixSignals() { + return std::make_shared(); +} diff --git a/lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt b/lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt --- a/lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt +++ b/lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt @@ -1,4 +1,5 @@ add_lldb_library(lldbPluginPlatformNetBSD PLUGIN + NetBSDSignals.cpp PlatformNetBSD.cpp LINK_LIBS diff --git a/lldb/source/Plugins/Process/Utility/NetBSDSignals.h b/lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.h rename from lldb/source/Plugins/Process/Utility/NetBSDSignals.h rename to lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.h diff --git a/lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp b/lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.cpp rename from lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp rename to lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.cpp diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h @@ -61,6 +61,8 @@ std::vector m_supported_architectures; + lldb::UnixSignalsSP CreateUnixSignals() override; + private: std::mutex m_mutex; std::shared_ptr m_type_system; diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "PlatformNetBSD.h" +#include "NetBSDSignals.h" #include "lldb/Host/Config.h" #include @@ -348,3 +349,7 @@ ast->CompleteTagDeclarationDefinition(siginfo_type); return siginfo_type; } + +lldb::UnixSignalsSP PlatformNetBSD::CreateUnixSignals() { + return std::make_shared(); +} diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h @@ -35,7 +35,7 @@ GetFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination) override; - const lldb::UnixSignalsSP &GetRemoteUnixSignals() override; + lldb::UnixSignalsSP GetRemoteUnixSignals() override; lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, @@ -69,6 +69,8 @@ lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override; + lldb::UnixSignalsSP CreateUnixSignals() override; + protected: std::unique_ptr m_option_group_platform_rsync; diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -27,6 +27,7 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" +#include "lldb/Target/UnixSignals.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/LLDBLog.h" @@ -294,9 +295,13 @@ return ""; } -const lldb::UnixSignalsSP &PlatformPOSIX::GetRemoteUnixSignals() { - if (IsRemote() && m_remote_platform_sp) - return m_remote_platform_sp->GetRemoteUnixSignals(); +lldb::UnixSignalsSP PlatformPOSIX::GetRemoteUnixSignals() { + if (IsRemote() && m_remote_platform_sp) { + if (auto unix_signals_sp = m_remote_platform_sp->GetRemoteUnixSignals()) + return unix_signals_sp; + } + if (auto unix_signals_sp = CreateUnixSignals()) + return unix_signals_sp; return Platform::GetRemoteUnixSignals(); } @@ -989,3 +994,7 @@ stream.Printf("lib%s.so", basename.GetCString()); return ConstString(stream.GetString()); } + +lldb::UnixSignalsSP PlatformPOSIX::CreateUnixSignals() { + return std::make_shared(); +} diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h @@ -69,6 +69,12 @@ arch, addr, length, prot, flags, fd, offset); } + lldb::UnixSignalsSP CreateUnixSignals() override { + // PlatformQemuUser shouldn't create its own UnixSignals. It should defer to + // other platforms. + return lldb::UnixSignalsSP(); + } + private: static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); static void DebuggerInitialize(Debugger &debugger); diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h @@ -82,6 +82,10 @@ std::vector m_supported_architectures; + lldb::UnixSignalsSP CreateUnixSignals() override { + return lldb::UnixSignalsSP(); + } + private: std::unique_ptr MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &context, diff --git a/lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt b/lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt --- a/lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt +++ b/lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt @@ -1,4 +1,5 @@ add_lldb_library(lldbPluginPlatformGDB PLUGIN + GDBRemoteSignals.cpp PlatformRemoteGDBServer.cpp LINK_LIBS @@ -6,6 +7,5 @@ lldbCore lldbHost lldbTarget - lldbPluginProcessUtility lldbPluginProcessGDBRemote ) diff --git a/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h b/lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.h rename from lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h rename to lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.h diff --git a/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp b/lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.cpp rename from lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp rename to lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.cpp diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h @@ -13,7 +13,6 @@ #include #include -#include "Plugins/Process/Utility/GDBRemoteSignals.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "lldb/Target/Platform.h" @@ -146,7 +145,7 @@ void CalculateTrapHandlerSymbolNames() override; - const lldb::UnixSignalsSP &GetRemoteUnixSignals() override; + lldb::UnixSignalsSP GetRemoteUnixSignals() override; size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger, lldb_private::Status &error) override; @@ -154,6 +153,11 @@ virtual size_t GetPendingGdbServerList(std::vector &connection_urls); + lldb::UnixSignalsSP CreateUnixSignals() override { + // PlatformRemoteGDBServer should defer to other platforms. + return lldb::UnixSignalsSP(); + } + protected: std::unique_ptr m_gdb_client_up; diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "PlatformRemoteGDBServer.h" +#include "GDBRemoteSignals.h" #include "lldb/Host/Config.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -31,7 +32,6 @@ #include "lldb/Utility/UriParser.h" #include "llvm/Support/FormatAdapters.h" -#include "Plugins/Process/Utility/GDBRemoteSignals.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" #include @@ -680,17 +680,13 @@ m_trap_handlers.push_back(ConstString("_sigtramp")); } -const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() { +UnixSignalsSP PlatformRemoteGDBServer::GetRemoteUnixSignals() { if (!IsConnected()) - return Platform::GetRemoteUnixSignals(); + return UnixSignalsSP(); if (m_remote_signals_sp) return m_remote_signals_sp; - // If packet not implemented or JSON failed to parse, we'll guess the signal - // set based on the remote architecture. - m_remote_signals_sp = UnixSignals::Create(GetRemoteSystemArchitecture()); - StringExtractorGDBRemote response; auto result = m_gdb_client_up->SendPacketAndWaitForResponse("jSignalsInfo", response); diff --git a/lldb/source/Plugins/Process/Utility/CMakeLists.txt b/lldb/source/Plugins/Process/Utility/CMakeLists.txt --- a/lldb/source/Plugins/Process/Utility/CMakeLists.txt +++ b/lldb/source/Plugins/Process/Utility/CMakeLists.txt @@ -1,18 +1,14 @@ add_lldb_library(lldbPluginProcessUtility AuxVector.cpp - FreeBSDSignals.cpp - GDBRemoteSignals.cpp HistoryThread.cpp HistoryUnwind.cpp InferiorCallPOSIX.cpp LinuxProcMaps.cpp - LinuxSignals.cpp MemoryTagManagerAArch64MTE.cpp NativeProcessSoftwareSingleStep.cpp NativeRegisterContextDBReg_arm64.cpp NativeRegisterContextDBReg_x86.cpp NativeRegisterContextRegisterInfo.cpp - NetBSDSignals.cpp RegisterContext_x86.cpp RegisterContextDarwin_arm.cpp RegisterContextDarwin_arm64.cpp diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -18,6 +18,7 @@ #include "lldb/Target/ABI.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Target/Platform.h" #include "lldb/Target/Target.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/DataBufferHeap.h" @@ -223,9 +224,10 @@ ArchSpec target_arch = GetTarget().GetArchitecture(); ArchSpec core_arch(m_core_module_sp->GetArchitecture()); target_arch.MergeFrom(core_arch); - GetTarget().SetArchitecture(target_arch); - - SetUnixSignals(UnixSignals::Create(GetArchitecture())); + GetTarget().SetArchitecture(target_arch, /* set_platform = */ true); + + if (auto platform_sp = GetTarget().GetPlatform()) + SetUnixSignals(platform_sp->GetUnixSignals()); // Ensure we found at least one thread that was stopped on a signal. bool siginfo_signal_found = false; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -74,7 +74,7 @@ #include "GDBRemoteRegisterContext.h" #include "GDBRemoteRegisterFallback.h" -#include "Plugins/Process/Utility/GDBRemoteSignals.h" +#include "Plugins/Platform/gdb-server/GDBRemoteSignals.h" #include "Plugins/Process/Utility/InferiorCallPOSIX.h" #include "Plugins/Process/Utility/StopInfoMachException.h" #include "ProcessGDBRemote.h" @@ -967,15 +967,13 @@ MapSupportedStructuredDataPlugins(*supported_packets); // If connected to LLDB ("native-signals+"), use signal defs for - // the remote platform. If connected to GDB, just use the standard set. - if (!m_gdb_comm.UsesNativeSignals()) { + // the remote platform (assuming it's available). If connected to GDB, just + // use the standard set. + auto platform_sp = GetTarget().GetPlatform(); + if (!platform_sp || !m_gdb_comm.UsesNativeSignals()) SetUnixSignals(std::make_shared()); - } else { - PlatformSP platform_sp = GetTarget().GetPlatform(); - if (platform_sp && platform_sp->IsConnected()) - SetUnixSignals(platform_sp->GetUnixSignals()); - else - SetUnixSignals(UnixSignals::Create(GetTarget().GetArchitecture())); + else { + SetUnixSignals(platform_sp->GetUnixSignals()); } } diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp --- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -206,12 +206,14 @@ arch.GetArchitectureName()); return error; } - GetTarget().SetArchitecture(arch, true /*set_platform*/); + GetTarget().SetArchitecture(arch, /*set_platform = */ true); m_thread_list = m_minidump_parser->GetThreads(); m_active_exception = m_minidump_parser->GetExceptionStream(); - SetUnixSignals(UnixSignals::Create(GetArchitecture())); + auto platform_sp = GetTarget().GetPlatform(); + if (platform_sp) + SetUnixSignals(platform_sp->GetUnixSignals()); ReadModuleList(); if (ModuleSP module = GetTarget().GetExecutableModule()) diff --git a/lldb/source/Target/CMakeLists.txt b/lldb/source/Target/CMakeLists.txt --- a/lldb/source/Target/CMakeLists.txt +++ b/lldb/source/Target/CMakeLists.txt @@ -85,7 +85,6 @@ lldbInterpreter lldbSymbol lldbUtility - lldbPluginProcessUtility LINK_COMPONENTS Support diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -1672,7 +1672,7 @@ const char *Platform::GetCacheHostname() { return GetHostname(); } -const UnixSignalsSP &Platform::GetRemoteUnixSignals() { +UnixSignalsSP Platform::GetRemoteUnixSignals() { static const auto s_default_unix_signals_sp = std::make_shared(); return s_default_unix_signals_sp; } diff --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp --- a/lldb/source/Target/UnixSignals.cpp +++ b/lldb/source/Target/UnixSignals.cpp @@ -7,10 +7,8 @@ //===----------------------------------------------------------------------===// #include "lldb/Target/UnixSignals.h" -#include "Plugins/Process/Utility/FreeBSDSignals.h" -#include "Plugins/Process/Utility/LinuxSignals.h" -#include "Plugins/Process/Utility/NetBSDSignals.h" #include "lldb/Host/HostInfo.h" +#include "lldb/Target/Platform.h" #include "lldb/Utility/ArchSpec.h" #include @@ -29,24 +27,25 @@ m_description.assign(description); } -lldb::UnixSignalsSP UnixSignals::Create(const ArchSpec &arch) { - const auto &triple = arch.GetTriple(); - switch (triple.getOS()) { - case llvm::Triple::Linux: - return std::make_shared(); - case llvm::Triple::FreeBSD: - case llvm::Triple::OpenBSD: - return std::make_shared(); - case llvm::Triple::NetBSD: - return std::make_shared(); - default: - return std::make_shared(); +lldb::UnixSignalsSP UnixSignals::CreateForHost() { + static lldb::UnixSignalsSP s_unix_signals_sp; + if (s_unix_signals_sp) + return s_unix_signals_sp; + + auto host_platform_sp = Platform::GetHostPlatform(); + + // If we have no host platform, be resilient and use default UnixSignals. + if (!host_platform_sp) + s_unix_signals_sp = std::make_shared(); + else { + s_unix_signals_sp = host_platform_sp->CreateUnixSignals(); + // If the Host platform cannot create a UnixSignals object, fall back to the + // default UnixSignals. This may happen on platforms without a + // UnixSignals implementation (e.g. Windows). + if (!s_unix_signals_sp) + s_unix_signals_sp = std::make_shared(); } -} -lldb::UnixSignalsSP UnixSignals::CreateForHost() { - static lldb::UnixSignalsSP s_unix_signals_sp = - Create(HostInfo::GetArchitecture()); return s_unix_signals_sp; } diff --git a/lldb/unittests/Process/gdb-remote/CMakeLists.txt b/lldb/unittests/Process/gdb-remote/CMakeLists.txt --- a/lldb/unittests/Process/gdb-remote/CMakeLists.txt +++ b/lldb/unittests/Process/gdb-remote/CMakeLists.txt @@ -11,7 +11,7 @@ lldbCore lldbHost lldbPluginPlatformMacOSX - lldbPluginProcessUtility + lldbPluginPlatformLinux lldbPluginProcessGDBRemote LLVMTestingSupport diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp --- a/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp @@ -9,7 +9,7 @@ #include "GDBRemoteTestUtils.h" -#include "Plugins/Process/Utility/LinuxSignals.h" +#include "Plugins/Platform/Linux/LinuxSignals.h" #include "Plugins/Process/gdb-remote/GDBRemoteClientBase.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h" #include "lldb/Utility/GDBRemote.h" diff --git a/lldb/unittests/Target/RemoteAwarePlatformTest.cpp b/lldb/unittests/Target/RemoteAwarePlatformTest.cpp --- a/lldb/unittests/Target/RemoteAwarePlatformTest.cpp +++ b/lldb/unittests/Target/RemoteAwarePlatformTest.cpp @@ -35,6 +35,8 @@ MOCK_METHOD2(ResolveRemoteExecutable, std::pair(const ModuleSpec &, const FileSpecList *)); + MOCK_METHOD0(CreateUnixSignals, lldb::UnixSignalsSP()); + Status ResolveRemoteExecutable( const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) /*override*/ @@ -61,6 +63,7 @@ ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &)); MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void()); MOCK_METHOD0(GetUserIDResolver, UserIDResolver &()); + MOCK_METHOD0(CreateUnixSignals, lldb::UnixSignalsSP()); }; namespace {