diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 |
commit | f3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch) | |
tree | 48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /source/Plugins/Process/FreeBSD | |
parent | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff) |
Notes
Diffstat (limited to 'source/Plugins/Process/FreeBSD')
-rw-r--r-- | source/Plugins/Process/FreeBSD/FreeBSDThread.cpp | 38 | ||||
-rw-r--r-- | source/Plugins/Process/FreeBSD/Makefile | 17 | ||||
-rw-r--r-- | source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp | 28 | ||||
-rw-r--r-- | source/Plugins/Process/FreeBSD/ProcessFreeBSD.h | 9 | ||||
-rw-r--r-- | source/Plugins/Process/FreeBSD/ProcessMonitor.cpp | 17 | ||||
-rw-r--r-- | source/Plugins/Process/FreeBSD/ProcessMonitor.h | 8 |
6 files changed, 59 insertions, 58 deletions
diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp index 2b292442399ff..3cb1cec6983ff 100644 --- a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp +++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp @@ -558,22 +558,40 @@ FreeBSDThread::WatchNotify(const ProcessMessage &message) void FreeBSDThread::TraceNotify(const ProcessMessage &message) { - POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol(); - if (reg_ctx) + Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); + + // Try to resolve the breakpoint object corresponding to the current PC. + assert(GetRegisterContext()); + lldb::addr_t pc = GetRegisterContext()->GetPC(); + if (log) + log->Printf ("FreeBSDThread::%s () PC=0x%8.8" PRIx64, __FUNCTION__, pc); + lldb::BreakpointSiteSP bp_site(GetProcess()->GetBreakpointSiteList().FindByAddress(pc)); + + // If the current pc is a breakpoint site then set the StopInfo to Breakpoint. + // Otherwise, set the StopInfo to Watchpoint or Trace. + // If we have an operating system plug-in, we might have set a thread specific breakpoint using the + // operating system thread ID, so we can't make any assumptions about the thread ID so we must always + // report the breakpoint regardless of the thread. + if (bp_site && (bp_site->ValidForThisThread(this) || GetProcess()->GetOperatingSystem () != NULL)) + SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_site->GetID())); + else { - uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints(); - uint32_t wp_idx; - for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++) + POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol(); + if (reg_ctx) { - if (reg_ctx->IsWatchpointHit(wp_idx)) + uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints(); + uint32_t wp_idx; + for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++) { - WatchNotify(message); - return; + if (reg_ctx->IsWatchpointHit(wp_idx)) + { + WatchNotify(message); + return; + } } } + SetStopInfo (StopInfo::CreateStopReasonToTrace(*this)); } - - SetStopInfo (StopInfo::CreateStopReasonToTrace(*this)); } void diff --git a/source/Plugins/Process/FreeBSD/Makefile b/source/Plugins/Process/FreeBSD/Makefile deleted file mode 100644 index 7f546540e5566..0000000000000 --- a/source/Plugins/Process/FreeBSD/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -##===- source/Plugins/Process/FreeBSD/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 := lldbPluginProcessFreeBSD -BUILD_ARCHIVE = 1 - -# Extend the include path so we may locate UnwindLLDB.h -CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source/Plugins/Utility - -include $(LLDB_LEVEL)/Makefile diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp index 769ccd7248ac1..3a72a65da696f 100644 --- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -63,12 +63,12 @@ namespace lldb::ProcessSP ProcessFreeBSD::CreateInstance(lldb::TargetSP target_sp, - Listener &listener, + lldb::ListenerSP listener_sp, const FileSpec *crash_file_path) { lldb::ProcessSP process_sp; if (crash_file_path == NULL) - process_sp.reset(new ProcessFreeBSD (target_sp, listener, GetFreeBSDSignals())); + process_sp.reset(new ProcessFreeBSD (target_sp, listener_sp, GetFreeBSDSignals())); return process_sp; } @@ -143,7 +143,7 @@ ProcessFreeBSD::DoResume() SetPrivateState(eStateRunning); - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); bool do_step = false; for (tid_collection::const_iterator t_pos = m_run_tids.begin(), t_end = m_run_tids.end(); t_pos != t_end; ++t_pos) @@ -229,7 +229,7 @@ ProcessFreeBSD::WillResume() void ProcessFreeBSD::SendMessage(const ProcessMessage &message) { - Mutex::Locker lock(m_message_mutex); + std::lock_guard<std::recursive_mutex> guard(m_message_mutex); switch (message.GetKind()) { @@ -269,12 +269,12 @@ ProcessFreeBSD::SendMessage(const ProcessMessage &message) //------------------------------------------------------------------------------ // Constructors and destructors. -ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp, Listener &listener, UnixSignalsSP &unix_signals_sp) - : Process(target_sp, listener, unix_signals_sp), +ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, UnixSignalsSP &unix_signals_sp) + : Process(target_sp, listener_sp, unix_signals_sp), m_byte_order(endian::InlHostByteOrder()), m_monitor(NULL), m_module(NULL), - m_message_mutex (Mutex::eMutexTypeRecursive), + m_message_mutex(), m_exit_now(false), m_seen_initial_stop(), m_resume_signo(0) @@ -603,7 +603,7 @@ ProcessFreeBSD::RefreshStateAfterStop() if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) log->Printf ("ProcessFreeBSD::%s(), message_queue size = %d", __FUNCTION__, (int)m_message_queue.size()); - Mutex::Locker lock(m_message_mutex); + std::lock_guard<std::recursive_mutex> guard(m_message_mutex); // This method used to only handle one message. Changing it to loop allows // it to handle the case where we hit a breakpoint while handling a different @@ -630,7 +630,7 @@ ProcessFreeBSD::RefreshStateAfterStop() if (log) log->Printf ("ProcessFreeBSD::%s() removing thread, tid = %" PRIi64, __FUNCTION__, tid); - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false); thread_sp.reset(); @@ -801,7 +801,7 @@ ProcessFreeBSD::EnableWatchpoint(Watchpoint *wp, bool notify) // Try to find a vacant watchpoint slot in the inferiors' main thread uint32_t wp_hw_index = LLDB_INVALID_INDEX32; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); FreeBSDThread *thread = static_cast<FreeBSDThread*>( m_thread_list.GetThreadAtIndex(0, false).get()); @@ -871,7 +871,7 @@ ProcessFreeBSD::DisableWatchpoint(Watchpoint *wp, bool notify) if (wp->IsHardware()) { bool wp_disabled = true; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); uint32_t thread_count = m_thread_list.GetSize(false); for (uint32_t i = 0; i < thread_count; ++i) { @@ -901,7 +901,7 @@ Error ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num) { Error error; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); FreeBSDThread *thread = static_cast<FreeBSDThread*>( m_thread_list.GetThreadAtIndex(0, false).get()); if (thread) @@ -924,7 +924,7 @@ ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num, bool &after) uint32_t ProcessFreeBSD::UpdateThreadListIfNeeded() { - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); // Do not allow recursive updates. return m_thread_list.GetSize(false); } @@ -1015,7 +1015,7 @@ bool ProcessFreeBSD::IsAThreadRunning() { bool is_running = false; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); uint32_t thread_count = m_thread_list.GetSize(false); for (uint32_t i = 0; i < thread_count; ++i) { diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h index 5f9365418d7af..888e2a90ad76b 100644 --- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h +++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h @@ -13,8 +13,9 @@ // C Includes // C++ Includes -#include <set> +#include <mutex> #include <queue> +#include <set> // Other libraries and framework includes #include "lldb/Target/Process.h" @@ -35,7 +36,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 @@ -54,7 +55,7 @@ public: // Constructors and destructors //------------------------------------------------------------------ ProcessFreeBSD(lldb::TargetSP target_sp, - lldb_private::Listener &listener, + lldb::ListenerSP listener_sp, lldb::UnixSignalsSP &unix_signals_sp); ~ProcessFreeBSD(); @@ -212,7 +213,7 @@ protected: lldb_private::Module *m_module; /// Message queue notifying this instance of inferior process state changes. - lldb_private::Mutex m_message_mutex; + std::recursive_mutex m_message_mutex; std::queue<ProcessMessage> m_message_queue; /// Drive any exit events to completion. diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp index cd016fbd4b8c5..16707a5c8b971 100644 --- a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -819,6 +819,8 @@ ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, m_terminal_fd(-1), m_operation(0) { + using namespace std::placeholders; + std::unique_ptr<LaunchArgs> args(new LaunchArgs(this, module, argv, envp, stdin_file_spec, stdout_file_spec, @@ -856,7 +858,7 @@ WAIT_AGAIN: // Finally, start monitoring the child process for change in state. m_monitor_thread = Host::StartMonitoringChildProcess( - ProcessMonitor::MonitorCallback, this, GetPID(), true); + std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4), GetPID(), true); if (!m_monitor_thread.IsJoinable()) { error.SetErrorToGenericError(); @@ -873,6 +875,8 @@ ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, m_terminal_fd(-1), m_operation(0) { + using namespace std::placeholders; + sem_init(&m_operation_pending, 0, 0); sem_init(&m_operation_done, 0, 0); @@ -906,7 +910,7 @@ WAIT_AGAIN: // Finally, start monitoring the child process for change in state. m_monitor_thread = Host::StartMonitoringChildProcess( - ProcessMonitor::MonitorCallback, this, GetPID(), true); + std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4), GetPID(), true); if (!m_monitor_thread.IsJoinable()) { error.SetErrorToGenericError(); @@ -1180,14 +1184,9 @@ ProcessMonitor::GetCurrentThreadIDs(std::vector<lldb::tid_t>&thread_ids) } bool -ProcessMonitor::MonitorCallback(void *callback_baton, - lldb::pid_t pid, - bool exited, - int signal, - int status) +ProcessMonitor::MonitorCallback(ProcessMonitor *monitor, lldb::pid_t pid, bool exited, int signal, int status) { ProcessMessage message; - ProcessMonitor *monitor = static_cast<ProcessMonitor*>(callback_baton); ProcessFreeBSD *process = monitor->m_process; assert(process); bool stop_monitoring; @@ -1349,7 +1348,7 @@ ProcessMonitor::ServeOperation(OperationArgs *args) void ProcessMonitor::DoOperation(Operation *op) { - Mutex::Locker lock(m_operation_mutex); + std::lock_guard<std::mutex> guard(m_operation_mutex); m_operation = op; diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/source/Plugins/Process/FreeBSD/ProcessMonitor.h index 07fa6b7869add..93f6be1113610 100644 --- a/source/Plugins/Process/FreeBSD/ProcessMonitor.h +++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.h @@ -15,11 +15,12 @@ #include <signal.h> // C++ Includes +#include <mutex> + // Other libraries and framework includes #include "lldb/lldb-types.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/HostThread.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -223,7 +224,7 @@ private: // current operation which must be executed on the privileged thread Operation *m_operation; - lldb_private::Mutex m_operation_mutex; + std::mutex m_operation_mutex; // semaphores notified when Operation is ready to be processed and when // the operation is complete. @@ -302,8 +303,7 @@ private: DupDescriptor(const lldb_private::FileSpec &file_spec, int fd, int flags); static bool - MonitorCallback(void *callback_baton, - lldb::pid_t pid, bool exited, int signal, int status); + MonitorCallback(ProcessMonitor *monitor, lldb::pid_t pid, bool exited, int signal, int status); static ProcessMessage MonitorSIGTRAP(ProcessMonitor *monitor, |