1 //===- CompilandDumper.cpp - llvm-pdbdump compiland symbol dumper *- C++ *-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "CompilandDumper.h"
11 #include "LinePrinter.h"
12 #include "llvm-pdbdump.h"
14 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
15 #include "llvm/DebugInfo/PDB/IPDBSession.h"
16 #include "llvm/DebugInfo/PDB/PDBExtras.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
25 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
26 #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
27 #include "llvm/Support/Format.h"
28 #include "llvm/Support/Path.h"
29 #include "llvm/Support/raw_ostream.h"
31 #include "FunctionDumper.h"
38 CompilandDumper::CompilandDumper(LinePrinter &P)
39 : PDBSymDumper(true), Printer(P) {}
41 void CompilandDumper::dump(const PDBSymbolCompilandDetails &Symbol) {}
43 void CompilandDumper::dump(const PDBSymbolCompilandEnv &Symbol) {}
45 void CompilandDumper::start(const PDBSymbolCompiland &Symbol, bool Children) {
46 std::string FullName = Symbol.getName();
47 if (Printer.IsCompilandExcluded(FullName))
51 WithColor(Printer, PDB_ColorItem::Path).get() << FullName;
55 auto ChildrenEnum = Symbol.findAllChildren();
57 while (auto Child = ChildrenEnum->getNext())
62 void CompilandDumper::dump(const PDBSymbolData &Symbol) {
63 if (Printer.IsSymbolExcluded(Symbol.getName()))
68 switch (auto LocType = Symbol.getLocationType()) {
69 case PDB_LocType::Static:
71 WithColor(Printer, PDB_ColorItem::Address).get()
72 << "[" << format_hex(Symbol.getRelativeVirtualAddress(), 10) << "]";
74 case PDB_LocType::Constant:
75 Printer << "constant: ";
76 WithColor(Printer, PDB_ColorItem::LiteralValue).get()
77 << "[" << Symbol.getValue() << "]";
80 Printer << "data(unexpected type=" << LocType << ")";
84 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
87 void CompilandDumper::dump(const PDBSymbolFunc &Symbol) {
88 if (Symbol.getLength() == 0)
90 if (Printer.IsSymbolExcluded(Symbol.getName()))
94 FunctionDumper Dumper(Printer);
95 Dumper.start(Symbol, FunctionDumper::PointerType::None);
98 void CompilandDumper::dump(const PDBSymbolLabel &Symbol) {
99 if (Printer.IsSymbolExcluded(Symbol.getName()))
104 WithColor(Printer, PDB_ColorItem::Address).get()
105 << "[" << format_hex(Symbol.getRelativeVirtualAddress(), 10) << "] ";
106 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
109 void CompilandDumper::dump(const PDBSymbolThunk &Symbol) {
110 if (Printer.IsSymbolExcluded(Symbol.getName()))
115 PDB_ThunkOrdinal Ordinal = Symbol.getThunkOrdinal();
116 uint32_t RVA = Symbol.getRelativeVirtualAddress();
117 if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) {
118 uint32_t Target = Symbol.getTargetRelativeVirtualAddress();
119 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(RVA, 10);
121 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Target, 10);
123 WithColor(Printer, PDB_ColorItem::Address).get()
124 << "[" << format_hex(RVA, 10) << " - "
125 << format_hex(RVA + Symbol.getLength(), 10) << "]";
128 WithColor(Printer, PDB_ColorItem::Register).get() << Ordinal;
130 std::string Name = Symbol.getName();
132 WithColor(Printer, PDB_ColorItem::Identifier).get() << Name;
135 void CompilandDumper::dump(const PDBSymbolTypeTypedef &Symbol) {}
137 void CompilandDumper::dump(const PDBSymbolUnknown &Symbol) {
139 Printer << "unknown (" << Symbol.getSymTag() << ")";