aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-04-21 20:58:35 +0000
committerZachary Turner <zturner@google.com>2016-04-21 20:58:35 +0000
commita12b3d4626ee6dcb5cc98b121dd287b444b6bd3c (patch)
tree372590fc3d32faad953fd3f78f528743e55738fa /llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp
parent5852c5a12f268aee0274ced9109d72da50985ebe (diff)
downloadllvm-a12b3d4626ee6dcb5cc98b121dd287b444b6bd3c.zip
llvm-a12b3d4626ee6dcb5cc98b121dd287b444b6bd3c.tar.gz
llvm-a12b3d4626ee6dcb5cc98b121dd287b444b6bd3c.tar.bz2
Refactor raw pdb dumper into library
PDB parsing code was hand-rolled into llvm-pdbdump. This patch moves the parsing of this code into DebugInfoPDB and makes the dumper use this. This is achieved by implementing the skeleton of RawPdbSession, the non-DIA counterpart to the existing PDB read interface. None of the type / source file / etc information is accessible yet, so this implementation is not yet close to achieving parity with the DIA counterpart, but the RawSession class simply holds a reference to a PDBFile class which handles parsing the file format. Additionally a PDBStream class is introduced which allows accessing the bytes of a particular stream in a PDB file. Differential Revision: http://reviews.llvm.org/D19343 Reviewed By: majnemer llvm-svn: 267049
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp126
1 files changed, 126 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp
new file mode 100644
index 0000000..05eac63
--- /dev/null
+++ b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp
@@ -0,0 +1,126 @@
+//===- RawSession.cpp - Raw 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.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/PDB/Raw/RawSession.h"
+#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
+#include "llvm/DebugInfo/PDB/Raw/PdbFile.h"
+
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+using namespace llvm;
+
+RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile)
+ : Pdb(std::move(PdbFile)) {}
+
+RawSession::~RawSession() {}
+
+PDB_ErrorCode RawSession::createFromPdb(StringRef Path,
+ std::unique_ptr<IPDBSession> &Session) {
+
+ ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
+ MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
+ /*RequiresNullTerminator=*/false);
+
+ std::error_code EC;
+ if (EC = ErrorOrBuffer.getError())
+ return PDB_ErrorCode::CouldNotCreateImpl;
+
+ std::unique_ptr<MemoryBuffer> &Buffer = ErrorOrBuffer.get();
+
+ std::unique_ptr<PDBFile> File(new PDBFile(std::move(Buffer)));
+ if (EC = File->parseFileHeaders())
+ return PDB_ErrorCode::InvalidFileFormat;
+ if (EC = File->parseStreamData())
+ return PDB_ErrorCode::InvalidFileFormat;
+
+ Session.reset(new RawSession(std::move(File)));
+
+ return PDB_ErrorCode::Success;
+}
+
+PDB_ErrorCode RawSession::createFromExe(StringRef Path,
+ std::unique_ptr<IPDBSession> &Session) {
+ return PDB_ErrorCode::CouldNotCreateImpl;
+}
+
+uint64_t RawSession::getLoadAddress() const { return 0; }
+
+void RawSession::setLoadAddress(uint64_t Address) {}
+
+std::unique_ptr<PDBSymbolExe> RawSession::getGlobalScope() const {
+ return nullptr;
+}
+
+std::unique_ptr<PDBSymbol> RawSession::getSymbolById(uint32_t SymbolId) const {
+ return nullptr;
+}
+
+std::unique_ptr<PDBSymbol>
+RawSession::findSymbolByAddress(uint64_t Address, PDB_SymType Type) const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBEnumLineNumbers>
+RawSession::findLineNumbers(const PDBSymbolCompiland &Compiland,
+ const IPDBSourceFile &File) const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBEnumLineNumbers>
+RawSession::findLineNumbersByAddress(uint64_t Address, uint32_t Length) const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBEnumSourceFiles>
+RawSession::findSourceFiles(const PDBSymbolCompiland *Compiland,
+ llvm::StringRef Pattern,
+ PDB_NameSearchFlags Flags) const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBSourceFile>
+RawSession::findOneSourceFile(const PDBSymbolCompiland *Compiland,
+ llvm::StringRef Pattern,
+ PDB_NameSearchFlags Flags) const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
+RawSession::findCompilandsForSourceFile(llvm::StringRef Pattern,
+ PDB_NameSearchFlags Flags) const {
+ return nullptr;
+}
+
+std::unique_ptr<PDBSymbolCompiland>
+RawSession::findOneCompilandForSourceFile(llvm::StringRef Pattern,
+ PDB_NameSearchFlags Flags) const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBEnumSourceFiles> RawSession::getAllSourceFiles() const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBEnumSourceFiles> RawSession::getSourceFilesForCompiland(
+ const PDBSymbolCompiland &Compiland) const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBSourceFile>
+RawSession::getSourceFileById(uint32_t FileId) const {
+ return nullptr;
+}
+
+std::unique_ptr<IPDBEnumDataStreams> RawSession::getDebugStreams() const {
+ return nullptr;
+}