[Lldb-commits] [lldb] r154244 - in /lldb/branches/lldb-platform-work/source: Commands/CommandObjectPlatform.cpp Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Utility/StringExtractor.cpp Utility/StringExtractor.h

Enrico Granata egranata at apple.com
Fri Apr 6 18:40:39 PDT 2012


Author: enrico
Date: Fri Apr  6 20:40:39 2012
New Revision: 154244

URL: http://llvm.org/viewvc/llvm-project?rev=154244&view=rev
Log:
Fixing several issues with the first version of the file I/O commands - importing Greg's patch to mainline StringExtractor into the branch

Modified:
    lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
    lldb/branches/lldb-platform-work/source/Utility/StringExtractor.cpp
    lldb/branches/lldb-platform-work/source/Utility/StringExtractor.h

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp?rev=154244&r1=154243&r2=154244&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp Fri Apr  6 20:40:39 2012
@@ -327,6 +327,7 @@
         {
             std::string cmd_line;
             args.GetCommandString(cmd_line);
+            // TODO: make permissions safer
             uint32_t retcode = platform_sp->OpenFile(FileSpec(cmd_line.c_str(),false),0x0200 | 0x0002, 0000700 | 0000070 | 0000007);
             result.AppendMessageWithFormat("Status = %d\n",retcode);
             result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -412,10 +413,10 @@
             std::string cmd_line;
             args.GetCommandString(cmd_line);
             uint32_t fd = ::atoi(cmd_line.c_str());
-            std::string buffer(m_options.m_count,' ');
+            std::string buffer(m_options.m_count,0);
             uint32_t retcode = platform_sp->ReadFile(fd, m_options.m_offset, &buffer[0], m_options.m_count);
             result.AppendMessageWithFormat("Return = %d\n",retcode);
-            result.AppendMessageWithFormat("Data = %s\n",buffer.c_str());
+            result.AppendMessageWithFormat("Data = \"%s\"\n",buffer.c_str());
             result.SetStatus (eReturnStatusSuccessFinishResult);
         }
         else
@@ -583,7 +584,7 @@
                     if (!success)
                         error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
                     break;
-                case 's':
+                case 'd':
                     m_data.assign(option_arg);
                     break;
                     

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=154244&r1=154243&r2=154244&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Fri Apr  6 20:40:39 2012
@@ -38,7 +38,11 @@
                                                const char *listener_name, 
                                                bool is_platform) :
     Communication(comm_name),
+#ifdef LLDB_CONFIGURATION_DEBUG
+    m_packet_timeout (1000),
+#else
     m_packet_timeout (1),
+#endif
     m_sequence_mutex (Mutex::eMutexTypeRecursive),
     m_public_is_running (false),
     m_private_is_running (false),

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=154244&r1=154243&r2=154244&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Apr  6 20:40:39 2012
@@ -1969,7 +1969,7 @@
                                         void *data_ptr, size_t len)
 {
     lldb_private::StreamString stream;
-    stream.PutCString("vFile:read:");
+    stream.PutCString("vFile:pread:");
     stream.PutHex32(fd);
     stream.PutChar(',');
     stream.PutHex32(len);
@@ -1985,10 +1985,12 @@
         uint32_t retcode = response.GetHexMaxU32(false, UINT32_MAX);
         if (retcode == UINT32_MAX)
             return retcode;
-        if (response.GetChar() == ',')
+        const char next = (response.Peek() ? *response.Peek() : 0);
+        if (next == ',')
             return UINT32_MAX;
-        if (response.GetChar() == ';')
+        if (next == ';')
         {
+            response.GetChar(); // skip the semicolon
             std::string buffer;
             response.GetEscapedBinaryData(buffer);
             size_t data_to_write = len;
@@ -2006,7 +2008,7 @@
                                          void* data, size_t len)
 {
     lldb_private::StreamGDBRemote stream;
-    stream.PutCString("vFile:write:");
+    stream.PutCString("vFile:pwrite:");
     stream.PutHex32(fd);
     stream.PutChar(',');
     stream.PutHex32(offset);

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=154244&r1=154243&r2=154244&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Fri Apr  6 20:40:39 2012
@@ -886,7 +886,9 @@
 {
     packet.SetFilePos(::strlen("vFile:open:"));
     std::string path;
-    packet.GetHexByteString(path);
+    packet.GetHexByteStringTerminatedBy(path,',');
+    if (path.size() == 0)
+        return false;
     if (packet.GetChar() != ',')
         return false;
     uint32_t flags = packet.GetHexMaxU32(false, UINT32_MAX);
@@ -945,7 +947,7 @@
         SendPacket(response);
         return true;
     }
-    std::string buffer(' ',count);
+    std::string buffer(count, 0);
     uint32_t retcode = Host::ReadFile(fd, offset, &buffer[0], count);
     response.PutChar('F');
     response.PutHex32(retcode);
@@ -971,6 +973,8 @@
     if (packet.GetChar() != ',')
         return false;
     uint32_t offset = packet.GetHexMaxU32(false, UINT32_MAX);
+    if (packet.GetChar() != ',')
+        return false;
     std::string buffer;
     packet.GetEscapedBinaryData(buffer);
     uint32_t retcode = Host::WriteFile(fd, offset, &buffer[0], buffer.size());

Modified: lldb/branches/lldb-platform-work/source/Utility/StringExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Utility/StringExtractor.cpp?rev=154244&r1=154243&r2=154244&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Utility/StringExtractor.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Utility/StringExtractor.cpp Fri Apr  6 20:40:39 2012
@@ -361,6 +361,20 @@
     return str.size();
 }
 
+size_t
+StringExtractor::GetHexByteStringTerminatedBy (std::string &str,
+                                               char terminator)
+{
+    str.clear();
+    char ch;
+    while ((ch = GetHexU8(0,false)) != '\0')
+        str.append(1, ch);
+    if (Peek() && *Peek() == terminator)
+        return str.size();
+    str.clear();
+    return str.size();
+}
+
 bool
 StringExtractor::GetNameColonValue (std::string &name, std::string &value)
 {

Modified: lldb/branches/lldb-platform-work/source/Utility/StringExtractor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Utility/StringExtractor.h?rev=154244&r1=154243&r2=154244&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Utility/StringExtractor.h (original)
+++ lldb/branches/lldb-platform-work/source/Utility/StringExtractor.h Fri Apr  6 20:40:39 2012
@@ -116,6 +116,10 @@
     size_t
     GetHexByteString (std::string &str);
 
+    size_t
+    GetHexByteStringTerminatedBy (std::string &str,
+                                  char terminator);
+    
     const char *
     Peek ()
     {





More information about the lldb-commits mailing list