From 581d79a440a6019d0c5b8218aa47403727a838d0 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 21 Mar 2019 09:18:59 +0000 Subject: [Object] Add basic minidump support Summary: This patch adds basic support for reading minidump files. It contains the definitions of various important minidump data structures (header, stream directory), and of one minidump stream (SystemInfo). The ability to read other streams will be added in follow-up patches. However, all streams can be read even now as raw data, which means lldb's minidump support (where this code is taken from) can be immediately rebased on top of this patch as soon as it lands. As we don't have any support for generating minidump files (yet), this tests the code via unit tests with some small handcrafted binaries in the form of c char arrays. Reviewers: Bigcheese, jhenderson, zturner Subscribers: srhines, dschuff, mgorny, fedor.sergeev, lemo, clayborg, JDevlieghere, aprantl, lldb-commits, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59291 llvm-svn: 356652 --- llvm/lib/BinaryFormat/Magic.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/BinaryFormat/Magic.cpp') diff --git a/llvm/lib/BinaryFormat/Magic.cpp b/llvm/lib/BinaryFormat/Magic.cpp index 5e9d6e73257..85f944fa6ab 100644 --- a/llvm/lib/BinaryFormat/Magic.cpp +++ b/llvm/lib/BinaryFormat/Magic.cpp @@ -181,7 +181,8 @@ file_magic llvm::identify_magic(StringRef Magic) { return file_magic::coff_object; break; - case 'M': // Possible MS-DOS stub on Windows PE file or MSF/PDB file. + case 'M': // Possible MS-DOS stub on Windows PE file, MSF/PDB file or a + // Minidump file. if (startswith(Magic, "MZ") && Magic.size() >= 0x3c + 4) { uint32_t off = read32le(Magic.data() + 0x3c); // PE/COFF file, either EXE or DLL. @@ -191,6 +192,8 @@ file_magic llvm::identify_magic(StringRef Magic) { } if (Magic.startswith("Microsoft C/C++ MSF 7.00\r\n")) return file_magic::pdb; + if (startswith(Magic, "MDMP")) + return file_magic::minidump; break; case 0x64: // x86-64 or ARM64 Windows. -- cgit v1.2.3