Minidump parsing

Summary:
This is a Minidump parsing code.
There are still some more structures/data streams that need to be added.
The aim ot this is to be used in the implementation of
a minidump debugging plugin that works on all platforms/architectures.
Currently we have a windows-only plugin that uses the WinAPI to parse
the dump files.
Also added unittests for the current functionality.

Reviewers: labath, amccarth

Subscribers: tberghammer, danalbert, srhines, lldb-commits, dschuff

Differential Revision: https://reviews.llvm.org/D23545

llvm-svn: 280356
diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.h b/lldb/source/Plugins/Process/minidump/MinidumpParser.h
new file mode 100644
index 0000000..d99bd57
--- /dev/null
+++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.h
@@ -0,0 +1,73 @@
+//===-- MinidumpParser.h -----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_MinidumpParser_h_
+#define liblldb_MinidumpParser_h_
+
+// Project includes
+#include "MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/Error.h"
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Optional.h"
+
+// C includes
+
+// C++ includes
+#include <cstring>
+#include <unordered_map>
+
+
+namespace lldb_private
+{
+
+namespace minidump
+{
+
+class MinidumpParser
+{
+public:
+    static llvm::Optional<MinidumpParser>
+    Create(const lldb::DataBufferSP &data_buf_sp);
+
+    lldb::offset_t
+    GetByteSize();
+
+    llvm::Optional<llvm::ArrayRef<uint8_t>>
+    GetStream(MinidumpStreamType stream_type);
+
+    llvm::Optional<std::vector<const MinidumpThread *>>
+    GetThreads();
+
+    const MinidumpSystemInfo *
+    GetSystemInfo();
+
+    ArchSpec
+    GetArchitecture();
+
+    const MinidumpMiscInfo *
+    GetMiscInfo();
+
+private:
+    lldb::DataBufferSP m_data_sp;
+    const MinidumpHeader *m_header;
+    llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> m_directory_map;
+
+    MinidumpParser(const lldb::DataBufferSP &data_buf_sp, const MinidumpHeader *header,
+                   const llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> &directory_map);
+};
+
+} // namespace minidump
+} // namespace lldb_private
+#endif // liblldb_MinidumpParser_h_