diff options
Diffstat (limited to 'source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp')
-rw-r--r-- | source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp | 156 |
1 files changed, 147 insertions, 9 deletions
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp index 04231f27ff9b5..30af2bb2250b1 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -158,14 +158,6 @@ PlatformRemoteAppleTV::CreateInstance (bool force, const ArchSpec *arch) case llvm::Triple::TvOS: // This is the right triple value for Apple TV debugging break; -#if defined(__APPLE__) - // Only accept "unknown" for the OS if the host is Apple and - // it "unknown" wasn't specified (it was just returned because it - // was NOT specified) - case llvm::Triple::UnknownOS: - create = !arch->TripleOSWasSpecified(); - break; -#endif default: create = false; break; @@ -314,9 +306,14 @@ PlatformRemoteAppleTV::GetContainedFilesIntoVectorOfStringsCallback (void *baton bool PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded() { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (m_sdk_directory_infos.empty()) { const char *device_support_dir = GetDeviceSupportDirectory(); + if (log) + { + log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded Got DeviceSupport directory %s", device_support_dir); + } if (device_support_dir) { const bool find_directories = true; @@ -341,12 +338,20 @@ PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded() if (sdk_symbols_symlink_fspec.Exists()) { m_sdk_directory_infos.push_back(sdk_directory_info); + if (log) + { + log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str()); + } } else { sdk_symbols_symlink_fspec.GetFilename().SetCString("Symbols"); if (sdk_symbols_symlink_fspec.Exists()) m_sdk_directory_infos.push_back(sdk_directory_info); + if (log) + { + log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str()); + } } } @@ -374,6 +379,10 @@ PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded() } if (local_sdk_cache.Exists()) { + if (log) + { + log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded searching %s for additional SDKs", local_sdk_cache.GetPath().c_str()); + } char path[PATH_MAX]; if (local_sdk_cache.GetPath(path, sizeof(path))) { @@ -388,6 +397,10 @@ PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded() for (uint32_t i=num_installed; i<num_sdk_infos; ++i) { m_sdk_directory_infos[i].user_cached = true; + if (log) + { + log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str()); + } } } } @@ -572,6 +585,7 @@ uint32_t PlatformRemoteAppleTV::FindFileInAllSDKs (const char *platform_file_path, FileSpecList &file_list) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE); if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded()) { const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); @@ -579,6 +593,10 @@ PlatformRemoteAppleTV::FindFileInAllSDKs (const char *platform_file_path, // First try for an exact match of major, minor and update for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx) { + if (log) + { + log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); + } if (GetFileInSDK (platform_file_path, sdk_idx, local_file)) @@ -618,6 +636,7 @@ PlatformRemoteAppleTV::GetFileInSDKRoot (const char *platform_file_path, bool symbols_dirs_only, lldb_private::FileSpec &local_file) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (sdkroot_path && sdkroot_path[0] && platform_file_path && platform_file_path[0]) { char resolved_path[PATH_MAX]; @@ -632,7 +651,13 @@ PlatformRemoteAppleTV::GetFileInSDKRoot (const char *platform_file_path, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the SDK dir %s", platform_file_path, sdkroot_path); + } return true; + } } ::snprintf (resolved_path, @@ -643,7 +668,13 @@ PlatformRemoteAppleTV::GetFileInSDKRoot (const char *platform_file_path, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the SDK dir %s/Symbols.Internal", platform_file_path, sdkroot_path); + } return true; + } ::snprintf (resolved_path, sizeof(resolved_path), "%s/Symbols%s", @@ -652,7 +683,13 @@ PlatformRemoteAppleTV::GetFileInSDKRoot (const char *platform_file_path, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the SDK dir %s/Symbols", platform_file_path, sdkroot_path); + } return true; + } } return false; } @@ -662,6 +699,7 @@ PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file, const UUID *uuid_ptr, FileSpec &local_file) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); Error error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) @@ -679,7 +717,13 @@ PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the DeviceSupport dir %s", platform_file_path, os_version_dir); + } return error; + } ::snprintf (resolved_path, sizeof(resolved_path), @@ -689,7 +733,13 @@ PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal", platform_file_path, os_version_dir); + } return error; + } ::snprintf (resolved_path, sizeof(resolved_path), "%s/Symbols/%s", @@ -698,8 +748,13 @@ PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols", platform_file_path, os_version_dir); + } return error; - + } } local_file = platform_file; if (local_file.Exists()) @@ -729,6 +784,7 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec, // then we attempt to get a shared module for the right architecture // with the right UUID. const FileSpec &platform_file = module_spec.GetFileSpec(); + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE); Error error; char platform_file_path[PATH_MAX]; @@ -746,6 +802,10 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec, const uint32_t connected_sdk_idx = GetConnectedSDKIndex (); if (connected_sdk_idx < num_sdk_infos) { + if (log) + { + log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[connected_sdk_idx].directory.GetPath().c_str()); + } if (GetFileInSDK (platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -765,6 +825,10 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec, // will tend to be valid in that same SDK. if (m_last_module_sdk_idx < num_sdk_infos) { + if (log) + { + log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[m_last_module_sdk_idx].directory.GetPath().c_str()); + } if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -788,6 +852,10 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec, // it above continue; } + if (log) + { + log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); + } if (GetFileInSDK (platform_file_path, sdk_idx, platform_module_spec.GetFileSpec())) { //printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str()); @@ -812,6 +880,76 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec, if (error.Success()) return error; + // See if the file is present in any of the module_search_paths_ptr directories. + if (!module_sp && module_search_paths_ptr && platform_file) + { + // create a vector of all the file / directory names in platform_file + // e.g. this might be /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation + // + // We'll need to look in the module_search_paths_ptr directories for + // both "UIFoundation" and "UIFoundation.framework" -- most likely the + // latter will be the one we find there. + + FileSpec platform_pull_apart (platform_file); + std::vector<std::string> path_parts; + ConstString unix_root_dir("/"); + while (true) + { + ConstString part = platform_pull_apart.GetLastPathComponent(); + platform_pull_apart.RemoveLastPathComponent(); + if (part.IsEmpty() || part == unix_root_dir) + break; + path_parts.push_back (part.AsCString()); + } + const size_t path_parts_size = path_parts.size(); + + size_t num_module_search_paths = module_search_paths_ptr->GetSize(); + for (size_t i = 0; i < num_module_search_paths; ++i) + { + // Create a new FileSpec with this module_search_paths_ptr + // plus just the filename ("UIFoundation"), then the parent + // dir plus filename ("UIFoundation.framework/UIFoundation") + // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo") + + for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) + { + FileSpec path_to_try (module_search_paths_ptr->GetFileSpecAtIndex (i)); + + // Add the components backwards. For .../PrivateFrameworks/UIFoundation.framework/UIFoundation + // path_parts is + // [0] UIFoundation + // [1] UIFoundation.framework + // [2] PrivateFrameworks + // + // and if 'j' is 2, we want to append path_parts[1] and then path_parts[0], aka + // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr path. + + for (int k = j; k >= 0; --k) + { + path_to_try.AppendPathComponent (path_parts[k]); + } + + if (path_to_try.Exists()) + { + ModuleSpec new_module_spec (module_spec); + new_module_spec.GetFileSpec() = path_to_try; + Error new_error (Platform::GetSharedModule (new_module_spec, + process, + module_sp, + NULL, + old_module_sp_ptr, + did_create_ptr)); + + if (module_sp) + { + module_sp->SetPlatformFileSpec (path_to_try); + return new_error; + } + } + } + } + } + const bool always_create = false; error = ModuleList::GetSharedModule (module_spec, module_sp, |