[Lldb-commits] [lldb] r131715 - in /lldb/trunk: scripts/disasm-gdb-remote.pl source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

Greg Clayton gclayton at apple.com
Thu May 19 20:15:54 PDT 2011


Author: gclayton
Date: Thu May 19 22:15:54 2011
New Revision: 131715

URL: http://llvm.org/viewvc/llvm-project?rev=131715&view=rev
Log:
Fixed an issue in GDBRemoteCommunicationClient where we weren't listening to
the "payload_length" argument for the "payload" packet data. This meant we 
could end up sending random extra data with a packet depending on how the 
packet was constructed.

Fixed GDBRemoteRegisterContext to properly save and restore all registers. 
Previous fixes had been added to work around the "payload_length" issues fixed
above and aren't needed anymore.

Fix logging in GDBRemoteCommunication to make sure we log the correct packet
data being sent by using the packet length when dumping the packet contents.

Added register definitions for 'arm-lldb' in the "disasm-gdb-remote.pl" script
so if you have a register dump from the GDB remote that doesn't include the
qRegisterInfo packets, you can manually tell the script which registers are
which.


Modified:
    lldb/trunk/scripts/disasm-gdb-remote.pl
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

Modified: lldb/trunk/scripts/disasm-gdb-remote.pl
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/disasm-gdb-remote.pl?rev=131715&r1=131714&r2=131715&view=diff
==============================================================================
--- lldb/trunk/scripts/disasm-gdb-remote.pl (original)
+++ lldb/trunk/scripts/disasm-gdb-remote.pl Thu May 19 22:15:54 2011
@@ -204,6 +204,95 @@
         { name => 'd31'     , info => $float64_href },
     ],
     
+    
+    'arm-lldb' => [
+        { name => 'r0'      , info => $reg32_href   },
+        { name => 'r1'      , info => $reg32_href   },
+        { name => 'r2'      , info => $reg32_href   },
+        { name => 'r3'      , info => $reg32_href   },
+        { name => 'r4'      , info => $reg32_href   },
+        { name => 'r5'      , info => $reg32_href   },
+        { name => 'r6'      , info => $reg32_href   },
+        { name => 'r7'      , info => $reg32_href   },
+        { name => 'r8'      , info => $reg32_href   },
+        { name => 'r9'      , info => $reg32_href   },
+        { name => 'r10'     , info => $reg32_href   },
+        { name => 'r11'     , info => $reg32_href   },
+        { name => 'r12'     , info => $reg32_href   },
+        { name => 'sp'      , info => $reg32_href   },
+        { name => 'lr'      , info => $reg32_href   },
+        { name => 'pc'      , info => $reg32_href   },
+        { name => 'cpsr'    , info => $reg32_href   },
+        { name => 's0'      , info => $float32_href },
+        { name => 's1'      , info => $float32_href },
+        { name => 's2'      , info => $float32_href },
+        { name => 's3'      , info => $float32_href },
+        { name => 's4'      , info => $float32_href },
+        { name => 's5'      , info => $float32_href },
+        { name => 's6'      , info => $float32_href },
+        { name => 's7'      , info => $float32_href },
+        { name => 's8'      , info => $float32_href },
+        { name => 's9'      , info => $float32_href },
+        { name => 's10'     , info => $float32_href },
+        { name => 's11'     , info => $float32_href },
+        { name => 's12'     , info => $float32_href },
+        { name => 's13'     , info => $float32_href },
+        { name => 's14'     , info => $float32_href },
+        { name => 's15'     , info => $float32_href },
+        { name => 's16'     , info => $float32_href },
+        { name => 's17'     , info => $float32_href },
+        { name => 's18'     , info => $float32_href },
+        { name => 's19'     , info => $float32_href },
+        { name => 's20'     , info => $float32_href },
+        { name => 's21'     , info => $float32_href },
+        { name => 's22'     , info => $float32_href },
+        { name => 's23'     , info => $float32_href }, 
+        { name => 's24'     , info => $float32_href },
+        { name => 's25'     , info => $float32_href },
+        { name => 's26'     , info => $float32_href },
+        { name => 's27'     , info => $float32_href },
+        { name => 's28'     , info => $float32_href },
+        { name => 's29'     , info => $float32_href },
+        { name => 's30'     , info => $float32_href },
+        { name => 's31'     , info => $float32_href },
+        { name => 'd0'      , info => $float64_href },
+        { name => 'd1'      , info => $float64_href },
+        { name => 'd2'      , info => $float64_href },
+        { name => 'd3'      , info => $float64_href },
+        { name => 'd4'      , info => $float64_href },
+        { name => 'd5'      , info => $float64_href },
+        { name => 'd6'      , info => $float64_href },
+        { name => 'd7'      , info => $float64_href },
+        { name => 'd8'      , info => $float64_href },
+        { name => 'd9'      , info => $float64_href },
+        { name => 'd10'     , info => $float64_href },
+        { name => 'd11'     , info => $float64_href },
+        { name => 'd12'     , info => $float64_href },
+        { name => 'd13'     , info => $float64_href },
+        { name => 'd14'     , info => $float64_href },
+        { name => 'd15'     , info => $float64_href },
+        { name => 'd16'     , info => $float64_href },
+        { name => 'd17'     , info => $float64_href },
+        { name => 'd18'     , info => $float64_href },
+        { name => 'd19'     , info => $float64_href },
+        { name => 'd20'     , info => $float64_href },
+        { name => 'd21'     , info => $float64_href },
+        { name => 'd22'     , info => $float64_href },
+        { name => 'd23'     , info => $float64_href }, 
+        { name => 'd24'     , info => $float64_href },
+        { name => 'd25'     , info => $float64_href },
+        { name => 'd26'     , info => $float64_href },
+        { name => 'd27'     , info => $float64_href },
+        { name => 'd28'     , info => $float64_href },
+        { name => 'd29'     , info => $float64_href },
+        { name => 'd30'     , info => $float64_href },
+        { name => 'd31'     , info => $float64_href },
+        { name => 'fpscr'   , info => $reg32_href   },
+        { name => 'exc'     , info => $reg32_href   },
+        { name => 'fsr'     , info => $reg32_href   },
+        { name => 'far'     , info => $reg32_href   },
+    ],    
+    
     'x86_64-gdb' => [
     	{ name => 'rax'		, info => $reg64_href   },
     	{ name => 'rbx'     , info => $reg64_href   },

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=131715&r1=131714&r2=131715&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Thu May 19 22:15:54 2011
@@ -147,7 +147,7 @@
                     "%s(void *$__lldb_arg_obj)                                              \n"
                     "{                                                                      \n"
                     "   struct __objc_object *obj = (struct __objc_object*)$__lldb_arg_obj; \n"
-                    "   strlen(obj->isa->name);                                             \n"
+                    "   (int)strlen(obj->isa->name);                                        \n"
                     "}                                                                      \n",
                     name) < sizeof(buf->contents));
 

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=131715&r1=131714&r2=131715&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu May 19 22:15:54 2011
@@ -138,7 +138,7 @@
 
         LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
         if (log)
-            log->Printf ("send packet: %s", packet.GetData());
+            log->Printf ("send packet: %.*s", (int)packet.GetSize(), packet.GetData());
         ConnectionStatus status = eConnectionStatusSuccess;
         size_t bytes_written = Write (packet.GetData(), packet.GetSize(), status, NULL);
         if (bytes_written == packet.GetSize())
@@ -156,7 +156,7 @@
         {
             LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
             if (log)
-                log->Printf ("error: failed to send packet: %s", packet.GetData());
+                log->Printf ("error: failed to send packet: %.*s", (int)packet.GetSize(), packet.GetData());
         }
         return bytes_written;
     }
@@ -218,11 +218,11 @@
             const EventDataBytes *event_bytes = EventDataBytes::GetEventDataFromEvent(event_sp.get());
             if (event_bytes)
             {
-                const char * packet_data =  (const char *)event_bytes->GetBytes();
+                const char *packet_data =  (const char *)event_bytes->GetBytes();
+                const uint32_t packet_size =  event_bytes->GetByteSize();
                 LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
                 if (log)
-                    log->Printf ("read packet: %s", packet_data);
-                const size_t packet_size =  event_bytes->GetByteSize();
+                    log->Printf ("read packet: %.*s", packet_size, packet_data);
                 if (packet_data && packet_size > 0)
                 {
                     std::string &packet_str = packet.GetStringRef();
@@ -242,9 +242,12 @@
                             packet_str.assign (packet_data + 1, packet_size - 4);
                         if (GetSendAcks ())
                         {
-                            char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16);
-                            char actual_checksum = CalculcateChecksum (&packet_str[0], packet_str.size());
-                            checksum_error = packet_checksum != actual_checksum;
+                            if (success)
+                            {
+                                char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16);
+                                char actual_checksum = CalculcateChecksum (&packet_str[0], packet_str.size());
+                                checksum_error = packet_checksum != actual_checksum;
+                            }
                             // Send the ack or nack if needed
                             if (checksum_error || !success)
                                 SendNack();

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=131715&r1=131714&r2=131715&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu May 19 22:15:54 2011
@@ -252,7 +252,7 @@
 
     if (GetSequenceMutex (locker))
     {
-        if (SendPacketNoLock (payload, strlen(payload)))
+        if (SendPacketNoLock (payload, payload_length))
             return WaitForPacketNoLock (response, &timeout_time);
     }
     else
@@ -1597,8 +1597,8 @@
             m_supports_qThreadStopInfo = false;
         }
     }
-    if (SetCurrentThread (tid))
-        return GetStopReply (response);
+//    if (SetCurrentThread (tid))
+//        return GetStopReply (response);
     return false;
 }
 

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=131715&r1=131714&r2=131715&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Thu May 19 22:15:54 2011
@@ -356,18 +356,17 @@
                 if (response.IsErrorResponse())
                     return false;
                 
-                response.GetStringRef().insert(0, 1, 'G');
-                if (thread_suffix_supported)
+                std::string &response_str = response.GetStringRef();
+                if (isxdigit(response_str[0]))
                 {
-                    char thread_id_cstr[64];
-                    ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4x;", m_thread.GetID());
-                    response.GetStringRef().append (thread_id_cstr);
-                }
-                const char *g_data = response.GetStringRef().c_str();
-                size_t g_data_len = strspn(g_data + 1, "0123456789abcdefABCDEF");
-                if (g_data_len > 0)
-                {
-                    data_sp.reset (new DataBufferHeap (g_data, g_data_len));
+                    response_str.insert(0, 1, 'G');
+                    if (thread_suffix_supported)
+                    {
+                        char thread_id_cstr[64];
+                        ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4x;", m_thread.GetID());
+                        response_str.append (thread_id_cstr);
+                    }
+                    data_sp.reset (new DataBufferHeap (response_str.c_str(), response_str.size()));
                     return true;
                 }
             }





More information about the lldb-commits mailing list