[Lldb-commits] [lldb] r125067 - in /lldb/trunk: include/lldb/lldb-types.h source/Core/Communication.cpp source/Host/common/Host.cpp source/Interpreter/ScriptInterpreterPython.cpp source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Process.cpp tools/driver/IOChannel.cpp
Greg Clayton
gclayton at apple.com
Mon Feb 7 17:34:25 PST 2011
Author: gclayton
Date: Mon Feb 7 19:34:25 2011
New Revision: 125067
URL: http://llvm.org/viewvc/llvm-project?rev=125067&view=rev
Log:
Patch that allows for thread_t to be something more complex than an
integer. Modified patch from Kirk Beitz.
Modified:
lldb/trunk/include/lldb/lldb-types.h
lldb/trunk/source/Core/Communication.cpp
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/tools/driver/IOChannel.cpp
Modified: lldb/trunk/include/lldb/lldb-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=125067&r1=125066&r2=125067&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-types.h (original)
+++ lldb/trunk/include/lldb/lldb-types.h Mon Feb 7 19:34:25 2011
@@ -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
+#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 }
//----------------------------------------------------------------------
Modified: lldb/trunk/source/Core/Communication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=125067&r1=125066&r2=125067&view=diff
==============================================================================
--- lldb/trunk/source/Core/Communication.cpp (original)
+++ lldb/trunk/source/Core/Communication.cpp Mon Feb 7 19:34:25 2011
@@ -228,7 +228,7 @@
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 @@
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 @@
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,
Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125067&r1=125066&r2=125067&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Mon Feb 7 19:34:25 2011
@@ -74,7 +74,7 @@
info_ap.get(),
NULL);
- if (thread != LLDB_INVALID_HOST_THREAD)
+ if (IS_VALID_LLDB_HOST_THREAD(thread))
info_ap.release();
}
return thread;
Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=125067&r1=125066&r2=125067&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Feb 7 19:34:25 2011
@@ -614,7 +614,7 @@
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);
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=125067&r1=125066&r2=125067&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Mon Feb 7 19:34:25 2011
@@ -1167,7 +1167,7 @@
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 @@
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 @@
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 @@
{
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;
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125067&r1=125066&r2=125067&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Feb 7 19:34:25 2011
@@ -131,7 +131,7 @@
{
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 @@
// 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 @@
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);
}
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=125067&r1=125066&r2=125067&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Feb 7 19:34:25 2011
@@ -2122,7 +2122,7 @@
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 @@
// 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;
Modified: lldb/trunk/tools/driver/IOChannel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.cpp?rev=125067&r1=125066&r2=125067&view=diff
==============================================================================
--- lldb/trunk/tools/driver/IOChannel.cpp (original)
+++ lldb/trunk/tools/driver/IOChannel.cpp Mon Feb 7 19:34:25 2011
@@ -412,19 +412,19 @@
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);
More information about the lldb-commits
mailing list