[Lldb-commits] [lldb] r167052 - /lldb/trunk/source/Host/macosx/Symbols.cpp

Jason Molenda jmolenda at apple.com
Tue Oct 30 14:26:30 PDT 2012


Author: jmolenda
Date: Tue Oct 30 16:26:30 2012
New Revision: 167052

URL: http://llvm.org/viewvc/llvm-project?rev=167052&view=rev
Log:
Change the MacOSX Symbols::DownloadObjectAndSymbolFile to look up
"~rc" via getpwnam() instead of doing tilde expansion and doing soft-link
dereferencing via realpath() - if we're pointing to a softlink, leave it
as-is.  
<rdar://problem/12597698>

Modified:
    lldb/trunk/source/Host/macosx/Symbols.cpp

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=167052&r1=167051&r2=167052&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Tue Oct 30 16:26:30 2012
@@ -11,6 +11,7 @@
 
 // C Includes
 #include <dirent.h>
+#include <pwd.h>
 #include "llvm/Support/MachO.h"
 
 // C++ Includes
@@ -696,12 +697,27 @@
             
             if (!g_dsym_for_uuid_exe_exists)
             {
-                dsym_for_uuid_exe_spec.SetFile("~rc/bin/dsymForUUID", true);
+                dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID", false);
                 g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
                 if (!g_dsym_for_uuid_exe_exists)
                 {
-                    dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID", false);
-                    g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
+                    int bufsize;
+                    if ((bufsize = sysconf(_SC_GETPW_R_SIZE_MAX)) != -1)
+                    {
+                        char buffer[bufsize];
+                        struct passwd pwd;
+                        struct passwd *tilde_rc = NULL;
+                        // we are a library so we need to use the reentrant version of getpwnam()
+                        if (getpwnam_r ("rc", &pwd, buffer, bufsize, &tilde_rc) == 0 
+                            && tilde_rc 
+                            && tilde_rc->pw_dir)
+                        {
+                            std::string dsymforuuid_path(tilde_rc->pw_dir);
+                            dsymforuuid_path += "/bin/dsymForUUID";
+                            dsym_for_uuid_exe_spec.SetFile(dsymforuuid_path.c_str(), false);
+                            g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
+                        }
+                    }
                 }
             }
             if (!g_dsym_for_uuid_exe_exists && g_dbgshell_command != NULL)





More information about the lldb-commits mailing list