PrettyExternalSymbolDumper.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //===- PrettyExternalSymbolDumper.cpp -------------------------- *- C++ *-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "PrettyExternalSymbolDumper.h"
  9. #include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
  10. #include "llvm/DebugInfo/PDB/Native/LinePrinter.h"
  11. #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
  12. #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h"
  13. #include "llvm/Support/Format.h"
  14. using namespace llvm;
  15. using namespace llvm::pdb;
  16. ExternalSymbolDumper::ExternalSymbolDumper(LinePrinter &P)
  17. : PDBSymDumper(true), Printer(P) {}
  18. void ExternalSymbolDumper::start(const PDBSymbolExe &Symbol) {
  19. if (auto Vars = Symbol.findAllChildren<PDBSymbolPublicSymbol>()) {
  20. while (auto Var = Vars->getNext())
  21. Var->dump(*this);
  22. }
  23. }
  24. void ExternalSymbolDumper::dump(const PDBSymbolPublicSymbol &Symbol) {
  25. std::string LinkageName = Symbol.getName();
  26. if (Printer.IsSymbolExcluded(LinkageName))
  27. return;
  28. Printer.NewLine();
  29. uint64_t Addr = Symbol.getVirtualAddress();
  30. Printer << "public [";
  31. WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Addr, 10);
  32. Printer << "] ";
  33. WithColor(Printer, PDB_ColorItem::Identifier).get() << LinkageName;
  34. }