diff options
Diffstat (limited to 'llvm/tools/llvm-pdbutil')
| -rw-r--r-- | llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp | 2 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/DumpOutputStyle.h | 2 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/OutputStyle.h | 2 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/PdbYaml.cpp | 45 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/PdbYaml.h | 21 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/PrettyClassDefinitionDumper.h | 2 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/PrettyCompilandDumper.cpp | 2 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/StreamUtil.h | 2 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp | 18 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp | 22 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/llvm-pdbutil.h | 1 |
11 files changed, 111 insertions, 8 deletions
diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp index b2362ec..d836d98 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -68,7 +68,7 @@ DumpOutputStyle::DumpOutputStyle(InputFile &File) RefTracker.reset(new TypeReferenceTracker(File)); } -DumpOutputStyle::~DumpOutputStyle() {} +DumpOutputStyle::~DumpOutputStyle() = default; PDBFile &DumpOutputStyle::getPdb() { return File.pdb(); } object::COFFObjectFile &DumpOutputStyle::getObj() { return File.obj(); } diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.h b/llvm/tools/llvm-pdbutil/DumpOutputStyle.h index 6714a6a..ea4a47f 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.h +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.h @@ -29,7 +29,7 @@ class TypeReferenceTracker; struct StatCollection { struct Stat { - Stat() {} + Stat() = default; Stat(uint32_t Count, uint32_t Size) : Count(Count), Size(Size) {} uint32_t Count = 0; uint32_t Size = 0; diff --git a/llvm/tools/llvm-pdbutil/OutputStyle.h b/llvm/tools/llvm-pdbutil/OutputStyle.h index 8cc9016..a09fb82 100644 --- a/llvm/tools/llvm-pdbutil/OutputStyle.h +++ b/llvm/tools/llvm-pdbutil/OutputStyle.h @@ -17,7 +17,7 @@ namespace pdb { class OutputStyle { public: - virtual ~OutputStyle() {} + virtual ~OutputStyle() = default; virtual Error dump() = 0; }; diff --git a/llvm/tools/llvm-pdbutil/PdbYaml.cpp b/llvm/tools/llvm-pdbutil/PdbYaml.cpp index fac1d89..4131292 100644 --- a/llvm/tools/llvm-pdbutil/PdbYaml.cpp +++ b/llvm/tools/llvm-pdbutil/PdbYaml.cpp @@ -22,6 +22,7 @@ using namespace llvm::pdb; using namespace llvm::pdb::yaml; using namespace llvm::yaml; +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::CoffSectionHeader) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::NamedStreamMapping) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbDbiModuleInfo) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::StreamBlockList) @@ -135,6 +136,49 @@ void MappingTraits<msf::SuperBlock>::mapping(IO &IO, msf::SuperBlock &SB) { IO.mapOptional("BlockMapAddr", SB.BlockMapAddr, u32(0U)); } +CoffSectionHeader::CoffSectionHeader() = default; + +CoffSectionHeader::CoffSectionHeader(const object::coff_section &Section) + : Name(Section.Name), VirtualSize(Section.VirtualSize), + VirtualAddress(Section.VirtualAddress), + SizeOfRawData(Section.SizeOfRawData), + PointerToRawData(Section.PointerToRawData), + PointerToRelocations(Section.PointerToRelocations), + PointerToLinenumbers(Section.PointerToLinenumbers), + NumberOfRelocations(Section.NumberOfRelocations), + NumberOfLinenumbers(Section.NumberOfLinenumbers), + Characteristics(Section.Characteristics) {} + +object::coff_section CoffSectionHeader::toCoffSection() const { + object::coff_section Sec; + std::memset(Sec.Name, 0, COFF::NameSize); + std::memcpy(Sec.Name, Name.data(), + std::min(static_cast<size_t>(COFF::NameSize), Name.size())); + Sec.VirtualSize = VirtualSize; + Sec.VirtualAddress = VirtualAddress; + Sec.SizeOfRawData = SizeOfRawData; + Sec.PointerToRawData = PointerToRawData; + Sec.PointerToRelocations = PointerToRelocations; + Sec.PointerToLinenumbers = PointerToLinenumbers; + Sec.NumberOfRelocations = NumberOfRelocations; + Sec.NumberOfLinenumbers = NumberOfLinenumbers; + Sec.Characteristics = Characteristics; + return Sec; +} + +void MappingTraits<CoffSectionHeader>::mapping(IO &IO, CoffSectionHeader &Obj) { + IO.mapRequired("Name", Obj.Name); + IO.mapOptional("VirtualSize", Obj.VirtualSize); + IO.mapOptional("VirtualAddress", Obj.VirtualAddress); + IO.mapOptional("SizeOfRawData", Obj.SizeOfRawData); + IO.mapOptional("PointerToRawData", Obj.PointerToRawData); + IO.mapOptional("PointerToRelocations", Obj.PointerToRelocations); + IO.mapOptional("PointerToLinenumbers", Obj.PointerToLinenumbers); + IO.mapOptional("NumberOfRelocations", Obj.NumberOfRelocations); + IO.mapOptional("NumberOfLinenumbers", Obj.NumberOfLinenumbers); + IO.mapOptional("Characteristics", Obj.Characteristics); +} + void MappingTraits<StreamBlockList>::mapping(IO &IO, StreamBlockList &SB) { IO.mapRequired("Stream", SB.Blocks); } @@ -163,6 +207,7 @@ void MappingTraits<PdbDbiStream>::mapping(IO &IO, PdbDbiStream &Obj) { IO.setContext(&Obj.FakeHeader); } IO.mapOptional("Modules", Obj.ModInfos); + IO.mapOptional("SectionHeaders", Obj.SectionHeaders); } void MappingTraits<PdbTpiStream>::mapping(IO &IO, diff --git a/llvm/tools/llvm-pdbutil/PdbYaml.h b/llvm/tools/llvm-pdbutil/PdbYaml.h index d5111a9e..8746675 100644 --- a/llvm/tools/llvm-pdbutil/PdbYaml.h +++ b/llvm/tools/llvm-pdbutil/PdbYaml.h @@ -18,6 +18,7 @@ #include "llvm/DebugInfo/PDB/Native/PDBFile.h" #include "llvm/DebugInfo/PDB/Native/RawConstants.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Object/COFF.h" #include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h" #include "llvm/ObjectYAML/CodeViewYAMLSymbols.h" #include "llvm/ObjectYAML/CodeViewYAMLTypes.h" @@ -40,6 +41,24 @@ struct MSFHeaders { uint64_t FileSize = 0; }; +struct CoffSectionHeader { + CoffSectionHeader(); + CoffSectionHeader(const object::coff_section &Section); + + object::coff_section toCoffSection() const; + + StringRef Name; + uint32_t VirtualSize = 0; + uint32_t VirtualAddress = 0; + uint32_t SizeOfRawData = 0; + uint32_t PointerToRawData = 0; + uint32_t PointerToRelocations = 0; + uint32_t PointerToLinenumbers = 0; + uint16_t NumberOfRelocations = 0; + uint16_t NumberOfLinenumbers = 0; + uint32_t Characteristics = 0; +}; + struct StreamBlockList { std::vector<uint32_t> Blocks; }; @@ -82,6 +101,7 @@ struct PdbDbiStream { std::vector<PdbDbiModuleInfo> ModInfos; COFF::header FakeHeader; + std::vector<CoffSectionHeader> SectionHeaders; }; struct PdbTpiStream { @@ -113,6 +133,7 @@ struct PdbObject { } } +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::CoffSectionHeader) LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbObject) LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::MSFHeaders) LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(msf::SuperBlock) diff --git a/llvm/tools/llvm-pdbutil/PrettyClassDefinitionDumper.h b/llvm/tools/llvm-pdbutil/PrettyClassDefinitionDumper.h index 50c8f5d..9e492a4 100644 --- a/llvm/tools/llvm-pdbutil/PrettyClassDefinitionDumper.h +++ b/llvm/tools/llvm-pdbutil/PrettyClassDefinitionDumper.h @@ -15,8 +15,6 @@ #include "llvm/DebugInfo/PDB/PDBSymbolData.h" #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" -#include <memory> - namespace llvm { class BitVector; diff --git a/llvm/tools/llvm-pdbutil/PrettyCompilandDumper.cpp b/llvm/tools/llvm-pdbutil/PrettyCompilandDumper.cpp index b347cfd..902a1d7 100644 --- a/llvm/tools/llvm-pdbutil/PrettyCompilandDumper.cpp +++ b/llvm/tools/llvm-pdbutil/PrettyCompilandDumper.cpp @@ -32,8 +32,6 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" -#include <utility> - using namespace llvm; using namespace llvm::pdb; diff --git a/llvm/tools/llvm-pdbutil/StreamUtil.h b/llvm/tools/llvm-pdbutil/StreamUtil.h index 9d6030c..6b8c13f 100644 --- a/llvm/tools/llvm-pdbutil/StreamUtil.h +++ b/llvm/tools/llvm-pdbutil/StreamUtil.h @@ -35,7 +35,7 @@ enum class StreamPurpose { struct StreamInfo { public: - StreamInfo() {} + StreamInfo() = default; uint32_t getModuleIndex() const { return *ModuleIndex; } StreamPurpose getPurpose() const { return Purpose; } diff --git a/llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp b/llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp index ecb4c21..8fe7f60 100644 --- a/llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp @@ -285,6 +285,24 @@ Error YAMLOutputStyle::dumpDbiStream() { } } } + + if (opts::pdb2yaml::DumpSectionHeaders) { + for (const auto &Section : DS.getSectionHeaders()) { + yaml::CoffSectionHeader Hdr; + Hdr.Name = Section.Name; + Hdr.VirtualSize = Section.VirtualSize; + Hdr.VirtualAddress = Section.VirtualAddress; + Hdr.SizeOfRawData = Section.SizeOfRawData; + Hdr.PointerToRawData = Section.PointerToRawData; + Hdr.PointerToRelocations = Section.PointerToRelocations; + Hdr.PointerToLinenumbers = Section.PointerToLinenumbers; + Hdr.NumberOfRelocations = Section.NumberOfRelocations; + Hdr.NumberOfLinenumbers = Section.NumberOfLinenumbers; + Hdr.Characteristics = Section.Characteristics; + Obj.DbiStream->SectionHeaders.emplace_back(Hdr); + } + } + return Error::success(); } diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp index a5b8e8b..befd331 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -716,6 +716,10 @@ cl::list<ModuleSubsection> DumpModuleSubsections( cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"), cl::cat(FileOptions), cl::sub(PdbToYamlSubcommand)); +cl::opt<bool> DumpSectionHeaders("section-headers", + cl::desc("Dump section headers."), + cl::cat(FileOptions), + cl::sub(PdbToYamlSubcommand)); cl::list<std::string> InputFilename(cl::Positional, cl::desc("<input PDB file>"), cl::Required, @@ -865,6 +869,20 @@ static void yamlToPdb(StringRef Path) { } } + std::vector<object::coff_section> Sections; + if (!Dbi.SectionHeaders.empty()) { + for (const auto &Hdr : Dbi.SectionHeaders) + Sections.emplace_back(Hdr.toCoffSection()); + + DbiBuilder.createSectionMap(Sections); + ExitOnErr(DbiBuilder.addDbgStream( + pdb::DbgHeaderType::SectionHdr, + // FIXME: Downcasting to an ArrayRef<uint8_t> should use a helper + // function in LLVM + ArrayRef<uint8_t>{(const uint8_t *)Sections.data(), + Sections.size() * sizeof(object::coff_section)})); + } + auto &TpiBuilder = Builder.getTpiBuilder(); const auto &Tpi = YamlObj.TpiStream.value_or(DefaultTpiStream); TpiBuilder.setVersionHeader(Tpi.Version); @@ -1541,6 +1559,7 @@ int main(int Argc, const char **Argv) { opts::pdb2yaml::DumpModules = true; opts::pdb2yaml::DumpModuleFiles = true; opts::pdb2yaml::DumpModuleSyms = true; + opts::pdb2yaml::DumpSectionHeaders = true; opts::pdb2yaml::DumpModuleSubsections.push_back( opts::ModuleSubsection::All); } @@ -1551,6 +1570,9 @@ int main(int Argc, const char **Argv) { if (opts::pdb2yaml::DumpModules) opts::pdb2yaml::DbiStream = true; + + if (opts::pdb2yaml::DumpSectionHeaders) + opts::pdb2yaml::DbiStream = true; } llvm::sys::InitializeCOMRAII COM(llvm::sys::COMThreadingMode::MultiThreaded); diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h index b8c8033..73ff2fe 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h @@ -201,6 +201,7 @@ extern llvm::cl::opt<bool> DumpModules; extern llvm::cl::opt<bool> DumpModuleFiles; extern llvm::cl::list<ModuleSubsection> DumpModuleSubsections; extern llvm::cl::opt<bool> DumpModuleSyms; +extern llvm::cl::opt<bool> DumpSectionHeaders; } // namespace pdb2yaml namespace explain { |
