[lldb-dev] Incorrect Linux/POSIX behaviour after main thread exits

Ed Maste emaste at freebsd.org
Tue Jul 9 05:53:58 PDT 2013


On 5 July 2013 13:09, Ed Maste <emaste at freebsd.org> wrote:
> While looking into supporting threaded debugging on FreeBSD I
> discovered an issue in the Linux implementation.
>
> ProcessPOSIX::SendMessage now looks up a POSIXThread in m_thread_list
> by tid, but is called from ::MonitorCallback with the pid of the
> process.  As it happens this usually works on Linux, because the first
> (or only) thread's tid is equal to the pid, resulting in a successful
> FindThreadByID.  However, this fails if the main thread exits.

Any objection to the following patch, which improves threaded
debugging on FreeBSD, and should have no effect on Linux for the
currently working cases?

diff --git a/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
b/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
index 6f25585..cbdb27a 100644
--- a/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
+++ b/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
@@ -373,6 +373,14 @@ ProcessPOSIX::SendMessage(const ProcessMessage &message)

     POSIXThread *thread = static_cast<POSIXThread*>(
         m_thread_list.FindThreadByID(message.GetTID(), false).get());
+    // FIXME: We overload the message's tid by setting it to either a tid or a
+    // pid.  For now provide the first thread if provided the pid and no match
+    // is found.
+    if (!thread && message.GetTID() == GetID())
+    {
+        thread = static_cast<POSIXThread*>(
+            m_thread_list.GetThreadAtIndex(0, false).get());
+    }

     switch (message.GetKind())
     {



More information about the lldb-dev mailing list