]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/minidump/MinidumpParser.h
MFV r325013,r325034: 640 number_to_scaled_string is duplicated in several commands
[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 // Other libraries and framework includes
18 #include "lldb/Core/ArchSpec.h"
19 #include "lldb/Utility/DataBuffer.h"
20 #include "lldb/Utility/Status.h"
21
22 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/DenseMap.h"
24 #include "llvm/ADT/Optional.h"
25 #include "llvm/ADT/StringRef.h"
26
27 // C includes
28
29 // C++ includes
30 #include <cstring>
31 #include <unordered_map>
32
33 namespace lldb_private {
34
35 namespace minidump {
36
37 // Describes a range of memory captured in the Minidump
38 struct Range {
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;
42
43   Range(lldb::addr_t start, llvm::ArrayRef<uint8_t> range_ref)
44       : start(start), range_ref(range_ref) {}
45 };
46
47 class MinidumpParser {
48 public:
49   static llvm::Optional<MinidumpParser>
50   Create(const lldb::DataBufferSP &data_buf_sp);
51
52   llvm::ArrayRef<uint8_t> GetData();
53
54   llvm::ArrayRef<uint8_t> GetStream(MinidumpStreamType stream_type);
55
56   llvm::Optional<std::string> GetMinidumpString(uint32_t rva);
57
58   llvm::ArrayRef<MinidumpThread> GetThreads();
59
60   llvm::ArrayRef<uint8_t> GetThreadContext(const MinidumpThread &td);
61
62   llvm::ArrayRef<uint8_t> GetThreadContextWow64(const MinidumpThread &td);
63
64   const MinidumpSystemInfo *GetSystemInfo();
65
66   ArchSpec GetArchitecture();
67
68   const MinidumpMiscInfo *GetMiscInfo();
69
70   llvm::Optional<LinuxProcStatus> GetLinuxProcStatus();
71
72   llvm::Optional<lldb::pid_t> GetPid();
73
74   llvm::ArrayRef<MinidumpModule> GetModuleList();
75
76   // There are cases in which there is more than one record in the ModuleList
77   // for the same module name.(e.g. when the binary has non contiguous segments)
78   // So this function returns a filtered module list - if it finds records that
79   // have the same name, it keeps the copy with the lowest load address.
80   std::vector<const MinidumpModule *> GetFilteredModuleList();
81
82   const MinidumpExceptionStream *GetExceptionStream();
83
84   llvm::Optional<Range> FindMemoryRange(lldb::addr_t addr);
85
86   llvm::ArrayRef<uint8_t> GetMemory(lldb::addr_t addr, size_t size);
87
88   llvm::Optional<MemoryRegionInfo> GetMemoryRegionInfo(lldb::addr_t);
89
90 private:
91   lldb::DataBufferSP m_data_sp;
92   const MinidumpHeader *m_header;
93   llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> m_directory_map;
94
95   MinidumpParser(
96       const lldb::DataBufferSP &data_buf_sp, const MinidumpHeader *header,
97       llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> &&directory_map);
98 };
99
100 } // end namespace minidump
101 } // end namespace lldb_private
102 #endif // liblldb_MinidumpParser_h_