17a7e6055SDimitry Andric //===- SymbolStream.cpp - PDB Symbol Stream Access ------------------------===// 27a7e6055SDimitry Andric // 37a7e6055SDimitry Andric // The LLVM Compiler Infrastructure 47a7e6055SDimitry Andric // 57a7e6055SDimitry Andric // This file is distributed under the University of Illinois Open Source 67a7e6055SDimitry Andric // License. See LICENSE.TXT for details. 77a7e6055SDimitry Andric // 87a7e6055SDimitry Andric //===----------------------------------------------------------------------===// 97a7e6055SDimitry Andric 107a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/SymbolStream.h" 117a7e6055SDimitry Andric 127a7e6055SDimitry Andric #include "llvm/DebugInfo/CodeView/CodeView.h" 13*2cab237bSDimitry Andric #include "llvm/DebugInfo/CodeView/SymbolRecord.h" 147a7e6055SDimitry Andric #include "llvm/DebugInfo/MSF/MappedBlockStream.h" 157a7e6055SDimitry Andric #include "llvm/Support/BinaryStreamReader.h" 167a7e6055SDimitry Andric #include "llvm/Support/Endian.h" 177a7e6055SDimitry Andric 187a7e6055SDimitry Andric using namespace llvm; 197a7e6055SDimitry Andric using namespace llvm::msf; 207a7e6055SDimitry Andric using namespace llvm::support; 217a7e6055SDimitry Andric using namespace llvm::pdb; 227a7e6055SDimitry Andric SymbolStream(std::unique_ptr<MappedBlockStream> Stream)237a7e6055SDimitry AndricSymbolStream::SymbolStream(std::unique_ptr<MappedBlockStream> Stream) 247a7e6055SDimitry Andric : Stream(std::move(Stream)) {} 257a7e6055SDimitry Andric ~SymbolStream()267a7e6055SDimitry AndricSymbolStream::~SymbolStream() {} 277a7e6055SDimitry Andric reload()287a7e6055SDimitry AndricError SymbolStream::reload() { 297a7e6055SDimitry Andric BinaryStreamReader Reader(*Stream); 307a7e6055SDimitry Andric 317a7e6055SDimitry Andric if (auto EC = Reader.readArray(SymbolRecords, Stream->getLength())) 327a7e6055SDimitry Andric return EC; 337a7e6055SDimitry Andric 347a7e6055SDimitry Andric return Error::success(); 357a7e6055SDimitry Andric } 367a7e6055SDimitry Andric 377a7e6055SDimitry Andric iterator_range<codeview::CVSymbolArray::Iterator> getSymbols(bool * HadError) const387a7e6055SDimitry AndricSymbolStream::getSymbols(bool *HadError) const { 397a7e6055SDimitry Andric return llvm::make_range(SymbolRecords.begin(HadError), SymbolRecords.end()); 407a7e6055SDimitry Andric } 417a7e6055SDimitry Andric commit()427a7e6055SDimitry AndricError SymbolStream::commit() { return Error::success(); } 43*2cab237bSDimitry Andric readRecord(uint32_t Offset) const44*2cab237bSDimitry Andriccodeview::CVSymbol SymbolStream::readRecord(uint32_t Offset) const { 45*2cab237bSDimitry Andric return *SymbolRecords.at(Offset); 46*2cab237bSDimitry Andric } 47