Author: jmolenda
Date: Mon Jun 24 15:08:43 2019
New Revision: 364243

URL: http://llvm.org/viewvc/llvm-project?rev=364243&view=rev
Log:
Don't link against the DebugSymbols private framework; try to dlopen
+ dlsym the two functions we need from there at runtime.

I'm not maintaining a negative cache if DebugSymbols is absent, so
we'll try to dlopen() it on every call to
LocateMacOSXFilesUsingDebugSymbols but this file is only built on
mac and iOS type systems, so there's a slight perf impact running
lldb on an iOS type system.

I store the function pointer results in two global variables without
any locking; two threads calling into LocateMacOSXFilesUsingDebugSymbols
for the first time will both try to set these fptrs, but they'll be
setting them to the same value, so I'm not too worried.

I didn't see where in the cmake build configurations we link against
DebugSymbols, but I removed the dependency from the xcode project
file.

<rdar://problem/49458356> 




Modified:
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Symbol/LocateSymbolFileMacOSX.cpp

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=364243&r1=364242&r2=364243&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Jun 24 15:08:43 2019
@@ -1824,7 +1824,6 @@
                6D0F613C1C80AA8900A4ECEE /* DebugMacros.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
DebugMacros.h; path = include/lldb/Symbol/DebugMacros.h; sourceTree = 
"<group>"; };
                AF116BED20CF234B0071093F /* DebugNamesDWARFIndex.cpp */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = DebugNamesDWARFIndex.cpp; sourceTree = "<group>"; };
                AF116BEE20CF234B0071093F /* DebugNamesDWARFIndex.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
DebugNamesDWARFIndex.h; sourceTree = "<group>"; };
-               265ABF6210F42EE900531910 /* DebugSymbols.framework */ = {isa = 
PBXFileReference; lastKnownFileType = wrapper.framework; name = 
DebugSymbols.framework; path = 
/System/Library/PrivateFrameworks/DebugSymbols.framework; sourceTree = 
"<absolute>"; };
                263664921140A4930075843B /* Debugger.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
lineEnding = 0; name = Debugger.cpp; path = source/Core/Debugger.cpp; 
sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
                263664941140A4C10075843B /* Debugger.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; 
lineEnding = 0; name = Debugger.h; path = include/lldb/Core/Debugger.h; 
sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; 
};
                49B01A2D15F67B1700666829 /* DeclVendor.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DeclVendor.h; path 
= include/lldb/Symbol/DeclVendor.h; sourceTree = "<group>"; };
@@ -6056,7 +6055,6 @@
                        isa = PBXGroup;
                        children = (
                                26F5C39010F3FA26009D5894 /* 
CoreFoundation.framework */,
-                               265ABF6210F42EE900531910 /* 
DebugSymbols.framework */,
                                260C876910F538E700BB2B04 /* 
Foundation.framework */,
                                26709E311964A34000B94724 /* 
LaunchServices.framework */,
                                26F5C32A10F3DFDD009D5894 /* libedit.dylib */,
@@ -9173,8 +9171,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9213,8 +9209,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9253,8 +9247,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9293,8 +9285,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9333,8 +9323,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9374,8 +9362,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9415,8 +9401,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9456,8 +9440,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9557,8 +9539,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -9625,8 +9605,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -10256,8 +10234,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -10523,8 +10499,6 @@
                                        "-lobjc",
                                        "-lpython",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Carbon,
                                        "-framework",
                                        Foundation,
@@ -10556,8 +10530,6 @@
                                        "-lpython2.7",
                                        "-lxml2",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Foundation,
                                        "-framework",
                                        Carbon,
@@ -10594,8 +10566,6 @@
                                        "-lobjc",
                                        "-lpython",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Carbon,
                                        "-framework",
                                        Foundation,
@@ -10627,8 +10597,6 @@
                                        "-lpython2.7",
                                        "-lxml2",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Foundation,
                                        "-framework",
                                        Carbon,
@@ -10664,8 +10632,6 @@
                                        "-lobjc",
                                        "-lpython",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Carbon,
                                        "-framework",
                                        Foundation,
@@ -10698,8 +10664,6 @@
                                        "-lpython2.7",
                                        "-lxml2",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Foundation,
                                        "-framework",
                                        Carbon,
@@ -10998,8 +10962,6 @@
                                        "-framework",
                                        Foundation,
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Security,
                                        "-framework",
                                        CoreServices,
@@ -11102,8 +11064,6 @@
                                        "-lobjc",
                                        "-lpython",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Carbon,
                                        "-framework",
                                        Foundation,
@@ -11135,8 +11095,6 @@
                                        "-lpython2.7",
                                        "-lxml2",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Foundation,
                                        "-framework",
                                        Carbon,
@@ -11224,8 +11182,6 @@
                                        "-lpython2.7",
                                        "-lxml2",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Foundation,
                                        "-framework",
                                        Carbon,
@@ -11290,8 +11246,6 @@
                                        "-lpython2.7",
                                        "-lxml2",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Foundation,
                                        "-framework",
                                        Carbon,
@@ -11353,8 +11307,6 @@
                                        "-lpython2.7",
                                        "-lxml2",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Foundation,
                                        "-framework",
                                        Carbon,
@@ -11418,8 +11370,6 @@
                                        "-lpython2.7",
                                        "-lxml2",
                                        "-framework",
-                                       DebugSymbols,
-                                       "-framework",
                                        Foundation,
                                        "-framework",
                                        Carbon,

Modified: lldb/trunk/source/Symbol/LocateSymbolFileMacOSX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LocateSymbolFileMacOSX.cpp?rev=364243&r1=364242&r2=364243&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/LocateSymbolFileMacOSX.cpp (original)
+++ lldb/trunk/source/Symbol/LocateSymbolFileMacOSX.cpp Mon Jun 24 15:08:43 2019
@@ -9,6 +9,7 @@
 #include "lldb/Symbol/LocateSymbolFile.h"
 
 #include <dirent.h>
+#include <dlfcn.h>
 #include <pwd.h>
 
 #include <CoreFoundation/CoreFoundation.h>
@@ -37,14 +38,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
-#if !defined(__arm__) && !defined(__arm64__) &&                                
\
-    !defined(__aarch64__) // No DebugSymbols on the iOS devices
-extern "C" {
-
-CFURLRef DBGCopyFullDSYMURLForUUID(CFUUIDRef uuid, CFURLRef exec_url);
-CFDictionaryRef DBGCopyDSYMPropertyLists(CFURLRef dsym_url);
-}
-#endif
+static CFURLRef (*g_dlsym_DBGCopyFullDSYMURLForUUID)(CFUUIDRef uuid, CFURLRef 
exec_url) = nullptr;
+static CFDictionaryRef (*g_dlsym_DBGCopyDSYMPropertyLists)(CFURLRef dsym_url) 
= nullptr;
 
 int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
                                        ModuleSpec &return_module_spec) {
@@ -61,8 +56,19 @@ int LocateMacOSXFilesUsingDebugSymbols(c
 
   int items_found = 0;
 
-#if !defined(__arm__) && !defined(__arm64__) &&                                
\
-    !defined(__aarch64__) // No DebugSymbols on the iOS devices
+  if (g_dlsym_DBGCopyFullDSYMURLForUUID == nullptr ||
+      g_dlsym_DBGCopyDSYMPropertyLists == nullptr) {
+    void *handle = dlopen 
("/System/Library/PrivateFrameworks/DebugSymbols.framework/DebugSymbols", 
RTLD_LAZY | RTLD_LOCAL);
+    if (handle) {
+      g_dlsym_DBGCopyFullDSYMURLForUUID = (CFURLRef (*)(CFUUIDRef, CFURLRef)) 
dlsym (handle, "DBGCopyFullDSYMURLForUUID");
+      g_dlsym_DBGCopyDSYMPropertyLists = (CFDictionaryRef (*)(CFURLRef)) dlsym 
(handle, "DBGCopyDSYMPropertyLists");
+    }
+  }
+
+  if (g_dlsym_DBGCopyFullDSYMURLForUUID == nullptr ||
+      g_dlsym_DBGCopyDSYMPropertyLists == nullptr) {
+    return items_found;
+  }
 
   const UUID *uuid = module_spec.GetUUIDPtr();
   const ArchSpec *arch = module_spec.GetArchitecturePtr();
@@ -89,7 +95,7 @@ int LocateMacOSXFilesUsingDebugSymbols(c
         }
 
         CFCReleaser<CFURLRef> dsym_url(
-            ::DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), 
exec_url.get()));
+            g_dlsym_DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), 
exec_url.get()));
         char path[PATH_MAX];
 
         if (dsym_url.get()) {
@@ -125,7 +131,7 @@ int LocateMacOSXFilesUsingDebugSymbols(c
           }
 
           CFCReleaser<CFDictionaryRef> dict(
-              ::DBGCopyDSYMPropertyLists(dsym_url.get()));
+              g_dlsym_DBGCopyDSYMPropertyLists(dsym_url.get()));
           CFDictionaryRef uuid_dict = NULL;
           if (dict.get()) {
             CFCString uuid_cfstr(uuid->GetAsString().c_str());
@@ -236,8 +242,6 @@ int LocateMacOSXFilesUsingDebugSymbols(c
       }
     }
   }
-#endif // #if !defined (__arm__) && !defined (__arm64__) && !defined
-       // (__aarch64__)
 
   return items_found;
 }


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to