35InputFile::InputFile() =
default;
45 const auto &Modules = Dbi.
modules();
46 if (Index >= Modules.getModuleCount())
48 "Invalid module index");
50 auto Modi = Modules.getModuleDescriptor(Index);
54 uint16_t ModiStream = Modi.getModuleStreamIndex();
57 "Module stream not present");
59 auto ModStreamData = File.createIndexedStream(ModiStream);
64 "Invalid module stream");
66 return std::move(ModS);
75 const auto &Modules = Dbi.
modules();
78 uint16_t ModiStream = Modi.getModuleStreamIndex();
81 "Module stream not present");
83 auto ModStreamData = File.createIndexedStream(ModiStream);
88 "Invalid module stream");
90 return std::move(ModS);
97 if (*NameOrErr != Name)
105 if (!ContentsOrErr) {
149template <
typename...
Args>
162 initializeForPdb(GroupIndex);
166 for (
const auto &S : File->obj().sections()) {
171 if (!SC.hasChecksums() || !SC.hasStrings())
177 if (SC.hasChecksums() && SC.hasStrings())
180 rebuildChecksumMap();
190void SymbolGroup::updatePdbModi(
uint32_t Modi) { initializeForPdb(Modi); }
192void SymbolGroup::initializeForPdb(
uint32_t Modi) {
212 DebugStream = std::make_shared<ModuleDebugStreamRef>(std::move(*MDS));
213 Subsections = DebugStream->getSubsectionsArray();
214 SC.initialize(Subsections);
215 rebuildChecksumMap();
218void SymbolGroup::rebuildChecksumMap() {
219 if (!SC.hasChecksums())
222 for (
const auto &Entry : SC.checksums()) {
223 auto S = SC.strings().getString(
Entry.FileNameOffset);
226 ChecksumsByFile[*S] =
Entry;
231 assert(File && File->isPdb() && DebugStream);
236 return SC.strings().getString(
Offset);
241 if (!SC.hasChecksums()) {
242 return std::move(Name);
245 auto Iter = SC.checksums().getArray().at(
Offset);
246 if (Iter == SC.checksums().getArray().end()) {
247 return std::move(Name);
253 return std::move(Name);
256 return *ExpectedFile;
261 auto FC = ChecksumsByFile.find(File);
262 if (FC == ChecksumsByFile.end()) {
269 toHex(FC->getValue().Checksum), File);
275 if (!SC.hasChecksums()) {
280 auto Iter = SC.checksums().getArray().at(
Offset);
281 if (Iter == SC.checksums().getArray().end()) {
310 formatv(
"Unable to identify file type for file {0}",
Path),
EC);
317 IF.CoffObject = std::move(*BinaryOrErr);
319 return std::move(IF);
323 std::unique_ptr<IPDBSession> Session;
325 return std::move(Err);
327 IF.PdbSession.reset(
static_cast<NativeSession *
>(Session.release()));
328 IF.PdbOrObj = &IF.PdbSession->getPDBFile();
330 return std::move(IF);
333 if (!AllowUnknownFile)
335 formatv(
"File {0} is not a supported file type",
Path),
342 formatv(
"File {0} could not be opened",
Path), Result.getError());
344 IF.UnknownFile = std::move(*Result);
345 IF.PdbOrObj = IF.UnknownFile.get();
346 return std::move(IF);
415InputFile::getOrCreateTypeCollection(TypeCollectionKind
Kind) {
416 if (Types &&
Kind == kTypes)
418 if (Ids &&
Kind == kIds)
428 TypeCollectionPtr &Collection = (
Kind == kIds) ? Ids : Types;
430 :
pdb().getPDBTpiStream());
432 auto &Array = Stream.typeArray();
434 auto Offsets = Stream.getTypeIndexOffsets();
436 std::make_unique<LazyRandomTypeCollection>(Array,
Count, Offsets);
449 Types = std::make_unique<LazyRandomTypeCollection>(Records, 100);
453 Types = std::make_unique<LazyRandomTypeCollection>(100);
458 return getOrCreateTypeCollection(kTypes);
465 if (
isObj() || !
pdb().hasPDBIpiStream())
468 return getOrCreateTypeCollection(kIds);
488 SectionIter = File.obj().section_begin();
499 if (Value.File != R.Value.File)
501 return Index == R.Index;
514 assert(Value.File && !isEnd());
519 if (Value.File->isPdb()) {
520 Value.updatePdbModi(Index);
528void SymbolGroupIterator::scanToNextDebugS() {
530 auto End =
Value.File->obj().section_end();
531 auto &Iter = *SectionIter;
534 while (++Iter != End) {
540 Value.updateDebugS(SS);
545bool SymbolGroupIterator::isEnd()
const {
548 if (
Value.File->isPdb()) {
552 return Index ==
Count;
556 return *SectionIter == Value.File->obj().section_end();
564 if (Name.starts_with(
"Import:"))
566 if (Name.ends_with_insensitive(
".dll"))
568 if (Name.equals_insensitive(
"* linker *"))
570 if (Name.starts_with_insensitive(
"f:\\binaries\\Intermediate\\vctools"))
572 if (Name.starts_with_insensitive(
"f:\\dd\\vctools\\crt"))
593llvm::pdb::InputFile::InputFile(
MemoryBuffer *Buffer) { PdbOrObj = Buffer; }
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
bbsections Prepares for basic block sections
dxil pretty DXIL Metadata Pretty Printer
Provides read only access to a subclass of BinaryStream.
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
uint64_t bytesRemaining() const
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
A class that wrap the SHA1 algorithm.
StringRef - Represent a constant reference to a string, i.e.
A table of densely packed, null-terminated strings indexed by offset.
LLVM Value Representation.
Provides amortized O(1) random access to a CodeView type stream.
LLVM_ABI void setStrings(const DebugStringTableSubsectionRef &Strings)
A range adaptor for a pair of iterators.
StringRef getFileName() const
This is a value type class that represents a single section in the list of sections in the object fil...
LLVM_ABI DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const
LLVM_ABI uint32_t getModuleCount() const
LLVM_ABI const DbiModuleList & modules() const
bool hasPDBTpiStream() const
bool hasPDBIpiStream() const
StringRef getFilePath() const
Expected< PDBStringTable & > getStringTable()
LLVM_ABI SymbolGroupIterator & operator++()
LLVM_ABI const SymbolGroup & operator*() const
LLVM_ABI SymbolGroupIterator()
LLVM_ABI bool operator==(const SymbolGroupIterator &R) const
LLVM_ABI Expected< StringRef > getNameFromChecksums(uint32_t Offset) const
LLVM_ABI Expected< StringRef > getNameFromStringTable(uint32_t Offset) const
LLVM_ABI SymbolGroup(InputFile *File, uint32_t GroupIndex=0)
LLVM_ABI void formatFromFileName(LinePrinter &Printer, StringRef File, bool Append=false) const
LLVM_ABI const ModuleDebugStreamRef & getPdbModuleStream() const
LLVM_ABI void formatFromChecksumsOffset(LinePrinter &Printer, uint32_t Offset, bool Append=false) const
LLVM_ABI StringRef name() const
const InputFile & getFile() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
VarStreamArray< CVType > CVTypeArray
VarStreamArray< DebugSubsectionRecord > DebugSubsectionArray
LLVM_ABI Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
LLVM_ABI bool shouldDumpSymbolGroup(uint32_t Idx, const SymbolGroup &Group, const FilterOptions &Filters)
const uint16_t kInvalidStreamIndex
std::string formatUnknownEnum(T Value)
LLVM_ABI Expected< ModuleDebugStreamRef > getModuleDebugStream(PDBFile &File, StringRef &ModuleName, uint32_t Index)
LLVM_ABI Error loadDataForPDB(PDB_ReaderType Type, StringRef Path, std::unique_ptr< IPDBSession > &Session)
LLVM_ABI bool exists(const basic_file_status &status)
Does file exist?
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
FunctionAddr VTableAddr Count
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
void toHex(ArrayRef< uint8_t > Input, bool LowerCase, SmallVectorImpl< char > &Output)
Convert buffer Input to its hexadecimal representation. The returned string is double the size of Inp...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
void consumeError(Error Err)
Consume a Error without doing anything.
std::optional< uint32_t > DumpModi
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
@ pdb
Windows PDB debug info file.
@ coff_object
COFF object file.