-//===- ModuleDebugLineFragment.h --------------------------------*- C++ -*-===//
+//===- ModuleDebugFileChecksumFragment.h ------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
namespace llvm {
namespace codeview {
-class ModuleDebugFileChecksumFragment final : public ModuleDebugFragment {
- typedef VarStreamArray<FileChecksumEntry> FileChecksumArray;
+class ModuleDebugFileChecksumFragmentRef final : public ModuleDebugFragmentRef {
+ typedef VarStreamArray<codeview::FileChecksumEntry> FileChecksumArray;
typedef FileChecksumArray::Iterator Iterator;
public:
- ModuleDebugFileChecksumFragment()
- : ModuleDebugFragment(ModuleDebugFragmentKind::FileChecksums) {}
+ ModuleDebugFileChecksumFragmentRef()
+ : ModuleDebugFragmentRef(ModuleDebugFragmentKind::FileChecksums) {}
- static bool classof(const ModuleDebugFragment *S) {
+ static bool classof(const ModuleDebugFragmentRef *S) {
return S->kind() == ModuleDebugFragmentKind::FileChecksums;
}
namespace llvm {
namespace codeview {
-class ModuleDebugFragment {
+class ModuleDebugFragmentRef {
public:
- explicit ModuleDebugFragment(ModuleDebugFragmentKind Kind) : Kind(Kind) {}
+ explicit ModuleDebugFragmentRef(ModuleDebugFragmentKind Kind) : Kind(Kind) {}
+ virtual ~ModuleDebugFragmentRef();
- virtual ~ModuleDebugFragment();
ModuleDebugFragmentKind kind() const { return Kind; }
protected:
namespace codeview {
-class ModuleDebugFileChecksumFragment;
+class ModuleDebugFileChecksumFragmentRef;
class ModuleDebugFragmentRecord;
-class ModuleDebugInlineeLineFragment;
-class ModuleDebugLineFragment;
-class ModuleDebugUnknownFragment;
+class ModuleDebugInlineeLineFragmentRef;
+class ModuleDebugLineFragmentRef;
+class ModuleDebugUnknownFragmentRef;
class ModuleDebugFragmentVisitor {
public:
virtual ~ModuleDebugFragmentVisitor() = default;
- virtual Error visitUnknown(ModuleDebugUnknownFragment &Unknown) {
+ virtual Error visitUnknown(ModuleDebugUnknownFragmentRef &Unknown) {
return Error::success();
}
- virtual Error visitLines(ModuleDebugLineFragment &Lines) {
+ virtual Error visitLines(ModuleDebugLineFragmentRef &Lines) {
return Error::success();
}
- virtual Error visitFileChecksums(ModuleDebugFileChecksumFragment &Checksums) {
+ virtual Error
+ visitFileChecksums(ModuleDebugFileChecksumFragmentRef &Checksums) {
return Error::success();
}
LineColumnEntry &Item, const LineFragmentHeader *Header);
};
-class ModuleDebugLineFragment final : public ModuleDebugFragment {
+class ModuleDebugLineFragmentRef final : public ModuleDebugFragmentRef {
friend class LineColumnExtractor;
typedef VarStreamArray<LineColumnEntry, LineColumnExtractor> LineInfoArray;
typedef LineInfoArray::Iterator Iterator;
public:
- ModuleDebugLineFragment();
+ ModuleDebugLineFragmentRef();
- static bool classof(const ModuleDebugFragment *S) {
+ static bool classof(const ModuleDebugFragmentRef *S) {
return S->kind() == ModuleDebugFragmentKind::Lines;
}
namespace llvm {
namespace codeview {
-class ModuleDebugUnknownFragment final : public ModuleDebugFragment {
+class ModuleDebugUnknownFragmentRef final : public ModuleDebugFragmentRef {
public:
- ModuleDebugUnknownFragment(ModuleDebugFragmentKind Kind, BinaryStreamRef Data)
- : ModuleDebugFragment(Kind), Data(Data) {}
+ ModuleDebugUnknownFragmentRef(ModuleDebugFragmentKind Kind,
+ BinaryStreamRef Data)
+ : ModuleDebugFragmentRef(Kind), Data(Data) {}
BinaryStreamRef getData() const { return Data; }
class PDBFile;
class DbiModuleDescriptor;
-class ModuleDebugStream {
+class ModuleDebugStreamRef {
typedef codeview::ModuleDebugFragmentArray::Iterator
LinesAndChecksumsIterator;
public:
- ModuleDebugStream(const DbiModuleDescriptor &Module,
- std::unique_ptr<msf::MappedBlockStream> Stream);
- ~ModuleDebugStream();
+ ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
+ std::unique_ptr<msf::MappedBlockStream> Stream);
+ ~ModuleDebugStreamRef();
Error reload();
std::unique_ptr<msf::MappedBlockStream> Stream;
codeview::CVSymbolArray SymbolsSubstream;
- BinaryStreamRef LinesSubstream;
+ BinaryStreamRef C11LinesSubstream;
BinaryStreamRef C13LinesSubstream;
BinaryStreamRef GlobalRefsSubstream;
return Error::success();
}
-Error ModuleDebugFileChecksumFragment::initialize(BinaryStreamReader Reader) {
+Error ModuleDebugFileChecksumFragmentRef::initialize(
+ BinaryStreamReader Reader) {
if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining()))
return EC;
using namespace llvm::codeview;
-ModuleDebugFragment::~ModuleDebugFragment() {}
+ModuleDebugFragmentRef::~ModuleDebugFragmentRef() {}
BinaryStreamReader Reader(R.getRecordData());
switch (R.kind()) {
case ModuleDebugFragmentKind::Lines: {
- ModuleDebugLineFragment Fragment;
+ ModuleDebugLineFragmentRef Fragment;
if (auto EC = Fragment.initialize(Reader))
return EC;
return V.visitLines(Fragment);
}
case ModuleDebugFragmentKind::FileChecksums: {
- ModuleDebugFileChecksumFragment Fragment;
+ ModuleDebugFileChecksumFragmentRef Fragment;
if (auto EC = Fragment.initialize(Reader))
return EC;
return V.visitFileChecksums(Fragment);
}
default: {
- ModuleDebugUnknownFragment Fragment(R.kind(), R.getRecordData());
+ ModuleDebugUnknownFragmentRef Fragment(R.kind(), R.getRecordData());
return V.visitUnknown(Fragment);
}
}
return Error::success();
}
-ModuleDebugLineFragment::ModuleDebugLineFragment()
- : ModuleDebugFragment(ModuleDebugFragmentKind::Lines) {}
+ModuleDebugLineFragmentRef::ModuleDebugLineFragmentRef()
+ : ModuleDebugFragmentRef(ModuleDebugFragmentKind::Lines) {}
-Error ModuleDebugLineFragment::initialize(BinaryStreamReader Reader) {
+Error ModuleDebugLineFragmentRef::initialize(BinaryStreamReader Reader) {
if (auto EC = Reader.readObject(Header))
return EC;
return Error::success();
}
-bool ModuleDebugLineFragment::hasColumnInfo() const {
- return Header->Flags & LF_HaveColumns;
+bool ModuleDebugLineFragmentRef::hasColumnInfo() const {
+ return !!(Header->Flags & LF_HaveColumns);
}
using namespace llvm::msf;
using namespace llvm::pdb;
-ModuleDebugStream::ModuleDebugStream(const DbiModuleDescriptor &Module,
- std::unique_ptr<MappedBlockStream> Stream)
+ModuleDebugStreamRef::ModuleDebugStreamRef(
+ const DbiModuleDescriptor &Module,
+ std::unique_ptr<MappedBlockStream> Stream)
: Mod(Module), Stream(std::move(Stream)) {}
-ModuleDebugStream::~ModuleDebugStream() = default;
+ModuleDebugStreamRef::~ModuleDebugStreamRef() = default;
-Error ModuleDebugStream::reload() {
+Error ModuleDebugStreamRef::reload() {
BinaryStreamReader Reader(*Stream);
uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
return EC;
- if (auto EC = Reader.readStreamRef(LinesSubstream, C11Size))
+ if (auto EC = Reader.readStreamRef(C11LinesSubstream, C11Size))
return EC;
if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size))
return EC;
}
iterator_range<codeview::CVSymbolArray::Iterator>
-ModuleDebugStream::symbols(bool *HadError) const {
+ModuleDebugStreamRef::symbols(bool *HadError) const {
return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end());
}
-llvm::iterator_range<ModuleDebugStream::LinesAndChecksumsIterator>
-ModuleDebugStream::linesAndChecksums() const {
+llvm::iterator_range<ModuleDebugStreamRef::LinesAndChecksumsIterator>
+ModuleDebugStreamRef::linesAndChecksums() const {
return make_range(LinesAndChecksums.begin(), LinesAndChecksums.end());
}
-bool ModuleDebugStream::hasLineInfo() const {
+bool ModuleDebugStreamRef::hasLineInfo() const {
return C13LinesSubstream.getLength() > 0;
}
-Error ModuleDebugStream::commit() { return Error::success(); }
+Error ModuleDebugStreamRef::commit() { return Error::success(); }
C13DebugFragmentVisitor::~C13DebugFragmentVisitor() {}
Error C13DebugFragmentVisitor::visitUnknown(
- codeview::ModuleDebugUnknownFragment &Fragment) {
+ codeview::ModuleDebugUnknownFragmentRef &Fragment) {
return Error::success();
}
Error C13DebugFragmentVisitor::visitFileChecksums(
- codeview::ModuleDebugFileChecksumFragment &Checksums) {
+ codeview::ModuleDebugFileChecksumFragmentRef &Checksums) {
assert(!this->Checksums.hasValue());
this->Checksums = Checksums;
return Error::success();
}
Error C13DebugFragmentVisitor::visitLines(
- codeview::ModuleDebugLineFragment &Lines) {
+ codeview::ModuleDebugLineFragmentRef &Lines) {
this->Lines.push_back(Lines);
return Error::success();
}
C13DebugFragmentVisitor(PDBFile &F);
~C13DebugFragmentVisitor();
- Error visitUnknown(codeview::ModuleDebugUnknownFragment &Fragment) final;
+ Error visitUnknown(codeview::ModuleDebugUnknownFragmentRef &Fragment) final;
Error visitFileChecksums(
- codeview::ModuleDebugFileChecksumFragment &Checksums) final;
+ codeview::ModuleDebugFileChecksumFragmentRef &Checksums) final;
- Error visitLines(codeview::ModuleDebugLineFragment &Lines) final;
+ Error visitLines(codeview::ModuleDebugLineFragmentRef &Lines) final;
Error finished() final;
Expected<StringRef> getNameFromStringTable(uint32_t Offset);
Expected<StringRef> getNameFromChecksumsBuffer(uint32_t Offset);
- Optional<codeview::ModuleDebugFileChecksumFragment> Checksums;
- std::vector<codeview::ModuleDebugLineFragment> Lines;
+ Optional<codeview::ModuleDebugFileChecksumFragmentRef> Checksums;
+ std::vector<codeview::ModuleDebugLineFragmentRef> Lines;
PDBFile &F;
};
BitVector UseAfterFreePages;
};
-// Define a locally scoped visitor to print the different
-// substream types types.
class C13RawVisitor : public C13DebugFragmentVisitor {
public:
C13RawVisitor(ScopedPrinter &P, PDBFile &F)
File.getMsfLayout(), File.getMsfBuffer(),
Modi.Info.getModuleStreamIndex());
- ModuleDebugStream ModS(Modi.Info, std::move(ModStreamData));
+ ModuleDebugStreamRef ModS(Modi.Info, std::move(ModStreamData));
if (auto EC = ModS.reload())
return EC;
if (opts::raw::DumpLineInfo) {
ListScope SS(P, "LineInfo");
- // Inlinee Line Type Indices refer to the IPI stream.
C13RawVisitor V(P, File);
if (auto EC = codeview::visitModuleDebugFragments(
ModS.linesAndChecksums(), V))
}
Expected<Optional<llvm::pdb::yaml::PdbSourceFileInfo>>
-YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStream &ModS) {
+YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS) {
if (!ModS.hasLineInfo())
return None;
continue;
auto ModStreamData = msf::MappedBlockStream::createIndexedStream(
- File.getMsfLayout(), File.getMsfBuffer(), ModiStream);
+ File.getMsfLayout(), File.getMsfBuffer(),
+ MI.Info.getModuleStreamIndex());
- pdb::ModuleDebugStream ModS(MI.Info, std::move(ModStreamData));
+ pdb::ModuleDebugStreamRef ModS(MI.Info, std::move(ModStreamData));
if (auto EC = ModS.reload())
return EC;
namespace llvm {
namespace pdb {
-class ModuleDebugStream;
+class ModuleDebugStreamRef;
class YAMLOutputStyle : public OutputStyle {
public:
private:
Expected<Optional<llvm::pdb::yaml::PdbSourceFileInfo>>
- getFileLineInfo(const pdb::ModuleDebugStream &ModS);
+ getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS);
Error dumpStringTable();
Error dumpFileHeaders();
consumeError(ModStreamData.takeError());
return 0;
}
- pdb::ModuleDebugStream ModS(Modi.Info, std::move(*ModStreamData));
+ pdb::ModuleDebugStreamRef ModS(Modi.Info, std::move(*ModStreamData));
if (auto E = ModS.reload()) {
consumeError(std::move(E));
return 0;
BinaryByteStream LineTableInfo(FunctionLineTables[Name], support::little);
BinaryStreamReader Reader(LineTableInfo);
- ModuleDebugLineFragment LineInfo;
+ ModuleDebugLineFragmentRef LineInfo;
error(LineInfo.initialize(Reader));
W.printHex("Flags", LineInfo.header()->Flags);
void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
BinaryByteStream S(Subsection, llvm::support::little);
BinaryStreamReader SR(S);
- ModuleDebugFileChecksumFragment Checksums;
+ ModuleDebugFileChecksumFragmentRef Checksums;
error(Checksums.initialize(SR));
for (auto &FC : Checksums) {