[Lldb-commits] [lldb] [lldb] Don't cache symtabs for memory modules w/ corefile (PR #237050)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 29 19:03:28 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Jason Molenda (jasonmolenda)
<details>
<summary>Changes</summary>
In https://github.com/llvm/llvm-project/pull/229305 I added a new setting, `symbols.enable-lldb-index-cache-memory-modules` which creates a DataFileCache symtab file for memory-read modules. Reading the symbol table out of memory is a serious performance issue, and caching those tables on the debug host is worth doing by default.
This is not the correct tradeoff if we are doing corefile debugging, where reading memory is cheap. In that case we need to ignore the `symbols.enable-lldb-index-cache-memory-modules` setting and not create the symtabs, unless the user has set
`symbols.enable-lldb-index-cache` themselves.
This patchset is a little tricky because the layers where we can make this judgement (DynamicLoader or Process) is pretty far away from the place where we create the Symtab, `ObjectFile::GetSymtab` and there is another scenario I want to override the default for in the future that is only knowable to the DynamicLoader (if the DynamicLoader believes ALL binaries are being read from memory, which indicates an error of the target device setup, then we will avoid creating symtab caches for all binaries, expecting the user to set up the target device properly. A future PR).
The DynamicLoader methods that call `Process::ReadModuleFromMemory` are the place where this decision is made. This argument is passed through `Module::GetMemoryObjectFile`, then through `ObjectFile::FindPlugin`. All ObjectFile memory-module subclass methods receive the new override parameter, and set an ObjectFile ivar. When ObjectFile creates a Symtab in ObjectFile::GetSymtab, it passes that setting through Symtab. Which is, in turn, passed to `Module::GetIndexCache()` which has the logic that decides whether to use the DataFileCache or not, based on whether this is a memory module, whether we are (now) overriding memory-module caching, and the user lldb-index settings.
The PR is 95% all mechanical passing around of the new argument; the DynamicLoader methods calling `Process::ReadModuleFromMemory` and `Module::GetIndexCache` have the logic of interest, everything else is trivial and obvious.
There is a new test case that creates a corefile with a binary, clears lldb's global module cache store, removes the binary from disk (so lldb must read it from corefile memory), then loads the corefile and confirms that a DataFileCache symtab was not created for the binary.
rdar://190698277
Assisted-by: Claude
---
Patch is 55.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/237050.diff
46 Files Affected:
- (modified) lldb/include/lldb/Core/Module.h (+11-1)
- (modified) lldb/include/lldb/Expression/ObjectFileJIT.h (+2-1)
- (modified) lldb/include/lldb/Symbol/ObjectFile.h (+21-1)
- (modified) lldb/include/lldb/Symbol/Symtab.h (+2-1)
- (modified) lldb/include/lldb/Target/Process.h (+5)
- (modified) lldb/include/lldb/lldb-private-interfaces.h (+2-1)
- (modified) lldb/source/API/SBModule.cpp (+5-1)
- (modified) lldb/source/Core/DynamicLoader.cpp (+10-3)
- (modified) lldb/source/Core/Module.cpp (+9-5)
- (modified) lldb/source/Expression/ObjectFileJIT.cpp (+4-4)
- (modified) lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (+11-2)
- (modified) lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp (+11-2)
- (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+9-3)
- (modified) lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (+5-1)
- (modified) lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp (+5-2)
- (modified) lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (+4)
- (modified) lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/COFF/ObjectFileCOFF.cpp (+5-3)
- (modified) lldb/source/Plugins/ObjectFile/COFF/ObjectFileCOFF.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+3-1)
- (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp (+4-4)
- (modified) lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+3-1)
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp (+4-4)
- (modified) lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (+3-1)
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.cpp (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h (+2-1)
- (modified) lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp (+5-4)
- (modified) lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h (+2-1)
- (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp (+4)
- (modified) lldb/source/Symbol/ObjectFile.cpp (+10-7)
- (modified) lldb/source/Symbol/Symtab.cpp (+7-4)
- (modified) lldb/source/Target/Process.cpp (+4-3)
- (added) lldb/test/API/functionalities/module_cache/corefile_memory_module/Makefile (+3)
- (added) lldb/test/API/functionalities/module_cache/corefile_memory_module/TestModuleCacheCorefileMemoryModule.py (+86)
- (added) lldb/test/API/functionalities/module_cache/corefile_memory_module/main.cpp (+19)
- (modified) lldb/unittests/ObjectFile/MachO/TestObjectFileMachO.cpp (+3-3)
- (modified) lldb/unittests/Symbol/SymtabTest.cpp (+4-3)
``````````diff
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 04aee9c101b444..5c4fe9fd2beb0a 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -596,11 +596,16 @@ class Module : public std::enable_shared_from_this<Module>,
/// enable the ObjectFile plugins to read the header of the object file
/// without going back to the process.
///
+ /// If \a disable_memory_symtab_caching is true, the symbol table for the
+ /// object file will not be loaded from or saved to the index cache, even if
+ /// caching of memory modules is enabled.
+ ///
/// \return
/// The object file loaded from memory or nullptr, if the operation
/// failed (see the `error` for more information in that case).
ObjectFile *GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr, Status &error,
+ bool disable_memory_symtab_caching,
size_t size_to_read = 512);
/// Get the module's symbol file
@@ -1047,10 +1052,15 @@ class Module : public std::enable_shared_from_this<Module>,
/// \param[in] memory_module
/// True if this binary exists only in memory.
///
+ /// \param[in] disable_memory_symtab_caching
+ /// If true, ignore the setting that enables the index cache for memory
+ /// modules.
+ ///
/// \returns
/// If caching is enabled in the lldb settings, return a pointer to the data
/// file cache. If caching is not enabled, return NULL.
- static DataFileCache *GetIndexCache(bool memory_module);
+ static DataFileCache *
+ GetIndexCache(bool memory_module, bool disable_memory_symtab_caching = false);
protected:
// Member Variables
diff --git a/lldb/include/lldb/Expression/ObjectFileJIT.h b/lldb/include/lldb/Expression/ObjectFileJIT.h
index 61e364fda4240d..d86c1d3051c4a5 100644
--- a/lldb/include/lldb/Expression/ObjectFileJIT.h
+++ b/lldb/include/lldb/Expression/ObjectFileJIT.h
@@ -59,7 +59,8 @@ class ObjectFileJIT : public ObjectFile {
static lldb_private::ObjectFile *CreateMemoryInstance(
const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
- const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+ const lldb::ProcessSP &process_sp, lldb::addr_t header_addr,
+ bool disable_memory_symtab_caching);
static ModuleSpecList
GetModuleSpecifications(const lldb_private::FileSpec &file,
diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index f626d0395ecf6a..a9e8b1a0c9d3c5 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -169,10 +169,16 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
///
/// \param[in] header_addr
/// The address of the header for the object file in memory.
+ ///
+ /// \param[in] disable_memory_symtab_caching
+ /// If true, the symbol table for this object file will not be loaded
+ /// from or saved to the index cache, even if caching of memory modules
+ /// is enabled. This is used for binaries read out of a corefile.
static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr,
- lldb::WritableDataBufferSP file_data_sp);
+ lldb::WritableDataBufferSP file_data_sp,
+ bool disable_memory_symtab_caching);
static ModuleSpecList
GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset,
@@ -691,6 +697,17 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
/// Returns true if the object file exists only in memory.
bool IsInMemory() const { return m_memory_addr != LLDB_INVALID_ADDRESS; }
+ /// Returns true if the symbol table for this in-memory object file should
+ /// not be loaded from the index cache, even if caching of memory modules is
+ /// enabled.
+ bool GetDisableMemorySymtabCaching() const {
+ return m_disable_memory_symtab_caching;
+ }
+
+ void SetDisableMemorySymtabCaching(bool disable) {
+ m_disable_memory_symtab_caching = disable;
+ }
+
// Strip linker annotations (such as @@VERSION) from symbol names.
virtual llvm::StringRef
StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const {
@@ -782,6 +799,9 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
lldb::ProcessWP m_process_wp;
/// Set if the object file only exists in memory.
const lldb::addr_t m_memory_addr;
+ /// Set if the symbol table for an in-memory object file should not be
+ /// loaded from the index cache.
+ bool m_disable_memory_symtab_caching;
std::unique_ptr<lldb_private::SectionList> m_sections_up;
std::recursive_mutex m_sections_mutex;
diff --git a/lldb/include/lldb/Symbol/Symtab.h b/lldb/include/lldb/Symbol/Symtab.h
index ea5e2d8044402b..99b6585ff5d568 100644
--- a/lldb/include/lldb/Symbol/Symtab.h
+++ b/lldb/include/lldb/Symbol/Symtab.h
@@ -32,7 +32,7 @@ class Symtab {
enum Visibility { eVisibilityAny, eVisibilityExtern, eVisibilityPrivate };
- Symtab(ObjectFile *objfile);
+ Symtab(ObjectFile *objfile, bool disable_memory_symtab_caching);
~Symtab();
void PreloadSymbols();
@@ -284,6 +284,7 @@ class Symtab {
bool m_name_indexes_computed = false;
bool m_loaded_from_cache = false;
bool m_saved_to_cache = false;
+ bool m_disable_memory_symtab_caching = false;
private:
UniqueCStringMap<uint32_t> &
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 226c58034dd655..95bac144c93c9c 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2072,11 +2072,16 @@ class Process : public std::enable_shared_from_this<Process>,
/// \param[in] header_addr
/// The address pointing to the beginning of the object file's header.
///
+ /// \param[in] disable_memory_symtab_caching
+ /// If true, the symbol table for this module will not be loaded from or
+ /// saved to the index cache, even if caching of memory modules is enabled.
+ ///
/// \param[in] size_to_read
/// The number of bytes to read from memory. This should be large enough to
/// identify the object file format. Defaults to 512.
llvm::Expected<lldb::ModuleSP>
ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr,
+ bool disable_memory_symtab_caching,
size_t size_to_read = 512);
/// Attempt to get the attributes for a region of memory in the process.
diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h
index 276774a2ec3fde..16769e9367bb42 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -56,7 +56,8 @@ typedef ObjectFile *(*ObjectFileCreateInstance)(
lldb::offset_t file_offset, lldb::offset_t length);
typedef ObjectFile *(*ObjectFileCreateMemoryInstance)(
const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
- const lldb::ProcessSP &process_sp, lldb::addr_t offset);
+ const lldb::ProcessSP &process_sp, lldb::addr_t offset,
+ bool disable_memory_symtab_caching);
typedef bool (*ObjectFileSaveCore)(const lldb::ProcessSP &process_sp,
lldb_private::SaveCoreOptions &options,
Status &error);
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 4bc3df9992a72e..0ae426775d39ff 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -53,8 +53,12 @@ SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr) {
ProcessSP process_sp(process.GetSP());
if (process_sp) {
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)process_sp->GetCoreFile();
llvm::Expected<ModuleSP> module_sp_or_err =
- process_sp->ReadModuleFromMemory(FileSpec(), header_addr);
+ process_sp->ReadModuleFromMemory(FileSpec(), header_addr,
+ disable_memory_symtab_caching);
if (auto err = module_sp_or_err.takeError()) {
llvm::consumeError(std::move(err));
return;
diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp
index 18226fb2be887a..94ab706300dce5 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -183,8 +183,12 @@ ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
// We have a core file, try to load the image from memory if we didn't find
// the module.
if (!module_sp && !m_process->IsLiveDebugSession()) {
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)m_process->GetCoreFile();
llvm::Expected<ModuleSP> memory_module_sp_or_err =
- m_process->ReadModuleFromMemory(file, base_addr);
+ m_process->ReadModuleFromMemory(file, base_addr,
+ disable_memory_symtab_caching);
if (auto err = memory_module_sp_or_err.takeError())
LLDB_LOG_ERROR(GetLog(LLDBLog::DynamicLoader), std::move(err),
"Failed to read module from memory: {0}");
@@ -206,8 +210,11 @@ static ModuleSP ReadUnnamedMemoryModule(Process *process, addr_t addr,
snprintf(namebuf, sizeof(namebuf), "memory-image-0x%" PRIx64, addr);
name = namebuf;
}
- llvm::Expected<ModuleSP> module_sp_or_err =
- process->ReadModuleFromMemory(FileSpec(name), addr);
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)process->GetCoreFile();
+ llvm::Expected<ModuleSP> module_sp_or_err = process->ReadModuleFromMemory(
+ FileSpec(name), addr, disable_memory_symtab_caching);
if (auto err = module_sp_or_err.takeError()) {
LLDB_LOG_ERROR(GetLog(LLDBLog::DynamicLoader), std::move(err),
"Failed to read module from memory: {0}");
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index d59c0fbaca97cd..4b0e80bfcca5de 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -288,6 +288,7 @@ Module::~Module() {
ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr, Status &error,
+ bool disable_memory_symtab_caching,
size_t size_to_read) {
if (m_objfile_sp) {
error = Status::FromErrorString("object file already exists");
@@ -304,8 +305,9 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
if (bytes_read < size_to_read)
data_sp->SetByteSize(bytes_read);
if (data_sp->GetByteSize() > 0) {
- m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp,
- header_addr, data_sp);
+ m_objfile_sp =
+ ObjectFile::FindPlugin(shared_from_this(), process_sp, header_addr,
+ data_sp, disable_memory_symtab_caching);
if (m_objfile_sp) {
m_memory_module_addr = header_addr;
@@ -1666,12 +1668,14 @@ std::string Module::GetCacheKey() {
return key;
}
-DataFileCache *Module::GetIndexCache(bool memory_module) {
+DataFileCache *Module::GetIndexCache(bool memory_module,
+ bool disable_memory_symtab_caching) {
bool lldb_index_enabled = false;
if (ModuleList::GetGlobalModuleListProperties().GetEnableLLDBIndexCache())
lldb_index_enabled = true;
- if (memory_module && ModuleList::GetGlobalModuleListProperties()
- .GetEnableLLDBIndexCacheMemoryModules())
+ if (memory_module && !disable_memory_symtab_caching &&
+ ModuleList::GetGlobalModuleListProperties()
+ .GetEnableLLDBIndexCacheMemoryModules())
lldb_index_enabled = true;
if (!lldb_index_enabled)
return nullptr;
diff --git a/lldb/source/Expression/ObjectFileJIT.cpp b/lldb/source/Expression/ObjectFileJIT.cpp
index b4fe84e868e766..022768236ad0dd 100644
--- a/lldb/source/Expression/ObjectFileJIT.cpp
+++ b/lldb/source/Expression/ObjectFileJIT.cpp
@@ -51,10 +51,10 @@ ObjectFile *ObjectFileJIT::CreateInstance(const lldb::ModuleSP &module_sp,
return nullptr;
}
-ObjectFile *ObjectFileJIT::CreateMemoryInstance(const lldb::ModuleSP &module_sp,
- WritableDataBufferSP data_sp,
- const ProcessSP &process_sp,
- lldb::addr_t header_addr) {
+ObjectFile *ObjectFileJIT::CreateMemoryInstance(
+ const lldb::ModuleSP &module_sp, WritableDataBufferSP data_sp,
+ const ProcessSP &process_sp, lldb::addr_t header_addr,
+ bool disable_memory_symtab_caching) {
// JIT'ed object file is backed by the ObjectFileJITDelegate, never read from
// memory
return nullptr;
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 7428523ae763b4..85c9ac0d65eccd 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -468,8 +468,12 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr,
if (header.filetype == llvm::MachO::MH_EXECUTE &&
(header.flags & llvm::MachO::MH_DYLDLINK) == 0) {
// Create a full module to get the UUID
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)process->GetCoreFile();
llvm::Expected<ModuleSP> memory_module_sp_or_err =
- process->ReadModuleFromMemory(FileSpec("temp_mach_kernel"), addr);
+ process->ReadModuleFromMemory(FileSpec("temp_mach_kernel"), addr,
+ disable_memory_symtab_caching);
if (auto err = memory_module_sp_or_err.takeError()) {
LLDB_LOG_ERROR(log, std::move(err),
"DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
@@ -673,8 +677,13 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule(
size_to_read = sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds;
}
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)process->GetCoreFile();
llvm::Expected<ModuleSP> memory_module_sp_or_err =
- process->ReadModuleFromMemory(file_spec, m_load_address, size_to_read);
+ process->ReadModuleFromMemory(file_spec, m_load_address,
+ disable_memory_symtab_caching,
+ size_to_read);
if (auto err = memory_module_sp_or_err.takeError()) {
LLDB_LOG_ERROR(log, std::move(err),
"KextImageInfo::ReadMemoryModule failed to read module from "
diff --git a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
index eb08683f4f1e67..f2520266c3d1c0 100644
--- a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
@@ -296,8 +296,12 @@ lldb_private::UUID DynamicLoaderFreeBSDKernel::CheckForKernelImageAtAddress(
if (header.e_type != expected_type)
return UUID();
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)process->GetCoreFile();
llvm::Expected<ModuleSP> memory_module_sp_or_err =
- process->ReadModuleFromMemory(FileSpec("temp_freebsd_kernel"), addr);
+ process->ReadModuleFromMemory(FileSpec("temp_freebsd_kernel"), addr,
+ disable_memory_symtab_caching);
if (auto err = memory_module_sp_or_err.takeError()) {
LLDB_LOG_ERROR(log, std::move(err),
"DynamicLoaderFreeBSDKernel::CheckForKernelImageAtAddress: "
@@ -394,8 +398,13 @@ bool DynamicLoaderFreeBSDKernel::KModImageInfo::ReadMemoryModule(
}
}
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)process->GetCoreFile();
llvm::Expected<ModuleSP> memory_module_sp_or_err =
- process->ReadModuleFromMemory(file_spec, m_load_address, size_to_read);
+ process->ReadModuleFromMemory(file_spec, m_load_address,
+ disable_memory_symtab_caching,
+ size_to_read);
if (auto err = memory_module_sp_or_err.takeError()) {
LLDB_LOG_ERROR(log, std::move(err),
"KextImageInfo::ReadMemoryModule: Failed to read module "
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 6afda72dbbfff2..de94de7d6a75cd 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -179,8 +179,11 @@ ModuleSP DynamicLoaderDarwin::FindTargetModuleForImageInfo(
// We'll call Target::ModulesDidLoad after all the modules have been
// added to the target, don't let it be called for every one.
if (!module_sp || module_sp->GetObjectFile() == nullptr) {
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)m_process->GetCoreFile();
llvm::Expected<ModuleSP> module_sp_or_err = m_process->ReadModuleFromMemory(
- image_info.file_spec, image_info.address,
+ image_info.file_spec, image_info.address, disable_memory_symtab_caching,
image_info.mh_and_load_cmd_size);
if (auto err = module_sp_or_err.takeError()) {
LLDB_LOG_ERROR(GetLog(LLDBLog::DynamicLoader), std::move(err),
@@ -785,9 +788,12 @@ bool DynamicLoaderDarwin::AddModulesUsingPreloadedModules(
true /* notify */);
if (!commpage_image_module_sp ||
commpage_image_module_sp->GetObjectFile() == nullptr) {
+ const bool disable_memory_symtab_caching =
+ (bool)m_process->GetCoreFile();
llvm::Expected<ModuleSP> module_sp_or_err =
- m_process->ReadModuleFromMemory(image_info.file_spec,
- image_info.address);
+ m_process->ReadModuleFromMemory(
+ image_info.file_spec, image_info.address,
+ disable_memory_symtab_caching);
if (auto err = module_sp_or_err.takeError()) {
LLDB_LOG_ERROR(log, std::move(err),
"Failed to read module from memory: {0}");
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 0ecb4528771a7f..a04496d4959e04 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -609,8 +609,12 @@ void DynamicLoaderPOSIXDYLD::LoadVDSO() {
return;
}
+ // Don't use the index cache for symbol tables of binaries read out of a
+ // corefile.
+ const bool disable_memory_symtab_caching = (bool)m_process->GetCoreFile();
llvm::Expected<ModuleSP> module_sp_or_err = m_process->ReadModuleFromMemory(
- file, m_vdso_base, info.GetRange().GetByteSize());
+ file, m_vdso_base, disable_memory_symtab_caching,
+...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/237050
More information about the lldb-commits
mailing list