Go to the documentation of this file.
34 InputFile::InputFile() =
default;
35 InputFile::~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");
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");
96 if (*NameOrErr !=
Name)
104 if (!ContentsOrErr) {
148 template <
typename...
Args>
151 Printer.format(std::forward<Args>(args)...);
153 Printer.formatLine(std::forward<Args>(args)...);
161 initializeForPdb(GroupIndex);
165 for (
const auto &
S : File->obj().sections()) {
179 rebuildChecksumMap();
189 void SymbolGroup::updatePdbModi(
uint32_t Modi) { initializeForPdb(Modi); }
191 void SymbolGroup::initializeForPdb(
uint32_t Modi) {
211 DebugStream = std::make_shared<ModuleDebugStreamRef>(
std::move(*MDS));
212 Subsections = DebugStream->getSubsectionsArray();
214 rebuildChecksumMap();
217 void SymbolGroup::rebuildChecksumMap() {
221 for (
const auto &Entry : SC.
checksums()) {
225 ChecksumsByFile[*
S] = Entry;
255 return *ExpectedFile;
260 auto FC = ChecksumsByFile.find(File);
261 if (
FC == ChecksumsByFile.end()) {
268 toHex(
FC->getValue().Checksum), File);
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);
317 IF.PdbOrObj = llvm::cast<COFFObjectFile>(
IF.CoffObject.getBinary());
322 std::unique_ptr<IPDBSession> Session;
327 IF.PdbOrObj = &
IF.PdbSession->getPDBFile();
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());
344 IF.PdbOrObj =
IF.UnknownFile.get();
350 return *PdbOrObj.get<
PDBFile *>();
355 return *PdbOrObj.get<
PDBFile *>();
391 for (
const auto &Section :
obj().sections()) {
414 InputFile::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()) {
527 void SymbolGroupIterator::scanToNextDebugS() {
529 auto End =
Value.File->obj().section_end();
530 auto &Iter = *SectionIter;
533 while (++Iter != End) {
544 bool 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.endswith_insensitive(
".dll"))
567 if (
Name.equals_insensitive(
"* linker *"))
569 if (
Name.startswith_insensitive(
"f:\\binaries\\Intermediate\\vctools"))
571 if (
Name.startswith_insensitive(
"f:\\dd\\vctools\\crt"))
uint32_t getModuleCount() const
bool hasPDBIpiStream() const
llvm::Optional< uint32_t > DumpModi
This is an optimization pass for GlobalISel generic memory operations.
void initialize(T &&FragmentRange)
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.
const SymbolGroup & operator*() const
StringRef getFilePath() const
Expected< StringRef > getNameFromStringTable(uint32_t Offset) const
void formatFromFileName(LinePrinter &Printer, StringRef File, bool Append=false) const
bool operator==(const SymbolGroupIterator &R) const
const uint16_t kInvalidStreamIndex
uint64_t bytesRemaining() const
Tagged union holding either a T or a Error.
Expected< StringRef > getNameFromChecksums(uint32_t Offset) const
void consumeError(Error Err)
Consume a Error without doing anything.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
SymbolGroupIterator & operator++()
print alias Alias Set Printer
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
bool hasPDBTpiStream() const
bool hasChecksums() const
A class that wrap the SHA1 algorithm.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Provides amortized O(1) random access to a CodeView type stream.
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
Provides read only access to a subclass of BinaryStream.
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
This is a value type class that represents a single section in the list of sections in the object fil...
Expected< ModuleDebugStreamRef > getModuleDebugStream(PDBFile &File, StringRef &ModuleName, uint32_t Index)
bool exists(const basic_file_status &status)
Does file exist?
const DebugChecksumsSubsectionRef & checksums() const
const ModuleDebugStreamRef & getPdbModuleStream() const
static std::string toHex(uint64_t V)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
@ coff_object
COFF object file.
Error loadDataForPDB(PDB_ReaderType Type, StringRef Path, std::unique_ptr< IPDBSession > &Session)
void formatFromChecksumsOffset(LinePrinter &Printer, uint32_t Offset, bool Append=false) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
static const char Magic[]
Expected< PDBStringTable & > getStringTable()
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void setStrings(const DebugStringTableSubsectionRef &Strings)
Lightweight error class with error context and mandatory checking.
bool shouldDumpSymbolGroup(uint32_t Idx, const SymbolGroup &Group, const FilterOptions &Filters)
std::string formatUnknownEnum(T Value)
Error takeError()
Take ownership of the stored error.
Expected< StringRef > getString(uint32_t Offset) const
const DebugStringTableSubsectionRef & strings() const
StringRef getFileName() const
DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const
A range adaptor for a pair of iterators.
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
Iterator at(uint32_t Offset) const
given an offset into the array's underlying stream, return an iterator to the record at that offset.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
const InputFile & getFile() const
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
const FileChecksumArray & getArray() const
LLVM Value Representation.
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 ...
const DbiModuleList & modules() const