[Lldb-commits] [lldb] r243091 - Handle old style S packet correctly

Bhushan Attarde Bhushan.Attarde at imgtec.com
Tue Jul 28 21:05:46 PDT 2015


Hi Hans,

Could you please add this to the release branch?

Thanks
Bhushan

-----Original Message-----
From: lldb-commits-bounces at cs.uiuc.edu [mailto:lldb-commits-bounces at cs.uiuc.edu] On Behalf Of Bhushan Attarde
Sent: 24 July 2015 09:36
To: lldb-commits at cs.uiuc.edu
Subject: [Lldb-commits] [lldb] r243091 - Handle old style S packet correctly

Author: bhushan.attarde
Date: Thu Jul 23 23:06:20 2015
New Revision: 243091

URL: http://llvm.org/viewvc/llvm-project?rev=243091&view=rev
Log:
Handle old style S packet correctly
    
    SUMMARY:
    This patch fixes couple of issues:
    1. A thread tries to lock a mutex which is already locked.
    2. Updating a thread list before the stop packet is parsed so that it can get a valid thread id and allows to set the stop info correctly.
    
    Reviewers: clayborg
    Subscribers: mohit.bhakkad, sagar, jaydeep, lldb-commits
    Differential Revision: http://reviews.llvm.org/D11449

Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

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=243091&r1=243090&r2=243091&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
+++ Thu Jul 23 23:06:20 2015
@@ -371,7 +371,7 @@ ProcessGDBRemote::ProcessGDBRemote(Targe
     m_flags (0),
     m_gdb_comm (),
     m_debugserver_pid (LLDB_INVALID_PROCESS_ID),
-    m_last_stop_packet_mutex (Mutex::eMutexTypeNormal),
+    m_last_stop_packet_mutex (Mutex::eMutexTypeRecursive),
     m_register_info (),
     m_async_broadcaster (NULL, "lldb.process.gdb-remote.async-broadcaster"),
     m_async_thread_state_mutex(Mutex::eMutexTypeRecursive),
@@ -2485,6 +2485,18 @@ ProcessGDBRemote::SetThreadStopInfo (Str
                 }
             }
 
+            if (tid == LLDB_INVALID_THREAD_ID)
+            {
+                // A thread id may be invalid if the response is old style 'S' packet which does not provide the 
+                // thread information. So update the thread list and choose the first one.
+                UpdateThreadIDList ();
+                
+                if (!m_thread_ids.empty ())
+                {
+                    tid = m_thread_ids.front ();
+                }
+            }
+
             ThreadSP thread_sp = SetThreadStopInfo (tid,
                                                     expedited_register_map,
                                                     signo, @@ -2499,19 +2511,6 @@ ProcessGDBRemote::SetThreadStopInfo (Str
                                                     queue_kind,
                                                     queue_serial);
 
-            // If the response is old style 'S' packet which does not provide us with thread information
-            // then update the thread list and choose the first one.
-            if (!thread_sp)
-            {
-                UpdateThreadIDList ();
-
-                if (!m_thread_ids.empty ())
-                {
-                    Mutex::Locker locker (m_thread_list_real.GetMutex ());
-                    thread_sp = m_thread_list_real.FindThreadByProtocolID (m_thread_ids.front (), false);
-                }
-            }
-
             return eStateStopped;
         }
         break;


_______________________________________________
lldb-commits mailing list
lldb-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list