1 //===- SymbolStream.cpp - PDB Symbol Stream Access ------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
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"
18 using namespace llvm::msf
;
19 using namespace llvm::support
;
20 using namespace llvm::pdb
;
22 SymbolStream::SymbolStream(std::unique_ptr
<MappedBlockStream
> Stream
)
23 : Stream(std::move(Stream
)) {}
25 SymbolStream::~SymbolStream() {}
27 Error
SymbolStream::reload() {
28 BinaryStreamReader
Reader(*Stream
);
30 if (auto EC
= Reader
.readArray(SymbolRecords
, Stream
->getLength()))
33 return Error::success();
36 iterator_range
<codeview::CVSymbolArray::Iterator
>
37 SymbolStream::getSymbols(bool *HadError
) const {
38 return llvm::make_range(SymbolRecords
.begin(HadError
), SymbolRecords
.end());
41 Error
SymbolStream::commit() { return Error::success(); }
43 codeview::CVSymbol
SymbolStream::readRecord(uint32_t Offset
) const {
44 return *SymbolRecords
.at(Offset
);