34InputFile::InputFile() =
default;
44 const auto &Modules = Dbi.
modules();
45 if (
Index >= Modules.getModuleCount())
46 return make_error<RawError>(raw_error_code::index_out_of_bounds,
47 "Invalid module index");
49 auto Modi = Modules.getModuleDescriptor(
Index);
53 uint16_t ModiStream = Modi.getModuleStreamIndex();
55 return make_error<RawError>(raw_error_code::no_stream,
56 "Module stream not present");
58 auto ModStreamData = File.createIndexedStream(ModiStream);
62 return make_error<RawError>(raw_error_code::corrupt_file,
63 "Invalid module stream");
65 return std::move(ModS);
74 const auto &Modules = Dbi.
modules();
77 uint16_t ModiStream = Modi.getModuleStreamIndex();
79 return make_error<RawError>(raw_error_code::no_stream,
80 "Module stream not present");
82 auto ModStreamData = File.createIndexedStream(ModiStream);
86 return make_error<RawError>(raw_error_code::corrupt_file,
87 "Invalid module stream");
89 return std::move(ModS);
96 if (*NameOrErr !=
Name)
104 if (!ContentsOrErr) {
148template <
typename...
Args>
161 initializeForPdb(GroupIndex);
165 for (
const auto &S : File->obj().sections()) {
179 rebuildChecksumMap();
189void SymbolGroup::updatePdbModi(
uint32_t Modi) { initializeForPdb(Modi); }
191void SymbolGroup::initializeForPdb(
uint32_t Modi) {
211 DebugStream = std::make_shared<ModuleDebugStreamRef>(std::move(*MDS));
212 Subsections = DebugStream->getSubsectionsArray();
214 rebuildChecksumMap();
217void SymbolGroup::rebuildChecksumMap() {
221 for (
const auto &Entry : SC.
checksums()) {
225 ChecksumsByFile[*S] = Entry;
241 return std::move(Name);
246 return std::move(Name);
252 return std::move(Name);
255 return *ExpectedFile;
260 auto FC = ChecksumsByFile.find(File);
261 if (FC == ChecksumsByFile.end()) {
268 toHex(FC->getValue().Checksum), File);
292 if (Iter->Kind == FileChecksumKind::None) {
303 return make_error<StringError>(
formatv(
"File {0} not found",
Path),
308 return make_error<StringError>(
309 formatv(
"Unable to identify file type for file {0}",
Path),
EC);
316 IF.CoffObject = std::move(*BinaryOrErr);
317 IF.PdbOrObj = llvm::cast<COFFObjectFile>(IF.CoffObject.getBinary());
318 return std::move(IF);
322 std::unique_ptr<IPDBSession> Session;
324 return std::move(Err);
326 IF.PdbSession.reset(
static_cast<NativeSession *
>(Session.release()));
327 IF.PdbOrObj = &IF.PdbSession->getPDBFile();
329 return std::move(IF);
332 if (!AllowUnknownFile)
333 return make_error<StringError>(
334 formatv(
"File {0} is not a supported file type",
Path),
340 return make_error<StringError>(
341 formatv(
"File {0} could not be opened",
Path), Result.getError());
343 IF.UnknownFile = std::move(*Result);
344 IF.PdbOrObj = IF.UnknownFile.get();
345 return std::move(IF);
350 return *cast<PDBFile *>(PdbOrObj);
355 return *cast<PDBFile *>(PdbOrObj);
360 return *cast<object::COFFObjectFile *>(PdbOrObj);
365 return *cast<object::COFFObjectFile *>(PdbOrObj);
370 return *cast<MemoryBuffer *>(PdbOrObj);
375 return *cast<MemoryBuffer *>(PdbOrObj);
391 for (
const auto &Section :
obj().sections()) {
408 return isa<object::COFFObjectFile *>(PdbOrObj);
414InputFile::getOrCreateTypeCollection(TypeCollectionKind
Kind) {
415 if (Types &&
Kind == kTypes)
417 if (Ids &&
Kind == kIds)
427 TypeCollectionPtr &Collection = (
Kind == kIds) ? Ids : Types;
429 :
pdb().getPDBTpiStream());
431 auto &Array = Stream.typeArray();
432 uint32_t Count = Stream.getNumTypeRecords();
433 auto Offsets = Stream.getTypeIndexOffsets();
435 std::make_unique<LazyRandomTypeCollection>(Array, Count, Offsets);
443 for (
const auto &Section :
obj().sections()) {
448 Types = std::make_unique<LazyRandomTypeCollection>(Records, 100);
452 Types = std::make_unique<LazyRandomTypeCollection>(100);
457 return getOrCreateTypeCollection(kTypes);
464 if (
isObj() || !
pdb().hasPDBIpiStream())
467 return getOrCreateTypeCollection(kIds);
487 SectionIter = File.obj().section_begin();
498 if (
Value.File != R.Value.File)
500 return Index == R.Index;
518 if (
Value.File->isPdb()) {
527void SymbolGroupIterator::scanToNextDebugS() {
529 auto End =
Value.File->obj().section_end();
530 auto &Iter = *SectionIter;
533 while (++Iter !=
End) {
539 Value.updateDebugS(SS);
544bool SymbolGroupIterator::isEnd()
const {
547 if (
Value.File->isPdb()) {
551 return Index == Count;
555 return *SectionIter ==
Value.File->obj().section_end();
563 if (
Name.startswith(
"Import:"))
565 if (
Name.ends_with_insensitive(
".dll"))
567 if (
Name.equals_insensitive(
"* linker *"))
569 if (
Name.starts_with_insensitive(
"f:\\binaries\\Intermediate\\vctools"))
571 if (
Name.starts_with_insensitive(
"f:\\dd\\vctools\\crt"))
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Memory true print Memory SSA Printer
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
LLVM Value Representation.
Iterator at(uint32_t Offset) const
given an offset into the array's underlying stream, return an iterator to the record at that offset.
const FileChecksumArray & getArray() const
Expected< StringRef > getString(uint32_t Offset) const
Provides amortized O(1) random access to a CodeView type stream.
void setStrings(const DebugStringTableSubsectionRef &Strings)
const DebugStringTableSubsectionRef & strings() const
bool hasChecksums() const
void initialize(T &&FragmentRange)
const DebugChecksumsSubsectionRef & checksums() const
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...
DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const
uint32_t getModuleCount() const
const DbiModuleList & modules() const
bool hasPDBTpiStream() const
bool hasPDBIpiStream() const
StringRef getFilePath() const
Expected< PDBStringTable & > getStringTable()
SymbolGroupIterator & operator++()
const SymbolGroup & operator*() const
bool operator==(const SymbolGroupIterator &R) const
Expected< StringRef > getNameFromChecksums(uint32_t Offset) const
Expected< StringRef > getNameFromStringTable(uint32_t Offset) const
SymbolGroup(InputFile *File, uint32_t GroupIndex=0)
void formatFromFileName(LinePrinter &Printer, StringRef File, bool Append=false) const
const ModuleDebugStreamRef & getPdbModuleStream() const
void formatFromChecksumsOffset(LinePrinter &Printer, uint32_t Offset, bool Append=false) const
const InputFile & getFile() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
bool shouldDumpSymbolGroup(uint32_t Idx, const SymbolGroup &Group, const FilterOptions &Filters)
const uint16_t kInvalidStreamIndex
std::string formatUnknownEnum(T Value)
Expected< ModuleDebugStreamRef > getModuleDebugStream(PDBFile &File, StringRef &ModuleName, uint32_t Index)
Error loadDataForPDB(PDB_ReaderType Type, StringRef Path, std::unique_ptr< IPDBSession > &Session)
bool exists(const basic_file_status &status)
Does file exist?
This is an optimization pass for GlobalISel generic memory operations.
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
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.