LLDB mainline
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MinidumpFileBuilder Class Reference

Minidump writer for Linux. More...

#include <MinidumpFileBuilder.h>

Public Member Functions

 MinidumpFileBuilder (lldb::FileUP &&core_file, const lldb::ProcessSP &process_sp)
 MinidumpFileBuilder (const MinidumpFileBuilder &)=delete
MinidumpFileBuilderoperator= (const MinidumpFileBuilder &)=delete
 MinidumpFileBuilder (MinidumpFileBuilder &&other)=default
MinidumpFileBuilderoperator= (MinidumpFileBuilder &&other)=default
 ~MinidumpFileBuilder ()=default
lldb_private::Status AddHeaderAndCalculateDirectories ()
lldb_private::Status AddSystemInfo ()
lldb_private::Status AddModuleList ()
lldb_private::Status AddThreadList ()
lldb_private::Status AddExceptions ()
lldb_private::Status AddMemoryList (lldb::SaveCoreStyle core_style)
lldb_private::Status AddMiscInfo ()
lldb_private::Status AddLinuxFileStreams ()
lldb_private::Status DumpFile ()

Private Member Functions

lldb_private::Status AddData (const void *data, uint64_t size)
lldb_private::Status AddMemoryList_64 (lldb_private::Process::CoreFileMemoryRanges &ranges)
lldb_private::Status AddMemoryList_32 (lldb_private::Process::CoreFileMemoryRanges &ranges)
lldb_private::Status FixThreadStacks ()
lldb_private::Status FlushBufferToDisk ()
lldb_private::Status DumpHeader () const
lldb_private::Status DumpDirectories () const
lldb_private::Status AddDirectory (llvm::minidump::StreamType type, uint64_t stream_size)
lldb::offset_t GetCurrentDataEndOffset () const

Private Attributes

std::vector< llvm::minidump::Directory > m_directories
std::unordered_map< lldb::addr_t, llvm::minidump::Thread > m_thread_by_range_end
lldb_private::DataBufferHeap m_data
lldb::ProcessSP m_process_sp
size_t m_expected_directories = 0
uint64_t m_saved_data_size = 0
lldb::offset_t m_thread_list_start = 0
std::unordered_map< lldb::tid_t, llvm::minidump::LocationDescriptor > m_tid_to_reg_ctx
lldb::FileUP m_core_file

Static Private Attributes

static constexpr size_t MAX_WRITE_CHUNK_SIZE = (1024 * 1024 * 128)
static constexpr size_t HEADER_SIZE = sizeof(llvm::minidump::Header)
static constexpr size_t DIRECTORY_SIZE = sizeof(llvm::minidump::Directory)

Detailed Description

Minidump writer for Linux.

This class provides a Minidump writer that is able to snapshot the current process state.

Minidumps are a Microsoft format for dumping process state. This class constructs the minidump on disk starting with Headers and Directories are written at the top of the file, with the amount of bytes being precalculates before any writing takes place Then the smaller data sections are written SystemInfo, ModuleList, Misc Info. Then Threads are emitted, threads are the first section that needs to be 'fixed up' this happens when later we emit the memory stream, we identify if that stream is the expected stack, and if so we update the stack with the current RVA. Lastly the Memory lists are added. For Memory List, this will contain everything that can fit within 4.2gb. MemoryList has it's descriptors written at the end so it cannot be allowed to overflow.

Memory64List is a special case where it has to be begin before 4.2gb but can expand forever The difference in Memory64List is there are no RVA's and all the addresses are figured out by starting at the base RVA, and adding the antecedent memory sections.

Because Memory64List can be arbitrarily large, this class has to write chunks to disk this means we have to precalculate the descriptors and write them first, and if we encounter any error, or are unable to read the same number of bytes we have to go back and update them on disk.

And as the last step, after all the directories have been added, we go back to the top of the file to fill in the header and the redirectory sections that we preallocated.

Definition at line 75 of file MinidumpFileBuilder.h.

Constructor & Destructor Documentation

◆ MinidumpFileBuilder() [1/3]

MinidumpFileBuilder::MinidumpFileBuilder ( lldb::FileUP &&  core_file,
const lldb::ProcessSP process_sp 

Definition at line 77 of file MinidumpFileBuilder.h.

◆ MinidumpFileBuilder() [2/3]

MinidumpFileBuilder::MinidumpFileBuilder ( const MinidumpFileBuilder )

◆ MinidumpFileBuilder() [3/3]

MinidumpFileBuilder::MinidumpFileBuilder ( MinidumpFileBuilder &&  other)

◆ ~MinidumpFileBuilder()

MinidumpFileBuilder::~MinidumpFileBuilder ( )

Member Function Documentation

◆ AddData()

Status MinidumpFileBuilder::AddData ( const void *  data,
uint64_t  size 

◆ AddDirectory()

Status MinidumpFileBuilder::AddDirectory ( llvm::minidump::StreamType  type,
uint64_t  stream_size 

◆ AddExceptions()

Status MinidumpFileBuilder::AddExceptions ( )

◆ AddHeaderAndCalculateDirectories()

Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories ( )

◆ AddLinuxFileStreams()

Status MinidumpFileBuilder::AddLinuxFileStreams ( )

◆ AddMemoryList()

Status MinidumpFileBuilder::AddMemoryList ( lldb::SaveCoreStyle  core_style)

◆ AddMemoryList_32()

Status MinidumpFileBuilder::AddMemoryList_32 ( lldb_private::Process::CoreFileMemoryRanges ranges)

◆ AddMemoryList_64()

Status MinidumpFileBuilder::AddMemoryList_64 ( lldb_private::Process::CoreFileMemoryRanges ranges)

◆ AddMiscInfo()

lldb_private::Status MinidumpFileBuilder::AddMiscInfo ( )

◆ AddModuleList()

Status MinidumpFileBuilder::AddModuleList ( )

◆ AddSystemInfo()

Status MinidumpFileBuilder::AddSystemInfo ( )

◆ AddThreadList()

Status MinidumpFileBuilder::AddThreadList ( )

◆ DumpDirectories()

Status MinidumpFileBuilder::DumpDirectories ( ) const

Definition at line 938 of file MinidumpFileBuilder.cpp.

References DIRECTORY_SIZE, error(), HEADER_SIZE, m_core_file, and m_directories.

Referenced by DumpFile().

◆ DumpFile()

Status MinidumpFileBuilder::DumpFile ( )

◆ DumpHeader()

Status MinidumpFileBuilder::DumpHeader ( ) const

Definition at line 899 of file MinidumpFileBuilder.cpp.

References error(), HEADER_SIZE, m_core_file, and m_directories.

Referenced by DumpFile().

◆ FixThreadStacks()

Status MinidumpFileBuilder::FixThreadStacks ( )

◆ FlushBufferToDisk()

Status MinidumpFileBuilder::FlushBufferToDisk ( )

◆ GetCurrentDataEndOffset()

offset_t MinidumpFileBuilder::GetCurrentDataEndOffset ( ) const

◆ operator=() [1/2]

MinidumpFileBuilder & MinidumpFileBuilder::operator= ( const MinidumpFileBuilder )

◆ operator=() [2/2]

MinidumpFileBuilder & MinidumpFileBuilder::operator= ( MinidumpFileBuilder &&  other)

Member Data Documentation


constexpr size_t MinidumpFileBuilder::DIRECTORY_SIZE = sizeof(llvm::minidump::Directory)

Definition at line 159 of file MinidumpFileBuilder.h.

Referenced by DumpDirectories().


constexpr size_t MinidumpFileBuilder::HEADER_SIZE = sizeof(llvm::minidump::Header)

◆ m_core_file

lldb::FileUP MinidumpFileBuilder::m_core_file

◆ m_data

lldb_private::DataBufferHeap MinidumpFileBuilder::m_data

◆ m_directories

std::vector<llvm::minidump::Directory> MinidumpFileBuilder::m_directories

Definition at line 136 of file MinidumpFileBuilder.h.

Referenced by AddDirectory(), DumpDirectories(), and DumpHeader().

◆ m_expected_directories

size_t MinidumpFileBuilder::m_expected_directories = 0

Definition at line 149 of file MinidumpFileBuilder.h.

Referenced by AddDirectory(), and AddHeaderAndCalculateDirectories().

◆ m_process_sp

lldb::ProcessSP MinidumpFileBuilder::m_process_sp

◆ m_saved_data_size

uint64_t MinidumpFileBuilder::m_saved_data_size = 0

◆ m_thread_by_range_end

std::unordered_map<lldb::addr_t, llvm::minidump::Thread> MinidumpFileBuilder::m_thread_by_range_end

Definition at line 143 of file MinidumpFileBuilder.h.

Referenced by AddMemoryList_32(), AddThreadList(), and FixThreadStacks().

◆ m_thread_list_start

lldb::offset_t MinidumpFileBuilder::m_thread_list_start = 0

Definition at line 151 of file MinidumpFileBuilder.h.

Referenced by AddThreadList(), and FixThreadStacks().

◆ m_tid_to_reg_ctx

std::unordered_map<lldb::tid_t, llvm::minidump::LocationDescriptor> MinidumpFileBuilder::m_tid_to_reg_ctx

Definition at line 165 of file MinidumpFileBuilder.h.

Referenced by AddExceptions(), and AddThreadList().


constexpr size_t MinidumpFileBuilder::MAX_WRITE_CHUNK_SIZE = (1024 * 1024 * 128)

Definition at line 156 of file MinidumpFileBuilder.h.

Referenced by AddData().

The documentation for this class was generated from the following files: