[Lldb-commits] [lldb] r184769 - <rdar://problem/14182286>

Han Ming Ong hanming at apple.com
Mon Jun 24 11:15:05 PDT 2013


Author: hanming
Date: Mon Jun 24 13:15:05 2013
New Revision: 184769

URL: http://llvm.org/viewvc/llvm-project?rev=184769&view=rev
Log:
<rdar://problem/14182286>

Made sure that temporary object created from HarmonizeThreadIdsForProfileData() doesn’t get passed around without creating an object first.

Reviewed by Greg

Modified:
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=184769&r1=184768&r2=184769&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Mon Jun 24 13:15:05 2013
@@ -3814,7 +3814,7 @@ protected:
     AppendSTDERR (const char *s, size_t len);
     
     void
-    BroadcastAsyncProfileData(const char *s, size_t len);
+    BroadcastAsyncProfileData(const std::string &one_profile_data);
     
     static void
     STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);

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=184769&r1=184768&r2=184769&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Jun 24 13:15:05 2013
@@ -764,8 +764,8 @@ GDBRemoteCommunicationClient::SendContin
                         while ((found = input.find(end_delimiter, pos)) != std::string::npos)
                         {
                             StringExtractorGDBRemote profileDataExtractor(input.substr(pos, found).c_str());
-                            const std::string& profile_data = HarmonizeThreadIdsForProfileData(process, profileDataExtractor);
-                            process->BroadcastAsyncProfileData (profile_data.c_str(), profile_data.length());
+                            std::string profile_data = HarmonizeThreadIdsForProfileData(process, profileDataExtractor);
+                            process->BroadcastAsyncProfileData (profile_data);
                             
                             pos = found + end_delimiter_len;
                         }

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=184769&r1=184768&r2=184769&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Jun 24 13:15:05 2013
@@ -4401,10 +4401,10 @@ Process::AppendSTDERR (const char * s, s
 }
 
 void
-Process::BroadcastAsyncProfileData(const char *s, size_t len)
+Process::BroadcastAsyncProfileData(const std::string &one_profile_data)
 {
     Mutex::Locker locker (m_profile_data_comm_mutex);
-    m_profile_data.push_back(s);
+    m_profile_data.push_back(one_profile_data);
     BroadcastEventIfUnique (eBroadcastBitProfileData, new ProcessEventData (shared_from_this(), GetState()));
 }
 
@@ -4414,8 +4414,9 @@ Process::GetAsyncProfileData (char *buf,
     Mutex::Locker locker(m_profile_data_comm_mutex);
     if (m_profile_data.empty())
         return 0;
-
-    size_t bytes_available = m_profile_data.front().size();
+    
+    std::string &one_profile_data = m_profile_data.front();
+    size_t bytes_available = one_profile_data.size();
     if (bytes_available > 0)
     {
         Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
@@ -4423,13 +4424,13 @@ Process::GetAsyncProfileData (char *buf,
             log->Printf ("Process::GetProfileData (buf = %p, size = %" PRIu64 ")", buf, (uint64_t)buf_size);
         if (bytes_available > buf_size)
         {
-            memcpy(buf, m_profile_data.front().data(), buf_size);
-            m_profile_data.front().erase(0, buf_size);
+            memcpy(buf, one_profile_data.c_str(), buf_size);
+            one_profile_data.erase(0, buf_size);
             bytes_available = buf_size;
         }
         else
         {
-            memcpy(buf, m_profile_data.front().data(), bytes_available);
+            memcpy(buf, one_profile_data.c_str(), bytes_available);
             m_profile_data.erase(m_profile_data.begin());
         }
     }





More information about the lldb-commits mailing list