summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
diff options
context:
space:
mode:
authorAdrian McCarthy <amccarth@google.com>2017-01-25 22:38:55 +0000
committerAdrian McCarthy <amccarth@google.com>2017-01-25 22:38:55 +0000
commit6b6b8c4fb9de06aecef40b8aadcc92dfbfec2e33 (patch)
treecdef766dc0d3728f643359f40671078727d9487e /llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
parent896b4513e1bb1a96192b71db9da3ed7955778346 (diff)
downloadbcm5719-llvm-6b6b8c4fb9de06aecef40b8aadcc92dfbfec2e33.tar.gz
bcm5719-llvm-6b6b8c4fb9de06aecef40b8aadcc92dfbfec2e33.zip
NFC: Rename (PDB) RawSession to NativeSession
This eliminates one overload on the term Raw. Differential Revision: https://reviews.llvm.org/D29098 llvm-svn: 293104
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/ModStream.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/ModStream.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp b/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
new file mode 100644
index 00000000000..25370f26ec3
--- /dev/null
+++ b/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
@@ -0,0 +1,85 @@
+//===- ModStream.cpp - PDB Module Info Stream Access ----------------------===//
+//
+// 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/Native/ModStream.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
+#include "llvm/DebugInfo/MSF/StreamReader.h"
+#include "llvm/DebugInfo/MSF/StreamRef.h"
+#include "llvm/DebugInfo/PDB/Native/ModInfo.h"
+#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
+#include "llvm/DebugInfo/PDB/Native/RawError.h"
+#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
+#include "llvm/Support/Error.h"
+#include <algorithm>
+#include <cstdint>
+
+using namespace llvm;
+using namespace llvm::msf;
+using namespace llvm::pdb;
+
+ModStream::ModStream(const ModInfo &Module,
+ std::unique_ptr<MappedBlockStream> Stream)
+ : Mod(Module), Stream(std::move(Stream)) {}
+
+ModStream::~ModStream() = default;
+
+Error ModStream::reload() {
+ StreamReader Reader(*Stream);
+
+ uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
+ uint32_t C11Size = Mod.getLineInfoByteSize();
+ uint32_t C13Size = Mod.getC13LineInfoByteSize();
+
+ if (C11Size > 0 && C13Size > 0)
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Module has both C11 and C13 line info");
+
+ ReadableStreamRef S;
+
+ if (auto EC = Reader.readInteger(Signature))
+ return EC;
+ if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
+ return EC;
+
+ if (auto EC = Reader.readStreamRef(LinesSubstream, C11Size))
+ return EC;
+ if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size))
+ return EC;
+
+ StreamReader LineReader(C13LinesSubstream);
+ if (auto EC = LineReader.readArray(LineInfo, LineReader.bytesRemaining()))
+ return EC;
+
+ uint32_t GlobalRefsSize;
+ if (auto EC = Reader.readInteger(GlobalRefsSize))
+ return EC;
+ if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize))
+ return EC;
+ if (Reader.bytesRemaining() > 0)
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Unexpected bytes in module stream.");
+
+ return Error::success();
+}
+
+iterator_range<codeview::CVSymbolArray::Iterator>
+ModStream::symbols(bool *HadError) const {
+ // It's OK if the stream is empty.
+ if (SymbolsSubstream.getUnderlyingStream().getLength() == 0)
+ return make_range(SymbolsSubstream.end(), SymbolsSubstream.end());
+ return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end());
+}
+
+iterator_range<codeview::ModuleSubstreamArray::Iterator>
+ModStream::lines(bool *HadError) const {
+ return make_range(LineInfo.begin(HadError), LineInfo.end());
+}
+
+Error ModStream::commit() { return Error::success(); }
OpenPOWER on IntegriCloud