Skip to content

Commit d230848

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
1 parent eafd345 commit d230848

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
@@ -671,7 +671,7 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
671671
static const ConstString g_objc_copyRealizedClassList(
672672
"_ZL33objc_copyRealizedClassList_nolockPj");
673673
m_has_objc_copyRealizedClassList = HasSymbol(g_objc_copyRealizedClassList);
674-
674+
WarnIfNoExpandedSharedCache();
675675
RegisterObjCExceptionRecognizer(process);
676676
}
677677

@@ -2355,6 +2355,32 @@ void AppleObjCRuntimeV2::WarnIfNoClassesCached(
23552355
}
23562356
}
23572357

2358+
void AppleObjCRuntimeV2::WarnIfNoExpandedSharedCache() {
2359+
if (!m_objc_module_sp)
2360+
return;
2361+
2362+
ObjectFile *object_file = m_objc_module_sp->GetObjectFile();
2363+
if (!object_file)
2364+
return;
2365+
2366+
if (!object_file->IsInMemory())
2367+
return;
2368+
2369+
Target &target = GetProcess()->GetTarget();
2370+
Debugger &debugger = target.GetDebugger();
2371+
if (auto stream = debugger.GetAsyncOutputStream()) {
2372+
const char *msg = "read from the shared cache";
2373+
if (PlatformSP platform_sp = target.GetPlatform())
2374+
msg = platform_sp->IsHost()
2375+
? "read from the host's in-memory shared cache"
2376+
: "find the on-disk shared cache for this device";
2377+
stream->Printf("warning: libobjc.A.dylib is being read from process "
2378+
"memory. This indicates that LLDB could not %s. This will "
2379+
"likely reduce debugging performance.\n",
2380+
msg);
2381+
}
2382+
}
2383+
23582384
DeclVendor *AppleObjCRuntimeV2::GetDeclVendor() {
23592385
if (!m_decl_vendor_up)
23602386
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
@@ -399,6 +399,7 @@ class AppleObjCRuntimeV2 : public AppleObjCRuntime {
399399
};
400400

401401
void WarnIfNoClassesCached(SharedCacheWarningReason reason);
402+
void WarnIfNoExpandedSharedCache();
402403

403404
lldb::addr_t GetSharedCacheReadOnlyAddress();
404405
lldb::addr_t GetSharedCacheBaseAddress();

0 commit comments

Comments
 (0)