PrettyExternalSymbolDumper.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 "LinePrinter.h"
  10. #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
  11. #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h"
  12. #include "llvm/Support/Format.h"
  13. using namespace llvm;
  14. using namespace llvm::pdb;
  15. ExternalSymbolDumper::ExternalSymbolDumper(LinePrinter &P)
  16. : PDBSymDumper(true), Printer(P) {}
  17. void ExternalSymbolDumper::start(const PDBSymbolExe &Symbol) {
  18. if (auto Vars = Symbol.findAllChildren<PDBSymbolPublicSymbol>()) {
  19. while (auto Var = Vars->getNext())
  20. Var->dump(*this);
  21. }
  22. }
  23. void ExternalSymbolDumper::dump(const PDBSymbolPublicSymbol &Symbol) {
  24. std::string LinkageName = Symbol.getName();
  25. if (Printer.IsSymbolExcluded(LinkageName))
  26. return;
  27. Printer.NewLine();
  28. uint64_t Addr = Symbol.getVirtualAddress();
  29. Printer << "public [";
  30. WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Addr, 10);
  31. Printer << "] ";
  32. WithColor(Printer, PDB_ColorItem::Identifier).get() << LinkageName;
  33. }