xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/SymbolStream.cpp (revision 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
1 //===- SymbolStream.cpp - PDB Symbol Stream Access ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
10 
11 #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
12 #include "llvm/Support/Endian.h"
13 
14 using namespace llvm;
15 using namespace llvm::msf;
16 using namespace llvm::support;
17 using namespace llvm::pdb;
18 
19 SymbolStream::SymbolStream(std::unique_ptr<MappedBlockStream> Stream)
20     : Stream(std::move(Stream)) {}
21 
22 SymbolStream::~SymbolStream() = default;
23 
24 Error SymbolStream::reload() {
25   BinaryStreamReader Reader(*Stream);
26 
27   if (auto EC = Reader.readArray(SymbolRecords, Stream->getLength()))
28     return EC;
29 
30   return Error::success();
31 }
32 
33 iterator_range<codeview::CVSymbolArray::Iterator>
34 SymbolStream::getSymbols(bool *HadError) const {
35   return llvm::make_range(SymbolRecords.begin(HadError), SymbolRecords.end());
36 }
37 
38 Error SymbolStream::commit() { return Error::success(); }
39 
40 codeview::CVSymbol SymbolStream::readRecord(uint32_t Offset) const {
41   return *SymbolRecords.at(Offset);
42 }
43