Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/tools/llvm-pdbutil/InputFile.cpp
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | if (!ContentsOrErr) { | ||||
consumeError(ContentsOrErr.takeError()); | consumeError(ContentsOrErr.takeError()); | ||||
return false; | return false; | ||||
} | } | ||||
Reader = BinaryStreamReader(*ContentsOrErr, support::little); | Reader = BinaryStreamReader(*ContentsOrErr, support::little); | ||||
uint32_t Magic; | uint32_t Magic; | ||||
if (Reader.bytesRemaining() < sizeof(uint32_t)) | if (Reader.bytesRemaining() < sizeof(uint32_t)) | ||||
return false; | return false; | ||||
cantFail(Reader.readInteger(Magic)); | llvm_cantFail(Reader.readInteger(Magic)); | ||||
if (Magic != COFF::DEBUG_SECTION_MAGIC) | if (Magic != COFF::DEBUG_SECTION_MAGIC) | ||||
return false; | return false; | ||||
return true; | return true; | ||||
} | } | ||||
static inline bool isDebugSSection(object::SectionRef Section, | static inline bool isDebugSSection(object::SectionRef Section, | ||||
DebugSubsectionArray &Subsections) { | DebugSubsectionArray &Subsections) { | ||||
BinaryStreamReader Reader; | BinaryStreamReader Reader; | ||||
if (!isCodeViewDebugSubsection(Section, ".debug$S", Reader)) | if (!isCodeViewDebugSubsection(Section, ".debug$S", Reader)) | ||||
return false; | return false; | ||||
cantFail(Reader.readArray(Subsections, Reader.bytesRemaining())); | llvm_cantFail(Reader.readArray(Subsections, Reader.bytesRemaining())); | ||||
return true; | return true; | ||||
} | } | ||||
static bool isDebugTSection(SectionRef Section, CVTypeArray &Types) { | static bool isDebugTSection(SectionRef Section, CVTypeArray &Types) { | ||||
BinaryStreamReader Reader; | BinaryStreamReader Reader; | ||||
if (!isCodeViewDebugSubsection(Section, ".debug$T", Reader) && | if (!isCodeViewDebugSubsection(Section, ".debug$T", Reader) && | ||||
!isCodeViewDebugSubsection(Section, ".debug$P", Reader)) | !isCodeViewDebugSubsection(Section, ".debug$P", Reader)) | ||||
return false; | return false; | ||||
cantFail(Reader.readArray(Types, Reader.bytesRemaining())); | llvm_cantFail(Reader.readArray(Types, Reader.bytesRemaining())); | ||||
return true; | return true; | ||||
} | } | ||||
static std::string formatChecksumKind(FileChecksumKind Kind) { | static std::string formatChecksumKind(FileChecksumKind Kind) { | ||||
switch (Kind) { | switch (Kind) { | ||||
RETURN_CASE(FileChecksumKind, None, "None"); | RETURN_CASE(FileChecksumKind, None, "None"); | ||||
RETURN_CASE(FileChecksumKind, MD5, "MD5"); | RETURN_CASE(FileChecksumKind, MD5, "MD5"); | ||||
RETURN_CASE(FileChecksumKind, SHA1, "SHA-1"); | RETURN_CASE(FileChecksumKind, SHA1, "SHA-1"); | ||||
▲ Show 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | InputFile::getOrCreateTypeCollection(TypeCollectionKind Kind) { | ||||
if (Kind == kIds) { | if (Kind == kIds) { | ||||
assert(isPdb() && pdb().hasPDBIpiStream()); | assert(isPdb() && pdb().hasPDBIpiStream()); | ||||
} | } | ||||
// If the collection was already initialized, we should have just returned it | // If the collection was already initialized, we should have just returned it | ||||
// in step 1. | // in step 1. | ||||
if (isPdb()) { | if (isPdb()) { | ||||
TypeCollectionPtr &Collection = (Kind == kIds) ? Ids : Types; | TypeCollectionPtr &Collection = (Kind == kIds) ? Ids : Types; | ||||
auto &Stream = cantFail((Kind == kIds) ? pdb().getPDBIpiStream() | auto &Stream = llvm_cantFail((Kind == kIds) ? pdb().getPDBIpiStream() | ||||
: pdb().getPDBTpiStream()); | : pdb().getPDBTpiStream()); | ||||
auto &Array = Stream.typeArray(); | auto &Array = Stream.typeArray(); | ||||
uint32_t Count = Stream.getNumTypeRecords(); | uint32_t Count = Stream.getNumTypeRecords(); | ||||
auto Offsets = Stream.getTypeIndexOffsets(); | auto Offsets = Stream.getTypeIndexOffsets(); | ||||
Collection = | Collection = | ||||
std::make_unique<LazyRandomTypeCollection>(Array, Count, Offsets); | std::make_unique<LazyRandomTypeCollection>(Array, Count, Offsets); | ||||
return *Collection; | return *Collection; | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | while (++Iter != End) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
bool SymbolGroupIterator::isEnd() const { | bool SymbolGroupIterator::isEnd() const { | ||||
if (!Value.File) | if (!Value.File) | ||||
return true; | return true; | ||||
if (Value.File->isPdb()) { | if (Value.File->isPdb()) { | ||||
auto &Dbi = cantFail(Value.File->pdb().getPDBDbiStream()); | auto &Dbi = llvm_cantFail(Value.File->pdb().getPDBDbiStream()); | ||||
uint32_t Count = Dbi.modules().getModuleCount(); | uint32_t Count = Dbi.modules().getModuleCount(); | ||||
assert(Index <= Count); | assert(Index <= Count); | ||||
return Index == Count; | return Index == Count; | ||||
} | } | ||||
assert(SectionIter.hasValue()); | assert(SectionIter.hasValue()); | ||||
return *SectionIter == Value.File->obj().section_end(); | return *SectionIter == Value.File->obj().section_end(); | ||||
} | } |