[llvm] r230744 - [llvm-pdbdump] Add support for dumping global variables.
Zachary Turner
zturner at google.com
Fri Feb 27 01:15:19 PST 2015
Author: zturner
Date: Fri Feb 27 03:15:18 2015
New Revision: 230744
URL: http://llvm.org/viewvc/llvm-project?rev=230744&view=rev
Log:
[llvm-pdbdump] Add support for dumping global variables.
Modified:
llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.cpp
llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.pdb
llvm/trunk/test/DebugInfo/PDB/pdbdump-flags.test
llvm/trunk/test/DebugInfo/PDB/pdbdump-symbol-format.test
llvm/trunk/tools/llvm-pdbdump/TypeDumper.cpp
llvm/trunk/tools/llvm-pdbdump/TypeDumper.h
llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
Modified: llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.cpp?rev=230744&r1=230743&r2=230744&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.cpp (original)
+++ llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.cpp Fri Feb 27 03:15:18 2015
@@ -55,6 +55,9 @@ struct MemberTest {
typedef int IntType;
typedef A ClassAType;
+int g_global_int;
+void *g_global_pointer = nullptr;
+
int main(int argc, char **argv) {
// Force symbol references so the linker generates debug info
B b;
Modified: llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.pdb
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.pdb?rev=230744&r1=230743&r2=230744&view=diff
==============================================================================
Binary files llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.pdb (original) and llvm/trunk/test/DebugInfo/PDB/Inputs/symbolformat.pdb Fri Feb 27 03:15:18 2015 differ
Modified: llvm/trunk/test/DebugInfo/PDB/pdbdump-flags.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/pdbdump-flags.test?rev=230744&r1=230743&r2=230744&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/pdbdump-flags.test (original)
+++ llvm/trunk/test/DebugInfo/PDB/pdbdump-flags.test Fri Feb 27 03:15:18 2015
@@ -1,32 +1,40 @@
; 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
+; RUN: llvm-pdbdump -types -compilands %p/Inputs/empty.pdb | FileCheck %s -check-prefix=MULTIPLE
; 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
+; NO_ARGS-NOT: ---TYPES---
+; NO_ARGS-NOT: ---COMPILANDS---
+; NO_ARGS-NOT: ---GLOBALS---
+; NO_ARGS-NOT: ---SYMBOLS---
-; Check that only symbols are dumped when only -types is specified.
+; Check that only types 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
+; TYPES: ---TYPES---
+; TYPES-NOT: ---COMPILANDS---
+; TYPES-NOT: ---GLOBALS---
+; TYPES-NOT: ---SYMBOLS---
; 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
+; COMPILANDS: ---COMPILANDS---
+; COMPILANDS-NOT: ---TYPES---
+; COMPILANDS-NOT: ---GLOBALS---
+; COMPILANDS-NOT: ---SYMBOLS---
; 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
+; MULTIPLE: empty.pdb
+; MULTIPLE: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
+; MULTIPLE: Attributes: HasPrivateSymbols
+; MULTIPLE: ---COMPILANDS---
+; MULTIPLE: ---TYPES---
+; MULTIPLE-NOT: ---GLOBALS---
+; MULTIPLE-NOT: ---SYMBOLS---
Modified: llvm/trunk/test/DebugInfo/PDB/pdbdump-symbol-format.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/pdbdump-symbol-format.test?rev=230744&r1=230743&r2=230744&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/pdbdump-symbol-format.test (original)
+++ llvm/trunk/test/DebugInfo/PDB/pdbdump-symbol-format.test Fri Feb 27 03:15:18 2015
@@ -1,8 +1,10 @@
; 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
; RUN: llvm-pdbdump -types -class-definitions %p/Inputs/symbolformat.pdb | FileCheck --check-prefix=FULL_CLASS %s
+; RUN: llvm-pdbdump -globals %p/Inputs/symbolformat.pdb | FileCheck --check-prefix=GLOBALS %s
; The format is func [0x<rva_start>+<prologue_length> - 0x<rva_end>-<epilogue_length>]
+; SYM_FORMAT: ---SYMBOLS---
; SYM_FORMAT: symbolformat-fpo.obj
; SYM_FORMAT-DAG: func [{{.*}}] (FPO) unsigned __cdecl fpo_func(unsigned n)
; SYM_FORMAT: symbolformat.obj
@@ -15,20 +17,10 @@
; SYM_FORMAT-DAG: func [{{.*}}] (EBP) void A::RegularFunc()
; SYM_FORMAT-DAG: func [{{.*}}] (EBP) virtual void A::VirtualFunc()
+; TYPES_FORMAT: ---TYPES---
; TYPES_FORMAT: Enums
; TYPES_FORMAT-DAG: enum TestEnum
; TYPES_FORMAT-DAG: enum TestEnumClass
-; TYPES_FORMAT: Function Signatures
-; TYPES_FORMAT-DAG: int __cdecl ()
-; TYPES_FORMAT-DAG: int __cdecl (int, char**)
-; TYPES_FORMAT-DAG: void (A::)()
-; TYPES_FORMAT-DAG: void (B::)()
-; TYPES_FORMAT-DAG: void (B::)(B&)
-; TYPES_FORMAT-DAG: void (B::)()
-; TYPES_FORMAT-DAG: B& (B::)(B&)
-; TYPES_FORMAT-DAG: void (A::)(A&)
-; TYPES_FORMAT-DAG: void (A::)()
-; TYPES_FORMAT-DAG: A& (A::)(A&)
; TYPES_FORMAT: Typedefs
; TYPES_FORMAT-DAG: typedef int IntType
; TYPES_FORMAT-DAG: typedef class A ClassAType
@@ -36,6 +28,7 @@
; TYPES_FORMAT-DAG: class A
; TYPES_FORMAT-DAG: class B
+; FULL_CLASS: ---TYPES---
; FULL_CLASS: Classes
; FULL_CLASS-DAG: class A {
; FULL_CLASS: public:
@@ -58,4 +51,9 @@
; FULL_CLASS: data +0x30 float m_float
; FULL_CLASS: data +0x38 double m_double
; FULL_CLASS: data +0x40 void (__cdecl *m_pfn_2_args)(int, double)
-; FULL_CLASS: }
\ No newline at end of file
+; FULL_CLASS: }
+
+; GLOBALS: ---GLOBALS---
+; GLOBALS-DAG: func [{{.*}}] (FPO) unsigned __cdecl fpo_func(unsigned n)
+; GLOBALS-DAG: data [{{.*}}] static void* g_global_pointer
+; GLOBALS-DAG: data [{{.*}}] static int g_global_int
Modified: llvm/trunk/tools/llvm-pdbdump/TypeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/TypeDumper.cpp?rev=230744&r1=230743&r2=230744&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/TypeDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/TypeDumper.cpp Fri Feb 27 03:15:18 2015
@@ -10,14 +10,12 @@
#include "TypeDumper.h"
#include "ClassDefinitionDumper.h"
-#include "FunctionDumper.h"
#include "llvm-pdbdump.h"
#include "TypedefDumper.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
@@ -32,12 +30,6 @@ void TypeDumper::start(const PDBSymbolEx
while (auto Enum = Enums->getNext())
Enum->dump(OS, Indent + 2, *this);
- auto FuncSigs = Exe.findAllChildren<PDBSymbolTypeFunctionSig>();
- OS << newline(Indent);
- OS << "Function Signatures: (" << FuncSigs->getChildCount() << " items)";
- while (auto Sig = FuncSigs->getNext())
- Sig->dump(OS, Indent + 2, *this);
-
auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
OS << newline(Indent) << "Typedefs: (" << Typedefs->getChildCount()
<< " items)";
@@ -62,15 +54,6 @@ void TypeDumper::dump(const PDBSymbolTyp
OS << "enum " << Symbol.getName();
}
-void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
- int Indent) {
- if (!InlineDump)
- OS << newline(Indent);
-
- FunctionDumper Dumper;
- Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None, OS);
-}
-
void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
int Indent) {
if (!InlineDump)
Modified: llvm/trunk/tools/llvm-pdbdump/TypeDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/TypeDumper.h?rev=230744&r1=230743&r2=230744&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/TypeDumper.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/TypeDumper.h Fri Feb 27 03:15:18 2015
@@ -22,8 +22,6 @@ public:
void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
int Indent) override;
- void dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
- int Indent) override;
void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
int Indent) override;
void dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=230744&r1=230743&r2=230744&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Fri Feb 27 03:15:18 2015
@@ -15,7 +15,9 @@
#include "llvm-pdbdump.h"
#include "CompilandDumper.h"
+#include "FunctionDumper.h"
#include "TypeDumper.h"
+#include "VariableDumper.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringExtras.h"
@@ -25,7 +27,10 @@
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/PDB.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FileSystem.h"
@@ -50,12 +55,13 @@ cl::list<std::string> InputFilenames(cl:
cl::desc("<input PDB files>"),
cl::OneOrMore);
-cl::opt<bool> DumpCompilands("compilands", cl::desc("Display compilands"));
-cl::opt<bool> DumpSymbols("symbols",
- cl::desc("Display symbols (implies --compilands"));
-cl::opt<bool> DumpTypes("types", cl::desc("Display types"));
-cl::opt<bool> DumpClassDefs("class-definitions",
- cl::desc("Display full class definitions"));
+cl::opt<bool> Compilands("compilands", cl::desc("Display compilands"));
+cl::opt<bool> Symbols("symbols",
+ cl::desc("Display symbols for each compiland"));
+cl::opt<bool> Globals("globals", cl::desc("Dump global symbols"));
+cl::opt<bool> Types("types", cl::desc("Display types"));
+cl::opt<bool> ClassDefs("class-definitions",
+ cl::desc("Display full class definitions"));
}
static void dumpInput(StringRef Path) {
@@ -85,18 +91,48 @@ static void dumpInput(StringRef Path) {
if (GlobalScope->hasPrivateSymbols())
outs() << "HasPrivateSymbols ";
- if (opts::DumpTypes) {
- outs() << "\nDumping types";
- TypeDumper Dumper(false, opts::DumpClassDefs);
+ if (opts::Compilands) {
+ outs() << "\n---COMPILANDS---";
+ auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
+ CompilandDumper Dumper;
+ while (auto Compiland = Compilands->getNext())
+ Dumper.start(*Compiland, outs(), 2, false);
+ }
+
+ if (opts::Types) {
+ outs() << "\n---TYPES---";
+ TypeDumper Dumper(false, opts::ClassDefs);
Dumper.start(*GlobalScope, outs(), 2);
}
- if (opts::DumpSymbols || opts::DumpCompilands) {
- outs() << "\nDumping compilands";
+ if (opts::Symbols) {
+ outs() << "\n---SYMBOLS---";
auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
CompilandDumper Dumper;
while (auto Compiland = Compilands->getNext())
- Dumper.start(*Compiland, outs(), 2, opts::DumpSymbols);
+ Dumper.start(*Compiland, outs(), 2, true);
+ }
+
+ if (opts::Globals) {
+ outs() << "\n---GLOBALS---";
+ {
+ FunctionDumper Dumper;
+ auto Functions = GlobalScope->findAllChildren<PDBSymbolFunc>();
+ while (auto Function = Functions->getNext())
+ Dumper.start(*Function, FunctionDumper::PointerType::None, outs(), 2);
+ }
+ {
+ auto Vars = GlobalScope->findAllChildren<PDBSymbolData>();
+ VariableDumper Dumper;
+ while (auto Var = Vars->getNext())
+ Dumper.start(*Var, outs(), 2);
+ }
+ {
+ auto Thunks = GlobalScope->findAllChildren<PDBSymbolThunk>();
+ CompilandDumper Dumper;
+ while (auto Thunk = Thunks->getNext())
+ Dumper.dump(*Thunk, outs(), 2);
+ }
}
outs().flush();
}
More information about the llvm-commits
mailing list