diff options
3 files changed, 67 insertions, 19 deletions
diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt index 5d1413ea4a0..79b7ab778c2 100644 --- a/lldb/docs/lldb-gdb-remote.txt +++ b/lldb/docs/lldb-gdb-remote.txt @@ -504,6 +504,48 @@ drwxrwxr-x 5 username groupname 4096 Aug 15 21:36 source.cpp -rw-r--r-- 1 username groupname 3190 Aug 12 16:46 Makefile //---------------------------------------------------------------------- +// "qPlatform_mkdir" +// +// BRIEF +// Creates a new directory on the connected remote machine. +// +// PRIORITY TO IMPLEMENT +// Low. This command allows LLDB clients to create new directories on +// a remote host. +// +/---------------------------------------------------------------------- + +Request: + qPlatform_mkdir:<hex-file-mode>,<ascii-hex-path> + +Reply: + F<mkdir-return-code> + mkdir called successfully and returned with the given return code + Exx + An error occurred + +//---------------------------------------------------------------------- +// "qPlatform_chmod" +// +// BRIEF +// Creates a new directory on the connected remote machine. +// +// PRIORITY TO IMPLEMENT +// Low. This command allows LLDB clients to change the permissions of +// a file on the remote host. +// +/---------------------------------------------------------------------- + +Request: + qPlatform_chmod:<hex-file-mode>,<ascii-hex-path> + +Reply: + F<chmod-return-code> + chmod called successfully and returned with the given return code + Exx + An error occurred + +//---------------------------------------------------------------------- // "qHostInfo" // // BRIEF diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 8f81278c7b5..c1951e42694 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -3168,12 +3168,14 @@ GDBRemoteCommunicationClient::MakeDirectory (const char *path, const char *packet = stream.GetData(); int packet_len = stream.GetSize(); StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse(packet, packet_len, response, false) == PacketResult::Success) - { - return Error(response.GetHexMaxU32(false, UINT32_MAX), eErrorTypePOSIX); - } - return Error(); + if (SendPacketAndWaitForResponse(packet, packet_len, response, false) != PacketResult::Success) + return Error("failed to send '%s' packet", packet); + + if (response.GetChar() != 'F') + return Error("invalid response to '%s' packet", packet); + + return Error(response.GetU32(UINT32_MAX), eErrorTypePOSIX); } Error @@ -3188,12 +3190,14 @@ GDBRemoteCommunicationClient::SetFilePermissions (const char *path, const char *packet = stream.GetData(); int packet_len = stream.GetSize(); StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse(packet, packet_len, response, false) == PacketResult::Success) - { - return Error(response.GetHexMaxU32(false, UINT32_MAX), eErrorTypePOSIX); - } - return Error(); - + + if (SendPacketAndWaitForResponse(packet, packet_len, response, false) != PacketResult::Success) + return Error("failed to send '%s' packet", packet); + + if (response.GetChar() != 'F') + return Error("invalid response to '%s' packet", packet); + + return Error(response.GetU32(false, UINT32_MAX), eErrorTypePOSIX); } static uint64_t diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index 25911ac65cb..edf38cf0faa 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -846,10 +846,11 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_mkdir (StringExtractorGDBRe std::string path; packet.GetHexByteString(path); Error error = FileSystem::MakeDirectory(path.c_str(), mode); - if (error.Success()) - return SendPacketNoLock ("OK", 2); - else - return SendErrorResponse(error.GetError()); + + StreamGDBRemote response; + response.Printf("F%u", error.GetError()); + + return SendPacketNoLock(response.GetData(), response.GetSize()); } return SendErrorResponse(20); } @@ -865,10 +866,11 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_chmod (StringExtractorGDBRe std::string path; packet.GetHexByteString(path); Error error = FileSystem::SetFilePermissions(path.c_str(), mode); - if (error.Success()) - return SendPacketNoLock ("OK", 2); - else - return SendErrorResponse(error.GetError()); + + StreamGDBRemote response; + response.Printf("F%u", error.GetError()); + + return SendPacketNoLock(response.GetData(), response.GetSize()); } return SendErrorResponse(19); } |