diff options
author | Han Ming Ong <hanming@apple.com> | 2012-11-29 22:14:45 +0000 |
---|---|---|
committer | Han Ming Ong <hanming@apple.com> | 2012-11-29 22:14:45 +0000 |
commit | 929a94f0263d436e92618097eab008e2d535436e (patch) | |
tree | d068b52c316edeed480fd106c51aab0ce82c69b7 /lldb/source/Target/Process.cpp | |
parent | 913c96da436e6e37bf2fcfad6ddad1918a542dd9 (diff) | |
download | bcm5719-llvm-929a94f0263d436e92618097eab008e2d535436e.tar.gz bcm5719-llvm-929a94f0263d436e92618097eab008e2d535436e.zip |
<rdar://problem/12780259>
Prevent async and sync calls to get profile data from stomping on each other.
At the same time, don't use '$' as end delimiter per chunk of profile data.
llvm-svn: 168948
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index ee44a8c5029..ca13fad86f5 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -4009,7 +4009,7 @@ void Process::BroadcastAsyncProfileData(const char *s, size_t len) { Mutex::Locker locker (m_profile_data_comm_mutex); - m_profile_data.append (s, len); + m_profile_data.push_back(s); BroadcastEventIfUnique (eBroadcastBitProfileData, new ProcessEventData (shared_from_this(), GetState())); } @@ -4017,7 +4017,10 @@ size_t Process::GetAsyncProfileData (char *buf, size_t buf_size, Error &error) { Mutex::Locker locker(m_profile_data_comm_mutex); - size_t bytes_available = m_profile_data.size(); + if (m_profile_data.empty()) + return 0; + + size_t bytes_available = m_profile_data.front().size(); if (bytes_available > 0) { LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); @@ -4025,14 +4028,14 @@ Process::GetAsyncProfileData (char *buf, size_t buf_size, Error &error) log->Printf ("Process::GetProfileData (buf = %p, size = %" PRIu64 ")", buf, (uint64_t)buf_size); if (bytes_available > buf_size) { - memcpy(buf, m_profile_data.c_str(), buf_size); - m_profile_data.erase(0, buf_size); + memcpy(buf, m_profile_data.front().data(), buf_size); + m_profile_data.front().erase(0, buf_size); bytes_available = buf_size; } else { - memcpy(buf, m_profile_data.c_str(), bytes_available); - m_profile_data.clear(); + memcpy(buf, m_profile_data.front().data(), bytes_available); + m_profile_data.erase(m_profile_data.begin()); } } return bytes_available; |