]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/minidump/MinidumpParser.h
Update to bmake-201802222
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / minidump / MinidumpParser.h
1 //===-- MinidumpParser.h -----------------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef liblldb_MinidumpParser_h_
12 #define liblldb_MinidumpParser_h_
13
14 // Project includes
15 #include "MinidumpTypes.h"
16
17 #include "lldb/Utility/ArchSpec.h"
18 #include "lldb/Utility/DataBuffer.h"
19 #include "lldb/Utility/Status.h"
20
21 #include "llvm/ADT/ArrayRef.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/Optional.h"
24 #include "llvm/ADT/StringRef.h"
25
26 // C includes
27
28 // C++ includes
29 #include <cstring>
30 #include <unordered_map>
31
32 namespace lldb_private {
33
34 namespace minidump {
35
36 // Describes a range of memory captured in the Minidump
37 struct Range {
38   lldb::addr_t start; // virtual address of the beginning of the range
39   // range_ref - absolute pointer to the first byte of the range and size
40   llvm::ArrayRef<uint8_t> range_ref;
41
42   Range(lldb::addr_t start, llvm::ArrayRef<uint8_t> range_ref)
43       : start(start), range_ref(range_ref) {}
44 };
45
46 class MinidumpParser {
47 public:
48   static llvm::Optional<MinidumpParser>
49   Create(const lldb::DataBufferSP &data_buf_sp);
50
51   llvm::ArrayRef<uint8_t> GetData();
52
53   llvm::ArrayRef<uint8_t> GetStream(MinidumpStreamType stream_type);
54
55   llvm::Optional<std::string> GetMinidumpString(uint32_t rva);
56
57   llvm::ArrayRef<MinidumpThread> GetThreads();
58
59   llvm::ArrayRef<uint8_t> GetThreadContext(const MinidumpThread &td);
60
61   llvm::ArrayRef<uint8_t> GetThreadContextWow64(const MinidumpThread &td);
62
63   const MinidumpSystemInfo *GetSystemInfo();
64
65   ArchSpec GetArchitecture();
66
67   const MinidumpMiscInfo *GetMiscInfo();
68
69   llvm::Optional<LinuxProcStatus> GetLinuxProcStatus();
70
71   llvm::Optional<lldb::pid_t> GetPid();
72
73   llvm::ArrayRef<MinidumpModule> GetModuleList();
74
75   // There are cases in which there is more than one record in the ModuleList
76   // for the same module name.(e.g. when the binary has non contiguous segments)
77   // So this function returns a filtered module list - if it finds records that
78   // have the same name, it keeps the copy with the lowest load address.
79   std::vector<const MinidumpModule *> GetFilteredModuleList();
80
81   const MinidumpExceptionStream *GetExceptionStream();
82
83   llvm::Optional<Range> FindMemoryRange(lldb::addr_t addr);
84
85   llvm::ArrayRef<uint8_t> GetMemory(lldb::addr_t addr, size_t size);
86
87   llvm::Optional<MemoryRegionInfo> GetMemoryRegionInfo(lldb::addr_t);
88
89 private:
90   lldb::DataBufferSP m_data_sp;
91   const MinidumpHeader *m_header;
92   llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> m_directory_map;
93
94   MinidumpParser(
95       const lldb::DataBufferSP &data_buf_sp, const MinidumpHeader *header,
96       llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> &&directory_map);
97 };
98
99 } // end namespace minidump
100 } // end namespace lldb_private
101 #endif // liblldb_MinidumpParser_h_