summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-03-08 21:42:24 +0000
committerZachary Turner <zturner@google.com>2016-03-08 21:42:24 +0000
commita99000dd311b972e35f889c61bbdbc22a1680abd (patch)
tree3dd5f55d15378b19e533c626075341f8c680e5ce /llvm/tools/llvm-pdbdump
parent8d950ce18c6d8ab3b43a4950cecbb17a83914910 (diff)
downloadbcm5719-llvm-a99000dd311b972e35f889c61bbdbc22a1680abd.tar.gz
bcm5719-llvm-a99000dd311b972e35f889c61bbdbc22a1680abd.zip
[llvm-pdbdump] Dump line table information.
This patch adds the -lines command line option which will dump source/line information for each compiland and source file. llvm-svn: 262962
Diffstat (limited to 'llvm/tools/llvm-pdbdump')
-rw-r--r--llvm/tools/llvm-pdbdump/CompilandDumper.cpp62
-rw-r--r--llvm/tools/llvm-pdbdump/CompilandDumper.h5
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp25
3 files changed, 80 insertions, 12 deletions
diff --git a/llvm/tools/llvm-pdbdump/CompilandDumper.cpp b/llvm/tools/llvm-pdbdump/CompilandDumper.cpp
index 68ceb620627..7d80f3234d1 100644
--- a/llvm/tools/llvm-pdbdump/CompilandDumper.cpp
+++ b/llvm/tools/llvm-pdbdump/CompilandDumper.cpp
@@ -12,7 +12,9 @@
#include "llvm-pdbdump.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
+#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
@@ -42,21 +44,65 @@ void CompilandDumper::dump(const PDBSymbolCompilandDetails &Symbol) {}
void CompilandDumper::dump(const PDBSymbolCompilandEnv &Symbol) {}
-void CompilandDumper::start(const PDBSymbolCompiland &Symbol, bool Children) {
+void CompilandDumper::start(const PDBSymbolCompiland &Symbol,
+ CompilandDumpFlags opts) {
std::string FullName = Symbol.getName();
if (Printer.IsCompilandExcluded(FullName))
return;
Printer.NewLine();
WithColor(Printer, PDB_ColorItem::Path).get() << FullName;
- if (!Children)
- return;
- auto ChildrenEnum = Symbol.findAllChildren();
- Printer.Indent();
- while (auto Child = ChildrenEnum->getNext())
- Child->dump(*this);
- Printer.Unindent();
+ if (opts & Flags::Lines) {
+ const IPDBSession &Session = Symbol.getSession();
+ auto Files = Session.getSourceFilesForCompiland(Symbol);
+ Printer.Indent();
+ while (auto File = Files->getNext()) {
+ Printer.NewLine();
+ WithColor(Printer, PDB_ColorItem::Path).get() << File->getFileName();
+
+ auto Lines = Session.findLineNumbers(Symbol, *File);
+ Printer.Indent();
+ while (auto Line = Lines->getNext()) {
+ Printer.NewLine();
+ uint32_t LineStart = Line->getLineNumber();
+ uint32_t LineEnd = Line->getLineNumberEnd();
+
+ Printer << "Line ";
+ PDB_ColorItem StatementColor = Line->isStatement()
+ ? PDB_ColorItem::Keyword
+ : PDB_ColorItem::LiteralValue;
+ WithColor(Printer, StatementColor).get() << LineStart;
+ if (LineStart != LineEnd)
+ WithColor(Printer, StatementColor).get() << " - " << LineEnd;
+
+ Printer << ", Address: ";
+ if (Line->getLength() > 0) {
+ uint64_t AddrStart = Line->getVirtualAddress();
+ uint64_t AddrEnd = AddrStart + Line->getLength() - 1;
+ WithColor(Printer, PDB_ColorItem::Address).get()
+ << "[" << format_hex(AddrStart, 10) << " - "
+ << format_hex(AddrEnd, 10) << "]";
+ Printer << " (" << Line->getLength() << " bytes)";
+ } else {
+ uint64_t AddrStart = Line->getVirtualAddress();
+ WithColor(Printer, PDB_ColorItem::Address).get()
+ << "[" << format_hex(AddrStart, 10) << "] ";
+ Printer << "(0 bytes)";
+ }
+ }
+ Printer.Unindent();
+ }
+ Printer.Unindent();
+ }
+
+ if (opts & Flags::Children) {
+ auto ChildrenEnum = Symbol.findAllChildren();
+ Printer.Indent();
+ while (auto Child = ChildrenEnum->getNext())
+ Child->dump(*this);
+ Printer.Unindent();
+ }
}
void CompilandDumper::dump(const PDBSymbolData &Symbol) {
diff --git a/llvm/tools/llvm-pdbdump/CompilandDumper.h b/llvm/tools/llvm-pdbdump/CompilandDumper.h
index 0d1d27cd7a4..204d34acf1b 100644
--- a/llvm/tools/llvm-pdbdump/CompilandDumper.h
+++ b/llvm/tools/llvm-pdbdump/CompilandDumper.h
@@ -16,11 +16,14 @@ namespace llvm {
class LinePrinter;
+typedef int CompilandDumpFlags;
class CompilandDumper : public PDBSymDumper {
public:
+ enum Flags { None = 0x0, Children = 0x1, Symbols = 0x2, Lines = 0x4 };
+
CompilandDumper(LinePrinter &P);
- void start(const PDBSymbolCompiland &Symbol, bool Children);
+ void start(const PDBSymbolCompiland &Symbol, CompilandDumpFlags flags);
void dump(const PDBSymbolCompilandDetails &Symbol) override;
void dump(const PDBSymbolCompilandEnv &Symbol) override;
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
index 8dd0c49d1c4..940ef1b6399 100644
--- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -76,6 +76,7 @@ cl::opt<bool> Globals("globals", cl::desc("Dump global symbols"),
cl::opt<bool> Externals("externals", cl::desc("Dump external symbols"),
cl::cat(TypeCategory));
cl::opt<bool> Types("types", cl::desc("Display types"), cl::cat(TypeCategory));
+cl::opt<bool> Lines("lines", cl::desc("Line tables"), cl::cat(TypeCategory));
cl::opt<bool>
All("all", cl::desc("Implies all other options in 'Symbol Types' category"),
cl::cat(TypeCategory));
@@ -684,8 +685,11 @@ static void dumpInput(StringRef Path) {
Printer.Indent();
auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
CompilandDumper Dumper(Printer);
+ CompilandDumpFlags options = CompilandDumper::Flags::None;
+ if (opts::Lines)
+ options = options | CompilandDumper::Flags::Lines;
while (auto Compiland = Compilands->getNext())
- Dumper.start(*Compiland, false);
+ Dumper.start(*Compiland, options);
Printer.Unindent();
}
@@ -742,6 +746,9 @@ static void dumpInput(StringRef Path) {
ExternalSymbolDumper Dumper(Printer);
Dumper.start(*GlobalScope);
}
+ if (opts::Lines) {
+ Printer.NewLine();
+ }
outs().flush();
}
@@ -762,20 +769,32 @@ int main(int argc_, const char *argv_[]) {
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argv.size(), argv.data(), "LLVM PDB Dumper\n");
+ if (opts::Lines)
+ opts::Compilands = true;
+
if (opts::All) {
opts::Compilands = true;
opts::Symbols = true;
opts::Globals = true;
opts::Types = true;
opts::Externals = true;
+ opts::Lines = true;
}
+
+ // When adding filters for excluded compilands and types, we need to remember
+ // that these are regexes. So special characters such as * and \ need to be
+ // escaped in the regex. In the case of a literal \, this means it needs to
+ // be escaped again in the C++. So matching a single \ in the input requires
+ // 4 \es in the C++.
if (opts::ExcludeCompilerGenerated) {
opts::ExcludeTypes.push_back("__vc_attributes");
- opts::ExcludeCompilands.push_back("* Linker *");
+ opts::ExcludeCompilands.push_back("\\* Linker \\*");
}
if (opts::ExcludeSystemLibraries) {
opts::ExcludeCompilands.push_back(
- "f:\\binaries\\Intermediate\\vctools\\crt_bld");
+ "f:\\\\binaries\\\\Intermediate\\\\vctools\\\\crt_bld");
+ opts::ExcludeCompilands.push_back("f:\\\\dd\\\\vctools\\\\crt");
+ opts::ExcludeCompilands.push_back("d:\\\\th.obj.x86fre\\\\minkernel");
}
#if defined(HAVE_DIA_SDK)
OpenPOWER on IntegriCloud