LLDB mainline
|
Minidump writer for Linux. More...
#include <MinidumpFileBuilder.h>
Public Member Functions | |
MinidumpFileBuilder (lldb::FileUP &&core_file, const lldb::ProcessSP &process_sp, lldb_private::SaveCoreOptions &save_core_options) | |
MinidumpFileBuilder (const MinidumpFileBuilder &)=delete | |
MinidumpFileBuilder & | operator= (const MinidumpFileBuilder &)=delete |
MinidumpFileBuilder (MinidumpFileBuilder &&other)=default | |
MinidumpFileBuilder & | operator= (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_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 |
std::unordered_set< lldb::addr_t > | m_saved_stack_ranges |
lldb::FileUP | m_core_file |
lldb_private::SaveCoreOptions | m_save_core_options |
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) |
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.
|
inline |
Definition at line 77 of file MinidumpFileBuilder.h.
|
delete |
|
default |
|
default |
|
private |
Definition at line 1142 of file MinidumpFileBuilder.cpp.
References lldb_private::DataBufferHeap::AppendData(), FlushBufferToDisk(), lldb_private::DataBufferHeap::GetByteSize(), m_data, and MAX_WRITE_CHUNK_SIZE.
Referenced by AddMemoryList_32(), and AddMemoryList_64().
|
private |
Definition at line 97 of file MinidumpFileBuilder.cpp.
References error(), GetCurrentDataEndOffset(), m_directories, m_expected_directories, and UINT32_MAX.
Referenced by AddExceptions(), AddLinuxFileStreams(), AddMemoryList_32(), AddMemoryList_64(), AddMiscInfo(), AddModuleList(), AddSystemInfo(), and AddThreadList().
Status MinidumpFileBuilder::AddExceptions | ( | ) |
Definition at line 674 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), lldb::eStopReasonException, lldb::eStopReasonSignal, lldb_private::Exception, m_data, m_process_sp, m_save_core_options, and m_tid_to_reg_ctx.
Referenced by ObjectFileMinidump::SaveCore().
Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories | ( | ) |
Definition at line 57 of file MinidumpFileBuilder.cpp.
References error(), lldb_private::Target::GetArchitecture(), lldb_private::ArchSpec::GetTriple(), HEADER_SIZE, m_core_file, m_expected_directories, m_process_sp, m_save_core_options, and m_saved_data_size.
Referenced by ObjectFileMinidump::SaveCore().
Status MinidumpFileBuilder::AddLinuxFileStreams | ( | ) |
Definition at line 767 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), getFileStreamHelper(), lldb_private::ProcessInfo::GetProcessID(), m_data, m_process_sp, and lldb_private::ProcessInfo::ProcessIDIsValid().
Referenced by ObjectFileMinidump::SaveCore().
Status MinidumpFileBuilder::AddMemoryList | ( | ) |
Definition at line 819 of file MinidumpFileBuilder.cpp.
References AddMemoryList_32(), AddMemoryList_64(), error(), FixThreadStacks(), GetCurrentDataEndOffset(), m_process_sp, m_save_core_options, m_saved_stack_ranges, and UINT32_MAX.
Referenced by ObjectFileMinidump::SaveCore().
|
private |
Definition at line 960 of file MinidumpFileBuilder.cpp.
References AddData(), AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), GetCurrentDataEndOffset(), GetLargestRangeSize(), lldb_private::GetLog(), LLDB_LOGF, m_data, m_process_sp, and m_thread_by_range_end.
Referenced by AddMemoryList().
|
private |
Definition at line 1037 of file MinidumpFileBuilder.cpp.
References AddData(), AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), FlushBufferToDisk(), GetCurrentDataEndOffset(), GetLargestRangeSize(), lldb_private::GetLog(), LLDB_LOGF, m_core_file, m_data, and m_process_sp.
Referenced by AddMemoryList().
lldb_private::Status MinidumpFileBuilder::AddMiscInfo | ( | ) |
Definition at line 729 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), lldb_private::minidump::MinidumpMiscInfo::flags1, lldb_private::ProcessInfo::GetProcessID(), m_data, m_process_sp, lldb_private::minidump::MinidumpMiscInfo::process_id, lldb_private::minidump::ProcessID, lldb_private::ProcessInfo::ProcessIDIsValid(), and lldb_private::minidump::MinidumpMiscInfo::size.
Referenced by ObjectFileMinidump::SaveCore().
Status MinidumpFileBuilder::AddModuleList | ( | ) |
Definition at line 285 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), GetCurrentDataEndOffset(), lldb_private::Target::GetImages(), lldb_private::ModuleList::GetModuleAtIndex(), getModuleFileSize(), lldb_private::ModuleList::GetSize(), m_data, m_process_sp, and WriteString().
Referenced by ObjectFileMinidump::SaveCore().
Status MinidumpFileBuilder::AddSystemInfo | ( | ) |
Definition at line 129 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), GetCurrentDataEndOffset(), m_data, m_process_sp, and WriteString().
Referenced by ObjectFileMinidump::SaveCore().
Status MinidumpFileBuilder::AddThreadList | ( | ) |
Definition at line 588 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), ArchThreadContexts::data(), error(), lldb_private::Target::GetArchitecture(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), GetCurrentDataEndOffset(), lldb_private::GetLog(), lldb_private::ArchSpec::GetMachine(), lldb_private::MemoryRegionInfo::GetRange(), lldb_private::Range< B, S >::GetRangeEnd(), lldb_private::RegisterContext::GetSP(), lldb_private::ArchSpec::GetTriple(), LLDB_LOGF, m_data, m_process_sp, m_save_core_options, m_thread_by_range_end, m_thread_list_start, m_tid_to_reg_ctx, ArchThreadContexts::prepareRegisterContext(), ArchThreadContexts::size(), and sp.
Referenced by ObjectFileMinidump::SaveCore().
|
private |
Definition at line 932 of file MinidumpFileBuilder.cpp.
References DIRECTORY_SIZE, error(), HEADER_SIZE, m_core_file, and m_directories.
Referenced by DumpFile().
Status MinidumpFileBuilder::DumpFile | ( | ) |
Definition at line 1186 of file MinidumpFileBuilder.cpp.
References DumpDirectories(), DumpHeader(), error(), and FlushBufferToDisk().
Referenced by ObjectFileMinidump::SaveCore().
|
private |
Definition at line 893 of file MinidumpFileBuilder.cpp.
References error(), HEADER_SIZE, m_core_file, and m_directories.
Referenced by DumpFile().
|
private |
Definition at line 565 of file MinidumpFileBuilder.cpp.
References error(), FlushBufferToDisk(), m_core_file, m_thread_by_range_end, and m_thread_list_start.
Referenced by AddMemoryList().
|
private |
Definition at line 1156 of file MinidumpFileBuilder.cpp.
References lldb_private::DataBufferHeap::Clear(), error(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), m_core_file, m_data, and m_saved_data_size.
Referenced by AddData(), AddMemoryList_64(), DumpFile(), and FixThreadStacks().
|
private |
Definition at line 928 of file MinidumpFileBuilder.cpp.
References lldb_private::DataBufferHeap::GetByteSize(), m_data, and m_saved_data_size.
Referenced by AddDirectory(), AddMemoryList(), AddMemoryList_32(), AddMemoryList_64(), AddModuleList(), AddSystemInfo(), and AddThreadList().
|
delete |
|
default |
|
staticconstexprprivate |
Definition at line 161 of file MinidumpFileBuilder.h.
Referenced by DumpDirectories().
|
staticconstexprprivate |
Definition at line 160 of file MinidumpFileBuilder.h.
Referenced by AddHeaderAndCalculateDirectories(), DumpDirectories(), and DumpHeader().
|
private |
Definition at line 169 of file MinidumpFileBuilder.h.
Referenced by AddHeaderAndCalculateDirectories(), AddMemoryList_64(), DumpDirectories(), DumpHeader(), FixThreadStacks(), and FlushBufferToDisk().
|
private |
Definition at line 148 of file MinidumpFileBuilder.h.
Referenced by AddData(), AddExceptions(), AddLinuxFileStreams(), AddMemoryList_32(), AddMemoryList_64(), AddMiscInfo(), AddModuleList(), AddSystemInfo(), AddThreadList(), FlushBufferToDisk(), and GetCurrentDataEndOffset().
|
private |
Definition at line 138 of file MinidumpFileBuilder.h.
Referenced by AddDirectory(), DumpDirectories(), and DumpHeader().
|
private |
Definition at line 151 of file MinidumpFileBuilder.h.
Referenced by AddDirectory(), and AddHeaderAndCalculateDirectories().
|
private |
Definition at line 149 of file MinidumpFileBuilder.h.
Referenced by AddExceptions(), AddHeaderAndCalculateDirectories(), AddLinuxFileStreams(), AddMemoryList(), AddMemoryList_32(), AddMemoryList_64(), AddMiscInfo(), AddModuleList(), AddSystemInfo(), and AddThreadList().
|
private |
Definition at line 170 of file MinidumpFileBuilder.h.
Referenced by AddExceptions(), AddHeaderAndCalculateDirectories(), AddMemoryList(), and AddThreadList().
|
private |
Definition at line 152 of file MinidumpFileBuilder.h.
Referenced by AddHeaderAndCalculateDirectories(), FlushBufferToDisk(), and GetCurrentDataEndOffset().
|
private |
Definition at line 168 of file MinidumpFileBuilder.h.
Referenced by AddMemoryList().
|
private |
Definition at line 145 of file MinidumpFileBuilder.h.
Referenced by AddMemoryList_32(), AddThreadList(), and FixThreadStacks().
|
private |
Definition at line 153 of file MinidumpFileBuilder.h.
Referenced by AddThreadList(), and FixThreadStacks().
|
private |
Definition at line 167 of file MinidumpFileBuilder.h.
Referenced by AddExceptions(), and AddThreadList().
|
staticconstexprprivate |
Definition at line 158 of file MinidumpFileBuilder.h.
Referenced by AddData().