[Lldb-commits] [lldb] r279057 - Move QSyncThreadState packet generation to the gdb-remote client

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 18 05:32:41 PDT 2016


Author: labath
Date: Thu Aug 18 07:32:41 2016
New Revision: 279057

URL: http://llvm.org/viewvc/llvm-project?rev=279057&view=rev
Log:
Move QSyncThreadState packet generation to the gdb-remote client

Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
    lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=279057&r1=279056&r2=279057&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu Aug 18 07:32:41 2016
@@ -3582,9 +3582,22 @@ GDBRemoteCommunicationClient::RestoreReg
 }
 
 bool
-GDBRemoteCommunicationClient::GetModuleInfo (const FileSpec& module_file_spec,
-                                             const lldb_private::ArchSpec& arch_spec,
-                                             ModuleSpec &module_spec)
+GDBRemoteCommunicationClient::SyncThreadState(lldb::tid_t tid)
+{
+    if (!GetSyncThreadStateSupported())
+        return false;
+
+    StreamString packet;
+    StringExtractorGDBRemote response;
+    packet.Printf("QSyncThreadState:%4.4" PRIx64 ";", tid);
+    return SendPacketAndWaitForResponse(packet.GetString(), response, false) ==
+               GDBRemoteCommunication::PacketResult::Success &&
+           response.IsOKResponse();
+}
+
+bool
+GDBRemoteCommunicationClient::GetModuleInfo(const FileSpec &module_file_spec, const lldb_private::ArchSpec &arch_spec,
+                                            ModuleSpec &module_spec)
 {
     if (!m_supports_qModuleInfo)
         return false;

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=279057&r1=279056&r2=279057&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Thu Aug 18 07:32:41 2016
@@ -509,6 +509,9 @@ public:
     bool
     RestoreRegisterState (lldb::tid_t tid, uint32_t save_id);
 
+    bool
+    SyncThreadState(lldb::tid_t tid);
+
     const char *
     GetGDBServerProgramName();
     

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=279057&r1=279056&r2=279057&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Thu Aug 18 07:32:41 2016
@@ -334,28 +334,6 @@ GDBRemoteRegisterContext::SetPrimordialR
                         reg_info->byte_size));
 }
 
-void
-GDBRemoteRegisterContext::SyncThreadState(Process *process)
-{
-    // NB.  We assume our caller has locked the sequence mutex.
-    
-    GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *) process)->GetGDBRemote());
-    if (!gdb_comm.GetSyncThreadStateSupported())
-        return;
-
-    StreamString packet;
-    StringExtractorGDBRemote response;
-    packet.Printf ("QSyncThreadState:%4.4" PRIx64 ";", m_thread.GetProtocolID());
-    if (gdb_comm.SendPacketAndWaitForResponse(packet.GetString().c_str(),
-                                              packet.GetString().size(),
-                                              response,
-                                              false) == GDBRemoteCommunication::PacketResult::Success)
-    {
-        if (response.IsOKResponse())
-            InvalidateAllRegisters();
-    }
-}
-
 bool
 GDBRemoteRegisterContext::WriteRegisterBytes (const RegisterInfo *reg_info, DataExtractor &data, uint32_t data_offset)
 {
@@ -562,7 +540,8 @@ GDBRemoteRegisterContext::ReadAllRegiste
     GDBRemoteClientBase::Lock lock(gdb_comm, false);
     if (lock)
     {
-        SyncThreadState(process);
+        if (gdb_comm.SyncThreadState(m_thread.GetProtocolID()))
+            InvalidateAllRegisters();
 
         if (use_g_packet && gdb_comm.ReadAllRegisters(m_thread.GetProtocolID(), response))
         {

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h?rev=279057&r1=279056&r2=279057&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h Thu Aug 18 07:32:41 2016
@@ -143,9 +143,6 @@ protected:
             m_reg_valid[reg] = valid;
     }
 
-    void
-    SyncThreadState(Process *process);  // Assumes the sequence mutex has already been acquired.
-    
     GDBRemoteDynamicRegisterInfo &m_reg_info;
     std::vector<bool> m_reg_valid;
     DataExtractor m_reg_data;

Modified: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp?rev=279057&r1=279056&r2=279057&view=diff
==============================================================================
--- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp (original)
+++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Thu Aug 18 07:32:41 2016
@@ -159,3 +159,18 @@ TEST_F(GDBRemoteCommunicationClientTest,
     HandlePacket(server, "QRestoreRegisterState:1", "OK");
     ASSERT_TRUE(async_result.get());
 }
+
+TEST_F(GDBRemoteCommunicationClientTest, SyncThreadState)
+{
+    TestClient client;
+    MockServer server;
+    Connect(client, server);
+    if (HasFailure())
+        return;
+
+    const lldb::tid_t tid = 0x47;
+    std::future<bool> async_result = std::async(std::launch::async, [&] { return client.SyncThreadState(tid); });
+    HandlePacket(server, "qSyncThreadStateSupported", "OK");
+    HandlePacket(server, "QSyncThreadState:0047;", "OK");
+    ASSERT_TRUE(async_result.get());
+}




More information about the lldb-commits mailing list