[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add 64b support to LLDB's minidump file builder. (PR #95312)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 14 17:46:17 PDT 2024


================
@@ -791,26 +812,101 @@ void MinidumpFileBuilder::AddLinuxFileStreams(
       size_t size = memory_buffer->getBufferSize();
       if (size == 0)
         continue;
-      AddDirectory(stream, size);
+      error = AddDirectory(stream, size);
+      if (error.Fail())
+        return error;
       m_data.AppendData(memory_buffer->getBufferStart(), size);
     }
   }
+
+  return error;
 }
 
-Status MinidumpFileBuilder::Dump(lldb::FileUP &core_file) const {
-  constexpr size_t header_size = sizeof(llvm::minidump::Header);
-  constexpr size_t directory_size = sizeof(llvm::minidump::Directory);
+Status MinidumpFileBuilder::AddMemoryList(SaveCoreStyle core_style) {
+  Status error;
+
+  Process::CoreFileMemoryRanges ranges_32;
+  Process::CoreFileMemoryRanges ranges_64;
+  error = m_process_sp->CalculateCoreFileSaveRanges(
+      SaveCoreStyle::eSaveCoreStackOnly, ranges_32);
+  if (error.Fail())
+    return error;
+
+  std::set<addr_t> stack_start_addresses;
+  for (const auto &core_range : ranges_32)
+    stack_start_addresses.insert(core_range.range.start());
+
+  uint64_t total_size =
+      ranges_32.size() * sizeof(llvm::minidump::MemoryDescriptor);
+  for (const auto &core_range : ranges_32)
+    total_size += core_range.range.size();
----------------
clayborg wrote:

Merge this `total_size` calculation stuff into the loop above on line 836. No need to iterate over this twice.

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


More information about the lldb-commits mailing list