[Lldb-commits] [lldb] r107502 - /lldb/trunk/source/Host/linux/Host.cpp

Eli Friedman eli.friedman at gmail.com
Fri Jul 2 12:38:10 PDT 2010


Author: efriedma
Date: Fri Jul  2 14:38:10 2010
New Revision: 107502

URL: http://llvm.org/viewvc/llvm-project?rev=107502&view=rev
Log:
Implement GetProgramFileSpec().


Modified:
    lldb/trunk/source/Host/linux/Host.cpp

Modified: lldb/trunk/source/Host/linux/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=107502&r1=107501&r2=107502&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/Host.cpp (original)
+++ lldb/trunk/source/Host/linux/Host.cpp Fri Jul  2 14:38:10 2010
@@ -402,23 +402,10 @@
     static FileSpec g_program_filepsec;
     if (!g_program_filepsec)
     {
-#if 0
-        std::string program_fullpath;
-        program_fullpath.resize (PATH_MAX);
-        // If DST is NULL, then return the number of bytes needed.
-        uint32_t len = program_fullpath.size();
-        int err = _NSGetExecutablePath ((char *)program_fullpath.data(), &len);
-        if (err < 0)
-        {
-            // The path didn't fit in the buffer provided, increase its size
-            // and try again
-            program_fullpath.resize(len);
-            len = program_fullpath.size();
-            err = _NSGetExecutablePath ((char *)program_fullpath.data(), &len);
-        }
-        if (err == 0)
-            g_program_filepsec.SetFile(program_fullpath.data());
-#endif
+      char exe_path[PATH_MAX];
+      ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path));
+      if (len >= 0)
+        g_program_filepsec = FileSpec(exe_path);
     }
     return g_program_filepsec;
 }





More information about the lldb-commits mailing list