summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Process')
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp14
-rw-r--r--lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp14
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp11
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp7
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp24
5 files changed, 26 insertions, 44 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 6a397361d2a..20ac736e424 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1396,7 +1396,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
NativeProcessLinux::MonitorCallback, this, GetID(), true);
- if (m_monitor_thread.GetState() != eThreadStateRunning)
+ if (!m_monitor_thread.IsJoinable())
{
error.SetErrorToGenericError();
error.SetErrorString ("Process attach failed to create monitor thread for NativeProcessLinux::MonitorCallback.");
@@ -1474,7 +1474,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess (
NativeProcessLinux::MonitorCallback, this, GetID (), true);
- if (m_monitor_thread.GetState() != eThreadStateRunning)
+ if (!m_monitor_thread.IsJoinable())
{
error.SetErrorToGenericError ();
error.SetErrorString ("Process attach failed to create monitor thread for NativeProcessLinux::MonitorCallback.");
@@ -1495,7 +1495,7 @@ NativeProcessLinux::StartLaunchOpThread(LaunchArgs *args, Error &error)
{
static const char *g_thread_name = "lldb.process.nativelinux.operation";
- if (m_operation_thread.GetState() == eThreadStateRunning)
+ if (m_operation_thread.IsJoinable())
return;
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error);
@@ -1804,7 +1804,7 @@ NativeProcessLinux::StartAttachOpThread(AttachArgs *args, lldb_private::Error &e
{
static const char *g_thread_name = "lldb.process.linux.operation";
- if (m_operation_thread.GetState() == eThreadStateRunning)
+ if (m_operation_thread.IsJoinable())
return;
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error);
@@ -3645,11 +3645,10 @@ NativeProcessLinux::DupDescriptor(const char *path, int fd, int flags)
void
NativeProcessLinux::StopMonitoringChildProcess()
{
- if (m_monitor_thread.GetState() == eThreadStateRunning)
+ if (m_monitor_thread.IsJoinable())
{
m_monitor_thread.Cancel();
m_monitor_thread.Join(nullptr);
- m_monitor_thread.Reset();
}
}
@@ -3671,12 +3670,11 @@ NativeProcessLinux::StopMonitor()
void
NativeProcessLinux::StopOpThread()
{
- if (m_operation_thread.GetState() != eThreadStateRunning)
+ if (!m_operation_thread.IsJoinable())
return;
m_operation_thread.Cancel();
m_operation_thread.Join(nullptr);
- m_operation_thread.Reset();
}
bool
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
index 99d14d2aa7b..8f626be0581 100644
--- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -1199,7 +1199,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
ProcessMonitor::MonitorCallback, this, GetPID(), true);
- if (m_monitor_thread.GetState() != eThreadStateRunning)
+ if (!m_monitor_thread.IsJoinable())
{
error.SetErrorToGenericError();
error.SetErrorString("Process launch failed.");
@@ -1250,7 +1250,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
ProcessMonitor::MonitorCallback, this, GetPID(), true);
- if (m_monitor_thread.GetState() != eThreadStateRunning)
+ if (!m_monitor_thread.IsJoinable())
{
error.SetErrorToGenericError();
error.SetErrorString("Process attach failed.");
@@ -1270,7 +1270,7 @@ ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Error &error)
{
static const char *g_thread_name = "lldb.process.linux.operation";
- if (m_operation_thread.GetState() == eThreadStateRunning)
+ if (m_operation_thread.IsJoinable())
return;
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error);
@@ -1493,7 +1493,7 @@ ProcessMonitor::StartAttachOpThread(AttachArgs *args, lldb_private::Error &error
{
static const char *g_thread_name = "lldb.process.linux.operation";
- if (m_operation_thread.GetState() == eThreadStateRunning)
+ if (m_operation_thread.IsJoinable())
return;
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error);
@@ -2466,11 +2466,10 @@ ProcessMonitor::DupDescriptor(const char *path, int fd, int flags)
void
ProcessMonitor::StopMonitoringChildProcess()
{
- if (m_monitor_thread.GetState() == eThreadStateRunning)
+ if (m_monitor_thread.IsJoinable())
{
m_monitor_thread.Cancel();
m_monitor_thread.Join(nullptr);
- m_monitor_thread.Reset();
}
}
@@ -2491,10 +2490,9 @@ ProcessMonitor::StopMonitor()
void
ProcessMonitor::StopOpThread()
{
- if (m_operation_thread.GetState() != eThreadStateRunning)
+ if (!m_operation_thread.IsJoinable())
return;
m_operation_thread.Cancel();
m_operation_thread.Join(nullptr);
- m_operation_thread.Reset();
}
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 9ea65adf5c6..668d1b25569 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -469,7 +469,7 @@ ProcessKDP::DoResume ()
Error error;
Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS));
// Only start the async thread if we try to do any process control
- if (m_async_thread.GetState() != eThreadStateRunning)
+ if (!m_async_thread.IsJoinable())
StartAsyncThread();
bool resume = false;
@@ -870,11 +870,11 @@ ProcessKDP::StartAsyncThread ()
if (log)
log->Printf ("ProcessKDP::StartAsyncThread ()");
- if (m_async_thread.GetState() == eThreadStateRunning)
+ if (m_async_thread.IsJoinable())
return true;
m_async_thread = ThreadLauncher::LaunchThread("<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this, NULL);
- return m_async_thread.GetState() == eThreadStateRunning;
+ return m_async_thread.IsJoinable();
}
void
@@ -888,11 +888,8 @@ ProcessKDP::StopAsyncThread ()
m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit);
// Stop the stdio thread
- if (m_async_thread.GetState() == eThreadStateRunning)
- {
+ if (m_async_thread.IsJoinable())
m_async_thread.Join(nullptr);
- m_async_thread.Reset();
- }
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 7cef02e5002..eea7655fd09 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -634,7 +634,7 @@ Error
GDBRemoteCommunication::StartListenThread (const char *hostname, uint16_t port)
{
Error error;
- if (m_listen_thread.GetState() == eThreadStateRunning)
+ if (m_listen_thread.IsJoinable())
{
error.SetErrorString("listen thread already running");
}
@@ -655,11 +655,8 @@ GDBRemoteCommunication::StartListenThread (const char *hostname, uint16_t port)
bool
GDBRemoteCommunication::JoinListenThread ()
{
- if (m_listen_thread.GetState() == eThreadStateRunning)
- {
+ if (m_listen_thread.IsJoinable())
m_listen_thread.Join(nullptr);
- m_listen_thread.Reset();
- }
return true;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 28708be5ccb..4a78f6dd189 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1432,7 +1432,7 @@ ProcessGDBRemote::DoResume ()
TimeValue timeout;
timeout = TimeValue::Now();
timeout.OffsetWithSeconds (5);
- if (m_async_thread.GetState() != eThreadStateRunning)
+ if (!m_async_thread.IsJoinable())
{
error.SetErrorString ("Trying to resume but the async thread is dead.");
if (log)
@@ -2891,22 +2891,17 @@ ProcessGDBRemote::StartAsyncThread ()
log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__);
Mutex::Locker start_locker(m_async_thread_state_mutex);
- if (m_async_thread.GetState() != eThreadStateRunning)
+ if (!m_async_thread.IsJoinable())
{
// Create a thread that watches our internal state and controls which
// events make it to clients (into the DCProcess event queue).
m_async_thread = ThreadLauncher::LaunchThread("<lldb.process.gdb-remote.async>", ProcessGDBRemote::AsyncThread, this, NULL);
}
- else
- {
- // Somebody tried to start the async thread while it was either being started or stopped. If the former, and
- // it started up successfully, then say all's well. Otherwise it is an error, since we aren't going to restart it.
- if (log)
- log->Printf("ProcessGDBRemote::%s () - Called when Async thread was in state: %d.", __FUNCTION__, m_async_thread.GetState());
- }
+ else if (log)
+ log->Printf("ProcessGDBRemote::%s () - Called when Async thread was already running.", __FUNCTION__);
- return (m_async_thread.GetState() == eThreadStateRunning);
+ return m_async_thread.IsJoinable();
}
void
@@ -2918,7 +2913,7 @@ ProcessGDBRemote::StopAsyncThread ()
log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__);
Mutex::Locker start_locker(m_async_thread_state_mutex);
- if (m_async_thread.GetState() == eThreadStateRunning)
+ if (m_async_thread.IsJoinable())
{
m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit);
@@ -2928,11 +2923,8 @@ ProcessGDBRemote::StopAsyncThread ()
// Stop the stdio thread
m_async_thread.Join(nullptr);
}
- else
- {
- if (log)
- log->Printf("ProcessGDBRemote::%s () - Called when Async thread was in state: %d.", __FUNCTION__, m_async_thread.GetState());
- }
+ else if (log)
+ log->Printf("ProcessGDBRemote::%s () - Called when Async thread was not running.", __FUNCTION__);
}
OpenPOWER on IntegriCloud