aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 20:23:46 +0100
committerBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 23:25:25 +0100
commitadcd02683856c30ba6f349279509acecd90063df (patch)
tree7b5927ef2ecab1618842183fac5ebe848f5832dd /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
parent5eaf44f99f0a0a3bdfa892892b8aaca841c8dbe0 (diff)
downloadllvm-adcd02683856c30ba6f349279509acecd90063df.zip
llvm-adcd02683856c30ba6f349279509acecd90063df.tar.gz
llvm-adcd02683856c30ba6f349279509acecd90063df.tar.bz2
Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 939cc2b..12b05e7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -573,7 +573,8 @@ StructuredData::ObjectSP GDBRemoteCommunicationClient::GetThreadsInfo() {
if (response.IsUnsupportedResponse()) {
m_supports_jThreadsInfo = false;
} else if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -685,7 +686,7 @@ GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses(
if (result != PacketResult::Success)
return result;
- const std::string &this_string = this_response.GetStringRef();
+ const std::string &this_string = std::string(this_response.GetStringRef());
// Check for m or l as first character; l seems to mean this is the last
// chunk
@@ -757,7 +758,7 @@ bool GDBRemoteCommunicationClient::GetLaunchSuccess(std::string &error_str) {
return true;
if (response.GetChar() == 'E') {
// A string the describes what failed when launching...
- error_str = response.GetStringRef().substr(1);
+ error_str = std::string(response.GetStringRef().substr(1));
} else {
error_str.assign("unknown error occurred launching process");
}
@@ -1000,7 +1001,7 @@ bool GDBRemoteCommunicationClient::GetGDBServerVersion() {
while (response.GetNameColonValue(name, value)) {
if (name.equals("name")) {
success = true;
- m_gdb_server_name = value;
+ m_gdb_server_name = std::string(value);
} else if (name.equals("version")) {
llvm::StringRef major, minor;
std::tie(major, minor) = value.split('.');
@@ -1158,7 +1159,7 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) {
if (!value.getAsInteger(0, sub))
++num_keys_decoded;
} else if (name.equals("arch")) {
- arch_name = value;
+ arch_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("triple")) {
StringExtractor extractor(value);
@@ -1185,10 +1186,10 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) {
os_name = "ios";
environment = "macabi";
} else
- os_name = value;
+ os_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("vendor")) {
- vendor_name = value;
+ vendor_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("endian")) {
byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
@@ -1956,9 +1957,9 @@ bool GDBRemoteCommunicationClient::DecodeProcessInfoResponse(
} else if (name.equals("cpusubtype")) {
value.getAsInteger(0, sub);
} else if (name.equals("vendor")) {
- vendor = value;
+ vendor = std::string(value);
} else if (name.equals("ostype")) {
- os_type = value;
+ os_type = std::string(value);
}
}
@@ -2049,10 +2050,10 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
os_name = "ios";
environment = "macabi";
} else
- os_name = value;
+ os_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("vendor")) {
- vendor_name = value;
+ vendor_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("endian")) {
byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
@@ -2069,7 +2070,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
if (!value.getAsInteger(16, pid))
++num_keys_decoded;
} else if (name.equals("elf_abi")) {
- elf_abi = value;
+ elf_abi = std::string(value);
++num_keys_decoded;
}
}
@@ -2536,7 +2537,7 @@ size_t GDBRemoteCommunicationClient::QueryGDBServer(
return 0;
StructuredData::ObjectSP data =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!data)
return 0;
@@ -2557,7 +2558,7 @@ size_t GDBRemoteCommunicationClient::QueryGDBServer(
std::string socket_name;
if (StructuredData::ObjectSP socket_name_osp =
element->GetValueForKey(llvm::StringRef("socket_name")))
- socket_name = socket_name_osp->GetStringValue();
+ socket_name = std::string(socket_name_osp->GetStringValue());
if (port != 0 || !socket_name.empty())
connection_urls.emplace_back(port, socket_name);
@@ -3667,7 +3668,7 @@ GDBRemoteCommunicationClient::GetModulesInfo(
}
StructuredData::ObjectSP response_object_sp =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!response_object_sp)
return llvm::None;
@@ -3722,7 +3723,7 @@ bool GDBRemoteCommunicationClient::ReadExtFeature(
return false;
}
- const std::string &str = chunk.GetStringRef();
+ const std::string &str = std::string(chunk.GetStringRef());
if (str.length() == 0) {
// should have some data in chunk
err.SetErrorString("Empty response from $qXfer packet");
@@ -3936,7 +3937,7 @@ GDBRemoteCommunicationClient::GetSupportedStructuredDataPlugins() {
if (SendPacketAndWaitForResponse("qStructuredDataPlugins", response,
send_async) == PacketResult::Success) {
m_supported_async_json_packets_sp =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (m_supported_async_json_packets_sp &&
!m_supported_async_json_packets_sp->GetAsArray()) {
// We were returned something other than a JSON array. This is