Add a new directory path to
authorJason Molenda <jmolenda@apple.com>
Thu, 31 Jul 2014 06:36:24 +0000 (06:36 +0000)
committerJason Molenda <jmolenda@apple.com>
Thu, 31 Jul 2014 06:36:24 +0000 (06:36 +0000)
PlatformDarwinKernel::GetGenericSDKDirectoriesToSearch
 - /Library/Developer/KDKs where users may store
the kernel debug kits on their systems.

Change PlatformDarwinKernel::GetKextDirectoriesInSDK
to look in the root directory of places like
/Library/Developer/KDKs/KDK_10.10_14A298i.kdk
as well as the System/Library/Extensions subdir
in that directory (if it exists) and the
Library/Extensions subdir in that directory (if it
exists).
<rdar://problem/16568635>

llvm-svn: 214391

lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

index 50e1fbf..4ed96c6 100644 (file)
@@ -370,6 +370,16 @@ PlatformDarwinKernel::GetGenericSDKDirectoriesToSearch (std::vector<lldb_private
     {
         directories.push_back (generic_sdk);
     }
+
+    // The KDKs distributed from Apple installed on external
+    // developer systems may be in directories like
+    // /Library/Developer/KDKs/KDK_10.10_14A298i.kdk
+    FileSpec installed_kdks("/Library/Developer/KDKs", true);
+    if (installed_kdks.Exists() && installed_kdks.IsDirectory())
+    {
+        directories.push_back (installed_kdks);
+    }
+
 }
 
 void
@@ -487,12 +497,32 @@ PlatformDarwinKernel::GetKextDirectoriesInSDK (void *baton,
             || file_spec.GetFileNameExtension() == ConstString("kdk")))
     {
         std::string kext_directory_path = file_spec.GetPath();
-        kext_directory_path.append ("/System/Library/Extensions");
-        FileSpec kext_directory (kext_directory_path.c_str(), true);
-        if (kext_directory.Exists() && kext_directory.IsDirectory())
+
+        // Append the raw directory path, e.g. /Library/Developer/KDKs/KDK_10.10_14A298i.kdk
+        // to the directory search list -- there may be kexts sitting directly
+        // in that directory instead of being in a System/Library/Extensions subdir.
+        ((std::vector<lldb_private::FileSpec> *)baton)->push_back(file_spec);
+
+        // Check to see if there is a System/Library/Extensions subdir & add it if it exists
+
+        std::string sle_kext_directory_path (kext_directory_path);
+        sle_kext_directory_path.append ("/System/Library/Extensions");
+        FileSpec sle_kext_directory (sle_kext_directory_path.c_str(), true);
+        if (sle_kext_directory.Exists() && sle_kext_directory.IsDirectory())
+        {
+            ((std::vector<lldb_private::FileSpec> *)baton)->push_back(sle_kext_directory);
+        }
+
+        // Check to see if there is a Library/Extensions subdir & add it if it exists
+
+        std::string le_kext_directory_path (kext_directory_path);
+        le_kext_directory_path.append ("/Library/Extensions");
+        FileSpec le_kext_directory (le_kext_directory_path.c_str(), true);
+        if (le_kext_directory.Exists() && le_kext_directory.IsDirectory())
         {
-            ((std::vector<lldb_private::FileSpec> *)baton)->push_back(kext_directory);
+            ((std::vector<lldb_private::FileSpec> *)baton)->push_back(le_kext_directory);
         }
+
     }
     return FileSpec::eEnumerateDirectoryResultNext;
 }