Zachary Turner | a9054dd | 2017-01-11 00:35:43 +0000 | [diff] [blame] | 1 | //===- PrettyExternalSymbolDumper.cpp -------------------------- *- C++ *-===// |
Zachary Turner | e5cb269 | 2015-05-01 20:24:26 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Zachary Turner | a9054dd | 2017-01-11 00:35:43 +0000 | [diff] [blame] | 10 | #include "PrettyExternalSymbolDumper.h" |
Zachary Turner | e5cb269 | 2015-05-01 20:24:26 +0000 | [diff] [blame] | 11 | #include "LinePrinter.h" |
| 12 | |
| 13 | #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" |
| 14 | #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h" |
| 15 | #include "llvm/Support/Format.h" |
| 16 | |
| 17 | using namespace llvm; |
Zachary Turner | ec28fc3 | 2016-05-04 20:32:13 +0000 | [diff] [blame] | 18 | using namespace llvm::pdb; |
Zachary Turner | e5cb269 | 2015-05-01 20:24:26 +0000 | [diff] [blame] | 19 | |
| 20 | ExternalSymbolDumper::ExternalSymbolDumper(LinePrinter &P) |
| 21 | : PDBSymDumper(true), Printer(P) {} |
| 22 | |
| 23 | void ExternalSymbolDumper::start(const PDBSymbolExe &Symbol) { |
| 24 | auto Vars = Symbol.findAllChildren<PDBSymbolPublicSymbol>(); |
| 25 | while (auto Var = Vars->getNext()) |
| 26 | Var->dump(*this); |
| 27 | } |
| 28 | |
| 29 | void ExternalSymbolDumper::dump(const PDBSymbolPublicSymbol &Symbol) { |
| 30 | std::string LinkageName = Symbol.getName(); |
| 31 | if (Printer.IsSymbolExcluded(LinkageName)) |
| 32 | return; |
| 33 | |
| 34 | Printer.NewLine(); |
| 35 | uint64_t Addr = Symbol.getVirtualAddress(); |
| 36 | |
| 37 | Printer << "["; |
| 38 | WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Addr, 10); |
| 39 | Printer << "] "; |
| 40 | WithColor(Printer, PDB_ColorItem::Identifier).get() << LinkageName; |
| 41 | } |