blob: 1270223b1c78b1ce39e396b103d7fe6bc8e96b4b [file] [log] [blame]
Zachary Turnereb6ab042017-01-11 00:35:43 +00001//===- PrettyExternalSymbolDumper.cpp -------------------------- *- C++ *-===//
Zachary Turner7c69a582015-05-01 20:24:26 +00002//
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 Turnereb6ab042017-01-11 00:35:43 +000010#include "PrettyExternalSymbolDumper.h"
Zachary Turner7c69a582015-05-01 20:24:26 +000011#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
17using namespace llvm;
Zachary Turnerc95df942016-05-04 20:32:13 +000018using namespace llvm::pdb;
Zachary Turner7c69a582015-05-01 20:24:26 +000019
20ExternalSymbolDumper::ExternalSymbolDumper(LinePrinter &P)
21 : PDBSymDumper(true), Printer(P) {}
22
23void ExternalSymbolDumper::start(const PDBSymbolExe &Symbol) {
Aaron Smith71e93df2018-03-07 02:23:08 +000024 if (auto Vars = Symbol.findAllChildren<PDBSymbolPublicSymbol>()) {
25 while (auto Var = Vars->getNext())
26 Var->dump(*this);
27 }
Zachary Turner7c69a582015-05-01 20:24:26 +000028}
29
30void ExternalSymbolDumper::dump(const PDBSymbolPublicSymbol &Symbol) {
31 std::string LinkageName = Symbol.getName();
32 if (Printer.IsSymbolExcluded(LinkageName))
33 return;
34
35 Printer.NewLine();
36 uint64_t Addr = Symbol.getVirtualAddress();
37
Zachary Turnerc779b362018-07-06 21:01:42 +000038 Printer << "public [";
Zachary Turner7c69a582015-05-01 20:24:26 +000039 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Addr, 10);
40 Printer << "] ";
41 WithColor(Printer, PDB_ColorItem::Identifier).get() << LinkageName;
42}