diff options
Diffstat (limited to 'source/Plugins/Process/MacOSX-Kernel')
5 files changed, 39 insertions, 54 deletions
diff --git a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 5c1c3284a35c2..29a0d58f7080e 100644 --- a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -37,21 +37,21 @@ using namespace lldb_private; //---------------------------------------------------------------------- // CommunicationKDP constructor //---------------------------------------------------------------------- -CommunicationKDP::CommunicationKDP (const char *comm_name) : - Communication(comm_name), - m_addr_byte_size (4), - m_byte_order (eByteOrderLittle), - m_packet_timeout (5), - m_sequence_mutex (Mutex::eMutexTypeRecursive), - m_is_running (false), - m_session_key (0u), - m_request_sequence_id (0u), - m_exception_sequence_id (0u), - m_kdp_version_version (0u), - m_kdp_version_feature (0u), - m_kdp_hostinfo_cpu_mask (0u), - m_kdp_hostinfo_cpu_type (0u), - m_kdp_hostinfo_cpu_subtype (0u) +CommunicationKDP::CommunicationKDP(const char *comm_name) + : Communication(comm_name), + m_addr_byte_size(4), + m_byte_order(eByteOrderLittle), + m_packet_timeout(5), + m_sequence_mutex(), + m_is_running(false), + m_session_key(0u), + m_request_sequence_id(0u), + m_exception_sequence_id(0u), + m_kdp_version_version(0u), + m_kdp_version_feature(0u), + m_kdp_hostinfo_cpu_mask(0u), + m_kdp_hostinfo_cpu_type(0u), + m_kdp_hostinfo_cpu_subtype(0u) { } @@ -69,7 +69,7 @@ CommunicationKDP::~CommunicationKDP() bool CommunicationKDP::SendRequestPacket (const PacketStreamType &request_packet) { - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex); return SendRequestPacketNoLock (request_packet); } @@ -111,7 +111,7 @@ CommunicationKDP::SendRequestAndGetReply (const CommandType command, return false; } - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex); #ifdef LLDB_CONFIGURATION_DEBUG // NOTE: this only works for packets that are in native endian byte order assert (request_packet.GetSize() == *((uint16_t *)(request_packet.GetData() + 2))); @@ -205,9 +205,9 @@ CommunicationKDP::SendRequestPacketNoLock (const PacketStreamType &request_packe } bool -CommunicationKDP::GetSequenceMutex (Mutex::Locker& locker) +CommunicationKDP::GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock) { - return locker.TryLock (m_sequence_mutex); + return (lock = std::unique_lock<std::recursive_mutex>(m_sequence_mutex, std::try_to_lock)).owns_lock(); } @@ -220,7 +220,7 @@ CommunicationKDP::WaitForNotRunningPrivate (const TimeValue *timeout_ptr) size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSeconds (DataExtractor &packet, uint32_t timeout_usec) { - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex); return WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec); } @@ -284,8 +284,8 @@ bool CommunicationKDP::CheckForPacket (const uint8_t *src, size_t src_len, DataExtractor &packet) { // Put the packet data into the buffer in a thread safe fashion - Mutex::Locker locker(m_bytes_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); if (src && src_len > 0) @@ -326,6 +326,7 @@ CommunicationKDP::CheckForPacket (const uint8_t *src, size_t src_len, DataExtrac SendRequestPacketNoLock (request_ack_packet); } // Fall through to case below to get packet contents + LLVM_FALLTHROUGH; case ePacketTypeReply | KDP_CONNECT: case ePacketTypeReply | KDP_DISCONNECT: case ePacketTypeReply | KDP_HOSTINFO: diff --git a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h index 98a146d5a06da..89e55a561e744 100644 --- a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h +++ b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <list> +#include <mutex> #include <string> // Other libraries and framework includes @@ -21,7 +22,6 @@ #include "lldb/Core/Communication.h" #include "lldb/Core/Listener.h" #include "lldb/Core/StreamBuffer.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" #include "lldb/Host/TimeValue.h" @@ -109,7 +109,7 @@ public: uint32_t usec); bool - GetSequenceMutex(lldb_private::Mutex::Locker& locker); + GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock); bool CheckForPacket (const uint8_t *src, @@ -324,7 +324,7 @@ protected: uint32_t m_addr_byte_size; lldb::ByteOrder m_byte_order; uint32_t m_packet_timeout; - lldb_private::Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time + std::recursive_mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time lldb_private::Predicate<bool> m_is_running; uint32_t m_session_key; uint8_t m_request_sequence_id; diff --git a/source/Plugins/Process/MacOSX-Kernel/Makefile b/source/Plugins/Process/MacOSX-Kernel/Makefile deleted file mode 100644 index e42f390ffe0d6..0000000000000 --- a/source/Plugins/Process/MacOSX-Kernel/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -##===- source/Plugins/Process/MacOSX-Darwin/Makefile -------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LLDB_LEVEL := ../../../.. -LIBRARYNAME := lldbPluginProcessDarwin -BUILD_ARCHIVE = 1 - -include $(LLDB_LEVEL)/Makefile diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index 628f76d104fe3..898677df616b4 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -132,12 +132,12 @@ ProcessKDP::Terminate() lldb::ProcessSP ProcessKDP::CreateInstance (TargetSP target_sp, - Listener &listener, + ListenerSP listener_sp, const FileSpec *crash_file_path) { lldb::ProcessSP process_sp; if (crash_file_path == NULL) - process_sp.reset(new ProcessKDP (target_sp, listener)); + process_sp.reset(new ProcessKDP (target_sp, listener_sp)); return process_sp; } @@ -178,8 +178,8 @@ ProcessKDP::CanDebug(TargetSP target_sp, bool plugin_specified_by_name) //---------------------------------------------------------------------- // ProcessKDP constructor //---------------------------------------------------------------------- -ProcessKDP::ProcessKDP(TargetSP target_sp, Listener &listener) : - Process (target_sp, listener), +ProcessKDP::ProcessKDP(TargetSP target_sp, ListenerSP listener_sp) : + Process (target_sp, listener_sp), m_comm("lldb.process.kdp-remote.communication"), m_async_broadcaster (NULL, "lldb.process.kdp-remote.async-broadcaster"), m_dyld_plugin_name (), @@ -927,13 +927,13 @@ ProcessKDP::AsyncThread (void *arg) if (log) log->Printf ("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 ") thread starting...", arg, pid); - Listener listener ("ProcessKDP::AsyncThread"); + ListenerSP listener_sp (Listener::MakeListener("ProcessKDP::AsyncThread")); EventSP event_sp; const uint32_t desired_event_mask = eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit; - if (listener.StartListeningForEvents (&process->m_async_broadcaster, desired_event_mask) == desired_event_mask) + if (listener_sp->StartListeningForEvents (&process->m_async_broadcaster, desired_event_mask) == desired_event_mask) { bool done = false; while (!done) @@ -941,7 +941,7 @@ ProcessKDP::AsyncThread (void *arg) if (log) log->Printf ("ProcessKDP::AsyncThread (pid = %" PRIu64 ") listener.WaitForEvent (NULL, event_sp)...", pid); - if (listener.WaitForEvent (NULL, event_sp)) + if (listener_sp->WaitForEvent (NULL, event_sp)) { uint32_t event_type = event_sp->GetType(); if (log) @@ -981,7 +981,7 @@ ProcessKDP::AsyncThread (void *arg) // Check to see if we are supposed to exit. There is no way to // interrupt a running kernel, so all we can do is wait for an // exception or detach... - if (listener.GetNextEvent(event_sp)) + if (listener_sp->GetNextEvent(event_sp)) { // We got an event, go through the loop again event_type = event_sp->GetType(); @@ -1187,11 +1187,9 @@ public: class CommandObjectMultiwordProcessKDP : public CommandObjectMultiword { public: - CommandObjectMultiwordProcessKDP (CommandInterpreter &interpreter) : - CommandObjectMultiword (interpreter, - "process plugin", - "A set of commands for operating on a ProcessKDP process.", - "process plugin <subcommand> [<subcommand-options>]") + CommandObjectMultiwordProcessKDP(CommandInterpreter &interpreter) + : CommandObjectMultiword(interpreter, "process plugin", "Commands for operating on a ProcessKDP process.", + "process plugin <subcommand> [<subcommand-options>]") { LoadSubCommand ("packet", CommandObjectSP (new CommandObjectProcessKDPPacket (interpreter))); } diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h index fe9a4e2844bf3..49f6362425103 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h +++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h @@ -40,7 +40,7 @@ public: //------------------------------------------------------------------ static lldb::ProcessSP CreateInstance (lldb::TargetSP target_sp, - lldb_private::Listener &listener, + lldb::ListenerSP listener_sp, const lldb_private::FileSpec *crash_file_path); static void @@ -61,7 +61,7 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - ProcessKDP(lldb::TargetSP target_sp, lldb_private::Listener &listener); + ProcessKDP(lldb::TargetSP target_sp, lldb::ListenerSP listener); virtual ~ProcessKDP(); |