[Lldb-commits] [PATCH] D117623: [lldb] Print an error message when we're reading libobjc.A.dylib from memory

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 18 16:05:50 PST 2022


JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, jingham.
JDevlieghere requested review of this revision.

Use libobjc.A.dylib as a sentinel to detect situations where we're reading libraries from memory instead of the shared cache.


https://reviews.llvm.org/D117623

Files:
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp


Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===================================================================
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -2356,24 +2356,29 @@
 }
 
 void AppleObjCRuntimeV2::WarnIfNoExpandedSharedCache() {
-  printf("We are checking to warn\n");
+#ifdef __APPLE__
   if (!m_objc_module_sp)
     return;
-  printf("We have a module\n");
 
   ObjectFile* object_file = m_objc_module_sp->GetObjectFile();
   if (!object_file)
     return;
-  printf("We have an object file\n");
 
   if (!object_file->IsInMemory())
     return;
-  printf("We are not in memory\n");
 
-  Debugger &debugger = GetProcess()->GetTarget().GetDebugger();
+  Target &target = GetProcess()->GetTarget();
+  Debugger &debugger = target.GetDebugger();
   if (auto stream = debugger.GetAsyncOutputStream()) {
-      stream->PutCString("warning: no expanded shared cache?\n");
+    const char *shared_cache_type = "";
+    if (PlatformSP platform_sp = target.GetPlatform())
+      shared_cache_type = platform_sp->IsHost() ? "host " : "expanded ";
+    stream->Printf(
+        "warning: libobjc.A.dylib is being read from memory instead of the %s"
+        "shared cache. This will likely reduce performance.\n",
+        shared_cache_type);
   }
+#endif
 }
 
 DeclVendor *AppleObjCRuntimeV2::GetDeclVendor() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117623.401027.patch
Type: text/x-patch
Size: 1487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220119/cff51195/attachment-0001.bin>


More information about the lldb-commits mailing list