Zachary Turner | f34e016 | 2016-04-26 16:20:00 +0000 | [diff] [blame^] | 1 | //===- PDBInfoStream.cpp - PDB Info Stream (Stream 1) Access ----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/DebugInfo/PDB/Raw/PDBInfoStream.h" |
| 11 | #include "llvm/ADT/BitVector.h" |
| 12 | #include "llvm/ADT/SmallVector.h" |
| 13 | |
| 14 | using namespace llvm; |
| 15 | |
| 16 | PDBInfoStream::PDBInfoStream(const PDBFile &File) |
| 17 | : Pdb(File), Stream1(1, File) {} |
| 18 | |
| 19 | std::error_code PDBInfoStream::reload() { |
| 20 | Stream1.setOffset(0); |
| 21 | support::ulittle32_t Value; |
| 22 | |
| 23 | Stream1.readObject(&Version); |
| 24 | if (Version < PdbRaw_ImplVer::VC70) |
| 25 | return std::make_error_code(std::errc::not_supported); |
| 26 | |
| 27 | Stream1.readObject(&Value); |
| 28 | Signature = Value; |
| 29 | |
| 30 | Stream1.readObject(&Value); |
| 31 | Age = Value; |
| 32 | |
| 33 | Stream1.readObject(&Guid); |
| 34 | NamedStreams.load(Stream1); |
| 35 | |
| 36 | return std::error_code(); |
| 37 | } |
| 38 | |
| 39 | uint32_t PDBInfoStream::getNamedStreamIndex(llvm::StringRef Name) const { |
| 40 | uint32_t Result; |
| 41 | if (!NamedStreams.tryGetValue(Name, Result)) |
| 42 | return 0; |
| 43 | return Result; |
| 44 | } |
| 45 | |
| 46 | PdbRaw_ImplVer PDBInfoStream::getVersion() const { |
| 47 | return static_cast<PdbRaw_ImplVer>(Version); |
| 48 | } |
| 49 | |
| 50 | uint32_t PDBInfoStream::getSignature() const { return Signature; } |
| 51 | |
| 52 | uint32_t PDBInfoStream::getAge() const { return Age; } |
| 53 | |
| 54 | PDB_UniqueId PDBInfoStream::getGuid() const { return Guid; } |