summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/MacOSX-Kernel
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2014-09-09 20:54:56 +0000
committerZachary Turner <zturner@google.com>2014-09-09 20:54:56 +0000
commit39de3110712cb4547a835777310dbead46c1a002 (patch)
treed0f99eb4b7f8ab35272587ad4a0e070675752b54 /lldb/source/Plugins/Process/MacOSX-Kernel
parent7decae153bdb4b4a98fa48bb27564fa4597d1cfa (diff)
downloadbcm5719-llvm-39de3110712cb4547a835777310dbead46c1a002.tar.gz
bcm5719-llvm-39de3110712cb4547a835777310dbead46c1a002.zip
Create a HostThread abstraction.
This patch moves creates a thread abstraction that represents a thread running inside the LLDB process. This is a replacement for otherwise using lldb::thread_t, and provides a platform agnostic interface to managing these threads. Differential Revision: http://reviews.llvm.org/D5198 Reviewed by: Jim Ingham llvm-svn: 217460
Diffstat (limited to 'lldb/source/Plugins/Process/MacOSX-Kernel')
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp24
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h3
2 files changed, 14 insertions, 13 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 8b1850dcccf..9ea65adf5c6 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -23,6 +23,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Host/Socket.h"
+#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -176,7 +177,6 @@ ProcessKDP::ProcessKDP(Target& target, Listener &listener) :
Process (target, listener),
m_comm("lldb.process.kdp-remote.communication"),
m_async_broadcaster (NULL, "lldb.process.kdp-remote.async-broadcaster"),
- m_async_thread (LLDB_INVALID_HOST_THREAD),
m_dyld_plugin_name (),
m_kernel_load_addr (LLDB_INVALID_ADDRESS),
m_command_sp(),
@@ -469,8 +469,8 @@ 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 (!IS_VALID_LLDB_HOST_THREAD(m_async_thread))
- StartAsyncThread ();
+ if (m_async_thread.GetState() != eThreadStateRunning)
+ StartAsyncThread();
bool resume = false;
@@ -869,12 +869,12 @@ ProcessKDP::StartAsyncThread ()
if (log)
log->Printf ("ProcessKDP::StartAsyncThread ()");
-
- if (IS_VALID_LLDB_HOST_THREAD(m_async_thread))
+
+ if (m_async_thread.GetState() == eThreadStateRunning)
return true;
- m_async_thread = Host::ThreadCreate ("<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this, NULL);
- return IS_VALID_LLDB_HOST_THREAD(m_async_thread);
+ m_async_thread = ThreadLauncher::LaunchThread("<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this, NULL);
+ return m_async_thread.GetState() == eThreadStateRunning;
}
void
@@ -888,10 +888,10 @@ ProcessKDP::StopAsyncThread ()
m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit);
// Stop the stdio thread
- if (IS_VALID_LLDB_HOST_THREAD(m_async_thread))
+ if (m_async_thread.GetState() == eThreadStateRunning)
{
- Host::ThreadJoin (m_async_thread, NULL, NULL);
- m_async_thread = LLDB_INVALID_HOST_THREAD;
+ m_async_thread.Join(nullptr);
+ m_async_thread.Reset();
}
}
@@ -1003,8 +1003,8 @@ ProcessKDP::AsyncThread (void *arg)
log->Printf ("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 ") thread exiting...",
arg,
pid);
-
- process->m_async_thread = LLDB_INVALID_HOST_THREAD;
+
+ process->m_async_thread.Reset();
return NULL;
}
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
index f6432bbe5aa..f7f12350fa5 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
@@ -24,6 +24,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/ThreadSafeValue.h"
+#include "lldb/Host/HostThread.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
@@ -246,7 +247,7 @@ protected:
//------------------------------------------------------------------
CommunicationKDP m_comm;
lldb_private::Broadcaster m_async_broadcaster;
- lldb::thread_t m_async_thread;
+ lldb_private::HostThread m_async_thread;
lldb_private::ConstString m_dyld_plugin_name;
lldb::addr_t m_kernel_load_addr;
lldb::CommandObjectSP m_command_sp;
OpenPOWER on IntegriCloud