xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/SymbolStream.cpp (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
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/CodeView/CodeView.h"
12 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
13 #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
14 #include "llvm/Support/BinaryStreamReader.h"
15 #include "llvm/Support/Endian.h"
16 
17 using namespace llvm;
18 using namespace llvm::msf;
19 using namespace llvm::support;
20 using namespace llvm::pdb;
21 
22 SymbolStream::SymbolStream(std::unique_ptr<MappedBlockStream> Stream)
23     : Stream(std::move(Stream)) {}
24 
25 SymbolStream::~SymbolStream() {}
26 
27 Error SymbolStream::reload() {
28   BinaryStreamReader Reader(*Stream);
29 
30   if (auto EC = Reader.readArray(SymbolRecords, Stream->getLength()))
31     return EC;
32 
33   return Error::success();
34 }
35 
36 iterator_range<codeview::CVSymbolArray::Iterator>
37 SymbolStream::getSymbols(bool *HadError) const {
38   return llvm::make_range(SymbolRecords.begin(HadError), SymbolRecords.end());
39 }
40 
41 Error SymbolStream::commit() { return Error::success(); }
42 
43 codeview::CVSymbol SymbolStream::readRecord(uint32_t Offset) const {
44   return *SymbolRecords.at(Offset);
45 }
46