From fc4ecedb754b67e00b31b0ff8be2e450e2505467 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Sun, 22 Feb 2015 21:45:38 +0000 Subject: [PATCH] [llvm-pdbdump] Simplify options and output. This removes a wealth of options, and instead now only provides three options. -symbols, -types, and -compilands. This greatly simplifies use of the tool, and makes it easier to understand what you're going to see when you run the tool. llvm-svn: 230182 --- llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp | 1 + llvm/test/DebugInfo/PDB/pdbdump-flags.test | 46 ++++++++---- llvm/test/DebugInfo/PDB/pdbdump-symbol-format.test | 39 ++++++---- llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | 86 ++++------------------ 4 files changed, 74 insertions(+), 98 deletions(-) diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp index 5d3da21..efd28bc 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp @@ -53,6 +53,7 @@ void PDBSymbolExe::dump(raw_ostream &OS, int Indent, OS << "\n"; if (Flags & PDB_DF_Children) { + OS << stream_indent(Indent + 2) << "Dumping types\n"; if (Flags & PDB_DF_Hidden) { // For some reason, for each SymTag T, this dumps more items of type T // than are dumped by calling dumpChildren(T). In other words, there are diff --git a/llvm/test/DebugInfo/PDB/pdbdump-flags.test b/llvm/test/DebugInfo/PDB/pdbdump-flags.test index fd14e8a..d8d38cb 100644 --- a/llvm/test/DebugInfo/PDB/pdbdump-flags.test +++ b/llvm/test/DebugInfo/PDB/pdbdump-flags.test @@ -1,14 +1,32 @@ -; RUN: llvm-pdbdump %p/Inputs/empty.pdb | FileCheck %s -check-prefix SUMMARY_CHECK -; RUN: llvm-pdbdump -functions %p/Inputs/empty.pdb | FileCheck %s -check-prefix MAIN_CHECK - -; Check PDB file summary information -; SUMMARY_CHECK: empty.pdb -; SUMMARY_CHECK: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0} -; SUMMARY_CHECK: Attributes: HasPrivateSymbols - -; Check that running with only -compilands doesn't include unwanted symbol types -; MAIN_CHECK: (EBP) int32_t __cdecl main() -; MAIN_CHECK-NOT: vtbl: -; MAIN_CHECK-NOT: enum: -; MAIN_CHECK-NOT: class: -; MAIN_CHECK-NOT: data: +; RUN: llvm-pdbdump %p/Inputs/empty.pdb | FileCheck %s -check-prefix=NO_ARGS +; RUN: llvm-pdbdump -types %p/Inputs/empty.pdb | FileCheck %s -check-prefix=TYPES +; RUN: llvm-pdbdump -compilands %p/Inputs/empty.pdb | FileCheck %s -check-prefix=COMPILANDS +; RUN: llvm-pdbdump -types -compilands %p/Inputs/empty.pdb | FileCheck %s -check-prefix=BOTH + +; Check that neither symbols nor compilands are dumped when neither argument specified. +; NO_ARGS: empty.pdb +; NO_ARGS: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0} +; NO_ARGS: Attributes: HasPrivateSymbols +; NO_ARGS-NOT: Dumping compilands +; NO_ARGS-NOT: Dumping symbols + +; Check that only symbols are dumped when only -types is specified. +; TYPES: empty.pdb +; TYPES: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0} +; TYPES: Attributes: HasPrivateSymbols +; TYPES: Dumping types +; TYPES-NOT: Dumping compilands + +; Check that only compilands are dumped when only -compilands is specified. +; COMPILANDS: empty.pdb +; COMPILANDS: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0} +; COMPILANDS: Attributes: HasPrivateSymbols +; COMPILANDS-NOT: Dumping types +; COMPILANDS: Dumping compilands + +; Check that types and compilands are dumped when both arguments are specified. +; BOTH: empty.pdb +; BOTH: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0} +; BOTH: Attributes: HasPrivateSymbols +; BOTH: Dumping types +; BOTH: Dumping compilands diff --git a/llvm/test/DebugInfo/PDB/pdbdump-symbol-format.test b/llvm/test/DebugInfo/PDB/pdbdump-symbol-format.test index 64753df1..243fcc4 100644 --- a/llvm/test/DebugInfo/PDB/pdbdump-symbol-format.test +++ b/llvm/test/DebugInfo/PDB/pdbdump-symbol-format.test @@ -1,14 +1,27 @@ -; RUN: llvm-pdbdump -all -hidden -group-by=compiland %p/Inputs/symbolformat.pdb | FileCheck --check-prefix=FORMAT %s +; RUN: llvm-pdbdump -symbols %p/Inputs/symbolformat.pdb | FileCheck --check-prefix=SYM_FORMAT %s +; RUN: llvm-pdbdump -types %p/Inputs/symbolformat.pdb | FileCheck --check-prefix=TYPES_FORMAT %s -; The format here is func [0x+ - 0x-] -; FORMAT: test\DebugInfo\PDB\Inputs\symbolformat-fpo.obj -; FORMAT-DAG: func [0x001130+0 - 0x001137-1] (VFrame) uint32_t __cdecl fpo_func(uint32_t) -; FORMAT: d:\src\llvm\test\DebugInfo\PDB\Inputs\symbolformat.obj -; FORMAT-DAG: func [0x001060+3 - 0x001067-2] (EBP) int32_t __cdecl _purecall() -; FORMAT-DAG: func [0x001070+6 - 0x001099-4] (EBP) int32_t __cdecl main(int32_t, char**) -; FORMAT-DAG: func [0x0010b0+7 - 0x0010c7-4] (EBP) void __thiscall A::A() -; FORMAT-DAG: func [0x0010d0+7 - 0x0010ef-4] (EBP) void __thiscall B::B() -; FORMAT-DAG: thunk [0x000010f6 - 0x000010fa] (Pcode) B::`vcall'{0}' -; FORMAT-DAG: func [0x001100+7 - 0x00110b-4] (EBP) virtual void __thiscall B::PureFunc() -; FORMAT-DAG: func [0x001110+7 - 0x00111b-4] (EBP) void __thiscall A::RegularFunc() -; FORMAT-DAG: func [0x001120+7 - 0x00112b-4] (EBP) virtual void __thiscall A::VirtualFunc() +; The format is func [0x+ - 0x-] +; SYM_FORMAT: symbolformat-fpo.obj +; SYM_FORMAT-DAG: func [0x001130+0 - 0x001137-1] (VFrame) uint32_t __cdecl fpo_func(uint32_t) +; SYM_FORMAT: symbolformat.obj +; SYM_FORMAT-DAG: func [0x001060+3 - 0x001067-2] (EBP) int32_t __cdecl _purecall() +; SYM_FORMAT-DAG: func [0x001070+6 - 0x001099-4] (EBP) int32_t __cdecl main(int32_t, char**) +; SYM_FORMAT-DAG: func [0x0010b0+7 - 0x0010c7-4] (EBP) void __thiscall A::A() +; SYM_FORMAT-DAG: func [0x0010d0+7 - 0x0010ef-4] (EBP) void __thiscall B::B() +; SYM_FORMAT-DAG: thunk [0x000010f6 - 0x000010fa] (Pcode) B::`vcall'{0}' +; SYM_FORMAT-DAG: func [0x001100+7 - 0x00110b-4] (EBP) virtual void __thiscall B::PureFunc() +; SYM_FORMAT-DAG: func [0x001110+7 - 0x00111b-4] (EBP) void __thiscall A::RegularFunc() +; SYM_FORMAT-DAG: func [0x001120+7 - 0x00112b-4] (EBP) virtual void __thiscall A::VirtualFunc() + +; TYPES_FORMAT: Function Signatures +; TYPES_FORMAT-DAG: int32_t __cdecl () +; TYPES_FORMAT-DAG: int32_t __cdecl (int32_t, char**) +; TYPES_FORMAT-DAG: void __thiscall (A::*)() +; TYPES_FORMAT-DAG: void __thiscall (B::*)() +; TYPES_FORMAT-DAG: void __thiscall (B::*)(B&) +; TYPES_FORMAT-DAG: void __thiscall (B::*)() +; TYPES_FORMAT-DAG: B& __thiscall (B::*)(B&) +; TYPES_FORMAT-DAG: void __thiscall (A::*)(A&) +; TYPES_FORMAT-DAG: void __thiscall (A::*)() +; TYPES_FORMAT-DAG: A& __thiscall (A::*)(A&) diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp index f350c43..cc51dc0 100644 --- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -45,71 +45,10 @@ cl::list InputFilenames(cl::Positional, cl::desc(""), cl::OneOrMore); -cl::opt DumpHidden( - "hidden", - cl::desc("Attempt to find hidden symbols. This can find additional\n" - "symbols that cannot be found otherwise. For example, vtables\n" - "can only be found with an exhaustive search such as this. Be\n" - "warned that the performance can be prohibitive on large PDB " - "files.")); - -cl::opt DumpAll( - "all", - cl::desc("Specifies all other options except -hidden and -group-by")); -cl::opt DumpObjFiles("compilands", cl::desc("Display object files")); -cl::opt DumpFuncs("functions", cl::desc("Display function information")); -cl::opt DumpData( - "data", - cl::desc("Display global, class, and constant variable information.")); -cl::opt DumpLabels("labels", cl::desc("Display labels")); -cl::opt DumpPublic("public", cl::desc("Display public symbols")); -cl::opt DumpClasses("classes", cl::desc("Display class type information")); -cl::opt DumpEnums("enums", cl::desc("Display enum information")); -cl::opt DumpFuncsigs("funcsigs", - cl::desc("Display unique function signatures")); -cl::opt DumpTypedefs("typedefs", cl::desc("Display typedefs")); -cl::opt DumpThunks("thunks", cl::desc("Display thunks")); -cl::opt DumpVtables( - "vtables", - cl::desc("Display virtual function tables (only with --exhaustive)")); - -static cl::opt DumpMode( - "group-by", cl::init(PDB_DumpType::ByType), cl::desc("Dump mode:"), - cl::values( - clEnumValN(PDB_DumpType::ByType, "type", - "(Default) Display symbols grouped by type"), - clEnumValN(PDB_DumpType::ByObjFile, "compiland", - "Display symbols grouped under their containing object " - "file."), - clEnumValN(PDB_DumpType::Both, "both", - "Display symbols grouped by type, and then by object file."), - clEnumValEnd)); -} - -#define SET_DUMP_FLAG_FROM_OPT(Var, Flag, Opt) \ - if (opts::Opt) \ - Var |= Flag; - -PDB_DumpFlags CalculateDumpFlags() { - PDB_DumpFlags Flags = PDB_DF_None; - - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Hidden, DumpHidden) - - if (opts::DumpAll) - return Flags | PDB_DF_All; - - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_ObjFiles, DumpObjFiles) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Functions, DumpFuncs) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Data, DumpData) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Labels, DumpLabels) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_PublicSyms, DumpPublic) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Classes, DumpClasses) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Enums, DumpEnums) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Funcsigs, DumpFuncsigs) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Typedefs, DumpTypedefs) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_Thunks, DumpThunks) - SET_DUMP_FLAG_FROM_OPT(Flags, PDB_DF_VTables, DumpVtables) - return Flags; +cl::opt DumpCompilands("compilands", cl::desc("Display compilands")); +cl::opt DumpSymbols("symbols", + cl::desc("Display symbols (implies --compilands")); +cl::opt DumpTypes("types", cl::desc("Display types")); } static void dumpInput(StringRef Path) { @@ -120,19 +59,24 @@ static void dumpInput(StringRef Path) { outs() << " is available for your platform."; return; } - PDB_DumpFlags Flags = CalculateDumpFlags(); - if (opts::DumpMode != opts::PDB_DumpType::ByObjFile) - Flags |= PDB_DF_Children; auto GlobalScope(Session->getGlobalScope()); + PDB_DumpFlags Flags = PDB_DF_None; + if (opts::DumpTypes) + Flags |= PDB_DF_Children | PDB_DF_Enums | PDB_DF_Funcsigs | + PDB_DF_Typedefs | PDB_DF_VTables; GlobalScope->dump(outs(), 0, PDB_DumpLevel::Normal, Flags); outs() << "\n"; - if (opts::DumpMode != opts::PDB_DumpType::ByType) { + if (opts::DumpSymbols || opts::DumpCompilands) { + outs() << "Dumping compilands\n"; auto Compilands = GlobalScope->findAllChildren(); + Flags = PDB_DF_None; + if (opts::DumpSymbols) + Flags |= PDB_DF_Children | PDB_DF_Data | PDB_DF_Functions | + PDB_DF_Thunks | PDB_DF_Labels; while (auto Compiland = Compilands->getNext()) { - Compiland->dump(outs(), 0, PDB_DumpLevel::Detailed, - Flags | PDB_DF_Children); + Compiland->dump(outs(), 2, PDB_DumpLevel::Detailed, Flags); outs() << "\n"; } } -- 2.7.4