Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Process/minidump/MinidumpParser.h
39645 views
//===-- MinidumpParser.h -----------------------------------------*- C++-*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPPARSER_H9#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPPARSER_H1011#include "MinidumpTypes.h"1213#include "lldb/Target/MemoryRegionInfo.h"14#include "lldb/Utility/ArchSpec.h"15#include "lldb/Utility/DataBuffer.h"16#include "lldb/Utility/Status.h"17#include "lldb/Utility/UUID.h"1819#include "llvm/ADT/ArrayRef.h"20#include "llvm/ADT/DenseMap.h"21#include "llvm/ADT/StringRef.h"22#include "llvm/Object/Minidump.h"2324// C includes2526// C++ includes27#include <cstring>28#include <optional>29#include <unordered_map>3031namespace lldb_private {3233namespace minidump {3435// Describes a range of memory captured in the Minidump36struct Range {37lldb::addr_t start; // virtual address of the beginning of the range38// range_ref - absolute pointer to the first byte of the range and size39llvm::ArrayRef<uint8_t> range_ref;4041Range(lldb::addr_t start, llvm::ArrayRef<uint8_t> range_ref)42: start(start), range_ref(range_ref) {}4344friend bool operator==(const Range &lhs, const Range &rhs) {45return lhs.start == rhs.start && lhs.range_ref == rhs.range_ref;46}47};4849class MinidumpParser {50public:51static llvm::Expected<MinidumpParser>52Create(const lldb::DataBufferSP &data_buf_sp);5354llvm::ArrayRef<uint8_t> GetData();5556llvm::ArrayRef<uint8_t> GetStream(StreamType stream_type);5758UUID GetModuleUUID(const minidump::Module *module);5960llvm::ArrayRef<minidump::Thread> GetThreads();6162llvm::ArrayRef<uint8_t> GetThreadContext(const LocationDescriptor &location);6364llvm::ArrayRef<uint8_t> GetThreadContext(const minidump::Thread &td);6566llvm::ArrayRef<uint8_t> GetThreadContextWow64(const minidump::Thread &td);6768ArchSpec GetArchitecture();6970const MinidumpMiscInfo *GetMiscInfo();7172std::optional<LinuxProcStatus> GetLinuxProcStatus();7374std::optional<lldb::pid_t> GetPid();7576llvm::ArrayRef<minidump::Module> GetModuleList();7778// There are cases in which there is more than one record in the ModuleList79// for the same module name.(e.g. when the binary has non contiguous segments)80// So this function returns a filtered module list - if it finds records that81// have the same name, it keeps the copy with the lowest load address.82std::vector<const minidump::Module *> GetFilteredModuleList();8384const llvm::minidump::ExceptionStream *GetExceptionStream();8586std::optional<Range> FindMemoryRange(lldb::addr_t addr);8788llvm::ArrayRef<uint8_t> GetMemory(lldb::addr_t addr, size_t size);8990/// Returns a list of memory regions and a flag indicating whether the list is91/// complete (includes all regions mapped into the process memory).92std::pair<MemoryRegionInfos, bool> BuildMemoryRegions();9394static llvm::StringRef GetStreamTypeAsString(StreamType stream_type);9596llvm::object::MinidumpFile &GetMinidumpFile() { return *m_file; }9798static MemoryRegionInfo GetMemoryRegionInfo(const MemoryRegionInfos ®ions,99lldb::addr_t load_addr);100101private:102MinidumpParser(lldb::DataBufferSP data_sp,103std::unique_ptr<llvm::object::MinidumpFile> file);104105lldb::DataBufferSP m_data_sp;106std::unique_ptr<llvm::object::MinidumpFile> m_file;107ArchSpec m_arch;108};109110} // end namespace minidump111} // end namespace lldb_private112#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPPARSER_H113114115