Don't allow direct access to StreamString's internal buffer.
This is a large API change that removes the two functions from
StreamString that return a std::string& and a const std::string&,
and instead provide one function which returns a StringRef.
Direct access to the underlying buffer violates the concept of
a "stream" which is intended to provide forward only access,
and makes porting to llvm::raw_ostream more difficult in the
future.
Differential Revision: https://reviews.llvm.org/D26698
llvm-svn: 287152
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index c0fbccb..3761f06 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1226,7 +1226,7 @@
m_async_broadcaster.BroadcastEvent(
eBroadcastBitAsyncContinue,
- new EventDataBytes(packet.GetData(), packet.GetSize()));
+ new EventDataBytes(packet.GetString().data(), packet.GetSize()));
} else
SetExitStatus(-1, error.AsCString());
@@ -1330,7 +1330,7 @@
}
if (continue_packet_error)
- continue_packet.GetString().clear();
+ continue_packet.Clear();
}
} else
continue_packet_error = true;
@@ -1455,7 +1455,7 @@
m_async_broadcaster.BroadcastEvent(
eBroadcastBitAsyncContinue,
- new EventDataBytes(continue_packet.GetData(),
+ new EventDataBytes(continue_packet.GetString().data(),
continue_packet.GetSize()));
if (listener_sp->WaitForEvent(std::chrono::seconds(5), event_sp) ==
@@ -2812,10 +2812,10 @@
else
error.SetErrorStringWithFormat(
"unexpected response to GDB server memory write packet '%s': '%s'",
- packet.GetString().c_str(), response.GetStringRef().c_str());
+ packet.GetData(), response.GetStringRef().c_str());
} else {
error.SetErrorStringWithFormat("failed to send packet: '%s'",
- packet.GetString().c_str());
+ packet.GetData());
}
return 0;
}
@@ -4043,8 +4043,7 @@
module_spec.Dump(stream);
log->Printf("ProcessGDBRemote::%s - got module info for (%s:%s) : %s",
__FUNCTION__, module_file_spec.GetPath().c_str(),
- arch.GetTriple().getTriple().c_str(),
- stream.GetString().c_str());
+ arch.GetTriple().getTriple().c_str(), stream.GetData());
}
m_cached_module_specs[key] = module_spec;
@@ -4836,7 +4835,7 @@
json_str.Flush();
log->Printf("ProcessGDBRemote::%s() "
"received Async StructuredData packet: %s",
- __FUNCTION__, json_str.GetString().c_str());
+ __FUNCTION__, json_str.GetData());
} else {
log->Printf("ProcessGDBRemote::%s"
"() received StructuredData packet:"
@@ -5083,7 +5082,7 @@
packet.GetString(), response, send_async);
result.SetStatus(eReturnStatusSuccessFinishResult);
Stream &output_strm = result.GetOutputStream();
- output_strm.Printf(" packet: %s\n", packet.GetString().c_str());
+ output_strm.Printf(" packet: %s\n", packet.GetData());
const std::string &response_str = response.GetStringRef();
if (response_str.empty())