[Lldb-commits] [lldb] r125181 - in /lldb/trunk: include/lldb/Host/File.h include/lldb/lldb-enumerations.h source/Host/common/File.cpp

Greg Clayton gclayton at apple.com
Tue Feb 8 23:19:18 PST 2011


Author: gclayton
Date: Wed Feb  9 01:19:18 2011
New Revision: 125181

URL: http://llvm.org/viewvc/llvm-project?rev=125181&view=rev
Log:
File::GetFileSpec() support for linux patch from Stephen Wilson.


Modified:
    lldb/trunk/include/lldb/Host/File.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/source/Host/common/File.cpp

Modified: lldb/trunk/include/lldb/Host/File.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=125181&r1=125180&r2=125181&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/File.h (original)
+++ lldb/trunk/include/lldb/Host/File.h Wed Feb  9 01:19:18 2011
@@ -11,6 +11,8 @@
 #define liblldb_File_h_
 #if defined(__cplusplus)
 
+#include <stdio.h>
+
 #include "lldb/lldb-private.h"
 
 namespace lldb_private {

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=125181&r1=125180&r2=125181&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Feb  9 01:19:18 2011
@@ -85,7 +85,7 @@
     eByteOrderInvalid   = 0,
     eByteOrderBig       = 1,
     eByteOrderPDP       = 2,
-    eByteOrderLittle    = 4,
+    eByteOrderLittle    = 4
 } ByteOrder;
 
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Host/common/File.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=125181&r1=125180&r2=125181&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Wed Feb  9 01:19:18 2011
@@ -269,8 +269,24 @@
     {
         error.SetErrorString("invalid file handle");
     }
+#elif defined(__linux__)
+    char proc[64];
+    char path[PATH_MAX];
+    if (::snprintf(proc, sizeof(proc), "/proc/self/fd/%d", GetDescriptor()) < 0)
+        error.SetErrorString ("Cannot resolve file descriptor\n");
+    else
+    {
+        ssize_t len;
+        if ((len = ::readlink(proc, path, sizeof(path) - 1)) == -1)
+            error.SetErrorToErrno();
+        else
+        {
+            path[len] = '\0';
+            file_spec.SetFile (path, false);
+        }
+    }
 #else
-    error.SetErrorString ("fcntl (fd, F_GETPATH, ...) is not supported on this platform");
+    error.SetErrorString ("File::GetFileSpec is not supported on this platform");
 #endif
 
     if (error.Fail())





More information about the lldb-commits mailing list