Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/InjectedSourceStream.cpp
35293 views
//===- InjectedSourceStream.cpp - PDB Headerblock Stream Access -----------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/DebugInfo/PDB/Native/InjectedSourceStream.h"910#include "llvm/DebugInfo/MSF/MappedBlockStream.h"11#include "llvm/DebugInfo/PDB/Native/HashTable.h"12#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"13#include "llvm/DebugInfo/PDB/Native/RawConstants.h"14#include "llvm/DebugInfo/PDB/Native/RawTypes.h"15#include "llvm/Support/BinaryStreamReader.h"1617using namespace llvm;18using namespace llvm::msf;19using namespace llvm::support;20using namespace llvm::pdb;2122InjectedSourceStream::InjectedSourceStream(23std::unique_ptr<MappedBlockStream> Stream)24: Stream(std::move(Stream)) {}2526Error InjectedSourceStream::reload(const PDBStringTable &Strings) {27BinaryStreamReader Reader(*Stream);2829if (auto EC = Reader.readObject(Header))30return EC;3132if (Header->Version !=33static_cast<uint32_t>(PdbRaw_SrcHeaderBlockVer::SrcVerOne))34return make_error<RawError>(raw_error_code::corrupt_file,35"Invalid headerblock header version");3637if (auto EC = InjectedSourceTable.load(Reader))38return EC;3940for (const auto& Entry : *this) {41if (Entry.second.Size != sizeof(SrcHeaderBlockEntry))42return make_error<RawError>(raw_error_code::corrupt_file,43"Invalid headerbock entry size");44if (Entry.second.Version !=45static_cast<uint32_t>(PdbRaw_SrcHeaderBlockVer::SrcVerOne))46return make_error<RawError>(raw_error_code::corrupt_file,47"Invalid headerbock entry version");4849// Check that all name references are valid.50auto Name = Strings.getStringForID(Entry.second.FileNI);51if (!Name)52return Name.takeError();53auto ObjName = Strings.getStringForID(Entry.second.ObjNI);54if (!ObjName)55return ObjName.takeError();56auto VName = Strings.getStringForID(Entry.second.VFileNI);57if (!VName)58return VName.takeError();59}6061assert(Reader.bytesRemaining() == 0);62return Error::success();63}646566