[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:16 PDT 2024
================
@@ -81,38 +82,42 @@ Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
// Now offset the file by the directores so we can write them in later.
offset_t directory_offset = m_expected_directories * directory_size;
m_saved_data_size += directory_offset;
- // Replace this when we make a better way to do this.
Status error;
- Header empty_header;
- size_t bytes_written;
- bytes_written = header_size;
- error = m_core_file->Write(&empty_header, bytes_written);
- if (error.Fail() || bytes_written != header_size) {
- if (bytes_written != header_size)
+ size_t zeroes = 0; // 8 0's
+ size_t remaining_bytes = m_saved_data_size;
+ while (remaining_bytes > 0) {
+ // Keep filling in zero's until we preallocate enough space for the header
+ // and directory sections.
+ size_t bytes_written = std::min(remaining_bytes, sizeof(size_t));
+ error = m_core_file->Write(&zeroes, bytes_written);
+ if (error.Fail()) {
error.SetErrorStringWithFormat(
- "unable to write the header (written %zd/%zd)", bytes_written,
- header_size);
- return error;
- }
-
- for (uint i = 0; i < m_expected_directories; i++) {
- size_t bytes_written;
- bytes_written = directory_size;
- Directory empty_directory;
- error = m_core_file->Write(&empty_directory, bytes_written);
- if (error.Fail() || bytes_written != directory_size) {
- if (bytes_written != directory_size)
- error.SetErrorStringWithFormat(
- "unable to write the directory (written %zd/%zd)", bytes_written,
- directory_size);
- return error;
+ "Unable to write header and directory padding (written %zd/%zd)",
+ remaining_bytes - m_saved_data_size, m_saved_data_size);
+ break;
}
+
+ remaining_bytes -= bytes_written;
}
----------------
clayborg wrote:
Remove this while look and complex functionality and just call:
```
m_core_file->SeekFromStart(m_saved_data_size);
```
No need to write zeroes.
https://github.com/llvm/llvm-project/pull/95312
More information about the lldb-commits
mailing list