[Lldb-commits] [lldb] [lldb][Darwin] Fetch detailed binary info in chunks (PR #190720)
Jason Molenda via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 8 15:55:57 PDT 2026
================
@@ -413,26 +440,43 @@ void DynamicLoaderMacOS::AddBinaries(
Log *log = GetLog(LLDBLog::DynamicLoader);
ImageInfo::collection image_infos;
- LLDB_LOGF(log, "Adding %" PRId64 " modules.",
- (uint64_t)load_addresses.size());
- StructuredData::ObjectSP binaries_info_sp =
- m_process->GetLoadedDynamicLibrariesInfos(load_addresses);
- if (binaries_info_sp.get() && binaries_info_sp->GetAsDictionary() &&
- binaries_info_sp->GetAsDictionary()->HasKey("images") &&
- binaries_info_sp->GetAsDictionary()
- ->GetValueForKey("images")
- ->GetAsArray() &&
- binaries_info_sp->GetAsDictionary()
- ->GetValueForKey("images")
- ->GetAsArray()
- ->GetSize() == load_addresses.size()) {
- if (JSONImageInformationIntoImageInfo(binaries_info_sp, image_infos)) {
- auto images = PreloadModulesFromImageInfos(image_infos);
- UpdateSpecialBinariesFromPreloadedModules(images);
- AddModulesUsingPreloadedModules(images);
+ const size_t image_fetch_max = 600;
+ std::vector<addr_t> fetch_binaries;
+ size_t fetched = 0;
+ size_t total_image_size = load_addresses.size();
+ fetch_binaries.reserve(std::min(image_fetch_max, total_image_size));
+ while (fetched < total_image_size) {
+ size_t this_fetch_amt =
+ std::min(image_fetch_max, total_image_size - fetched);
+ fetch_binaries.resize(this_fetch_amt);
+ // `addr_t* + num_elem` -- pointer math is addr_t sized.
+ const addr_t *this_chunk_start = load_addresses.data() + fetched;
----------------
jasonmolenda wrote:
Yeah we enter this method with a vector<addr_t> that might have 800 addr_t's in it. I want to fetch the first 600 addr_t's, and then the remainder 200 addr_t's. C++20 has a std::span which acts like a vector but is an unowned reference to the data, that would be ideal. I could update the method I'm calling to take an addr_t *array, size_t count and point into the original vector<addr_t>, or take start & end iterators or something.
In the end, I opted to create a second vector<addr_t> with the subset of binaries we're operating on in the loop right now.
https://github.com/llvm/llvm-project/pull/190720
More information about the lldb-commits
mailing list