summaryrefslogtreecommitdiff
path: root/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp')
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp155
1 files changed, 147 insertions, 8 deletions
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
index 808fd96a5284..ba59887ccf27 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
@@ -158,14 +158,6 @@ PlatformRemoteAppleWatch::CreateInstance (bool force, const ArchSpec *arch)
case llvm::Triple::WatchOS: // This is the right triple value for Apple Watch 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;
@@ -322,9 +314,14 @@ PlatformRemoteAppleWatch::GetContainedFilesIntoVectorOfStringsCallback (void *ba
bool
PlatformRemoteAppleWatch::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 ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded Got DeviceSupport directory %s", device_support_dir);
+ }
if (device_support_dir)
{
const bool find_directories = true;
@@ -349,12 +346,20 @@ PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded()
if (sdk_symbols_symlink_fspec.Exists())
{
m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleWatch::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 ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
}
}
@@ -374,6 +379,10 @@ PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded()
}
if (local_sdk_cache.Exists())
{
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleWatch::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 @@ PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded()
for (uint32_t i=num_installed; i<num_sdk_infos; ++i)
{
m_sdk_directory_infos[i].user_cached = true;
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str());
+ }
}
}
}
@@ -583,6 +596,7 @@ uint32_t
PlatformRemoteAppleWatch::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();
@@ -590,6 +604,10 @@ PlatformRemoteAppleWatch::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))
@@ -629,6 +647,7 @@ PlatformRemoteAppleWatch::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];
@@ -643,7 +662,13 @@ PlatformRemoteAppleWatch::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,
@@ -654,7 +679,13 @@ PlatformRemoteAppleWatch::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",
@@ -663,7 +694,13 @@ PlatformRemoteAppleWatch::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;
}
@@ -673,6 +710,7 @@ PlatformRemoteAppleWatch::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)))
@@ -690,7 +728,13 @@ PlatformRemoteAppleWatch::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),
@@ -700,7 +744,13 @@ PlatformRemoteAppleWatch::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",
@@ -709,7 +759,13 @@ PlatformRemoteAppleWatch::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;
@@ -740,6 +796,7 @@ PlatformRemoteAppleWatch::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];
@@ -757,6 +814,10 @@ PlatformRemoteAppleWatch::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();
@@ -776,6 +837,10 @@ PlatformRemoteAppleWatch::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();
@@ -799,6 +864,10 @@ PlatformRemoteAppleWatch::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());
@@ -823,6 +892,76 @@ PlatformRemoteAppleWatch::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,