diff options
Diffstat (limited to 'lldb/source')
7 files changed, 45 insertions, 47 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 8a5bbc33b0c..afa8e9c37ad 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1746,7 +1746,7 @@ int GDBRemoteCommunicationClient::SetSTDIN(const FileSpec &file_spec) { std::string path{file_spec.GetPath(false)}; StreamString packet; packet.PutCString("QSetSTDIN:"); - packet.PutCStringAsRawHex8(path.c_str()); + packet.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(packet.GetString(), response, false) == @@ -1766,7 +1766,7 @@ int GDBRemoteCommunicationClient::SetSTDOUT(const FileSpec &file_spec) { std::string path{file_spec.GetPath(false)}; StreamString packet; packet.PutCString("QSetSTDOUT:"); - packet.PutCStringAsRawHex8(path.c_str()); + packet.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(packet.GetString(), response, false) == @@ -1786,7 +1786,7 @@ int GDBRemoteCommunicationClient::SetSTDERR(const FileSpec &file_spec) { std::string path{file_spec.GetPath(false)}; StreamString packet; packet.PutCString("QSetSTDERR:"); - packet.PutCStringAsRawHex8(path.c_str()); + packet.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(packet.GetString(), response, false) == @@ -1822,7 +1822,7 @@ int GDBRemoteCommunicationClient::SetWorkingDir(const FileSpec &working_dir) { std::string path{working_dir.GetPath(false)}; StreamString packet; packet.PutCString("QSetWorkingDir:"); - packet.PutCStringAsRawHex8(path.c_str()); + packet.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(packet.GetString(), response, false) == @@ -2792,7 +2792,7 @@ lldb_private::Status GDBRemoteCommunicationClient::RunShellCommand( if (working_dir) { std::string path{working_dir.GetPath(false)}; stream.PutChar(','); - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); } StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(stream.GetString(), response, false) == @@ -2829,7 +2829,7 @@ Status GDBRemoteCommunicationClient::MakeDirectory(const FileSpec &file_spec, stream.PutCString("qPlatform_mkdir:"); stream.PutHex32(file_permissions); stream.PutChar(','); - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); llvm::StringRef packet = stream.GetString(); StringExtractorGDBRemote response; @@ -2851,7 +2851,7 @@ GDBRemoteCommunicationClient::SetFilePermissions(const FileSpec &file_spec, stream.PutCString("qPlatform_chmod:"); stream.PutHex32(file_permissions); stream.PutChar(','); - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); llvm::StringRef packet = stream.GetString(); StringExtractorGDBRemote response; @@ -2892,7 +2892,7 @@ GDBRemoteCommunicationClient::OpenFile(const lldb_private::FileSpec &file_spec, stream.PutCString("vFile:open:"); if (path.empty()) return UINT64_MAX; - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); stream.PutChar(','); stream.PutHex32(flags); stream.PutChar(','); @@ -2923,7 +2923,7 @@ lldb::user_id_t GDBRemoteCommunicationClient::GetFileSize( std::string path(file_spec.GetPath(false)); lldb_private::StreamString stream; stream.PutCString("vFile:size:"); - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(stream.GetString(), response, false) == PacketResult::Success) { @@ -2942,7 +2942,7 @@ GDBRemoteCommunicationClient::GetFilePermissions(const FileSpec &file_spec, Status error; lldb_private::StreamString stream; stream.PutCString("vFile:mode:"); - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(stream.GetString(), response, false) == PacketResult::Success) { @@ -3044,9 +3044,9 @@ Status GDBRemoteCommunicationClient::CreateSymlink(const FileSpec &src, stream.PutCString("vFile:symlink:"); // the unix symlink() command reverses its parameters where the dst if first, // so we follow suit here - stream.PutCStringAsRawHex8(dst_path.c_str()); + stream.PutStringAsRawHex8(dst_path); stream.PutChar(','); - stream.PutCStringAsRawHex8(src_path.c_str()); + stream.PutStringAsRawHex8(src_path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(stream.GetString(), response, false) == PacketResult::Success) { @@ -3077,7 +3077,7 @@ Status GDBRemoteCommunicationClient::Unlink(const FileSpec &file_spec) { stream.PutCString("vFile:unlink:"); // the unix symlink() command reverses its parameters where the dst if first, // so we follow suit here - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(stream.GetString(), response, false) == PacketResult::Success) { @@ -3107,7 +3107,7 @@ bool GDBRemoteCommunicationClient::GetFileExists( std::string path(file_spec.GetPath(false)); lldb_private::StreamString stream; stream.PutCString("vFile:exists:"); - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(stream.GetString(), response, false) == PacketResult::Success) { @@ -3126,7 +3126,7 @@ bool GDBRemoteCommunicationClient::CalculateMD5( std::string path(file_spec.GetPath(false)); lldb_private::StreamString stream; stream.PutCString("vFile:MD5:"); - stream.PutCStringAsRawHex8(path.c_str()); + stream.PutStringAsRawHex8(path); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(stream.GetString(), response, false) == PacketResult::Success) { @@ -3507,10 +3507,10 @@ bool GDBRemoteCommunicationClient::GetModuleInfo( StreamString packet; packet.PutCString("qModuleInfo:"); - packet.PutCStringAsRawHex8(module_path.c_str()); + packet.PutStringAsRawHex8(module_path); packet.PutCString(";"); const auto &triple = arch_spec.GetTriple().getTriple(); - packet.PutCStringAsRawHex8(triple.c_str()); + packet.PutStringAsRawHex8(triple); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(packet.GetString(), response, false) != diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index ddcd4cbbeb0..f27573a2f9e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -106,7 +106,7 @@ GDBRemoteCommunicationServer::SendErrorResponse(const Status &error) { if (m_send_error_strings) { lldb_private::StreamString packet; packet.Printf("E%2.2x;", static_cast<uint8_t>(error.GetError())); - packet.PutCStringAsRawHex8(error.AsCString()); + packet.PutStringAsRawHex8(error.AsCString()); return SendPacketNoLock(packet.GetString()); } else return SendErrorResponse(error.GetError()); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index 13e7748ce0a..c7a4127d9d4 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -191,13 +191,13 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo( ArchSpec host_arch(HostInfo::GetArchitecture()); const llvm::Triple &host_triple = host_arch.GetTriple(); response.PutCString("triple:"); - response.PutCStringAsRawHex8(host_triple.getTriple().c_str()); + response.PutStringAsRawHex8(host_triple.getTriple()); response.Printf(";ptrsize:%u;", host_arch.GetAddressByteSize()); const char *distribution_id = host_arch.GetDistributionId().AsCString(); if (distribution_id) { response.PutCString("distribution_id:"); - response.PutCStringAsRawHex8(distribution_id); + response.PutStringAsRawHex8(distribution_id); response.PutCString(";"); } @@ -271,12 +271,12 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo( std::string s; if (HostInfo::GetOSBuildString(s)) { response.PutCString("os_build:"); - response.PutCStringAsRawHex8(s.c_str()); + response.PutStringAsRawHex8(s); response.PutChar(';'); } if (HostInfo::GetOSKernelDescription(s)) { response.PutCString("os_kernel:"); - response.PutCStringAsRawHex8(s.c_str()); + response.PutStringAsRawHex8(s); response.PutChar(';'); } @@ -287,12 +287,12 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo( // actually have a hostname as far as the remote lldb that is connecting to // this lldb-platform is concerned response.PutCString("hostname:"); - response.PutCStringAsRawHex8("127.0.0.1"); + response.PutStringAsRawHex8("127.0.0.1"); response.PutChar(';'); #else // #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) if (HostInfo::GetHostname(s)) { response.PutCString("hostname:"); - response.PutCStringAsRawHex8(s.c_str()); + response.PutStringAsRawHex8(s); response.PutChar(';'); } #endif // #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) @@ -300,7 +300,7 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo( #else // #if defined(__APPLE__) if (HostInfo::GetHostname(s)) { response.PutCString("hostname:"); - response.PutCStringAsRawHex8(s.c_str()); + response.PutStringAsRawHex8(s); response.PutChar(';'); } #endif // #if defined(__APPLE__) @@ -439,7 +439,7 @@ GDBRemoteCommunicationServerCommon::Handle_qUserName( std::string name; if (HostInfo::LookupUserName(uid, name)) { StreamString response; - response.PutCStringAsRawHex8(name.c_str()); + response.PutStringAsRawHex8(name); return SendPacketNoLock(response.GetString()); } } @@ -460,7 +460,7 @@ GDBRemoteCommunicationServerCommon::Handle_qGroupName( std::string name; if (HostInfo::LookupGroupName(gid, name)) { StreamString response; - response.PutCStringAsRawHex8(name.c_str()); + response.PutStringAsRawHex8(name); return SendPacketNoLock(response.GetString()); } } @@ -1084,20 +1084,20 @@ GDBRemoteCommunicationServerCommon::Handle_qModuleInfo( if (!Result) return SendErrorResponse(5); response.PutCString("md5:"); - response.PutCStringAsRawHex8(Result->digest().c_str()); + response.PutStringAsRawHex8(Result->digest()); } else { response.PutCString("uuid:"); - response.PutCStringAsRawHex8(uuid_str.c_str()); + response.PutStringAsRawHex8(uuid_str); } response.PutChar(';'); const auto &module_arch = matched_module_spec.GetArchitecture(); response.PutCString("triple:"); - response.PutCStringAsRawHex8(module_arch.GetTriple().getTriple().c_str()); + response.PutStringAsRawHex8(module_arch.GetTriple().getTriple()); response.PutChar(';'); response.PutCString("file_path:"); - response.PutCStringAsRawHex8(matched_module_spec.GetFileSpec().GetCString()); + response.PutStringAsRawHex8(matched_module_spec.GetFileSpec().GetCString()); response.PutChar(';'); response.PutCString("file_offset:"); response.PutHex64(file_offset); @@ -1175,13 +1175,13 @@ void GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse( proc_info.GetUserID(), proc_info.GetGroupID(), proc_info.GetEffectiveUserID(), proc_info.GetEffectiveGroupID()); response.PutCString("name:"); - response.PutCStringAsRawHex8(proc_info.GetExecutableFile().GetCString()); + response.PutStringAsRawHex8(proc_info.GetExecutableFile().GetCString()); response.PutChar(';'); const ArchSpec &proc_arch = proc_info.GetArchitecture(); if (proc_arch.IsValid()) { const llvm::Triple &proc_triple = proc_arch.GetTriple(); response.PutCString("triple:"); - response.PutCStringAsRawHex8(proc_triple.getTriple().c_str()); + response.PutStringAsRawHex8(proc_triple.getTriple()); response.PutChar(';'); } } @@ -1215,7 +1215,7 @@ void GDBRemoteCommunicationServerCommon:: #else // We'll send the triple. response.PutCString("triple:"); - response.PutCStringAsRawHex8(proc_triple.getTriple().c_str()); + response.PutStringAsRawHex8(proc_triple.getTriple()); response.PutChar(';'); #endif std::string ostype = proc_triple.getOSName(); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 857f428d7b7..c4b5c69f761 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -622,7 +622,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( } else { // The thread name contains special chars, send as hex bytes. response.PutCString("hexname:"); - response.PutCStringAsRawHex8(thread_name.c_str()); + response.PutStringAsRawHex8(thread_name); } response.PutChar(';'); } @@ -662,7 +662,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( response.PutCString("jstopinfo:"); StreamString unescaped_response; threads_info_sp->Write(unescaped_response); - response.PutCStringAsRawHex8(unescaped_response.GetData()); + response.PutStringAsRawHex8(unescaped_response.GetData()); response.PutChar(';'); } else LLDB_LOG(log, "failed to prepare a jstopinfo field for pid {0}", @@ -763,7 +763,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread( if (!description.empty()) { // Description may contains special chars, send as hex bytes. response.PutCString("description:"); - response.PutCStringAsRawHex8(description.c_str()); + response.PutStringAsRawHex8(description); response.PutChar(';'); } else if ((tid_stop_info.reason == eStopReasonException) && tid_stop_info.details.exception.type) { @@ -1340,7 +1340,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qGetWorkingDir( FileSpec working_dir{m_process_launch_info.GetWorkingDirectory()}; if (working_dir) { StreamString response; - response.PutCStringAsRawHex8(working_dir.GetCString()); + response.PutStringAsRawHex8(working_dir.GetCString()); return SendPacketNoLock(response.GetString()); } @@ -2425,7 +2425,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfo( // Return the error message. response.PutCString("error:"); - response.PutCStringAsRawHex8(error.AsCString()); + response.PutStringAsRawHex8(error.AsCString()); response.PutChar(';'); } else { // Range start and size. @@ -2453,7 +2453,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfo( ConstString name = region_info.GetName(); if (name) { response.PutCString("name:"); - response.PutCStringAsRawHex8(name.AsCString()); + response.PutStringAsRawHex8(name.AsCString()); response.PutChar(';'); } } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index 08aa015e62c..808299120c3 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -206,7 +206,7 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer( port + m_port_offset); if (!socket_name.empty()) { response.PutCString("socket_name:"); - response.PutCStringAsRawHex8(socket_name.c_str()); + response.PutStringAsRawHex8(socket_name); response.PutChar(';'); } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 57c28d54698..1969d652744 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4930,7 +4930,7 @@ Status ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file, StreamString packet; packet.PutCString("qFileLoadAddress:"); - packet.PutCStringAsRawHex8(file_path.c_str()); + packet.PutStringAsRawHex8(file_path); StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse(packet.GetString(), response, diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index 160932ab251..69a48d62690 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -493,14 +493,12 @@ size_t Stream::PutBytesAsRawHex8(const void *s, size_t src_len, return *delta; } -size_t Stream::PutCStringAsRawHex8(const char *s) { +size_t Stream::PutStringAsRawHex8(llvm::StringRef s) { ByteDelta delta(*this); bool binary_is_set = m_flags.Test(eBinary); m_flags.Clear(eBinary); - while(*s) { - _PutHex8(*s, false); - ++s; - } + for (char c : s) + _PutHex8(c, false); if (binary_is_set) m_flags.Set(eBinary); return *delta; |