[Lldb-commits] [lldb] r279917 - Convert some functions to use StringRef instead of c_str, len

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Sat Aug 27 08:52:31 PDT 2016


Author: zturner
Date: Sat Aug 27 10:52:29 2016
New Revision: 279917

URL: http://llvm.org/viewvc/llvm-project?rev=279917&view=rev
Log:
Convert some functions to use StringRef instead of c_str, len

This started as an effort to change StringExtractor to store a
StringRef internally instead of a std::string.  I got that working
locally with just 1 test failure which I was unable to figure out the
cause of.  But it was also a massive changelist due to a trickle
down effect of changes.

So I'm starting over, using what I learned from the first time to
tackle smaller, more isolated changes hopefully leading up to
a full conversion by the end.

At first the changes (such as in this CL) will seem mostly
a matter of preference and pointless otherwise.  However, there
are some places in my larger CL where using StringRef turned 20+
lines of code into 2, drastically simplifying logic.  Hopefully
once these go in they will illustrate some of the benefits of
thinking in terms of StringRef.

Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
    lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp?rev=279917&r1=279916&r2=279917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp Sat Aug 27 10:52:29 2016
@@ -216,7 +216,7 @@ GDBRemoteClientBase::SendPacketAndWaitFo
                                                   const Lock &lock)
 {
     assert(lock);
-    PacketResult packet_result = SendPacketNoLock(payload.data(), payload.size());
+    PacketResult packet_result = SendPacketNoLock(payload);
     if (packet_result != PacketResult::Success)
         return packet_result;
 
@@ -255,7 +255,7 @@ GDBRemoteClientBase::SendvContPacket(llv
         log->Printf("GDBRemoteCommunicationClient::%s () sending vCont packet: %.*s", __FUNCTION__, int(payload.size()),
                     payload.data());
 
-    if (SendPacketNoLock(payload.data(), payload.size()) != PacketResult::Success)
+    if (SendPacketNoLock(payload) != PacketResult::Success)
         return false;
 
     OnRunPacketSent(true);
@@ -354,8 +354,7 @@ GDBRemoteClientBase::ContinueLock::lock(
             log->Printf("GDBRemoteClientBase::ContinueLock::%s() cancelled", __FUNCTION__);
         return LockResult::Cancelled;
     }
-    if (m_comm.SendPacketNoLock(m_comm.m_continue_packet.data(), m_comm.m_continue_packet.size()) !=
-        PacketResult::Success)
+    if (m_comm.SendPacketNoLock(m_comm.m_continue_packet) != PacketResult::Success)
         return LockResult::Failed;
 
     lldbassert(!m_comm.m_is_running);

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=279917&r1=279916&r2=279917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Sat Aug 27 10:52:29 2016
@@ -187,12 +187,12 @@ GDBRemoteCommunication::~GDBRemoteCommun
 }
 
 char
-GDBRemoteCommunication::CalculcateChecksum (const char *payload, size_t payload_length)
+GDBRemoteCommunication::CalculcateChecksum (llvm::StringRef payload)
 {
     int checksum = 0;
 
-    for (size_t i = 0; i < payload_length; ++i)
-        checksum += payload[i];
+    for (char c : payload)
+        checksum += c;
 
     return checksum & 255;
 }
@@ -224,16 +224,16 @@ GDBRemoteCommunication::SendNack ()
 }
 
 GDBRemoteCommunication::PacketResult
-GDBRemoteCommunication::SendPacketNoLock (const char *payload, size_t payload_length)
+GDBRemoteCommunication::SendPacketNoLock (llvm::StringRef payload)
 {
     if (IsConnected())
     {
         StreamString packet(0, 4, eByteOrderBig);
 
         packet.PutChar('$');
-        packet.Write (payload, payload_length);
+        packet.Write (payload.data(), payload.size());
         packet.PutChar('#');
-        packet.PutHex8(CalculcateChecksum (payload, payload_length));
+        packet.PutHex8(CalculcateChecksum (payload));
 
         Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
         ConnectionStatus status = eConnectionStatusSuccess;
@@ -455,7 +455,7 @@ GDBRemoteCommunication::WaitForPacketWit
                         response_regex.Compile("^QC[0-9A-Fa-f]+$");
                     }
 
-                    PacketResult echo_packet_result = SendPacketNoLock (echo_packet, echo_packet_len);
+                    PacketResult echo_packet_result = SendPacketNoLock (llvm::StringRef(echo_packet, echo_packet_len));
                     if (echo_packet_result == PacketResult::Success)
                     {
                         const uint32_t max_retries = 3;
@@ -603,7 +603,7 @@ GDBRemoteCommunication::DecompressPacket
         packet_checksum_cstr[2] = '\0';
         long packet_checksum = strtol (packet_checksum_cstr, NULL, 16);
 
-        long actual_checksum = CalculcateChecksum (m_bytes.data() + 1, hash_mark_idx - 1);
+        long actual_checksum = CalculcateChecksum (llvm::StringRef(m_bytes).substr(1, hash_mark_idx - 1));
         bool success = packet_checksum == actual_checksum;
         if (!success)
         {
@@ -747,7 +747,7 @@ GDBRemoteCommunication::DecompressPacket
     new_packet.push_back ('#');
     if (GetSendAcks ())
     {
-        uint8_t decompressed_checksum = CalculcateChecksum ((const char *) decompressed_buffer, decompressed_bytes);
+        uint8_t decompressed_checksum = CalculcateChecksum (llvm::StringRef((const char *) decompressed_buffer, decompressed_bytes));
         char decompressed_checksum_str[3];
         snprintf (decompressed_checksum_str, 3, "%02x", decompressed_checksum);
         new_packet.append (decompressed_checksum_str);
@@ -1001,7 +1001,7 @@ GDBRemoteCommunication::CheckForPacket (
                     {
                         const char *packet_checksum_cstr = &m_bytes[checksum_idx];
                         char packet_checksum = strtol (packet_checksum_cstr, NULL, 16);
-                        char actual_checksum = CalculcateChecksum (packet_str.c_str(), packet_str.size());
+                        char actual_checksum = CalculcateChecksum (packet_str);
                         success = packet_checksum == actual_checksum;
                         if (!success)
                         {

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=279917&r1=279916&r2=279917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Sat Aug 27 10:52:29 2016
@@ -111,8 +111,7 @@ public:
     SendNack ();
 
     char
-    CalculcateChecksum (const char *payload,
-                        size_t payload_length);
+    CalculcateChecksum (llvm::StringRef payload);
 
     PacketType
     CheckForPacket (const uint8_t *src, 
@@ -280,8 +279,7 @@ protected:
     CompressionType m_compression_type;
 
     PacketResult
-    SendPacketNoLock (const char *payload, 
-                      size_t payload_length);
+    SendPacketNoLock (llvm::StringRef payload);
 
     PacketResult
     ReadPacket (StringExtractorGDBRemote &response, uint32_t timeout_usec, bool sync_on_timeout);

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=279917&r1=279916&r2=279917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Sat Aug 27 10:52:29 2016
@@ -103,7 +103,7 @@ GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServer::SendUnimplementedResponse (const char *)
 {
     // TODO: Log the packet we aren't handling...
-    return SendPacketNoLock ("", 0);
+    return SendPacketNoLock ("");
 }
 
 
@@ -113,7 +113,7 @@ GDBRemoteCommunicationServer::SendErrorR
     char packet[16];
     int packet_len = ::snprintf (packet, sizeof(packet), "E%2.2x", err);
     assert (packet_len < (int)sizeof(packet));
-    return SendPacketNoLock (packet, packet_len);
+    return SendPacketNoLock (llvm::StringRef(packet, packet_len));
 }
 
 GDBRemoteCommunication::PacketResult
@@ -128,7 +128,7 @@ GDBRemoteCommunicationServer::SendIllFor
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServer::SendOKResponse ()
 {
-    return SendPacketNoLock ("OK", 2);
+    return SendPacketNoLock ("OK");
 }
 
 bool

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp?rev=279917&r1=279916&r2=279917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp Sat Aug 27 10:52:29 2016
@@ -264,7 +264,7 @@ GDBRemoteCommunicationServerCommon::Hand
     if (g_default_packet_timeout_sec > 0)
         response.Printf ("default_packet_timeout:%u;", g_default_packet_timeout_sec);
 
-    return SendPacketNoLock (response.GetData(), response.GetSize());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -280,7 +280,7 @@ GDBRemoteCommunicationServerCommon::Hand
         {
             StreamString response;
             CreateProcessInfoResponse (proc_info, response);
-            return SendPacketNoLock (response.GetData(), response.GetSize());
+            return SendPacketNoLock (response.GetString());
         }
     }
     return SendErrorResponse (1);
@@ -395,7 +395,7 @@ GDBRemoteCommunicationServerCommon::Hand
         StreamString response;
         CreateProcessInfoResponse (m_proc_infos.GetProcessInfoAtIndex(m_proc_infos_index), response);
         ++m_proc_infos_index;
-        return SendPacketNoLock (response.GetData(), response.GetSize());
+        return SendPacketNoLock (response.GetString());
     }
     return SendErrorResponse (4);
 }
@@ -480,7 +480,7 @@ GDBRemoteCommunicationServerCommon::Hand
                     bytes_left = 0;
                 }
             }
-            return SendPacketNoLock (response.GetData(), response.GetSize());
+            return SendPacketNoLock (response.GetString());
         }
     }
     return SendErrorResponse (7);
@@ -510,7 +510,7 @@ GDBRemoteCommunicationServerCommon::Hand
                 response.Printf("%i", fd);
                 if (save_errno)
                     response.Printf(",%i", save_errno);
-                return SendPacketNoLock(response.GetData(), response.GetSize());
+                return SendPacketNoLock(response.GetString());
             }
         }
     }
@@ -539,7 +539,7 @@ GDBRemoteCommunicationServerCommon::Hand
     response.Printf("%i", err);
     if (save_errno)
         response.Printf(",%i", save_errno);
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -638,7 +638,7 @@ GDBRemoteCommunicationServerCommon::Hand
             response.PutChar(',');
             response.PutHex64(retcode); // TODO: replace with Host::GetSyswideErrorCode()
         }
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(22);
 }
@@ -657,7 +657,7 @@ GDBRemoteCommunicationServerCommon::Hand
         response.Printf("F%u", mode);
         if (mode == 0 || error.Fail())
             response.Printf(",%i", (int)error.GetError());
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(23);
 }
@@ -678,7 +678,7 @@ GDBRemoteCommunicationServerCommon::Hand
             response.PutChar('1');
         else
             response.PutChar('0');
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(24);
 }
@@ -694,7 +694,7 @@ GDBRemoteCommunicationServerCommon::Hand
     Error error = FileSystem::Symlink(FileSpec{src, true}, FileSpec{dst, false});
     StreamString response;
     response.Printf("F%u,%u", error.GetError(), error.GetError());
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -706,7 +706,7 @@ GDBRemoteCommunicationServerCommon::Hand
     Error error = FileSystem::Unlink(FileSpec{path, true});
     StreamString response;
     response.Printf("F%u,%u", error.GetError(), error.GetError());
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -745,7 +745,7 @@ GDBRemoteCommunicationServerCommon::Hand
                 response.PutChar(',');
                 response.PutEscapedBytes(output.c_str(), output.size());
             }
-            return SendPacketNoLock(response.GetData(), response.GetSize());
+            return SendPacketNoLock(response.GetString());
         }
     }
     return SendErrorResponse(24);
@@ -779,7 +779,7 @@ GDBRemoteCommunicationServerCommon::Hand
             response.PutHex64(a);
             response.PutHex64(b);
         }
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(25);
 }
@@ -798,7 +798,7 @@ GDBRemoteCommunicationServerCommon::Hand
         StreamGDBRemote response;
         response.Printf("F%u", error.GetError());
 
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(20);
 }
@@ -818,7 +818,7 @@ GDBRemoteCommunicationServerCommon::Hand
         StreamGDBRemote response;
         response.Printf("F%u", error.GetError());
 
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(19);
 }
@@ -840,7 +840,7 @@ GDBRemoteCommunicationServerCommon::Hand
     response.PutCString (";qXfer:auxv:read+");
 #endif
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -936,7 +936,7 @@ GDBRemoteCommunicationServerCommon::Hand
     StreamString response;
     response.PutChar('E');
     response.PutCString(m_process_launch_error.AsCString("<unknown error>"));
-    return SendPacketNoLock (response.GetData(), response.GetSize());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1077,7 +1077,7 @@ GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerCommon::Handle_qEcho (StringExtractorGDBRemote &packet)
 {
     // Just echo back the exact same packet for qEcho...
-    return SendPacketNoLock(packet.GetStringRef().c_str(), packet.GetStringRef().size());
+    return SendPacketNoLock(packet.GetStringRef());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1144,7 +1144,7 @@ GDBRemoteCommunicationServerCommon::Hand
     response.PutHex64(file_size);
     response.PutChar(';');
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 void

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp?rev=279917&r1=279916&r2=279917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp Sat Aug 27 10:52:29 2016
@@ -347,7 +347,7 @@ GDBRemoteCommunicationServerLLGS::SendWR
         StreamGDBRemote response;
         response.PutChar ('E');
         response.PutHex8 (GDBRemoteServerError::eErrorExitStatus);
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     else
     {
@@ -377,7 +377,7 @@ GDBRemoteCommunicationServerLLGS::SendWR
         // POSIX exit status limited to unsigned 8 bits.
         response.PutHex8 (return_code);
 
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
 }
 
@@ -792,7 +792,7 @@ GDBRemoteCommunicationServerLLGS::SendSt
         }
     }
 
-    return SendPacketNoLock (response.GetData(), response.GetSize());
+    return SendPacketNoLock (response.GetString());
 }
 
 void
@@ -969,7 +969,7 @@ GDBRemoteCommunicationServerLLGS::SendON
     response.PutChar ('O');
     response.PutBytesAsRawHex8 (buffer, len);
 
-    return SendPacketNoLock (response.GetData (), response.GetSize ());
+    return SendPacketNoLock (response.GetString());
 }
 
 Error
@@ -1072,7 +1072,7 @@ GDBRemoteCommunicationServerLLGS::Handle
 
     StreamString response;
     CreateProcessInfoResponse_DebugServerStyle(proc_info, response);
-    return SendPacketNoLock (response.GetData (), response.GetSize ());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1094,7 +1094,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     StreamString response;
     response.Printf ("QC%" PRIx64, thread_sp->GetID ());
 
-    return SendPacketNoLock (response.GetData(), response.GetSize());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1150,7 +1150,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     {
         StreamString response;
         response.PutCStringAsRawHex8(working_dir.GetCString());
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
 
     return SendErrorResponse(14);
@@ -1298,7 +1298,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     StreamString response;
     response.Printf("vCont;c;C;s;S");
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1635,7 +1635,7 @@ GDBRemoteCommunicationServerLLGS::Handle
            response.PutHex8 (reg_info->dynamic_size_dwarf_expr_bytes[i]);
        response.PutChar(';');
     }
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1673,14 +1673,14 @@ GDBRemoteCommunicationServerLLGS::Handle
     if (log)
         log->Printf ("GDBRemoteCommunicationServerLLGS::%s() finished thread iteration", __FUNCTION__);
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::Handle_qsThreadInfo (StringExtractorGDBRemote &packet)
 {
     // FIXME for now we return the full thread list in the initial packet and always do nothing here.
-    return SendPacketNoLock ("l", 1);
+    return SendPacketNoLock ("l");
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1757,7 +1757,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     for (uint32_t i = 0; i < reg_value.GetByteSize (); ++i)
         response.PutHex8 (data[i]);
 
-    return SendPacketNoLock (response.GetData (), response.GetSize ());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -2067,7 +2067,7 @@ GDBRemoteCommunicationServerLLGS::Handle
             response.PutHex8(buf[i]);
     }
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -2243,7 +2243,7 @@ GDBRemoteCommunicationServerLLGS::Handle
         }
     }
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -2556,7 +2556,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     if (done_with_buffer)
         m_active_auxv_buffer_sp.reset ();
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 #else
     return SendUnimplementedResponse ("not implemented on this platform");
 #endif
@@ -2612,7 +2612,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     // Write the response.
     StreamGDBRemote response;
     response.Printf ("%" PRIu32, save_id);
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -2807,7 +2807,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     threads_array_sp->Write(response);
     StreamGDBRemote escaped_response;
     escaped_response.PutEscapedBytes(response.GetData(), response.GetSize());
-    return SendPacketNoLock (escaped_response.GetData(), escaped_response.GetSize());
+    return SendPacketNoLock (escaped_response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -2827,7 +2827,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     uint32_t num = m_debugged_process_sp->GetMaxWatchpoints();
     StreamGDBRemote response;
     response.Printf ("num:%d;", num);
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -2855,7 +2855,7 @@ GDBRemoteCommunicationServerLLGS::Handle
 
     StreamGDBRemote response;
     response.PutHex64(file_load_address);
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 void

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp?rev=279917&r1=279916&r2=279917&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp Sat Aug 27 10:52:29 2016
@@ -247,7 +247,7 @@ GDBRemoteCommunicationServerPlatform::Ha
 
     StreamGDBRemote escaped_response;
     escaped_response.PutEscapedBytes(response.GetData(), response.GetSize());
-    return SendPacketNoLock(escaped_response.GetData(), escaped_response.GetSize());
+    return SendPacketNoLock(escaped_response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -353,7 +353,7 @@ GDBRemoteCommunicationServerPlatform::Ha
 
     StreamString response;
     CreateProcessInfoResponse_DebugServerStyle(proc_info, response);
-    return SendPacketNoLock (response.GetData (), response.GetSize ());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -367,7 +367,7 @@ GDBRemoteCommunicationServerPlatform::Ha
 
     StreamString response;
     response.PutBytesAsRawHex8(cwd, strlen(cwd));
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -408,7 +408,7 @@ GDBRemoteCommunicationServerPlatform::Ha
         m_process_launch_info.Clear();
     }
 
-    return SendPacketNoLock (response.GetData(), response.GetSize());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -437,7 +437,7 @@ GDBRemoteCommunicationServerPlatform::Ha
 
     StreamString response;
     signal_array.Dump(response);
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 bool

Modified: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h?rev=279917&r1=279916&r2=279917&view=diff
==============================================================================
--- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h (original)
+++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h Sat Aug 27 10:52:29 2016
@@ -37,7 +37,7 @@ struct MockServer : public GDBRemoteComm
     PacketResult
     SendPacket(llvm::StringRef payload)
     {
-        return GDBRemoteCommunicationServer::SendPacketNoLock(payload.data(), payload.size());
+        return GDBRemoteCommunicationServer::SendPacketNoLock(payload);
     }
 
     PacketResult




More information about the lldb-commits mailing list