summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/IPDBSession.h1
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/PDBTypes.h31
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h53
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/Raw/PDBStream.h46
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h72
5 files changed, 173 insertions, 30 deletions
diff --git a/llvm/include/llvm/DebugInfo/PDB/IPDBSession.h b/llvm/include/llvm/DebugInfo/PDB/IPDBSession.h
index b6bccbeb884..a79b8e26a4c 100644
--- a/llvm/include/llvm/DebugInfo/PDB/IPDBSession.h
+++ b/llvm/include/llvm/DebugInfo/PDB/IPDBSession.h
@@ -11,6 +11,7 @@
#define LLVM_DEBUGINFO_PDB_IPDBSESSION_H
#include "PDBTypes.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include <memory>
diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
index 1e42d9a6a8b..05beb24e6b1 100644
--- a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
+++ b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
@@ -12,7 +12,6 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
-#include "llvm/Support/Endian.h"
#include <functional>
#include <cstdint>
#include <cstring>
@@ -70,6 +69,7 @@ class PDBSymbolUnknown;
/// of PDB_ReaderType::DIA is supported.
enum class PDB_ReaderType {
DIA = 0,
+ Raw = 1,
};
/// Defines a 128-bit unique identifier. This maps to a GUID on Windows, but
@@ -429,35 +429,6 @@ struct Variant {
}
};
-namespace PDB {
-static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f',
- 't', ' ', 'C', '/', 'C', '+', '+', ' ',
- 'M', 'S', 'F', ' ', '7', '.', '0', '0',
- '\r', '\n', '\x1a', 'D', 'S', '\0', '\0', '\0'};
-
-// The superblock is overlaid at the beginning of the file (offset 0).
-// It starts with a magic header and is followed by information which describes
-// the layout of the file system.
-struct SuperBlock {
- char MagicBytes[sizeof(Magic)];
- // The file system is split into a variable number of fixed size elements.
- // These elements are referred to as blocks. The size of a block may vary
- // from system to system.
- support::ulittle32_t BlockSize;
- // This field's purpose is not yet known.
- support::ulittle32_t Unknown0;
- // This contains the number of blocks resident in the file system. In
- // practice, NumBlocks * BlockSize is equivalent to the size of the PDB file.
- support::ulittle32_t NumBlocks;
- // This contains the number of bytes which make up the directory.
- support::ulittle32_t NumDirectoryBytes;
- // This field's purpose is not yet known.
- support::ulittle32_t Unknown1;
- // This contains the block # of the block map.
- support::ulittle32_t BlockMapAddr;
-};
-} // end namespace PDB
-
} // end namespace llvm
namespace std {
diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h
new file mode 100644
index 00000000000..78c05ace728
--- /dev/null
+++ b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h
@@ -0,0 +1,53 @@
+//===- PDBFile.h - Low level interface to a PDB file ------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
+#define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/Support/Endian.h"
+
+#include <memory>
+
+namespace llvm {
+class MemoryBuffer;
+
+struct PDBContext;
+
+class PDBFile {
+public:
+ explicit PDBFile(std::unique_ptr<MemoryBuffer> MemBuffer);
+ ~PDBFile();
+
+ uint32_t getBlockSize() const;
+ uint32_t getUnknown0() const;
+ uint32_t getBlockCount() const;
+ uint32_t getNumDirectoryBytes() const;
+ uint32_t getBlockMapIndex() const;
+ uint32_t getUnknown1() const;
+ uint32_t getNumDirectoryBlocks() const;
+ uint64_t getBlockMapOffset() const;
+
+ uint32_t getNumStreams() const;
+ uint32_t getStreamByteSize(uint32_t StreamIndex) const;
+ llvm::ArrayRef<uint32_t> getStreamBlockList(uint32_t StreamIndex) const;
+
+ StringRef getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const;
+
+ llvm::ArrayRef<uint32_t> getDirectoryBlockArray();
+
+ std::error_code parseFileHeaders();
+ std::error_code parseStreamData();
+
+private:
+ std::unique_ptr<PDBContext> Context;
+};
+}
+
+#endif
diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBStream.h
new file mode 100644
index 00000000000..0f71e81cf2e
--- /dev/null
+++ b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBStream.h
@@ -0,0 +1,46 @@
+//===- PDBStream.h - Low level interface to a PDB stream --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTREAM_H
+#define LLVM_DEBUGINFO_PDB_RAW_PDBSTREAM_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+
+class MemoryBufferRef;
+class PDBFile;
+
+class PDBStream {
+public:
+ PDBStream(uint32_t StreamIdx, const PDBFile &File);
+
+ std::error_code readInteger(uint32_t &Dest);
+ std::error_code readZeroString(std::string &Dest);
+ std::error_code readBytes(void *Dest, uint32_t Length);
+
+ void setOffset(uint32_t Off);
+ uint32_t getOffset() const;
+ uint32_t getLength() const;
+
+ template <typename T> std::error_code readObject(T *Dest) {
+ return readBytes(reinterpret_cast<void *>(Dest), sizeof(T));
+ }
+
+private:
+ uint32_t Offset;
+
+ uint32_t StreamLength;
+ std::vector<uint32_t> BlockList;
+ const PDBFile &Pdb;
+};
+}
+
+#endif
diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h b/llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h
new file mode 100644
index 00000000000..55edb6fe24d
--- /dev/null
+++ b/llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h
@@ -0,0 +1,72 @@
+//===- RawSession.h - Native implementation of IPDBSession ------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_RAW_RAWSESSION_H
+#define LLVM_DEBUGINFO_PDB_RAW_RAWSESSION_H
+
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
+
+namespace llvm {
+class PDBFile;
+class StringRef;
+
+class RawSession : public IPDBSession {
+public:
+ explicit RawSession(std::unique_ptr<PDBFile> PdbFile);
+ ~RawSession() override;
+
+ static PDB_ErrorCode createFromPdb(StringRef Path,
+ std::unique_ptr<IPDBSession> &Session);
+ static PDB_ErrorCode createFromExe(StringRef Path,
+ std::unique_ptr<IPDBSession> &Session);
+
+ uint64_t getLoadAddress() const override;
+ void setLoadAddress(uint64_t Address) override;
+ std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;
+ std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
+
+ std::unique_ptr<PDBSymbol>
+ findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override;
+
+ std::unique_ptr<IPDBEnumLineNumbers>
+ findLineNumbers(const PDBSymbolCompiland &Compiland,
+ const IPDBSourceFile &File) const override;
+ std::unique_ptr<IPDBEnumLineNumbers>
+ findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override;
+
+ std::unique_ptr<IPDBEnumSourceFiles>
+ findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern,
+ PDB_NameSearchFlags Flags) const override;
+ std::unique_ptr<IPDBSourceFile>
+ findOneSourceFile(const PDBSymbolCompiland *Compiland,
+ llvm::StringRef Pattern,
+ PDB_NameSearchFlags Flags) const override;
+ std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
+ findCompilandsForSourceFile(llvm::StringRef Pattern,
+ PDB_NameSearchFlags Flags) const override;
+ std::unique_ptr<PDBSymbolCompiland>
+ findOneCompilandForSourceFile(llvm::StringRef Pattern,
+ PDB_NameSearchFlags Flags) const override;
+ std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const override;
+ std::unique_ptr<IPDBEnumSourceFiles> getSourceFilesForCompiland(
+ const PDBSymbolCompiland &Compiland) const override;
+ std::unique_ptr<IPDBSourceFile>
+ getSourceFileById(uint32_t FileId) const override;
+
+ std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
+
+ PDBFile &getPDBFile() { return *Pdb; }
+ const PDBFile &getPDBFile() const { return *Pdb; }
+
+private:
+ std::unique_ptr<PDBFile> Pdb;
+};
+}
+
+#endif
OpenPOWER on IntegriCloud