[Lldb-commits] [lldb] r230213 - Fix the communication in qPlatform_[mkdir, chmod]
Tamas Berghammer
tberghammer at google.com
Mon Feb 23 03:03:08 PST 2015
Author: tberghammer
Date: Mon Feb 23 05:03:08 2015
New Revision: 230213
URL: http://llvm.org/viewvc/llvm-project?rev=230213&view=rev
Log:
Fix the communication in qPlatform_[mkdir,chmod]
With the previous implementation the protocol used by the client and the
server for the response was different and worked only by an accident.
With this change the communication is fixed and the return code from
mkdir and chmod correctly captured by lldb. The change also add
documentation for the qPlatform__[mkdir,chmod] packages.
Differential revision: http://reviews.llvm.org/D7786
Modified:
lldb/trunk/docs/lldb-gdb-remote.txt
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
Modified: lldb/trunk/docs/lldb-gdb-remote.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=230213&r1=230212&r2=230213&view=diff
==============================================================================
--- lldb/trunk/docs/lldb-gdb-remote.txt (original)
+++ lldb/trunk/docs/lldb-gdb-remote.txt Mon Feb 23 05:03:08 2015
@@ -504,6 +504,48 @@ drwxrwxr-x 5 username groupname 4096
-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
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=230213&r1=230212&r2=230213&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Feb 23 05:03:08 2015
@@ -3168,12 +3168,14 @@ GDBRemoteCommunicationClient::MakeDirect
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::SetFilePer
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
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp?rev=230213&r1=230212&r2=230213&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp Mon Feb 23 05:03:08 2015
@@ -846,10 +846,11 @@ GDBRemoteCommunicationServerCommon::Hand
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::Hand
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);
}
More information about the lldb-commits
mailing list