diff options
author | Zachary Turner <zturner@google.com> | 2018-07-06 21:01:42 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2018-07-06 21:01:42 +0000 |
commit | c779b36d254d32d46f9fab6ec1ef16c5c58620ec (patch) | |
tree | 849d458d36cd057697d85a86d3e8380e45653c1b /tools/llvm-pdbutil | |
parent | c2801b164018b2c7d2e7a20a617e2953fbbdc07d (diff) |
[PDB] One more fix for hasing GSI records.
The reference implementation uses a case-insensitive string
comparison for strings of equal length. This will cause the
string "tEo" to compare less than "VUo". However we were using
a case sensitive comparison, which would generate the opposite
outcome. Switch to a case insensitive comparison. Also, when
one of the strings contains non-ascii characters, fallback to
a straight memcmp.
The only way to really test this is with a DIA test. Before this
patch, the test will fail (but succeed if link.exe is used instead
of lld-link). After the patch, it succeeds even with lld-link.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-pdbutil')
-rw-r--r-- | tools/llvm-pdbutil/PrettyExternalSymbolDumper.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-pdbutil/llvm-pdbutil.cpp | 88 | ||||
-rw-r--r-- | tools/llvm-pdbutil/llvm-pdbutil.h | 2 |
3 files changed, 91 insertions, 1 deletions
diff --git a/tools/llvm-pdbutil/PrettyExternalSymbolDumper.cpp b/tools/llvm-pdbutil/PrettyExternalSymbolDumper.cpp index 739a95e6342..1270223b1c7 100644 --- a/tools/llvm-pdbutil/PrettyExternalSymbolDumper.cpp +++ b/tools/llvm-pdbutil/PrettyExternalSymbolDumper.cpp @@ -35,7 +35,7 @@ void ExternalSymbolDumper::dump(const PDBSymbolPublicSymbol &Symbol) { Printer.NewLine(); uint64_t Addr = Symbol.getVirtualAddress(); - Printer << "["; + Printer << "public ["; WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Addr, 10); Printer << "] "; WithColor(Printer, PDB_ColorItem::Identifier).get() << LinkageName; diff --git a/tools/llvm-pdbutil/llvm-pdbutil.cpp b/tools/llvm-pdbutil/llvm-pdbutil.cpp index 0088d30babd..5b0d21f83db 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -20,10 +20,13 @@ #include "InputFile.h" #include "LinePrinter.h" #include "OutputStyle.h" +#include "PrettyClassDefinitionDumper.h" #include "PrettyCompilandDumper.h" +#include "PrettyEnumDumper.h" #include "PrettyExternalSymbolDumper.h" #include "PrettyFunctionDumper.h" #include "PrettyTypeDumper.h" +#include "PrettyTypedefDumper.h" #include "PrettyVariableDumper.h" #include "YAMLOutputStyle.h" @@ -65,7 +68,11 @@ #include "llvm/DebugInfo/PDB/PDBSymbolData.h" #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" +#include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" #include "llvm/Support/BinaryByteStream.h" #include "llvm/Support/COM.h" #include "llvm/Support/CommandLine.h" @@ -161,6 +168,11 @@ cl::opt<bool> ShowInjectedSourceContent( cl::desc("When displaying an injected source, display the file content"), cl::cat(OtherOptions), cl::sub(PrettySubcommand)); +cl::list<std::string> WithName( + "with-name", + cl::desc("Display any symbol or type with the specified exact name"), + cl::cat(TypeCategory), cl::ZeroOrMore, cl::sub(PrettySubcommand)); + cl::opt<bool> Compilands("compilands", cl::desc("Display compilands"), cl::cat(TypeCategory), cl::sub(PrettySubcommand)); cl::opt<bool> Symbols("module-syms", @@ -963,6 +975,82 @@ static void dumpPretty(StringRef Path) { outs() << "HasPrivateSymbols "; Printer.Unindent(); + if (!opts::pretty::WithName.empty()) { + Printer.NewLine(); + WithColor(Printer, PDB_ColorItem::SectionHeader).get() + << "---SYMBOLS & TYPES BY NAME---"; + + for (StringRef Name : opts::pretty::WithName) { + auto Symbols = GlobalScope->findChildren( + PDB_SymType::None, Name, PDB_NameSearchFlags::NS_CaseSensitive); + if (!Symbols || Symbols->getChildCount() == 0) { + Printer.formatLine("[not found] - {0}", Name); + continue; + } + Printer.formatLine("[{0} occurrences] - {1}", Symbols->getChildCount(), + Name); + + AutoIndent Indent(Printer); + Printer.NewLine(); + + while (auto Symbol = Symbols->getNext()) { + switch (Symbol->getSymTag()) { + case PDB_SymType::Typedef: { + TypedefDumper TD(Printer); + std::unique_ptr<PDBSymbolTypeTypedef> T = + llvm::unique_dyn_cast<PDBSymbolTypeTypedef>(std::move(Symbol)); + TD.start(*T); + break; + } + case PDB_SymType::Enum: { + EnumDumper ED(Printer); + std::unique_ptr<PDBSymbolTypeEnum> E = + llvm::unique_dyn_cast<PDBSymbolTypeEnum>(std::move(Symbol)); + ED.start(*E); + break; + } + case PDB_SymType::UDT: { + ClassDefinitionDumper CD(Printer); + std::unique_ptr<PDBSymbolTypeUDT> C = + llvm::unique_dyn_cast<PDBSymbolTypeUDT>(std::move(Symbol)); + CD.start(*C); + break; + } + case PDB_SymType::BaseClass: + case PDB_SymType::Friend: { + TypeDumper TD(Printer); + Symbol->dump(TD); + break; + } + case PDB_SymType::Function: { + FunctionDumper FD(Printer); + std::unique_ptr<PDBSymbolFunc> F = + llvm::unique_dyn_cast<PDBSymbolFunc>(std::move(Symbol)); + FD.start(*F, FunctionDumper::PointerType::None); + break; + } + case PDB_SymType::Data: { + VariableDumper VD(Printer); + std::unique_ptr<PDBSymbolData> D = + llvm::unique_dyn_cast<PDBSymbolData>(std::move(Symbol)); + VD.start(*D); + break; + } + case PDB_SymType::PublicSymbol: { + ExternalSymbolDumper ED(Printer); + std::unique_ptr<PDBSymbolPublicSymbol> PS = + llvm::unique_dyn_cast<PDBSymbolPublicSymbol>(std::move(Symbol)); + ED.dump(*PS); + break; + } + default: + llvm_unreachable("Unexpected symbol tag!"); + } + } + } + llvm::outs().flush(); + } + if (opts::pretty::Compilands) { Printer.NewLine(); WithColor(Printer, PDB_ColorItem::SectionHeader).get() diff --git a/tools/llvm-pdbutil/llvm-pdbutil.h b/tools/llvm-pdbutil/llvm-pdbutil.h index 8dad5e87ef2..7496adaeb62 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.h +++ b/tools/llvm-pdbutil/llvm-pdbutil.h @@ -75,6 +75,8 @@ bool compareFunctionSymbols( bool compareDataSymbols(const std::unique_ptr<llvm::pdb::PDBSymbolData> &F1, const std::unique_ptr<llvm::pdb::PDBSymbolData> &F2); +extern llvm::cl::list<std::string> WithName; + extern llvm::cl::opt<bool> Compilands; extern llvm::cl::opt<bool> Symbols; extern llvm::cl::opt<bool> Globals; |