static void dumpNamedStream(ScopedPrinter &P, PDBFile &File, StringRef Stream) { InfoStream &IS = File.getPDBInfoStream(); uint32_t NameStreamIndex = IS.getNamedStreamIndex(Stream); if (NameStreamIndex != 0) { std::string Name("Stream '"); Name += Stream; Name += "'"; DictScope D(P, Name); P.printNumber("Index", NameStreamIndex); MappedBlockStream NameStream(NameStreamIndex, File); StreamReader Reader(NameStream); NameHashTable NameTable; NameTable.load(Reader); P.printHex("Signature", NameTable.getSignature()); P.printNumber("Version", NameTable.getHashVersion()); P.printNumber("Name Count", NameTable.getNameCount()); ListScope L(P, "Names"); for (uint32_t ID : NameTable.name_ids()) { StringRef Str = NameTable.getStringForID(ID); if (!Str.empty()) P.printString(Str); } } }
void DWARFDebugNames::Abbrev::dump(ScopedPrinter &W) const { DictScope AbbrevScope(W, ("Abbreviation 0x" + Twine::utohexstr(Code)).str()); W.startLine() << formatv("Tag: {0}\n", Tag); for (const auto &Attr : Attributes) W.startLine() << formatv("{0}: {1}\n", Attr.Index, Attr.Form); }
void DWARFDebugNames::Abbrev::dump(ScopedPrinter &W) const { DictScope AbbrevScope(W, ("Abbreviation 0x" + Twine::utohexstr(Code)).str()); W.startLine() << "Tag: " << formatTag(Tag) << '\n'; for (const auto &Attr : Attributes) { W.startLine() << formatIndex(Attr.Index) << ": " << formatForm(Attr.Form) << '\n'; } }
static void dumpInfoStream(ScopedPrinter &P, PDBFile &File) { InfoStream &IS = File.getPDBInfoStream(); DictScope D(P, "PDB Stream"); P.printNumber("Version", IS.getVersion()); P.printHex("Signature", IS.getSignature()); P.printNumber("Age", IS.getAge()); P.printObject("Guid", IS.getGuid()); }
void CVTypeDumper::printTypeIndex(ScopedPrinter &Printer, StringRef FieldName, TypeIndex TI, TypeDatabase &DB) { StringRef TypeName; if (!TI.isNoneType()) TypeName = DB.getTypeName(TI); if (!TypeName.empty()) Printer.printHex(FieldName, TypeName, TI.getIndex()); else Printer.printHex(FieldName, TI.getIndex()); }
void DWARFDebugNames::Entry::dump(ScopedPrinter &W) const { W.printHex("Abbrev", Abbr->Code); W.startLine() << formatv("Tag: {0}\n", Abbr->Tag); assert(Abbr->Attributes.size() == Values.size()); for (const auto &Tuple : zip_first(Abbr->Attributes, Values)) { W.startLine() << formatv("{0}: ", std::get<0>(Tuple).Index); std::get<1>(Tuple).dump(W.getOStream()); W.getOStream() << '\n'; } }
static void dumpTpiHash(ScopedPrinter &P, TpiStream &Tpi) { if (!opts::raw::DumpTpiHash) return; DictScope DD(P, "Hash"); P.printNumber("Number of Hash Buckets", Tpi.NumHashBuckets()); P.printNumber("Hash Key Size", Tpi.getHashKeySize()); P.printList("Values", Tpi.getHashValues()); P.printList("Type Index Offsets", Tpi.getTypeIndexOffsets(), printTypeIndexOffset); P.printList("Hash Adjustments", Tpi.getHashAdjustments(), printTypeIndexOffset); }
void DWARFDebugNames::Header::dump(ScopedPrinter &W) const { DictScope HeaderScope(W, "Header"); W.printHex("Length", UnitLength); W.printNumber("Version", Version); W.printHex("Padding", Padding); W.printNumber("CU count", CompUnitCount); W.printNumber("Local TU count", LocalTypeUnitCount); W.printNumber("Foreign TU count", ForeignTypeUnitCount); W.printNumber("Bucket count", BucketCount); W.printNumber("Name count", NameCount); W.printHex("Abbreviations table size", AbbrevTableSize); W.startLine() << "Augmentation: '" << AugmentationString << "'\n"; }
void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W, const NameTableEntry &NTE, Optional<uint32_t> Hash) const { DictScope NameScope(W, ("Name " + Twine(NTE.getIndex())).str()); if (Hash) W.printHex("Hash", *Hash); W.startLine() << format("String: 0x%08x", NTE.getStringOffset()); W.getOStream() << " \"" << NTE.getString() << "\"\n"; uint32_t EntryOffset = NTE.getEntryOffset(); while (dumpEntry(W, &EntryOffset)) /*empty*/; }
void llvm::codeview::printTypeIndex(ScopedPrinter &Printer, StringRef FieldName, TypeIndex TI, TypeCollection &Types) { StringRef TypeName; if (!TI.isNoneType()) { if (TI.isSimple()) TypeName = TypeIndex::simpleTypeName(TI); else TypeName = Types.getTypeName(TI); } if (!TypeName.empty()) Printer.printHex(FieldName, TypeName, TI.getIndex()); else Printer.printHex(FieldName, TI.getIndex()); }
void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W, uint32_t Index, Optional<uint32_t> Hash) const { const DataExtractor &SS = Section.StringSection; NameTableEntry NTE = getNameTableEntry(Index); DictScope NameScope(W, ("Name " + Twine(Index)).str()); if (Hash) W.printHex("Hash", *Hash); W.startLine() << format("String: 0x%08x", NTE.StringOffset); W.getOStream() << " \"" << SS.getCStr(&NTE.StringOffset) << "\"\n"; while (dumpEntry(W, &NTE.EntryOffset)) /*empty*/; }
void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const { if (Hdr.LocalTypeUnitCount == 0) return; ListScope TUScope(W, "Local Type Unit offsets"); for (uint32_t TU = 0; TU < Hdr.LocalTypeUnitCount; ++TU) W.startLine() << format("LocalTU[%u]: 0x%08x\n", TU, getLocalTUOffset(TU)); }
bool AppleAcceleratorTable::dumpName(ScopedPrinter &W, SmallVectorImpl<DWARFFormValue> &AtomForms, uint32_t *DataOffset) const { DWARFFormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32}; uint32_t NameOffset = *DataOffset; if (!AccelSection.isValidOffsetForDataOfSize(*DataOffset, 4)) { W.printString("Incorrectly terminated list."); return false; } unsigned StringOffset = AccelSection.getRelocatedValue(4, DataOffset); if (!StringOffset) return false; // End of list DictScope NameScope(W, ("Name@0x" + Twine::utohexstr(NameOffset)).str()); W.startLine() << format("String: 0x%08x", StringOffset); W.getOStream() << " \"" << StringSection.getCStr(&StringOffset) << "\"\n"; unsigned NumData = AccelSection.getU32(DataOffset); for (unsigned Data = 0; Data < NumData; ++Data) { ListScope DataScope(W, ("Data " + Twine(Data)).str()); unsigned i = 0; for (auto &Atom : AtomForms) { W.startLine() << format("Atom[%d]: ", i++); if (Atom.extractValue(AccelSection, DataOffset, FormParams)) Atom.dump(W.getOStream()); else W.getOStream() << "Error extracting the value"; W.getOStream() << "\n"; } } return true; // more entries follow }
void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const { if (Hdr.ForeignTypeUnitCount == 0) return; ListScope TUScope(W, "Foreign Type Unit signatures"); for (uint32_t TU = 0; TU < Hdr.ForeignTypeUnitCount; ++TU) { W.startLine() << format("ForeignTU[%u]: 0x%016" PRIx64 "\n", TU, getForeignTUSignature(TU)); } }
static void dumpFileHeaders(ScopedPrinter &P, PDBFile &File) { if (!opts::DumpHeaders) return; DictScope D(P, "FileHeaders"); P.printNumber("BlockSize", File.getBlockSize()); P.printNumber("Unknown0", File.getUnknown0()); P.printNumber("NumBlocks", File.getBlockCount()); P.printNumber("NumDirectoryBytes", File.getNumDirectoryBytes()); P.printNumber("Unknown1", File.getUnknown1()); P.printNumber("BlockMapAddr", File.getBlockMapIndex()); P.printNumber("NumDirectoryBlocks", File.getNumDirectoryBlocks()); P.printNumber("BlockMapOffset", File.getBlockMapOffset()); // The directory is not contiguous. Instead, the block map contains a // contiguous list of block numbers whose contents, when concatenated in // order, make up the directory. P.printList("DirectoryBlocks", File.getDirectoryBlockArray()); P.printNumber("NumStreams", File.getNumStreams()); }
static void dumpTpiStream(ScopedPrinter &P, PDBFile &File) { if (!opts::DumpTypeStream) return; DictScope D(P, "Type Info Stream"); TpiStream &Tpi = File.getPDBTpiStream(); P.printNumber("TPI Version", Tpi.getTpiVersion()); P.printNumber("Record count", Tpi.NumTypeRecords()); if (!opts::DumpTpiRecordBytes) return; ListScope L(P, "Records"); for (auto &Type : Tpi.types()) { DictScope DD(P, ""); P.printHex("Kind", unsigned(Type.Leaf)); P.printBinaryBlock("Bytes", Type.LeafData); } }
void DWARFDebugNames::NameIndex::dumpBucket(ScopedPrinter &W, uint32_t Bucket) const { ListScope BucketScope(W, ("Bucket " + Twine(Bucket)).str()); uint32_t Index = getBucketArrayEntry(Bucket); if (Index == 0) { W.printString("EMPTY"); return; } if (Index > Hdr.NameCount) { W.printString("Name index is invalid"); return; } for (; Index <= Hdr.NameCount; ++Index) { uint32_t Hash = getHashArrayEntry(Index); if (Hash % Hdr.BucketCount != Bucket) break; dumpName(W, Index, Hash); } }
static void dumpStreamSizes(ScopedPrinter &P, PDBFile &File) { if (!opts::DumpStreamSizes) return; ListScope L(P, "StreamSizes"); uint32_t StreamCount = File.getNumStreams(); for (uint32_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) { std::string Name("Stream "); Name += to_string(StreamIdx); P.printNumber(Name, File.getStreamByteSize(StreamIdx)); } }
static void dumpStreamBlocks(ScopedPrinter &P, PDBFile &File) { if (!opts::DumpStreamBlocks) return; ListScope L(P, "StreamBlocks"); uint32_t StreamCount = File.getNumStreams(); for (uint32_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) { std::string Name("Stream "); Name += to_string(StreamIdx); auto StreamBlocks = File.getStreamBlockList(StreamIdx); P.printList(Name, StreamBlocks); } }
// Returns true if we should continue scanning for entries, false if this is the // last (sentinel) entry). In case of a parsing error we also return false, as // it's not possible to recover this entry list (but the other lists may still // parse OK). bool DWARFDebugNames::NameIndex::dumpEntry(ScopedPrinter &W, uint32_t *Offset) const { uint32_t EntryId = *Offset; auto EntryOr = getEntry(Offset); if (!EntryOr) { handleAllErrors(EntryOr.takeError(), [](const SentinelError &) {}, [&W](const ErrorInfoBase &EI) { EI.log(W.startLine()); }); return false; } DictScope EntryScope(W, ("Entry @ 0x" + Twine::utohexstr(EntryId)).str()); EntryOr->dump(W); return true; }
void AppleAcceleratorTable::Header::dump(ScopedPrinter &W) const { DictScope HeaderScope(W, "Header"); W.printHex("Magic", Magic); W.printHex("Version", Version); W.printHex("Hash function", HashFunction); W.printNumber("Bucket count", BucketCount); W.printNumber("Hashes count", HashCount); W.printNumber("HeaderData length", HeaderDataLength); }
LLVM_DUMP_METHOD void DWARFDebugNames::NameIndex::dump(ScopedPrinter &W) const { DictScope UnitScope(W, ("Name Index @ 0x" + Twine::utohexstr(Base)).str()); Hdr.dump(W); dumpCUs(W); dumpLocalTUs(W); dumpForeignTUs(W); dumpAbbreviations(W); if (Hdr.BucketCount > 0) { for (uint32_t Bucket = 0; Bucket < Hdr.BucketCount; ++Bucket) dumpBucket(W, Bucket); return; } W.startLine() << "Hash table not present\n"; for (uint32_t Index = 1; Index <= Hdr.NameCount; ++Index) dumpName(W, Index, None); }
/// Dumps the specified object file. static void dumpObject(const ObjectFile *Obj, ScopedPrinter &Writer) { std::unique_ptr<ObjDumper> Dumper; if (std::error_code EC = createDumper(Obj, Writer, Dumper)) reportError(Obj->getFileName(), EC); if (opts::Output == opts::LLVM) { Writer.startLine() << "\n"; Writer.printString("File", Obj->getFileName()); Writer.printString("Format", Obj->getFileFormatName()); Writer.printString("Arch", Triple::getArchTypeName( (llvm::Triple::ArchType)Obj->getArch())); Writer.printString("AddressSize", formatv("{0}bit", 8 * Obj->getBytesInAddress())); Dumper->printLoadName(); } if (opts::FileHeaders) Dumper->printFileHeaders(); if (opts::SectionHeaders) Dumper->printSectionHeaders(); if (opts::Relocations) Dumper->printRelocations(); if (opts::DynRelocs) Dumper->printDynamicRelocations(); if (opts::Symbols || opts::DynamicSymbols) Dumper->printSymbols(opts::Symbols, opts::DynamicSymbols); if (opts::HashSymbols) Dumper->printHashSymbols(); if (opts::UnwindInfo) Dumper->printUnwindInfo(); if (opts::DynamicTable) Dumper->printDynamicTable(); if (opts::NeededLibraries) Dumper->printNeededLibraries(); if (opts::ProgramHeaders || opts::SectionMapping == cl::BOU_TRUE) Dumper->printProgramHeaders(opts::ProgramHeaders, opts::SectionMapping); if (!opts::StringDump.empty()) llvm::for_each(opts::StringDump, [&Dumper, Obj](StringRef SectionName) { Dumper->printSectionAsString(Obj, SectionName); }); if (!opts::HexDump.empty()) llvm::for_each(opts::HexDump, [&Dumper, Obj](StringRef SectionName) { Dumper->printSectionAsHex(Obj, SectionName); }); if (opts::HashTable) Dumper->printHashTable(); if (opts::GnuHashTable) Dumper->printGnuHashTable(); if (opts::VersionInfo) Dumper->printVersionInfo(); if (Obj->isELF()) { if (opts::ELFLinkerOptions) Dumper->printELFLinkerOptions(); if (Obj->getArch() == llvm::Triple::arm) if (opts::ARMAttributes) Dumper->printAttributes(); if (isMipsArch(Obj->getArch())) { if (opts::MipsPLTGOT) Dumper->printMipsPLTGOT(); if (opts::MipsABIFlags) Dumper->printMipsABIFlags(); if (opts::MipsReginfo) Dumper->printMipsReginfo(); if (opts::MipsOptions) Dumper->printMipsOptions(); } if (opts::SectionGroups) Dumper->printGroupSections(); if (opts::HashHistogram) Dumper->printHashHistogram(); if (opts::CGProfile) Dumper->printCGProfile(); if (opts::Addrsig) Dumper->printAddrsig(); if (opts::Notes) Dumper->printNotes(); } if (Obj->isCOFF()) { if (opts::COFFImports) Dumper->printCOFFImports(); if (opts::COFFExports) Dumper->printCOFFExports(); if (opts::COFFDirectives) Dumper->printCOFFDirectives(); if (opts::COFFBaseRelocs) Dumper->printCOFFBaseReloc(); if (opts::COFFDebugDirectory) Dumper->printCOFFDebugDirectory(); if (opts::COFFResources) Dumper->printCOFFResources(); if (opts::COFFLoadConfig) Dumper->printCOFFLoadConfig(); if (opts::Addrsig) Dumper->printAddrsig(); if (opts::CodeView) Dumper->printCodeViewDebugInfo(); if (opts::CodeViewMergedTypes) Dumper->mergeCodeViewTypes(CVTypes.IDTable, CVTypes.TypeTable, CVTypes.GlobalIDTable, CVTypes.GlobalTypeTable, opts::CodeViewEnableGHash); } if (Obj->isMachO()) { if (opts::MachODataInCode) Dumper->printMachODataInCode(); if (opts::MachOIndirectSymbols) Dumper->printMachOIndirectSymbols(); if (opts::MachOLinkerOptions) Dumper->printMachOLinkerOptions(); if (opts::MachOSegment) Dumper->printMachOSegment(); if (opts::MachOVersionMin) Dumper->printMachOVersionMin(); if (opts::MachODysymtab) Dumper->printMachODysymtab(); } if (opts::PrintStackMap) Dumper->printStackMap(); }
static void dumpDbiStream(ScopedPrinter &P, PDBFile &File) { DbiStream &DS = File.getPDBDbiStream(); DictScope D(P, "DBI Stream"); P.printNumber("Dbi Version", DS.getDbiVersion()); P.printNumber("Age", DS.getAge()); P.printBoolean("Incremental Linking", DS.isIncrementallyLinked()); P.printBoolean("Has CTypes", DS.hasCTypes()); P.printBoolean("Is Stripped", DS.isStripped()); P.printObject("Machine Type", DS.getMachineType()); P.printNumber("Number of Symbols", DS.getNumberOfSymbols()); uint16_t Major = DS.getBuildMajorVersion(); uint16_t Minor = DS.getBuildMinorVersion(); P.printVersion("Toolchain Version", Major, Minor); std::string DllName; raw_string_ostream DllStream(DllName); DllStream << "mspdb" << Major << Minor << ".dll version"; DllStream.flush(); P.printVersion(DllName, Major, Minor, DS.getPdbDllVersion()); ListScope L(P, "Modules"); for (auto &Modi : DS.modules()) { DictScope DD(P); P.printString("Name", Modi.Info.getModuleName()); P.printNumber("Debug Stream Index", Modi.Info.getModuleStreamIndex()); P.printString("Object File Name", Modi.Info.getObjFileName()); P.printNumber("Num Files", Modi.Info.getNumberOfFiles()); P.printNumber("Source File Name Idx", Modi.Info.getSourceFileNameIndex()); P.printNumber("Pdb File Name Idx", Modi.Info.getPdbFilePathNameIndex()); P.printNumber("Line Info Byte Size", Modi.Info.getLineInfoByteSize()); P.printNumber("C13 Line Info Byte Size", Modi.Info.getC13LineInfoByteSize()); P.printNumber("Symbol Byte Size", Modi.Info.getSymbolDebugInfoByteSize()); P.printNumber("Type Server Index", Modi.Info.getTypeServerIndex()); P.printBoolean("Has EC Info", Modi.Info.hasECInfo()); std::string FileListName = to_string(Modi.SourceFiles.size()) + " Contributing Source Files"; ListScope LL(P, FileListName); for (auto File : Modi.SourceFiles) P.printString(File); } }
void DWARFDebugNames::NameIndex::dumpCUs(ScopedPrinter &W) const { ListScope CUScope(W, "Compilation Unit offsets"); for (uint32_t CU = 0; CU < Hdr.CompUnitCount; ++CU) W.startLine() << format("CU[%u]: 0x%08x\n", CU, getCUOffset(CU)); }