[Lldb-commits] [lldb] [lldb][NFC] Module, ModuleSpec, GetSectionData use DataExtractorSP (PR #178347)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 27 21:46:03 PST 2026


================
@@ -220,17 +220,18 @@ bool ObjectContainerMachOFileset::ParseHeader() {
 }
 
 size_t ObjectContainerMachOFileset::GetModuleSpecifications(
-    const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp,
+    const lldb_private::FileSpec &file, lldb::DataExtractorSP &extractor_sp,
     lldb::offset_t data_offset, lldb::offset_t file_offset,
     lldb::offset_t file_size, lldb_private::ModuleSpecList &specs) {
   const size_t initial_count = specs.GetSize();
+  if (!extractor_sp)
+    return initial_count;
----------------
JDevlieghere wrote:

Previously we didn't need to check `data_sp` because `DataExtractor::SetData` would handle it being null. But now we call `GetSubsetExtractorSP` on the extractor, so it needs to be valid. That part makes sense. 

However, shouldn't this return `0` instead of `initial_count`. If we had no data, we would fail the `MagicBytesMatch`  and return `specs.GetSize() - initial_count;` = `specs.GetSize() - specs.GetSize()` = `0`? 
```suggestion
  if (!extractor_sp)
    return 0;
```

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


More information about the lldb-commits mailing list