From fd443e9b6cd0559f2dd6e51ae40eb54542fccbf0 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 7 Feb 2018 01:28:29 +0000 Subject: [PATCH] lldb running on an ios device is using the _dyld_get_all_image_infos() SPI call to to find its own shared cache's UUID. On newer sytems we need to use the a new SPI which will return the UUID directly. llvm-svn: 324437 --- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 1f03f7b64a94..6a729e97b39d 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -2113,6 +2113,11 @@ UUID ObjectFileMachO::GetSharedCacheUUID(FileSpec dyld_shared_cache, sizeof(uuid_t)); dsc_uuid.SetBytes(uuid_bytes); } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS)); + if (log && dsc_uuid.IsValid()) { + log->Printf("Shared cache %s has UUID %s", dyld_shared_cache.GetPath().c_str(), + dsc_uuid.GetAsString().c_str()); + } return dsc_uuid; } @@ -5684,6 +5689,9 @@ UUID ObjectFileMachO::GetProcessSharedCacheUUID(Process *process) { dl->GetSharedCacheInformation(load_address, uuid, using_shared_cache, private_shared_cache); } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS | LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf("inferior process shared cache has a UUID of %s", uuid.GetAsString().c_str()); return uuid; } @@ -5714,7 +5722,20 @@ UUID ObjectFileMachO::GetLLDBSharedCacheUUID() { uuid.SetBytes(sharedCacheUUID_address); } } + } else { + // Exists in macOS 10.12 and later, iOS 10.0 and later - dyld SPI + bool *(*dyld_get_shared_cache_uuid)(uuid_t); + dyld_get_shared_cache_uuid = (bool *(*)(uuid_t)) + dlsym(RTLD_DEFAULT, "_dyld_get_shared_cache_uuid"); + if (dyld_get_shared_cache_uuid) { + uuid_t tmp_uuid; + if (dyld_get_shared_cache_uuid(tmp_uuid)) + uuid.SetBytes(tmp_uuid); + } } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS | LIBLLDB_LOG_PROCESS)); + if (log && uuid.IsValid()) + log->Printf("lldb's in-memory shared cache has a UUID of %s", uuid.GetAsString().c_str()); #endif return uuid; } -- 2.34.1