diff options
| author | Todd Fiala <todd.fiala@gmail.com> | 2014-08-29 17:35:57 +0000 |
|---|---|---|
| committer | Todd Fiala <todd.fiala@gmail.com> | 2014-08-29 17:35:57 +0000 |
| commit | 4ceced3f597f71e3b28d9e4f208d2786fff1ff45 (patch) | |
| tree | 362e9f32a697d2b21c9f68c67e09646f00249e4c | |
| parent | b5796cb40e6f7a5e504d8da41d0f31d4539d7110 (diff) | |
| download | bcm5719-llvm-4ceced3f597f71e3b28d9e4f208d2786fff1ff45.tar.gz bcm5719-llvm-4ceced3f597f71e3b28d9e4f208d2786fff1ff45.zip | |
Consolidate UnixSignals setting/getting in Process.
See http://reviews.llvm.org/D5108 for details.
This change does the following:
* eliminates the Process::GetUnixSignals() virtual method and replaces with a fixed getter.
* replaces the Process UnixSignals storage with a shared pointer.
* adds a Process constructor variant that can be passed the UnixSignalsSP. When the constructor without the UnixSignalsSP is specified, the Host's default UnixSignals is used.
* adds a host-specific version of GetUnixSignals() that is used when we need the host's appropriate UnixSignals variant.
* replaces GetUnixSignals() overrides in PlatformElfCore, ProcessGDBRemote, ProcessFreeBSD and ProcessLinux with code that appropriately sets the Process::UnixSignals for the process.
This change also enables some future patches that will enable llgs to be used for local Linux debugging.
llvm-svn: 216748
18 files changed, 118 insertions, 85 deletions
diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index 29f12fa685e..19ed7b01e80 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -17,6 +17,7 @@ #include <string> #include "lldb/lldb-private.h" +#include "lldb/lldb-private-forward.h" #include "lldb/Core/StringList.h" #include "lldb/Host/File.h" #include "lldb/Host/FileSpec.h" @@ -338,6 +339,9 @@ public: static bool AddPosixSpawnFileAction(void *file_actions, const FileAction *info, Log *log, Error &error); #endif + static const lldb_private::UnixSignalsSP& + GetUnixSignals (); + static lldb::pid_t LaunchApplication (const FileSpec &app_file_spec); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index d7a626bedff..641707c58de 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -895,10 +895,17 @@ public: //------------------------------------------------------------------ /// Construct with a shared pointer to a target, and the Process listener. + /// Uses the Host UnixSignalsSP by default. //------------------------------------------------------------------ Process(Target &target, Listener &listener); //------------------------------------------------------------------ + /// Construct with a shared pointer to a target, the Process listener, + /// and the appropriate UnixSignalsSP for the process. + //------------------------------------------------------------------ + Process(Target &target, Listener &listener, const UnixSignalsSP &unix_signals_sp); + + //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be @@ -1321,10 +1328,18 @@ public: Error Signal (int signal); - virtual UnixSignals & + void + SetUnixSignals (const UnixSignalsSP &signals_sp) + { + assert (signals_sp && "null signals_sp"); + m_unix_signals_sp = signals_sp; + } + + UnixSignals & GetUnixSignals () { - return m_unix_signals; + assert (m_unix_signals_sp && "null m_unix_signals_sp"); + return *m_unix_signals_sp; } //================================================================== @@ -3045,7 +3060,7 @@ protected: std::unique_ptr<DynamicCheckerFunctions> m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use. std::unique_ptr<OperatingSystem> m_os_ap; std::unique_ptr<SystemRuntime> m_system_runtime_ap; - UnixSignals m_unix_signals; /// This is the current signal set for this process. + UnixSignalsSP m_unix_signals_sp; /// This is the current signal set for this process. lldb::ABISP m_abi_sp; lldb::IOHandlerSP m_process_input_reader; Communication m_stdio_communication; diff --git a/lldb/include/lldb/lldb-private-forward.h b/lldb/include/lldb/lldb-private-forward.h index 08067d85bad..424aa4cc53f 100644 --- a/lldb/include/lldb/lldb-private-forward.h +++ b/lldb/include/lldb/lldb-private-forward.h @@ -24,6 +24,7 @@ namespace lldb_private class NativeProcessProtocol; class NativeRegisterContext; class NativeThreadProtocol; + class UnixSignals; // --------------------------------------------------------------- // SP/WP decls. @@ -33,6 +34,7 @@ namespace lldb_private typedef std::weak_ptr<lldb_private::NativeProcessProtocol> NativeProcessProtocolWP; typedef std::shared_ptr<lldb_private::NativeRegisterContext> NativeRegisterContextSP; typedef std::shared_ptr<lldb_private::NativeThreadProtocol> NativeThreadProtocolSP; + typedef std::shared_ptr<lldb_private::UnixSignals> UnixSignalsSP; } #endif // #if defined(__cplusplus) diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index f031c19696a..5fe83a4b5b1 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -957,6 +957,7 @@ 236124A31986B4E2004EFC37 /* Socket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Socket.cpp; sourceTree = "<group>"; }; 236124A61986B50E004EFC37 /* IOObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IOObject.h; path = include/lldb/Host/IOObject.h; sourceTree = "<group>"; }; 236124A71986B50E004EFC37 /* Socket.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Socket.h; path = include/lldb/Host/Socket.h; sourceTree = "<group>"; }; + 237C577A19AF9D9F00213D59 /* HostInfoLinux.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostInfoLinux.h; path = include/lldb/Host/linux/HostInfoLinux.h; sourceTree = SOURCE_ROOT; }; 23AB052D199FF639003B8084 /* FreeBSDThread.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FreeBSDThread.cpp; sourceTree = "<group>"; }; 23AB052E199FF639003B8084 /* FreeBSDThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FreeBSDThread.h; sourceTree = "<group>"; }; 23AB052F199FF639003B8084 /* ProcessFreeBSD.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessFreeBSD.cpp; sourceTree = "<group>"; }; @@ -2314,6 +2315,7 @@ isa = PBXGroup; children = ( 233B009D19610D6B0090E598 /* Host.cpp */, + 237C577A19AF9D9F00213D59 /* HostInfoLinux.h */, 3FDFE53619A2933E009756A7 /* HostInfoLinux.cpp */, ); name = linux; diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index bcd16994af9..00c2fa37b38 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -66,6 +66,7 @@ #include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Mutex.h" +#include "lldb/lldb-private-forward.h" #include "lldb/Target/FileAction.h" #include "lldb/Target/Process.h" #include "lldb/Target/ProcessLaunchInfo.h" @@ -1362,3 +1363,14 @@ Host::LaunchApplication (const FileSpec &app_file_spec) } #endif + +#if !defined (__linux__) && !defined (__FreeBSD__) && !defined (__NetBSD__) + +const lldb_private::UnixSignalsSP& +Host::GetUnixSignals () +{ + static UnixSignalsSP s_unix_signals_sp (new UnixSignals ()); + return s_unix_signals_sp; +} + +#endif diff --git a/lldb/source/Host/freebsd/Host.cpp b/lldb/source/Host/freebsd/Host.cpp index 8174015b828..dc092e86d78 100644 --- a/lldb/source/Host/freebsd/Host.cpp +++ b/lldb/source/Host/freebsd/Host.cpp @@ -39,8 +39,9 @@ #include "lldb/Core/DataExtractor.h" #include "lldb/Utility/CleanUp.h" -#include "llvm/Support/Host.h" +#include "Plugins/Process/Utility/FreeBSDSignals.h" +#include "llvm/Support/Host.h" extern "C" { extern char **environ; @@ -401,3 +402,11 @@ Host::GetAuxvData(lldb_private::Process *process) done: return buf_sp; } + +const UnixSignalsSP& +Host::GetUnixSignals () +{ + static const lldb_private::UnixSignalsSP s_unix_signals_sp (new FreeBSDSignals ()); + return s_unix_signals_sp; +} + diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index a7cca2cb44f..0bad90ee22e 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -30,6 +30,7 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Symbol/ObjectFile.h" #include "Plugins/Process/Linux/ProcFileReader.h" +#include "Plugins/Process/Utility/LinuxSignals.h" using namespace lldb; using namespace lldb_private; @@ -424,3 +425,11 @@ Host::GetEnvironment (StringList &env) env.AppendString(env_entry); return i; } + +const lldb_private::UnixSignalsSP& +Host::GetUnixSignals () +{ + static const lldb_private::UnixSignalsSP s_unix_signals_sp (new process_linux::LinuxSignals ()); + return s_unix_signals_sp; +} + diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp index 9fb022dc916..4b488444de1 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -22,12 +22,23 @@ #include "ProcessFreeBSD.h" #include "ProcessPOSIXLog.h" #include "Plugins/Process/Utility/InferiorCallPOSIX.h" +#include "Plugins/Process/Utility/FreeBSDSignals.h" #include "ProcessMonitor.h" #include "FreeBSDThread.h" using namespace lldb; using namespace lldb_private; +namespace +{ + UnixSignalsSP& + GetFreeBSDSignals () + { + static UnixSignalsSP s_freebsd_signals_sp (new FreeBSDSignals ()); + return s_freebsd_signals_sp; + } +} + //------------------------------------------------------------------------------ // Static functions. @@ -113,7 +124,7 @@ ProcessFreeBSD::EnablePluginLogging(Stream *strm, Args &command) // Constructors and destructors. ProcessFreeBSD::ProcessFreeBSD(Target& target, Listener &listener) - : ProcessPOSIX(target, listener), + : ProcessPOSIX(target, listener, GetFreeBSDSignals ()), m_resume_signo(0) { } @@ -271,4 +282,3 @@ ProcessFreeBSD::SendMessage(const ProcessMessage &message) m_message_queue.push(message); } - diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h index 9702a65b9af..d6ae3462c73 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h @@ -18,7 +18,6 @@ // Other libraries and framework includes #include "lldb/Target/Process.h" #include "lldb/Target/ThreadList.h" -#include "Plugins/Process/Utility/FreeBSDSignals.h" #include "ProcessMessage.h" #include "ProcessPOSIX.h" @@ -90,21 +89,9 @@ public: EnablePluginLogging(lldb_private::Stream *strm, lldb_private::Args &command); - //------------------------------------------------------------------ - // Plugin process overrides - //------------------------------------------------------------------ - virtual lldb_private::UnixSignals & - GetUnixSignals() - { - return m_freebsd_signals; - } - protected: friend class FreeBSDThread; - // FreeBSD-specific signal set. - FreeBSDSignals m_freebsd_signals; - typedef std::vector<lldb::tid_t> tid_collection; tid_collection m_suspend_tids; tid_collection m_run_tids; diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp index dae14d1c44c..81151b682d4 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp @@ -22,12 +22,23 @@ #include "ProcessLinux.h" #include "ProcessPOSIXLog.h" #include "Plugins/Process/Utility/InferiorCallPOSIX.h" +#include "Plugins/Process/Utility/LinuxSignals.h" #include "ProcessMonitor.h" #include "LinuxThread.h" using namespace lldb; using namespace lldb_private; +namespace +{ + UnixSignalsSP& + GetStaticLinuxSignalsSP () + { + static UnixSignalsSP s_unix_signals_sp (new process_linux::LinuxSignals ()); + return s_unix_signals_sp; + } +} + //------------------------------------------------------------------------------ // Static functions. @@ -64,7 +75,7 @@ ProcessLinux::Initialize() // Constructors and destructors. ProcessLinux::ProcessLinux(Target& target, Listener &listener, FileSpec *core_file) - : ProcessPOSIX(target, listener), m_core_file(core_file), m_stopping_threads(false) + : ProcessPOSIX(target, listener, GetStaticLinuxSignalsSP ()), m_core_file(core_file), m_stopping_threads(false) { #if 0 // FIXME: Putting this code in the ctor and saving the byte order in a diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.h b/lldb/source/Plugins/Process/Linux/ProcessLinux.h index da7eb437ba3..8618bcc1ef8 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessLinux.h +++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.h @@ -20,8 +20,6 @@ #include "ProcessMessage.h" #include "ProcessPOSIX.h" -#include "Plugins/Process/Utility/LinuxSignals.h" - class ProcessMonitor; class ProcessLinux : @@ -84,15 +82,6 @@ public: EnablePluginLogging(lldb_private::Stream *strm, lldb_private::Args &command); - //------------------------------------------------------------------ - // Plug-in process overrides - //------------------------------------------------------------------ - virtual lldb_private::UnixSignals & - GetUnixSignals () - { - return m_linux_signals; - } - virtual bool CanDebug(lldb_private::Target &target, bool plugin_specified_by_name); @@ -107,9 +96,6 @@ public: private: - /// Linux-specific signal set. - process_linux::LinuxSignals m_linux_signals; - lldb_private::FileSpec *m_core_file; // Flag to avoid recursion when stopping all threads. diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp index 858d8ae608e..f340631c7d0 100644 --- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp +++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp @@ -70,8 +70,8 @@ ProcessPOSIX::Initialize() //------------------------------------------------------------------------------ // Constructors and destructors. -ProcessPOSIX::ProcessPOSIX(Target& target, Listener &listener) - : Process(target, listener), +ProcessPOSIX::ProcessPOSIX(Target& target, Listener &listener, UnixSignalsSP &unix_signals_sp) + : Process(target, listener, unix_signals_sp), m_byte_order(lldb::endian::InlHostByteOrder()), m_monitor(NULL), m_module(NULL), @@ -878,12 +878,6 @@ ProcessPOSIX::PutSTDIN(const char *buf, size_t len, Error &error) return status; } -UnixSignals & -ProcessPOSIX::GetUnixSignals() -{ - return m_signals; -} - //------------------------------------------------------------------------------ // Utility functions. diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.h b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.h index a429b3c8264..033accf17f2 100644 --- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.h +++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.h @@ -18,7 +18,6 @@ // Other libraries and framework includes #include "lldb/Target/Process.h" -#include "lldb/Target/UnixSignals.h" #include "ProcessMessage.h" class ProcessMonitor; @@ -33,7 +32,8 @@ public: // Constructors and destructors //------------------------------------------------------------------ ProcessPOSIX(lldb_private::Target& target, - lldb_private::Listener &listener); + lldb_private::Listener &listener, + lldb_private::UnixSignalsSP &unix_signals_sp); virtual ~ProcessPOSIX(); @@ -154,9 +154,6 @@ public: ProcessMonitor & GetMonitor() { assert(m_monitor); return *m_monitor; } - lldb_private::UnixSignals & - GetUnixSignals(); - const char *GetFilePath(const lldb_private::FileAction *file_action, const char *default_path); /// Stops all threads in the process. @@ -192,9 +189,6 @@ protected: /// Drive any exit events to completion. bool m_exit_now; - /// OS-specific signal set. - lldb_private::UnixSignals m_signals; - /// Returns true if the process has exited. bool HasExited(); diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index 087ee4965fa..566816783c7 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -20,12 +20,14 @@ #include "lldb/Core/Log.h" #include "lldb/Target/Target.h" #include "lldb/Target/DynamicLoader.h" +#include "lldb/Target/UnixSignals.h" #include "llvm/Support/ELF.h" #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h" #include "Plugins/Process/Utility/FreeBSDSignals.h" +#include "Plugins/Process/Utility/LinuxSignals.h" // Project includes #include "ProcessElfCore.h" @@ -108,7 +110,6 @@ ProcessElfCore::ProcessElfCore(Target& target, Listener &listener, m_core_file (core_file), m_dyld_plugin_name (), m_os(llvm::Triple::UnknownOS), - m_signals_sp (), m_thread_data_valid(false), m_thread_data(), m_core_aranges () @@ -236,8 +237,17 @@ ProcessElfCore::DoLoadCore () switch (m_os) { case llvm::Triple::FreeBSD: - m_signals_sp.reset(new FreeBSDSignals()); + { + static UnixSignalsSP s_freebsd_signals_sp(new FreeBSDSignals ()); + SetUnixSignals(s_freebsd_signals_sp); + break; + } + case llvm::Triple::Linux: + { + static UnixSignalsSP s_linux_signals_sp(new process_linux::LinuxSignals ()); + SetUnixSignals(s_linux_signals_sp); break; + } default: break; } @@ -356,7 +366,9 @@ ProcessElfCore::Clear() { m_thread_list.Clear(); m_os = llvm::Triple::UnknownOS; - m_signals_sp.reset(); + + static UnixSignalsSP s_default_unix_signals_sp(new UnixSignals()); + SetUnixSignals(s_default_unix_signals_sp); } void @@ -587,4 +599,3 @@ ProcessElfCore::GetAuxvData() lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len)); return buffer; } - diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h index 6b4a857349d..2fc2e4ee794 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h @@ -104,18 +104,6 @@ public: IsAlive (); //------------------------------------------------------------------ - // Process Signals - //------------------------------------------------------------------ - virtual lldb_private::UnixSignals & - GetUnixSignals() - { - if (m_signals_sp) - return *m_signals_sp; - else - return Process::GetUnixSignals(); - } - - //------------------------------------------------------------------ // Process Memory //------------------------------------------------------------------ virtual size_t @@ -155,7 +143,6 @@ private: DISALLOW_COPY_AND_ASSIGN (ProcessElfCore); llvm::Triple::OSType m_os; - std::shared_ptr<lldb_private::UnixSignals> m_signals_sp; // True if m_thread_contexts contains valid entries bool m_thread_data_valid; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index b50f071e980..f35d954caa7 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -287,8 +287,7 @@ ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) : m_waiting_for_attach (false), m_destroy_tried_resuming (false), m_command_sp (), - m_breakpoint_pc_offset (0), - m_unix_signals_sp (new UnixSignals ()) + m_breakpoint_pc_offset (0) { m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit, "async thread should exit"); m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue, "async thread continue"); @@ -713,19 +712,19 @@ ProcessGDBRemote::DoConnectRemote (Stream *strm, const char *remote_url) switch (arch_spec.GetTriple ().getOS ()) { case llvm::Triple::Linux: - m_unix_signals_sp.reset (new process_linux::LinuxSignals ()); + SetUnixSignals (UnixSignalsSP (new process_linux::LinuxSignals ())); if (log) log->Printf ("ProcessGDBRemote::%s using Linux unix signals type for pid %" PRIu64, __FUNCTION__, GetID ()); break; case llvm::Triple::OpenBSD: case llvm::Triple::FreeBSD: case llvm::Triple::NetBSD: - m_unix_signals_sp.reset (new FreeBSDSignals ()); + SetUnixSignals (UnixSignalsSP (new FreeBSDSignals ())); if (log) log->Printf ("ProcessGDBRemote::%s using *BSD unix signals type for pid %" PRIu64, __FUNCTION__, GetID ()); break; default: - m_unix_signals_sp.reset (new UnixSignals ()); + SetUnixSignals (UnixSignalsSP (new UnixSignals ())); if (log) log->Printf ("ProcessGDBRemote::%s using generic unix signals type for pid %" PRIu64, __FUNCTION__, GetID ()); break; @@ -1086,13 +1085,6 @@ ProcessGDBRemote::DidLaunch () DidLaunchOrAttach (process_arch); } -UnixSignals& -ProcessGDBRemote::GetUnixSignals () -{ - assert (m_unix_signals_sp && "m_unix_signals_sp is null"); - return *m_unix_signals_sp; -} - Error ProcessGDBRemote::DoAttachToProcessWithID (lldb::pid_t attach_pid) { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 39395af2ee5..942b31c84dd 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -25,6 +25,7 @@ #include "lldb/Core/StringList.h" #include "lldb/Core/StructuredData.h" #include "lldb/Core/ThreadSafeValue.h" +#include "lldb/lldb-private-forward.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -91,9 +92,6 @@ public: virtual void DidLaunch (); - lldb_private::UnixSignals& - GetUnixSignals () override; - virtual lldb_private::Error WillAttachToProcessWithID (lldb::pid_t pid); @@ -360,8 +358,6 @@ protected: bool m_destroy_tried_resuming; lldb::CommandObjectSP m_command_sp; int64_t m_breakpoint_pc_offset; - std::shared_ptr<lldb_private::UnixSignals> m_unix_signals_sp; - bool StartAsyncThread (); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 140b0d09fb1..a1049787d82 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -653,6 +653,13 @@ Process::GetStaticBroadcasterClass () // Process constructor //---------------------------------------------------------------------- Process::Process(Target &target, Listener &listener) : + Process(target, listener, Host::GetUnixSignals ()) +{ + // This constructor just delegates to the full Process constructor, + // defaulting to using the Host's UnixSignals. +} + +Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_signals_sp) : ProcessProperties (false), UserID (LLDB_INVALID_PROCESS_ID), Broadcaster (&(target.GetDebugger()), "lldb.process"), @@ -682,7 +689,7 @@ Process::Process(Target &target, Listener &listener) : m_listener (listener), m_breakpoint_site_list (), m_dynamic_checkers_ap (), - m_unix_signals (), + m_unix_signals_sp (unix_signals_sp), m_abi_sp (), m_process_input_reader (), m_stdio_communication ("process.stdio"), @@ -712,6 +719,9 @@ Process::Process(Target &target, Listener &listener) : if (log) log->Printf ("%p Process::Process()", static_cast<void*>(this)); + if (!m_unix_signals_sp) + m_unix_signals_sp.reset (new UnixSignals ()); + SetEventName (eBroadcastBitStateChanged, "state-changed"); SetEventName (eBroadcastBitInterrupt, "interrupt"); SetEventName (eBroadcastBitSTDOUT, "stdout-available"); @@ -737,6 +747,8 @@ Process::Process(Target &target, Listener &listener) : eBroadcastInternalStateControlStop | eBroadcastInternalStateControlPause | eBroadcastInternalStateControlResume); + // We need something valid here, even if just the default UnixSignalsSP. + assert (m_unix_signals_sp && "null m_unix_signals_sp after initialization"); } //---------------------------------------------------------------------- |

