[Lldb-commits] [lldb] r154333 - in /lldb/branches/lldb-platform-work: include/lldb/Host/ include/lldb/Target/ source/Host/common/ source/Plugins/Platform/MacOSX/ source/Plugins/Platform/gdb-server/ source/Plugins/Process/gdb-remote/

Enrico Granata egranata at apple.com
Mon Apr 9 11:51:53 PDT 2012


Author: enrico
Date: Mon Apr  9 13:51:53 2012
New Revision: 154333

URL: http://llvm.org/viewvc/llvm-project?rev=154333&view=rev
Log:
Moving file IDs from 32-bit file descriptors to 64-bit generic lldb::user_id_t. On Mac OS X they will still be actual file descriptors, but the change should make us less dependent on any given implementation of File.

Modified:
    lldb/branches/lldb-platform-work/include/lldb/Host/Host.h
    lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h
    lldb/branches/lldb-platform-work/source/Host/common/Host.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
    lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp

Modified: lldb/branches/lldb-platform-work/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Host/Host.h?rev=154333&r1=154332&r2=154333&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Host/Host.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Host/Host.h Mon Apr  9 13:51:53 2012
@@ -458,19 +458,19 @@
     static uint32_t
     MakeDirectory (const char* path, mode_t mode);
     
-    static uint32_t
+    static lldb::user_id_t
     OpenFile (const FileSpec& file_spec,
               uint32_t flags,
               mode_t mode);
     
     static bool
-    CloseFile (uint32_t fd);
+    CloseFile (lldb::user_id_t fd);
     
     static uint32_t
-    WriteFile (uint32_t fd, uint64_t offset, void* data, size_t data_len);
+    WriteFile (lldb::user_id_t fd, uint64_t offset, void* data, size_t data_len);
     
     static uint32_t
-    ReadFile (uint32_t fd, uint64_t offset, void* data_ptr, size_t len_wanted);
+    ReadFile (lldb::user_id_t fd, uint64_t offset, void* data_ptr, size_t len_wanted);
 };
 
 } // namespace lldb_private

Modified: lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h?rev=154333&r1=154332&r2=154333&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h Mon Apr  9 13:51:53 2012
@@ -463,7 +463,7 @@
             return UINT32_MAX;
         }
         
-        virtual uint32_t
+        virtual lldb::user_id_t
         OpenFile (const FileSpec& file_spec,
                   uint32_t flags,
                   mode_t mode)
@@ -472,20 +472,20 @@
         }
         
         virtual bool
-        CloseFile (uint32_t fd)
+        CloseFile (lldb::user_id_t fd)
         {
             return false;
         }
         
         virtual uint32_t
-        ReadFile (uint32_t fd, uint64_t offset,
+        ReadFile (lldb::user_id_t fd, uint64_t offset,
                   void *data_ptr, size_t len)
         {
             return UINT32_MAX;
         }
         
         virtual uint32_t
-        WriteFile (uint32_t fd, uint64_t offset,
+        WriteFile (lldb::user_id_t fd, uint64_t offset,
                    void* data, size_t len)
         {
             return UINT32_MAX;

Modified: lldb/branches/lldb-platform-work/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Host/common/Host.cpp?rev=154333&r1=154332&r2=154333&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Host/common/Host.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Host/common/Host.cpp Mon Apr  9 13:51:53 2012
@@ -1275,14 +1275,14 @@
 }
 #endif
 
-typedef std::map<uint32_t, lldb::FileSP> FDToFileMap;
+typedef std::map<lldb::user_id_t, lldb::FileSP> FDToFileMap;
 FDToFileMap& GetFDToFileMap()
 {
     static FDToFileMap g_fd2filemap;
     return g_fd2filemap;
 }
 
-uint32_t
+lldb::user_id_t
 Host::OpenFile (const FileSpec& file_spec,
                 uint32_t flags,
                 mode_t mode)
@@ -1296,16 +1296,16 @@
     }
     FileSP file_sp(new File(path.c_str(),flags,mode));
     if (file_sp->IsValid() == false)
-        return UINT32_MAX;
+        return UINT64_MAX;
     uint32_t fd = file_sp->GetDescriptor();
     GetFDToFileMap()[fd] = file_sp;
     return fd;
 }
 
 bool
-Host::CloseFile (uint32_t fd)
+Host::CloseFile (lldb::user_id_t fd)
 {
-    if (fd == UINT32_MAX)
+    if (fd == UINT64_MAX)
         return false;
     FDToFileMap::iterator i = GetFDToFileMap().find(fd),
     end = GetFDToFileMap().end();
@@ -1320,9 +1320,9 @@
 }
 
 uint32_t
-Host::WriteFile (uint32_t fd, uint64_t offset, void* data, size_t data_len)
+Host::WriteFile (lldb::user_id_t fd, uint64_t offset, void* data, size_t data_len)
 {
-    if (fd == UINT32_MAX)
+    if (fd == UINT64_MAX)
         return false;
     FDToFileMap::iterator i = GetFDToFileMap().find(fd),
     end = GetFDToFileMap().end();
@@ -1343,9 +1343,9 @@
 }
 
 uint32_t
-Host::ReadFile (uint32_t fd, uint64_t offset, void* data_ptr, size_t len_wanted)
+Host::ReadFile (lldb::user_id_t fd, uint64_t offset, void* data_ptr, size_t len_wanted)
 {
-    if (fd == UINT32_MAX)
+    if (fd == UINT64_MAX)
         return false;
     FDToFileMap::iterator i = GetFDToFileMap().find(fd),
     end = GetFDToFileMap().end();

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=154333&r1=154332&r2=154333&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Mon Apr  9 13:51:53 2012
@@ -176,7 +176,7 @@
     return Platform::MakeDirectory(path,mode);
 }
 
-uint32_t
+lldb::user_id_t
 PlatformMacOSX::OpenFile (const FileSpec& file_spec,
           uint32_t flags,
           mode_t mode)
@@ -191,7 +191,7 @@
 }
 
 bool
-PlatformMacOSX::CloseFile (uint32_t fd)
+PlatformMacOSX::CloseFile (lldb::user_id_t fd)
 {
     if (IsHost())
     {
@@ -203,7 +203,7 @@
 }
 
 uint32_t
-PlatformMacOSX::ReadFile (uint32_t fd, uint64_t offset,
+PlatformMacOSX::ReadFile (lldb::user_id_t fd, uint64_t offset,
                           void *data_ptr, size_t len)
 {
     if (IsHost())
@@ -216,7 +216,7 @@
 }
 
 uint32_t
-PlatformMacOSX::WriteFile (uint32_t fd, uint64_t offset,
+PlatformMacOSX::WriteFile (lldb::user_id_t fd, uint64_t offset,
                            void* data, size_t len)
 {
     if (IsHost())

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h?rev=154333&r1=154332&r2=154333&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h Mon Apr  9 13:51:53 2012
@@ -94,20 +94,20 @@
              uint32_t uid = UINT32_MAX,
              uint32_t gid = UINT32_MAX);
     
-    virtual uint32_t
+    virtual lldb::user_id_t
     OpenFile (const lldb_private::FileSpec& file_spec,
               uint32_t flags,
               mode_t mode);
     
     virtual bool
-    CloseFile (uint32_t fd);
+    CloseFile (lldb::user_id_t fd);
     
     virtual uint32_t
-    ReadFile (uint32_t fd, uint64_t offset,
+    ReadFile (lldb::user_id_t fd, uint64_t offset,
               void *data_ptr, size_t len);
     
     virtual uint32_t
-    WriteFile (uint32_t fd, uint64_t offset,
+    WriteFile (lldb::user_id_t fd, uint64_t offset,
                void* data, size_t len);
 
     virtual bool

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=154333&r1=154332&r2=154333&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Mon Apr  9 13:51:53 2012
@@ -418,7 +418,7 @@
     return m_gdb_client.MakeDirectory(path,mode);
 }
 
-uint32_t
+lldb::user_id_t
 PlatformRemoteGDBServer::OpenFile (const lldb_private::FileSpec& file_spec,
                                    uint32_t flags,
                                    mode_t mode)
@@ -427,20 +427,20 @@
 }
 
 bool
-PlatformRemoteGDBServer::CloseFile (uint32_t fd)
+PlatformRemoteGDBServer::CloseFile (lldb::user_id_t fd)
 {
     return m_gdb_client.CloseFile (fd);
 }
 
 uint32_t
-PlatformRemoteGDBServer::ReadFile (uint32_t fd, uint64_t offset,
+PlatformRemoteGDBServer::ReadFile (lldb::user_id_t fd, uint64_t offset,
                                    void *data_ptr, size_t len)
 {
     return m_gdb_client.ReadFile (fd, offset, data_ptr, len);
 }
 
 uint32_t
-PlatformRemoteGDBServer::WriteFile (uint32_t fd, uint64_t offset,
+PlatformRemoteGDBServer::WriteFile (lldb::user_id_t fd, uint64_t offset,
                                     void* data, size_t len)
 {
     return m_gdb_client.WriteFile (fd, offset, data, len);

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h?rev=154333&r1=154332&r2=154333&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h Mon Apr  9 13:51:53 2012
@@ -148,20 +148,20 @@
     MakeDirectory (const std::string &path,
                    mode_t mode);
     
-    virtual uint32_t
+    virtual lldb::user_id_t
     OpenFile (const lldb_private::FileSpec& file_spec,
               uint32_t flags,
               mode_t mode);
     
     virtual bool
-    CloseFile (uint32_t fd);
+    CloseFile (lldb::user_id_t fd);
     
     virtual uint32_t
-    ReadFile (uint32_t fd, uint64_t offset,
+    ReadFile (lldb::user_id_t fd, uint64_t offset,
               void *data_ptr, size_t len);
     
     virtual uint32_t
-    WriteFile (uint32_t fd, uint64_t offset,
+    WriteFile (lldb::user_id_t fd, uint64_t offset,
                void* data, size_t len);
     
     virtual lldb_private::Error

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=154333&r1=154332&r2=154333&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 Mon Apr  9 13:51:53 2012
@@ -1913,7 +1913,7 @@
 
 }
 
-uint32_t
+lldb::user_id_t
 GDBRemoteCommunicationClient::OpenFile (const lldb_private::FileSpec& file_spec,
                                         uint32_t flags,
                                         mode_t mode)
@@ -1938,39 +1938,38 @@
     if (SendPacketAndWaitForResponse(packet, packet_len, response, false))
     {
         if (response.GetChar() != 'F')
-            return UINT32_MAX;
-        uint32_t retcode = response.GetHexMaxU32(false, UINT32_MAX);
+            return UINT64_MAX;
+        uint32_t retcode = response.GetHexMaxU64(false, UINT64_MAX);
         return retcode;
     }
-    return UINT32_MAX;
+    return UINT64_MAX;
 }
 
 bool
-GDBRemoteCommunicationClient::CloseFile (uint32_t fd)
+GDBRemoteCommunicationClient::CloseFile (lldb::user_id_t fd)
 {
     lldb_private::StreamString stream;
     stream.PutCString("vFile:close:");
-    stream.PutHex32(fd);
+    stream.PutHex64(fd);
     const char* packet = stream.GetData();
     int packet_len = stream.GetSize();
     StringExtractorGDBRemote response;
     if (SendPacketAndWaitForResponse(packet, packet_len, response, false))
     {
         if (response.GetChar() != 'F')
-            return UINT32_MAX;
-        uint32_t retcode = response.GetHexMaxU32(false, UINT32_MAX);
-        return retcode;
+            return UINT64_MAX;
+        return true;
     }
-    return UINT32_MAX;
+    return UINT64_MAX;
 }
 
 uint32_t
-GDBRemoteCommunicationClient::ReadFile (uint32_t fd, uint64_t offset,
+GDBRemoteCommunicationClient::ReadFile (lldb::user_id_t fd, uint64_t offset,
                                         void *data_ptr, size_t len)
 {
     lldb_private::StreamString stream;
     stream.PutCString("vFile:pread:");
-    stream.PutHex32(fd);
+    stream.PutHex64(fd);
     stream.PutChar(',');
     stream.PutHex32(len);
     stream.PutChar(',');
@@ -2004,12 +2003,12 @@
 }
 
 uint32_t
-GDBRemoteCommunicationClient::WriteFile (uint32_t fd, uint64_t offset,
+GDBRemoteCommunicationClient::WriteFile (lldb::user_id_t fd, uint64_t offset,
                                          void* data, size_t len)
 {
     lldb_private::StreamGDBRemote stream;
     stream.PutCString("vFile:pwrite:");
-    stream.PutHex32(fd);
+    stream.PutHex64(fd);
     stream.PutChar(',');
     stream.PutHex32(offset);
     stream.PutChar(',');

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=154333&r1=154332&r2=154333&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Mon Apr  9 13:51:53 2012
@@ -332,20 +332,20 @@
     virtual uint32_t
     RunShellCommand (const std::string &command_line);
     
-    virtual uint32_t
+    virtual lldb::user_id_t
     OpenFile (const lldb_private::FileSpec& file_spec,
               uint32_t flags,
               mode_t mode);
     
     virtual bool
-    CloseFile (uint32_t fd);
+    CloseFile (lldb::user_id_t fd);
     
     virtual uint32_t
-    ReadFile (uint32_t fd, uint64_t offset,
+    ReadFile (lldb::user_id_t fd, uint64_t offset,
               void *data_ptr, size_t len);
     
     virtual uint32_t
-    WriteFile (uint32_t fd, uint64_t offset,
+    WriteFile (lldb::user_id_t fd, uint64_t offset,
                void* data, size_t len);
     
     virtual uint32_t

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=154333&r1=154332&r2=154333&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 Mon Apr  9 13:51:53 2012
@@ -895,14 +895,14 @@
     if (packet.GetChar() != ',')
         return false;
     mode_t mode = packet.GetHexMaxU32(false, UINT32_MAX);
-    uint32_t retcode = Host::OpenFile(FileSpec(path.c_str(), false), flags, mode);
+    lldb::user_id_t retcode = Host::OpenFile(FileSpec(path.c_str(), false), flags, mode);
     StreamString response;
     response.PutChar('F');
-    response.PutHex32(retcode);
-    if (retcode == UINT32_MAX)
+    response.PutHex64(retcode);
+    if (retcode == UINT64_MAX)
     {
         response.PutChar(',');
-        response.PutHex32(retcode); // TODO: replace with Host::GetSyswideErrorCode()
+        response.PutHex64(retcode); // TODO: replace with Host::GetSyswideErrorCode()
     }
     SendPacket(response);
     return true;
@@ -912,7 +912,7 @@
 GDBRemoteCommunicationServer::Handle_vFile_Close (StringExtractorGDBRemote &packet)
 {
     packet.SetFilePos(::strlen("vFile:close:"));
-    uint32_t fd = packet.GetHexMaxU32(false, UINT32_MAX);
+    lldb::user_id_t fd = packet.GetHexMaxU64(false, UINT64_MAX);
     uint32_t retcode = Host::CloseFile(fd);
     StreamString response;
     response.PutChar('F');
@@ -931,7 +931,7 @@
 {
     StreamGDBRemote response;
     packet.SetFilePos(::strlen("vFile:pread:"));
-    uint32_t fd = packet.GetHexMaxU32(false, UINT32_MAX);
+    lldb::user_id_t fd = packet.GetHexMaxU64(false, UINT64_MAX);
     if (packet.GetChar() != ',')
         return false;
     uint32_t count = packet.GetHexMaxU32(false, UINT32_MAX);
@@ -969,7 +969,7 @@
 GDBRemoteCommunicationServer::Handle_vFile_pWrite (StringExtractorGDBRemote &packet)
 {
     packet.SetFilePos(::strlen("vFile:pwrite:"));
-    uint32_t fd = packet.GetHexMaxU32(false, UINT32_MAX);
+    lldb::user_id_t fd = packet.GetHexMaxU64(false, UINT64_MAX);
     if (packet.GetChar() != ',')
         return false;
     uint32_t offset = packet.GetHexMaxU32(false, UINT32_MAX);





More information about the lldb-commits mailing list