aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Target/UnixSignals.cpp
diff options
context:
space:
mode:
authorAlex Langford <alangford@apple.com>2023-03-16 14:47:17 -0700
committerAlex Langford <alangford@apple.com>2023-03-20 15:41:06 -0700
commitee232506b870ce5282cc4da5ca493d41d361feb3 (patch)
treeab8712836926a3dacd08f9cbec53dfde2a8ed3d3 /lldb/source/Target/UnixSignals.cpp
parentff48a2925fa3726815fc7666326d54a5c053b47b (diff)
downloadllvm-ee232506b870ce5282cc4da5ca493d41d361feb3.zip
llvm-ee232506b870ce5282cc4da5ca493d41d361feb3.tar.gz
llvm-ee232506b870ce5282cc4da5ca493d41d361feb3.tar.bz2
[lldb] Move UnixSignals creation into Platform plugins
The high level goal of this change is to remove lldbTarget's dependency on lldbPluginProcessUtility. The reason for this existing dependency is so that we can create the appropriate UnixSignals object based on an ArchSpec. Instead of using the ArchSpec, we can instead take advantage of the Platform associated with the current Target. This is accomplished by adding a new method to Platform, CreateUnixSignals, which will create the correct UnixSignals object for us. We then can use `Platform::GetUnixSignals` and rely on that to give us the correct signals as needed. Differential Revision: https://reviews.llvm.org/D146263
Diffstat (limited to 'lldb/source/Target/UnixSignals.cpp')
-rw-r--r--lldb/source/Target/UnixSignals.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp
index d754537..7c643c0 100644
--- 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 <optional>
#include <sstream>
@@ -30,24 +28,25 @@ UnixSignals::Signal::Signal(const char *name, bool default_suppress,
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<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;
+ 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::CreateForHost() {
- static lldb::UnixSignalsSP s_unix_signals_sp =
- Create(HostInfo::GetArchitecture());
return s_unix_signals_sp;
}