[Lldb-commits] [PATCH] Don't resume newly created threads if there is a pending thread stop.

Chaoren Lin chaorenl at google.com
Wed Apr 8 14:32:37 PDT 2015


Hi clayborg,

In the rare event that a thread is created immediately before a breakpoint hit,
the newly created thread would be incorrectly resumed by the creation process.

http://reviews.llvm.org/D8906

Files:
  source/Plugins/Process/Linux/NativeProcessLinux.cpp
  source/Plugins/Process/Linux/ThreadStateCoordinator.h

Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -2133,13 +2133,16 @@
             {
                 // We can now resume the newly created thread since it is fully created.
                 NotifyThreadCreateStopped (tid);
-                m_coordinator_up->RequestThreadResume (tid,
-                                                       [=](lldb::tid_t tid_to_resume, bool supress_signal)
-                                                       {
-                                                           std::static_pointer_cast<NativeThreadLinux> (new_thread_sp)->SetRunning ();
-                                                           return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
-                                                       },
-                                                       CoordinatorErrorHandler);
+                if (!m_coordinator_up->IsPendingThreadStop())
+                {
+                    m_coordinator_up->RequestThreadResume(
+                        tid, [=](lldb::tid_t tid_to_resume, bool supress_signal)
+                             {
+                                 std::static_pointer_cast<NativeThreadLinux> (new_thread_sp)->SetRunning ();
+                                 return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
+                             },
+                             CoordinatorErrorHandler);
+                }
             }
             else
             {
@@ -2484,13 +2487,16 @@
         {
             // We can now resume the newly created thread since it is fully created.
             NotifyThreadCreateStopped (pid);
-            m_coordinator_up->RequestThreadResume (pid,
-                                                   [=](lldb::tid_t tid_to_resume, bool supress_signal)
-                                                   {
-                                                       std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
-                                                       return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
-                                                   },
-                                                   CoordinatorErrorHandler);
+            if (!m_coordinator_up->IsPendingThreadStop())
+            {
+                m_coordinator_up->RequestThreadResume (
+                    pid, [=](lldb::tid_t tid_to_resume, bool supress_signal)
+                         {
+                             std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
+                             return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
+                         },
+                         CoordinatorErrorHandler);
+            }
         }
         else
         {
Index: source/Plugins/Process/Linux/ThreadStateCoordinator.h
===================================================================
--- source/Plugins/Process/Linux/ThreadStateCoordinator.h
+++ source/Plugins/Process/Linux/ThreadStateCoordinator.h
@@ -148,6 +148,10 @@
         void
         LogEnableEventProcessing (bool enabled);
 
+        bool
+        IsPendingThreadStop() {
+            return GetPendingThreadStopNotification();
+        }
     private:
 
         // Typedefs.

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8906.23443.patch
Type: text/x-patch
Size: 3458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150408/3fb69a9f/attachment.bin>


More information about the lldb-commits mailing list