Skip to content

Commit 21c0536

Browse files
committed
[lldb] Print an error message when we're reading libobjc.A.dylib from memory
Use libobjc.A.dylib as a sentinel to detect situations where we're reading libraries from process memory instead of the shared cache. Differential revision: https://reviews.llvm.org/D117623 (cherry picked from commit d230848)
1 parent 305429a commit 21c0536

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
672672
static const ConstString g_objc_copyRealizedClassList(
673673
"_ZL33objc_copyRealizedClassList_nolockPj");
674674
m_has_objc_copyRealizedClassList = HasSymbol(g_objc_copyRealizedClassList);
675-
675+
WarnIfNoExpandedSharedCache();
676676
RegisterObjCExceptionRecognizer(process);
677677
}
678678

@@ -2372,6 +2372,32 @@ void AppleObjCRuntimeV2::WarnIfNoClassesCached(
23722372
}
23732373
}
23742374

2375+
void AppleObjCRuntimeV2::WarnIfNoExpandedSharedCache() {
2376+
if (!m_objc_module_sp)
2377+
return;
2378+
2379+
ObjectFile *object_file = m_objc_module_sp->GetObjectFile();
2380+
if (!object_file)
2381+
return;
2382+
2383+
if (!object_file->IsInMemory())
2384+
return;
2385+
2386+
Target &target = GetProcess()->GetTarget();
2387+
Debugger &debugger = target.GetDebugger();
2388+
if (auto stream = debugger.GetAsyncOutputStream()) {
2389+
const char *msg = "read from the shared cache";
2390+
if (PlatformSP platform_sp = target.GetPlatform())
2391+
msg = platform_sp->IsHost()
2392+
? "read from the host's in-memory shared cache"
2393+
: "find the on-disk shared cache for this device";
2394+
stream->Printf("warning: libobjc.A.dylib is being read from process "
2395+
"memory. This indicates that LLDB could not %s. This will "
2396+
"likely reduce debugging performance.\n",
2397+
msg);
2398+
}
2399+
}
2400+
23752401
DeclVendor *AppleObjCRuntimeV2::GetDeclVendor() {
23762402
if (!m_decl_vendor_up)
23772403
m_decl_vendor_up = std::make_unique<AppleObjCDeclVendor>(*this);

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ class AppleObjCRuntimeV2 : public AppleObjCRuntime {
401401
};
402402

403403
void WarnIfNoClassesCached(SharedCacheWarningReason reason);
404+
void WarnIfNoExpandedSharedCache();
404405

405406
lldb::addr_t GetSharedCacheReadOnlyAddress();
406407
lldb::addr_t GetSharedCacheBaseAddress();

0 commit comments

Comments
 (0)