[Lldb-commits] [lldb] 41b6d58 - Revert "[lldb] Move UnixSignals creation into Platform plugins"
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 27 13:43:37 PDT 2023
Author: Alex Langford
Date: 2023-03-27T13:42:14-07:00
New Revision: 41b6d5863fef94bb3a9d184802c5bb6e2759da15
URL: https://github.com/llvm/llvm-project/commit/41b6d5863fef94bb3a9d184802c5bb6e2759da15
DIFF: https://github.com/llvm/llvm-project/commit/41b6d5863fef94bb3a9d184802c5bb6e2759da15.diff
LOG: Revert "[lldb] Move UnixSignals creation into Platform plugins"
This reverts commit ee232506b870ce5282cc4da5ca493d41d361feb3.
As discussed in https://reviews.llvm.org/D146668 we'll find another way
forward.
Added:
lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
lldb/source/Plugins/Process/Utility/FreeBSDSignals.h
lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
lldb/source/Plugins/Process/Utility/LinuxSignals.h
lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
lldb/source/Plugins/Process/Utility/NetBSDSignals.h
Modified:
lldb/include/lldb/Target/Platform.h
lldb/include/lldb/Target/UnixSignals.h
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
lldb/source/Plugins/Platform/Linux/CMakeLists.txt
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.h
lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
lldb/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Plugins/Process/Utility/CMakeLists.txt
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Target/CMakeLists.txt
lldb/source/Target/Platform.cpp
lldb/source/Target/UnixSignals.cpp
lldb/unittests/Process/gdb-remote/CMakeLists.txt
lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
lldb/unittests/Target/RemoteAwarePlatformTest.cpp
Removed:
lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.cpp
lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.h
lldb/source/Plugins/Platform/Linux/LinuxSignals.cpp
lldb/source/Plugins/Platform/Linux/LinuxSignals.h
lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.cpp
lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.h
lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.cpp
lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.h
################################################################################
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index e184249a62980..08e47cc132473 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -619,12 +619,10 @@ class Platform : public PluginInterface {
return 1;
}
- virtual lldb::UnixSignalsSP GetRemoteUnixSignals();
+ virtual const 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
index 65eac7ebdd823..859cf0c814f69 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -22,6 +22,7 @@ namespace lldb_private {
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
index 2844ba6b2bda2..3789f56325980 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
@@ -19,7 +19,6 @@ add_lldb_library(lldbPluginAppleObjCRuntime PLUGIN
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
index e277a8f5c9269..530144592ae44 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt
@@ -1,5 +1,4 @@
add_lldb_library(lldbPluginPlatformFreeBSD PLUGIN
- FreeBSDSignals.cpp
PlatformFreeBSD.cpp
LINK_LIBS
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index 5ef029b917031..3d29739c19adf 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "PlatformFreeBSD.h"
-#include "FreeBSDSignals.h"
#include "lldb/Host/Config.h"
#include <cstdio>
@@ -283,7 +282,3 @@ CompilerType PlatformFreeBSD::GetSiginfoType(const llvm::Triple &triple) {
ast->CompleteTagDeclarationDefinition(siginfo_type);
return siginfo_type;
}
-
-lldb::UnixSignalsSP PlatformFreeBSD::CreateUnixSignals() {
- return std::make_shared<FreeBSDSignals>();
-}
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
index d65b15aec243a..1e92bb4a1e147 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -59,8 +59,6 @@ class PlatformFreeBSD : public PlatformPOSIX {
std::vector<ArchSpec> m_supported_architectures;
- lldb::UnixSignalsSP CreateUnixSignals() override;
-
private:
std::mutex m_mutex;
std::shared_ptr<TypeSystemClang> m_type_system;
diff --git a/lldb/source/Plugins/Platform/Linux/CMakeLists.txt b/lldb/source/Plugins/Platform/Linux/CMakeLists.txt
index b8bfa3bc78863..bad039d0ad509 100644
--- a/lldb/source/Plugins/Platform/Linux/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/Linux/CMakeLists.txt
@@ -1,5 +1,4 @@
add_lldb_library(lldbPluginPlatformLinux PLUGIN
- LinuxSignals.cpp
PlatformLinux.cpp
LINK_LIBS
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index d4e09c971eb2d..bf226fabda5c9 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "PlatformLinux.h"
-#include "LinuxSignals.h"
#include "lldb/Host/Config.h"
#include <cstdio>
@@ -481,7 +480,3 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) {
ast->CompleteTagDeclarationDefinition(siginfo_type);
return siginfo_type;
}
-
-lldb::UnixSignalsSP PlatformLinux::CreateUnixSignals() {
- return std::make_shared<LinuxSignals>();
-}
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
index e604d735ae017..89f0bd709ef60 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -64,8 +64,6 @@ class PlatformLinux : public PlatformPOSIX {
std::vector<ArchSpec> m_supported_architectures;
- lldb::UnixSignalsSP CreateUnixSignals() override;
-
private:
std::mutex m_mutex;
std::shared_ptr<TypeSystemClang> m_type_system;
diff --git a/lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt b/lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt
index 9c8083cbf2f2e..5e63f10980672 100644
--- a/lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt
@@ -1,5 +1,4 @@
add_lldb_library(lldbPluginPlatformNetBSD PLUGIN
- NetBSDSignals.cpp
PlatformNetBSD.cpp
LINK_LIBS
diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
index 41a48249dbbe9..59bbc3f638af1 100644
--- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "PlatformNetBSD.h"
-#include "NetBSDSignals.h"
#include "lldb/Host/Config.h"
#include <cstdio>
@@ -349,7 +348,3 @@ CompilerType PlatformNetBSD::GetSiginfoType(const llvm::Triple &triple) {
ast->CompleteTagDeclarationDefinition(siginfo_type);
return siginfo_type;
}
-
-lldb::UnixSignalsSP PlatformNetBSD::CreateUnixSignals() {
- return std::make_shared<NetBSDSignals>();
-}
diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
index de591b8f7a255..3437d7e5eb511 100644
--- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -61,8 +61,6 @@ class PlatformNetBSD : public PlatformPOSIX {
std::vector<ArchSpec> m_supported_architectures;
- lldb::UnixSignalsSP CreateUnixSignals() override;
-
private:
std::mutex m_mutex;
std::shared_ptr<TypeSystemClang> m_type_system;
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 7033158c928e6..222dbfa719647 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -27,7 +27,6 @@
#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"
@@ -295,13 +294,9 @@ std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() {
return "";
}
-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;
+const lldb::UnixSignalsSP &PlatformPOSIX::GetRemoteUnixSignals() {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteUnixSignals();
return Platform::GetRemoteUnixSignals();
}
@@ -994,7 +989,3 @@ ConstString PlatformPOSIX::GetFullNameForDylib(ConstString basename) {
stream.Printf("lib%s.so", basename.GetCString());
return ConstString(stream.GetString());
}
-
-lldb::UnixSignalsSP PlatformPOSIX::CreateUnixSignals() {
- return std::make_shared<UnixSignals>();
-}
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index f48dc6ef53d04..511797ce6bb7c 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -35,7 +35,7 @@ class PlatformPOSIX : public lldb_private::RemoteAwarePlatform {
GetFile(const lldb_private::FileSpec &source,
const lldb_private::FileSpec &destination) override;
- lldb::UnixSignalsSP GetRemoteUnixSignals() override;
+ const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
@@ -69,8 +69,6 @@ class PlatformPOSIX : public lldb_private::RemoteAwarePlatform {
lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override;
- lldb::UnixSignalsSP CreateUnixSignals() override;
-
protected:
std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
m_option_group_platform_rsync;
diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
index ca72062b21e88..596cf75b591f2 100644
--- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
+++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
@@ -69,12 +69,6 @@ class PlatformQemuUser : public Platform {
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
index 8c36f8c4a13ba..771133f341e90 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -82,10 +82,6 @@ class PlatformWindows : public RemoteAwarePlatform {
std::vector<ArchSpec> m_supported_architectures;
- lldb::UnixSignalsSP CreateUnixSignals() override {
- return lldb::UnixSignalsSP();
- }
-
private:
std::unique_ptr<lldb_private::UtilityFunction>
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
index f00aa19cfac9c..2fbe817acbdd2 100644
--- a/lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt
@@ -1,5 +1,4 @@
add_lldb_library(lldbPluginPlatformGDB PLUGIN
- GDBRemoteSignals.cpp
PlatformRemoteGDBServer.cpp
LINK_LIBS
@@ -7,5 +6,6 @@ add_lldb_library(lldbPluginPlatformGDB PLUGIN
lldbCore
lldbHost
lldbTarget
+ lldbPluginProcessUtility
lldbPluginProcessGDBRemote
)
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index b25a151b0fcca..0858a2a8d3c8b 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "PlatformRemoteGDBServer.h"
-#include "GDBRemoteSignals.h"
#include "lldb/Host/Config.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -32,6 +31,7 @@
#include "lldb/Utility/UriParser.h"
#include "llvm/Support/FormatAdapters.h"
+#include "Plugins/Process/Utility/GDBRemoteSignals.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
#include <optional>
@@ -680,13 +680,17 @@ void PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames() {
m_trap_handlers.push_back(ConstString("_sigtramp"));
}
-UnixSignalsSP PlatformRemoteGDBServer::GetRemoteUnixSignals() {
+const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
if (!IsConnected())
- return UnixSignalsSP();
+ return Platform::GetRemoteUnixSignals();
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/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index f83f607830f4a..638f7db5ef800 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -13,6 +13,7 @@
#include <optional>
#include <string>
+#include "Plugins/Process/Utility/GDBRemoteSignals.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
#include "lldb/Target/Platform.h"
@@ -145,7 +146,7 @@ class PlatformRemoteGDBServer : public Platform, private UserIDResolver {
void CalculateTrapHandlerSymbolNames() override;
- lldb::UnixSignalsSP GetRemoteUnixSignals() override;
+ const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
lldb_private::Status &error) override;
@@ -153,11 +154,6 @@ class PlatformRemoteGDBServer : public Platform, private UserIDResolver {
virtual size_t
GetPendingGdbServerList(std::vector<std::string> &connection_urls);
- lldb::UnixSignalsSP CreateUnixSignals() override {
- // PlatformRemoteGDBServer should defer to other platforms.
- return lldb::UnixSignalsSP();
- }
-
protected:
std::unique_ptr<process_gdb_remote::GDBRemoteCommunicationClient>
m_gdb_client_up;
diff --git a/lldb/source/Plugins/Process/Utility/CMakeLists.txt b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
index 7feb8596d8bfe..edf4e851b653c 100644
--- a/lldb/source/Plugins/Process/Utility/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
@@ -1,14 +1,18 @@
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/Platform/FreeBSD/FreeBSDSignals.cpp b/lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
similarity index 100%
rename from lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.cpp
rename to lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
diff --git a/lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.h b/lldb/source/Plugins/Process/Utility/FreeBSDSignals.h
similarity index 100%
rename from lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.h
rename to lldb/source/Plugins/Process/Utility/FreeBSDSignals.h
diff --git a/lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.cpp b/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
similarity index 100%
rename from lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.cpp
rename to lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
diff --git a/lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.h b/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
similarity index 100%
rename from lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.h
rename to lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
diff --git a/lldb/source/Plugins/Platform/Linux/LinuxSignals.cpp b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
similarity index 100%
rename from lldb/source/Plugins/Platform/Linux/LinuxSignals.cpp
rename to lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
diff --git a/lldb/source/Plugins/Platform/Linux/LinuxSignals.h b/lldb/source/Plugins/Process/Utility/LinuxSignals.h
similarity index 100%
rename from lldb/source/Plugins/Platform/Linux/LinuxSignals.h
rename to lldb/source/Plugins/Process/Utility/LinuxSignals.h
diff --git a/lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.cpp b/lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
similarity index 100%
rename from lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.cpp
rename to lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
diff --git a/lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.h b/lldb/source/Plugins/Process/Utility/NetBSDSignals.h
similarity index 100%
rename from lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.h
rename to lldb/source/Plugins/Process/Utility/NetBSDSignals.h
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index a0f391b9b26ca..9c1b30d5f8024 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -18,7 +18,6 @@
#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"
@@ -224,10 +223,9 @@ Status ProcessElfCore::DoLoadCore() {
ArchSpec target_arch = GetTarget().GetArchitecture();
ArchSpec core_arch(m_core_module_sp->GetArchitecture());
target_arch.MergeFrom(core_arch);
- GetTarget().SetArchitecture(target_arch, /* set_platform = */ true);
-
- if (auto platform_sp = GetTarget().GetPlatform())
- SetUnixSignals(platform_sp->GetUnixSignals());
+ GetTarget().SetArchitecture(target_arch);
+
+ SetUnixSignals(UnixSignals::Create(GetArchitecture()));
// 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
index c2e60ac2b1797..7b083e1478db0 100644
--- 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/Platform/gdb-server/GDBRemoteSignals.h"
+#include "Plugins/Process/Utility/GDBRemoteSignals.h"
#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
#include "Plugins/Process/Utility/StopInfoMachException.h"
#include "ProcessGDBRemote.h"
@@ -967,13 +967,15 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) {
MapSupportedStructuredDataPlugins(*supported_packets);
// If connected to LLDB ("native-signals+"), use signal defs for
- // 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())
+ // the remote platform. If connected to GDB, just use the standard set.
+ if (!m_gdb_comm.UsesNativeSignals()) {
SetUnixSignals(std::make_shared<GDBRemoteSignals>());
- else {
- SetUnixSignals(platform_sp->GetUnixSignals());
+ } else {
+ PlatformSP platform_sp = GetTarget().GetPlatform();
+ if (platform_sp && platform_sp->IsConnected())
+ SetUnixSignals(platform_sp->GetUnixSignals());
+ else
+ SetUnixSignals(UnixSignals::Create(GetTarget().GetArchitecture()));
}
}
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index f082d6f0e8afa..cf6166ecd77b9 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -206,14 +206,12 @@ Status ProcessMinidump::DoLoadCore() {
arch.GetArchitectureName());
return error;
}
- GetTarget().SetArchitecture(arch, /*set_platform = */ true);
+ GetTarget().SetArchitecture(arch, true /*set_platform*/);
m_thread_list = m_minidump_parser->GetThreads();
m_active_exception = m_minidump_parser->GetExceptionStream();
- auto platform_sp = GetTarget().GetPlatform();
- if (platform_sp)
- SetUnixSignals(platform_sp->GetUnixSignals());
+ SetUnixSignals(UnixSignals::Create(GetArchitecture()));
ReadModuleList();
if (ModuleSP module = GetTarget().GetExecutableModule())
diff --git a/lldb/source/Target/CMakeLists.txt b/lldb/source/Target/CMakeLists.txt
index 37040294c618c..d3a922c0ffb5b 100644
--- a/lldb/source/Target/CMakeLists.txt
+++ b/lldb/source/Target/CMakeLists.txt
@@ -86,6 +86,7 @@ add_lldb_library(lldbTarget
lldbInterpreter
lldbSymbol
lldbUtility
+ lldbPluginProcessUtility
LINK_COMPONENTS
Support
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index e0c0e9b689b03..1ddd7596280ee 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1672,7 +1672,7 @@ FileSpec Platform::GetModuleCacheRoot() {
const char *Platform::GetCacheHostname() { return GetHostname(); }
-UnixSignalsSP Platform::GetRemoteUnixSignals() {
+const UnixSignalsSP &Platform::GetRemoteUnixSignals() {
static const auto s_default_unix_signals_sp = std::make_shared<UnixSignals>();
return s_default_unix_signals_sp;
}
diff --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp
index 7c643c05b2f9b..d754537cc4cf4 100644
--- a/lldb/source/Target/UnixSignals.cpp
+++ b/lldb/source/Target/UnixSignals.cpp
@@ -7,8 +7,10 @@
//===----------------------------------------------------------------------===//
#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 <optional>
#include <sstream>
@@ -28,25 +30,24 @@ UnixSignals::Signal::Signal(const char *name, bool default_suppress,
m_description.assign(description);
}
-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<UnixSignals>();
- 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<UnixSignals>();
+lldb::UnixSignalsSP UnixSignals::Create(const ArchSpec &arch) {
+ const auto &triple = arch.GetTriple();
+ switch (triple.getOS()) {
+ case llvm::Triple::Linux:
+ return std::make_shared<LinuxSignals>();
+ case llvm::Triple::FreeBSD:
+ case llvm::Triple::OpenBSD:
+ return std::make_shared<FreeBSDSignals>();
+ case llvm::Triple::NetBSD:
+ return std::make_shared<NetBSDSignals>();
+ default:
+ return std::make_shared<UnixSignals>();
}
+}
+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
index 233065609d841..de14dc0169c13 100644
--- a/lldb/unittests/Process/gdb-remote/CMakeLists.txt
+++ b/lldb/unittests/Process/gdb-remote/CMakeLists.txt
@@ -11,7 +11,7 @@ add_lldb_unittest(ProcessGdbRemoteTests
lldbCore
lldbHost
lldbPluginPlatformMacOSX
- lldbPluginPlatformLinux
+ lldbPluginProcessUtility
lldbPluginProcessGDBRemote
LLVMTestingSupport
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
index 934f0dcb0596f..99d1e12359e72 100644
--- 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/Platform/Linux/LinuxSignals.h"
+#include "Plugins/Process/Utility/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
index cf80de6bec056..c36bd35c819dd 100644
--- a/lldb/unittests/Target/RemoteAwarePlatformTest.cpp
+++ b/lldb/unittests/Target/RemoteAwarePlatformTest.cpp
@@ -35,8 +35,6 @@ class RemoteAwarePlatformTester : public RemoteAwarePlatform {
MOCK_METHOD2(ResolveRemoteExecutable,
std::pair<Status, ModuleSP>(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*/
@@ -63,7 +61,6 @@ class TargetPlatformTester : public Platform {
ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &));
MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void());
MOCK_METHOD0(GetUserIDResolver, UserIDResolver &());
- MOCK_METHOD0(CreateUnixSignals, lldb::UnixSignalsSP());
};
namespace {
More information about the lldb-commits
mailing list