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 () |
void | DeleteFile () noexcept |
Private Member Functions | |
lldb_private::Status | AddData (const void *data, uint64_t size) |
lldb_private::Status | AddMemoryList_64 (std::vector< lldb_private::CoreFileMemoryRange > &ranges, lldb_private::Progress &progress) |
lldb_private::Status | AddMemoryList_32 (std::vector< lldb_private::CoreFileMemoryRange > &ranges, lldb_private::Progress &progress) |
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 |
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 77 of file MinidumpFileBuilder.h.
|
inline |
Definition at line 79 of file MinidumpFileBuilder.h.
|
delete |
|
default |
|
default |
|
private |
Definition at line 1158 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 96 of file MinidumpFileBuilder.cpp.
References error(), lldb_private::Status::FromErrorStringWithFormat(), 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 681 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), lldb::eStopReasonInvalid, 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::eStopReasonInvalid, lldb_private::Status::FromErrorStringWithFormat(), 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 769 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 821 of file MinidumpFileBuilder.cpp.
References AddMemoryList_32(), AddMemoryList_64(), error(), FixThreadStacks(), lldb_private::Status::FromErrorStringWithFormat(), GetCurrentDataEndOffset(), lldb_private::RangeDataVector< B, S, T, N, Compare >::GetSize(), m_process_sp, m_save_core_options, m_thread_by_range_end, and UINT32_MAX.
Referenced by ObjectFileMinidump::SaveCore().
|
private |
Definition at line 972 of file MinidumpFileBuilder.cpp.
References AddData(), AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), GetCurrentDataEndOffset(), GetLargestRangeSize(), lldb_private::GetLog(), lldb_private::Progress::Increment(), LLDB_LOGF, m_data, m_process_sp, and m_thread_by_range_end.
Referenced by AddMemoryList().
|
private |
Definition at line 1051 of file MinidumpFileBuilder.cpp.
References AddData(), AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), FlushBufferToDisk(), lldb_private::Status::FromErrorStringWithFormat(), GetCurrentDataEndOffset(), GetLargestRangeSize(), lldb_private::GetLog(), lldb_private::Progress::Increment(), LLDB_LOGF, m_core_file, m_data, and m_process_sp.
Referenced by AddMemoryList().
lldb_private::Status MinidumpFileBuilder::AddMiscInfo | ( | ) |
Definition at line 731 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 287 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), error(), lldb_private::Status::FromErrorStringWithFormat(), 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(), lldb_private::Status::FromErrorString(), lldb_private::Status::FromErrorStringWithFormat(), GetCurrentDataEndOffset(), m_data, m_process_sp, and WriteString().
Referenced by ObjectFileMinidump::SaveCore().
Status MinidumpFileBuilder::AddThreadList | ( | ) |
Definition at line 595 of file MinidumpFileBuilder.cpp.
References AddDirectory(), lldb_private::DataBufferHeap::AppendData(), ArchThreadContexts::data(), error(), lldb_private::Status::FromErrorString(), lldb_private::Status::FromErrorStringWithFormat(), 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().
|
noexcept |
Definition at line 1222 of file MinidumpFileBuilder.cpp.
References error(), lldb_private::GetLog(), LLDB_LOGF, and m_core_file.
Referenced by DumpFailRemoveHolder::~DumpFailRemoveHolder().
|
private |
Definition at line 944 of file MinidumpFileBuilder.cpp.
References DIRECTORY_SIZE, error(), lldb_private::Status::FromErrorStringWithFormat(), HEADER_SIZE, m_core_file, and m_directories.
Referenced by DumpFile().
Status MinidumpFileBuilder::DumpFile | ( | ) |
Definition at line 1202 of file MinidumpFileBuilder.cpp.
References DumpDirectories(), DumpHeader(), error(), and FlushBufferToDisk().
Referenced by ObjectFileMinidump::SaveCore().
|
private |
Definition at line 905 of file MinidumpFileBuilder.cpp.
References error(), lldb_private::Status::FromErrorStringWithFormat(), HEADER_SIZE, m_core_file, and m_directories.
Referenced by DumpFile().
|
private |
Definition at line 572 of file MinidumpFileBuilder.cpp.
References error(), FlushBufferToDisk(), lldb_private::Status::FromErrorStringWithFormat(), m_core_file, m_thread_by_range_end, and m_thread_list_start.
Referenced by AddMemoryList().
|
private |
Definition at line 1172 of file MinidumpFileBuilder.cpp.
References lldb_private::DataBufferHeap::Clear(), error(), lldb_private::Status::FromErrorStringWithFormat(), 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 940 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 168 of file MinidumpFileBuilder.h.
Referenced by DumpDirectories().
|
staticconstexprprivate |
Definition at line 167 of file MinidumpFileBuilder.h.
Referenced by AddHeaderAndCalculateDirectories(), DumpDirectories(), and DumpHeader().
|
private |
Definition at line 175 of file MinidumpFileBuilder.h.
Referenced by AddHeaderAndCalculateDirectories(), AddMemoryList_64(), DeleteFile(), DumpDirectories(), DumpHeader(), FixThreadStacks(), and FlushBufferToDisk().
|
private |
Definition at line 155 of file MinidumpFileBuilder.h.
Referenced by AddData(), AddExceptions(), AddLinuxFileStreams(), AddMemoryList_32(), AddMemoryList_64(), AddMiscInfo(), AddModuleList(), AddSystemInfo(), AddThreadList(), FlushBufferToDisk(), and GetCurrentDataEndOffset().
|
private |
Definition at line 145 of file MinidumpFileBuilder.h.
Referenced by AddDirectory(), DumpDirectories(), and DumpHeader().
|
private |
Definition at line 158 of file MinidumpFileBuilder.h.
Referenced by AddDirectory(), and AddHeaderAndCalculateDirectories().
|
private |
Definition at line 156 of file MinidumpFileBuilder.h.
Referenced by AddExceptions(), AddHeaderAndCalculateDirectories(), AddLinuxFileStreams(), AddMemoryList(), AddMemoryList_32(), AddMemoryList_64(), AddMiscInfo(), AddModuleList(), AddSystemInfo(), and AddThreadList().
|
private |
Definition at line 176 of file MinidumpFileBuilder.h.
Referenced by AddExceptions(), AddHeaderAndCalculateDirectories(), AddMemoryList(), and AddThreadList().
|
private |
Definition at line 159 of file MinidumpFileBuilder.h.
Referenced by AddHeaderAndCalculateDirectories(), FlushBufferToDisk(), and GetCurrentDataEndOffset().
|
private |
Definition at line 152 of file MinidumpFileBuilder.h.
Referenced by AddMemoryList(), AddMemoryList_32(), AddThreadList(), and FixThreadStacks().
|
private |
Definition at line 160 of file MinidumpFileBuilder.h.
Referenced by AddThreadList(), and FixThreadStacks().
|
private |
Definition at line 174 of file MinidumpFileBuilder.h.
Referenced by AddExceptions(), and AddThreadList().
|
staticconstexprprivate |
Definition at line 165 of file MinidumpFileBuilder.h.
Referenced by AddData().