summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/lldb-types.h13
-rw-r--r--lldb/source/Core/Communication.cpp6
-rw-r--r--lldb/source/Host/common/Host.cpp2
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp2
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp9
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp6
-rw-r--r--lldb/source/Target/Process.cpp4
-rw-r--r--lldb/tools/driver/IOChannel.cpp6
8 files changed, 32 insertions, 16 deletions
diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h
index 41153ee1c27..193d758b808 100644
--- a/lldb/include/lldb/lldb-types.h
+++ b/lldb/include/lldb/lldb-types.h
@@ -39,6 +39,7 @@
// #define LLDB_INVALID_PROCESS_ID ...
// #define LLDB_INVALID_THREAD_ID ...
// #define LLDB_INVALID_HOST_THREAD ...
+// #define IS_VALID_LLDB_HOST_THREAD ...
//----------------------------------------------------------------------
// TODO: Add a bunch of ifdefs to determine the host system and what
@@ -72,7 +73,19 @@ namespace lldb {
} // namespace lldb
+#if defined(__MINGW32__)
+
+const lldb::thread_t lldb_invalid_host_thread_const = { NULL, 0 } ;
+#define LLDB_INVALID_HOST_THREAD (lldb_invalid_host_thread_const)
+#define IS_VALID_LLDB_HOST_THREAD(t) (!(NULL == (t).p && 0 == (t).x))
+
+#else
+
#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL)
+#define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD)
+
+#endif
+
#define LLDB_INVALID_HOST_TIME { 0, 0 }
//----------------------------------------------------------------------
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index 6b8a6fe530b..089daac4b64 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -228,7 +228,7 @@ Communication::Write (const void *src, size_t src_len, ConnectionStatus &status,
bool
Communication::StartReadThread (Error *error_ptr)
{
- if (m_read_thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(m_read_thread))
return true;
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
@@ -240,7 +240,7 @@ Communication::StartReadThread (Error *error_ptr)
m_read_thread_enabled = true;
m_read_thread = Host::ThreadCreate (thread_name, Communication::ReadThread, this, error_ptr);
- if (m_read_thread == LLDB_INVALID_HOST_THREAD)
+ if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread))
m_read_thread_enabled = false;
return m_read_thread_enabled;
}
@@ -248,7 +248,7 @@ Communication::StartReadThread (Error *error_ptr)
bool
Communication::StopReadThread (Error *error_ptr)
{
- if (m_read_thread == LLDB_INVALID_HOST_THREAD)
+ if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread))
return true;
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 9c4b61fcc04..b017461afb0 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -74,7 +74,7 @@ Host::StartMonitoringChildProcess
info_ap.get(),
NULL);
- if (thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(thread))
info_ap.release();
}
return thread;
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index a8f3e485747..88f42233789 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -614,7 +614,7 @@ ScriptInterpreterPython::InputReaderCallback
embedded_interpreter_thread = Host::ThreadCreate ("<lldb.script-interpreter.embedded-python-loop>",
ScriptInterpreterPython::RunEmbeddedPythonInterpreter,
script_interpreter, NULL);
- if (embedded_interpreter_thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(embedded_interpreter_thread))
{
if (log)
log->Printf ("ScriptInterpreterPython::InputReaderCallback, Activate, succeeded in creating thread (thread = %d)", embedded_interpreter_thread);
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index cfcd7f9fe2d..f2e906e0ae2 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -1167,7 +1167,7 @@ ProcessMacOSX::Clear()
m_exception_messages.clear();
}
- if (m_monitor_thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
{
Host::ThreadCancel (m_monitor_thread, NULL);
thread_result_t thread_result;
@@ -1180,6 +1180,9 @@ ProcessMacOSX::Clear()
bool
ProcessMacOSX::StartSTDIOThread()
{
+ if (IS_VALID_LLDB_HOST_THREAD(m_stdio_thread))
+ return true;
+
// If we created and own the child STDIO file handles, then we track the
// STDIO ourselves, else we let whomever owns these file handles track
// the IO themselves.
@@ -1188,7 +1191,7 @@ ProcessMacOSX::StartSTDIOThread()
ProcessMacOSXLog::LogIf (PD_LOG_PROCESS, "ProcessMacOSX::%s ( )", __FUNCTION__);
// Create the thread that watches for the child STDIO
m_stdio_thread = Host::ThreadCreate ("<lldb.process.process-macosx.stdio>", ProcessMacOSX::STDIOThread, this, NULL);
- return m_stdio_thread != LLDB_INVALID_HOST_THREAD;
+ return IS_VALID_LLDB_HOST_THREAD(m_stdio_thread);
}
return false;
}
@@ -1199,7 +1202,7 @@ ProcessMacOSX::StopSTDIOThread(bool close_child_fds)
{
ProcessMacOSXLog::LogIf (PD_LOG_PROCESS, "ProcessMacOSX::%s ( )", __FUNCTION__);
// Stop the stdio thread
- if (m_stdio_thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(m_stdio_thread))
{
Host::ThreadCancel (m_stdio_thread, NULL);
thread_result_t result = NULL;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 41296d9733f..50fa2005e17 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -131,7 +131,7 @@ ProcessGDBRemote::~ProcessGDBRemote()
{
m_dynamic_loader_ap.reset();
- if (m_debugserver_thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(m_debugserver_thread))
{
Host::ThreadCancel (m_debugserver_thread, NULL);
thread_result_t thread_result;
@@ -2174,7 +2174,7 @@ ProcessGDBRemote::StartAsyncThread ()
// Create a thread that watches our internal state and controls which
// events make it to clients (into the DCProcess event queue).
m_async_thread = Host::ThreadCreate ("<lldb.process.gdb-remote.async>", ProcessGDBRemote::AsyncThread, this, NULL);
- return m_async_thread != LLDB_INVALID_HOST_THREAD;
+ return IS_VALID_LLDB_HOST_THREAD(m_async_thread);
}
void
@@ -2188,7 +2188,7 @@ ProcessGDBRemote::StopAsyncThread ()
m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit);
// Stop the stdio thread
- if (m_async_thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(m_async_thread))
{
Host::ThreadJoin (m_async_thread, NULL, NULL);
}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 0df8077b75f..9b5718a0adf 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2122,7 +2122,7 @@ Process::StartPrivateStateThread ()
char thread_name[1024];
snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state(pid=%i)>", GetID());
m_private_state_thread = Host::ThreadCreate (thread_name, Process::PrivateStateThread, this, NULL);
- return m_private_state_thread != LLDB_INVALID_HOST_THREAD;
+ return IS_VALID_LLDB_HOST_THREAD(m_private_state_thread);
}
void
@@ -2159,7 +2159,7 @@ Process::ControlPrivateStateThread (uint32_t signal)
// thread starts exiting since the private state thread will NULL this out
// when it exits
const lldb::thread_t private_state_thread = m_private_state_thread;
- if (private_state_thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(private_state_thread))
{
TimeValue timeout_time;
bool timed_out;
diff --git a/lldb/tools/driver/IOChannel.cpp b/lldb/tools/driver/IOChannel.cpp
index bf7891abdb7..9bf2b8e583f 100644
--- a/lldb/tools/driver/IOChannel.cpp
+++ b/lldb/tools/driver/IOChannel.cpp
@@ -412,19 +412,19 @@ IOChannel::Run ()
bool
IOChannel::Start ()
{
- if (m_read_thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(m_read_thread))
return true;
m_read_thread = SBHostOS::ThreadCreate ("<lldb.driver.commandline_io>", IOChannel::IOReadThread, this,
NULL);
- return (m_read_thread != LLDB_INVALID_HOST_THREAD);
+ return (IS_VALID_LLDB_HOST_THREAD(m_read_thread));
}
bool
IOChannel::Stop ()
{
- if (m_read_thread == LLDB_INVALID_HOST_THREAD)
+ if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread))
return true;
BroadcastEventByType (eBroadcastBitThreadShouldExit);
OpenPOWER on IntegriCloud