================ @@ -59,39 +68,67 @@ class MinidumpFileBuilder { // Add ThreadList stream, containing information about all threads running // at the moment of core saving. Contains information about thread // contexts. - lldb_private::Status AddThreadList(const lldb::ProcessSP &process_sp); - // Add Exception streams for any threads that stopped with exceptions. - void AddExceptions(const lldb::ProcessSP &process_sp); - // Add MemoryList stream, containing dumps of important memory segments - lldb_private::Status AddMemoryList(const lldb::ProcessSP &process_sp, - lldb::SaveCoreStyle core_style); // Add MiscInfo stream, mainly providing ProcessId void AddMiscInfo(const lldb::ProcessSP &process_sp); // Add informative files about a Linux process void AddLinuxFileStreams(const lldb::ProcessSP &process_sp); + // Add Exception streams for any threads that stopped with exceptions. + void AddExceptions(const lldb::ProcessSP &process_sp); // Dump the prepared data into file. In case of the failure data are // intact. - lldb_private::Status Dump(lldb::FileUP &core_file) const; - // Returns the current number of directories(streams) that have been so far - // created. This number of directories will be dumped when calling Dump() - size_t GetDirectoriesNum() const; + lldb_private::Status AddThreadList(const lldb::ProcessSP &process_sp); + + lldb_private::Status AddMemory(const lldb::ProcessSP &process_sp, + lldb::SaveCoreStyle core_style); + + lldb_private::Status DumpToFile(); private: + // Add data to the end of the buffer, if the buffer exceeds the flush level, + // trigger a flush. + lldb_private::Status AddData(const void *data, size_t size); + // Add MemoryList stream, containing dumps of important memory segments + lldb_private::Status + AddMemoryList_64(const lldb::ProcessSP &process_sp, + const lldb_private::Process::CoreFileMemoryRanges &ranges); + lldb_private::Status + AddMemoryList_32(const lldb::ProcessSP &process_sp, + const lldb_private::Process::CoreFileMemoryRanges &ranges); + lldb_private::Status FixThreads(); + lldb_private::Status FlushToDisk(); + + lldb_private::Status DumpHeader() const; + lldb_private::Status DumpDirectories() const; + bool CheckIf_64Bit(const size_t size); // Add directory of StreamType pointing to the current end of the prepared // file with the specified size. - void AddDirectory(llvm::minidump::StreamType type, size_t stream_size); - size_t GetCurrentDataEndOffset() const; - - // Stores directories to later put them at the end of minidump file + void AddDirectory(llvm::minidump::StreamType type, uint64_t stream_size); + lldb::addr_t GetCurrentDataEndOffset() const; + // Stores directories to fill in later std::vector<llvm::minidump::Directory> m_directories; + // When we write off the threads for the first time, we need to clean them up + // and give them the correct RVA once we write the stack memory list. + std::map<lldb::addr_t, llvm::minidump::Thread> m_thread_by_range_start; // Main data buffer consisting of data without the minidump header and // directories lldb_private::DataBufferHeap m_data; + uint m_expected_directories = 0; + uint64_t m_saved_data_size = 0; + size_t m_thread_list_start = 0; + // We set the max write amount to 128 mb + // Linux has a signed 32b - some buffer on writes + // and we have guarauntee a user memory region / 'object' could be over 2gb + // now that we support 64b memory dumps. + static constexpr size_t m_write_chunk_max = (1024 * 1024 * 128); ---------------- Jlalond wrote:
Avoiding OS limitations was the goal. Originally when I was testing large minidumps, I created a large array, that was 5.2gb in size. Linux has a max write byte size that is slightly less than `SSIZE_T` max. However that also ends up being platform specific, and we should probably make the write size the architecture byte width max value for `SSIZE_T`. https://github.com/llvm/llvm-project/pull/95312 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits