[Lldb-commits] [lldb] r189576 - Discover support of 'p' packet.

Hafiz Abid Qadeer hafiz_abid at mentor.com
Thu Aug 29 02:09:45 PDT 2013


Author: abidh
Date: Thu Aug 29 04:09:45 2013
New Revision: 189576

URL: http://llvm.org/viewvc/llvm-project?rev=189576&view=rev
Log:
Discover support of 'p' packet.

Some stubs only support g/G packets for registers.
This change makes sure that we check if remote stub supports 'p' packet before using it.

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/ThreadGDBRemote.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=189576&r1=189575&r2=189576&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu Aug 29 04:09:45 2013
@@ -55,6 +55,7 @@ GDBRemoteCommunicationClient::GDBRemoteC
     m_supports_vCont_C (eLazyBoolCalculate),
     m_supports_vCont_s (eLazyBoolCalculate),
     m_supports_vCont_S (eLazyBoolCalculate),
+    m_supports_p (eLazyBoolCalculate),
     m_qHostInfo_is_valid (eLazyBoolCalculate),
     m_qProcessInfo_is_valid (eLazyBoolCalculate),
     m_supports_alloc_dealloc_memory (eLazyBoolCalculate),
@@ -200,6 +201,7 @@ GDBRemoteCommunicationClient::ResetDisco
     m_supports_vCont_C = eLazyBoolCalculate;
     m_supports_vCont_s = eLazyBoolCalculate;
     m_supports_vCont_S = eLazyBoolCalculate;
+    m_supports_p = eLazyBoolCalculate;
     m_qHostInfo_is_valid = eLazyBoolCalculate;
     m_qProcessInfo_is_valid = eLazyBoolCalculate;
     m_supports_alloc_dealloc_memory = eLazyBoolCalculate;
@@ -295,6 +297,24 @@ GDBRemoteCommunicationClient::GetVContSu
     return false;
 }
 
+// Check if the target supports 'p' packet. It sends out a 'p'
+// packet and checks the response. A normal packet will tell us
+// that support is available.
+bool
+GDBRemoteCommunicationClient::GetpPacketSupported ()
+{
+    if (m_supports_p == eLazyBoolCalculate)
+    {
+        StringExtractorGDBRemote response;
+        m_supports_p = eLazyBoolNo;
+        if (SendPacketAndWaitForResponse("p0", response, false))
+        {
+            if (response.IsNormalResponse())
+                m_supports_p = eLazyBoolYes;
+        }
+    }
+    return m_supports_p;
+}
 
 size_t
 GDBRemoteCommunicationClient::SendPacketAndWaitForResponse

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=189576&r1=189575&r2=189576&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Thu Aug 29 04:09:45 2013
@@ -228,6 +228,9 @@ public:
     GetVContSupported (char flavor);
 
     bool
+    GetpPacketSupported ();
+
+    bool
     GetVAttachOrWaitSupported ();
     
     bool
@@ -431,6 +434,7 @@ protected:
     lldb_private::LazyBool m_watchpoints_trigger_after_instruction;
     lldb_private::LazyBool m_attach_or_wait_reply;
     lldb_private::LazyBool m_prepare_for_reg_writing_reply;
+    lldb_private::LazyBool m_supports_p;
     
     bool
         m_supports_qProcessInfoPID:1,

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=189576&r1=189575&r2=189576&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Thu Aug 29 04:09:45 2013
@@ -164,7 +164,6 @@ lldb::RegisterContextSP
 ThreadGDBRemote::CreateRegisterContextForFrame (StackFrame *frame)
 {
     lldb::RegisterContextSP reg_ctx_sp;
-    const bool read_all_registers_at_once = false;
     uint32_t concrete_frame_idx = 0;
     
     if (frame)
@@ -177,6 +176,8 @@ ThreadGDBRemote::CreateRegisterContextFo
         if (process_sp)
         {
             ProcessGDBRemote *gdb_process = static_cast<ProcessGDBRemote *>(process_sp.get());
+            // read_all_registers_at_once will be true if 'p' packet is not supported.
+            bool read_all_registers_at_once = !gdb_process->GetGDBRemote().GetpPacketSupported ();
             reg_ctx_sp.reset (new GDBRemoteRegisterContext (*this, concrete_frame_idx, gdb_process->m_register_info, read_all_registers_at_once));
         }
     }





More information about the lldb-commits mailing list