1 //===-- MinidumpParser.h -----------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef liblldb_MinidumpParser_h_
12 #define liblldb_MinidumpParser_h_
15 #include "MinidumpTypes.h"
17 #include "lldb/Utility/ArchSpec.h"
18 #include "lldb/Utility/DataBuffer.h"
19 #include "lldb/Utility/Status.h"
20 #include "lldb/Utility/UUID.h"
22 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/DenseMap.h"
24 #include "llvm/ADT/Optional.h"
25 #include "llvm/ADT/StringRef.h"
31 #include <unordered_map>
33 namespace lldb_private {
37 // Describes a range of memory captured in the Minidump
39 lldb::addr_t start; // virtual address of the beginning of the range
40 // range_ref - absolute pointer to the first byte of the range and size
41 llvm::ArrayRef<uint8_t> range_ref;
43 Range(lldb::addr_t start, llvm::ArrayRef<uint8_t> range_ref)
44 : start(start), range_ref(range_ref) {}
47 class MinidumpParser {
49 static llvm::Optional<MinidumpParser>
50 Create(const lldb::DataBufferSP &data_buf_sp);
52 llvm::ArrayRef<uint8_t> GetData();
54 llvm::ArrayRef<uint8_t> GetStream(MinidumpStreamType stream_type);
56 llvm::Optional<std::string> GetMinidumpString(uint32_t rva);
58 UUID GetModuleUUID(const MinidumpModule* module);
60 llvm::ArrayRef<MinidumpThread> GetThreads();
62 llvm::ArrayRef<uint8_t> GetThreadContext(const MinidumpThread &td);
64 llvm::ArrayRef<uint8_t> GetThreadContextWow64(const MinidumpThread &td);
66 const MinidumpSystemInfo *GetSystemInfo();
68 ArchSpec GetArchitecture();
70 const MinidumpMiscInfo *GetMiscInfo();
72 llvm::Optional<LinuxProcStatus> GetLinuxProcStatus();
74 llvm::Optional<lldb::pid_t> GetPid();
76 llvm::ArrayRef<MinidumpModule> GetModuleList();
78 // There are cases in which there is more than one record in the ModuleList
79 // 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 that
81 // have the same name, it keeps the copy with the lowest load address.
82 std::vector<const MinidumpModule *> GetFilteredModuleList();
84 const MinidumpExceptionStream *GetExceptionStream();
86 llvm::Optional<Range> FindMemoryRange(lldb::addr_t addr);
88 llvm::ArrayRef<uint8_t> GetMemory(lldb::addr_t addr, size_t size);
90 llvm::Optional<MemoryRegionInfo> GetMemoryRegionInfo(lldb::addr_t);
92 // Perform consistency checks and initialize internal data structures
96 MinidumpParser(const lldb::DataBufferSP &data_buf_sp);
99 lldb::DataBufferSP m_data_sp;
100 llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> m_directory_map;
103 } // end namespace minidump
104 } // end namespace lldb_private
105 #endif // liblldb_MinidumpParser_h_