[Lldb-commits] [lldb] [lldb][Darwin] Fetch detailed binary info in chunks (PR #190720)

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 9 18:27:41 PDT 2026


================
@@ -203,22 +199,53 @@ void DynamicLoaderMacOS::DoInitialImageFetch() {
   UnloadAllImages();
 
   StructuredData::ObjectSP all_image_info_json_sp(
-      m_process->GetLoadedDynamicLibrariesInfos());
+      m_process->GetLoadedDynamicLibrariesInfos(
+          /*include_mh_and_load_commands=*/false));
   ImageInfo::collection image_infos;
   if (all_image_info_json_sp.get() &&
       all_image_info_json_sp->GetAsDictionary() &&
       all_image_info_json_sp->GetAsDictionary()->HasKey("images") &&
       all_image_info_json_sp->GetAsDictionary()
           ->GetValueForKey("images")
           ->GetAsArray()) {
-    if (JSONImageInformationIntoImageInfo(all_image_info_json_sp,
-                                          image_infos)) {
-      LLDB_LOGF(log, "Initial module fetch:  Adding %" PRId64 " modules.\n",
-                (uint64_t)image_infos.size());
-
-      auto images = PreloadModulesFromImageInfos(image_infos);
-      UpdateSpecialBinariesFromPreloadedModules(images);
-      AddModulesUsingPreloadedModules(images);
+
+    // Older debugserver (pre-2024-ish) will not recognize the
+    // include_mh_and_load_commands==false option above, and
+    // will return the full binary information including mach
+    // header and segments/load commands.  The response includes
+    // the full information on all binaries.
+    StructuredData::Array *images = all_image_info_json_sp->GetAsDictionary()
+                                        ->GetValueForKey("images")
+                                        ->GetAsArray();
+    if (images->GetSize() > 0 &&
+        images->GetItemAtIndex(0)->GetAsDictionary()->HasKey("mach_header")) {
+      if (JSONImageInformationIntoImageInfo(all_image_info_json_sp,
+                                            image_infos)) {
+        LLDB_LOGF(log, "Initial module fetch:  Adding %" PRId64 " modules.\n",
+                  (uint64_t)image_infos.size());
+
+        auto images = PreloadModulesFromImageInfos(image_infos);
----------------
jasonmolenda wrote:

FTR `PreloadModulesFromImageInfos` returns `std::vector<std::pair<ImageInfo, lldb::ModuleSP>>` so it's maybe an appropriate time to use auto.

https://github.com/llvm/llvm-project/pull/190720


More information about the lldb-commits mailing list