[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:21:30 PST 2022


JDevlieghere updated this revision to Diff 401034.
JDevlieghere added a comment.

Unbotch the patch


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117623/new/

https://reviews.llvm.org/D117623

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


Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
===================================================================
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -399,6 +399,7 @@
   };
 
   void WarnIfNoClassesCached(SharedCacheWarningReason reason);
+  void WarnIfNoExpandedSharedCache();
 
   lldb::addr_t GetSharedCacheReadOnlyAddress();
   lldb::addr_t GetSharedCacheBaseAddress();
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
@@ -671,7 +671,7 @@
   static const ConstString g_objc_copyRealizedClassList(
       "_ZL33objc_copyRealizedClassList_nolockPj");
   m_has_objc_copyRealizedClassList = HasSymbol(g_objc_copyRealizedClassList);
-
+  WarnIfNoExpandedSharedCache();
   RegisterObjCExceptionRecognizer(process);
 }
 
@@ -2355,6 +2355,32 @@
   }
 }
 
+void AppleObjCRuntimeV2::WarnIfNoExpandedSharedCache() {
+#ifdef __APPLE__
+  if (!m_objc_module_sp)
+    return;
+
+  ObjectFile *object_file = m_objc_module_sp->GetObjectFile();
+  if (!object_file)
+    return;
+
+  if (!object_file->IsInMemory())
+    return;
+
+  Target &target = GetProcess()->GetTarget();
+  Debugger &debugger = target.GetDebugger();
+  if (auto stream = debugger.GetAsyncOutputStream()) {
+    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() {
   if (!m_decl_vendor_up)
     m_decl_vendor_up = std::make_unique<AppleObjCDeclVendor>(*this);


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


More information about the lldb-commits mailing list