NativePublicSymbol.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //===- NativePublicSymbol.cpp - info about public symbols -------*- 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 "llvm/DebugInfo/PDB/Native/NativePublicSymbol.h"
  9. #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
  10. #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
  11. #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
  12. using namespace llvm;
  13. using namespace llvm::codeview;
  14. using namespace llvm::pdb;
  15. NativePublicSymbol::NativePublicSymbol(NativeSession &Session, SymIndexId Id,
  16. const codeview::PublicSym32 &Sym)
  17. : NativeRawSymbol(Session, PDB_SymType::PublicSymbol, Id), Sym(Sym) {}
  18. NativePublicSymbol::~NativePublicSymbol() {}
  19. void NativePublicSymbol::dump(raw_ostream &OS, int Indent,
  20. PdbSymbolIdField ShowIdFields,
  21. PdbSymbolIdField RecurseIdFields) const {
  22. NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
  23. dumpSymbolField(OS, "name", getName(), Indent);
  24. dumpSymbolField(OS, "offset", getAddressOffset(), Indent);
  25. dumpSymbolField(OS, "section", getAddressSection(), Indent);
  26. }
  27. uint32_t NativePublicSymbol::getAddressOffset() const { return Sym.Offset; }
  28. uint32_t NativePublicSymbol::getAddressSection() const { return Sym.Segment; }
  29. std::string NativePublicSymbol::getName() const {
  30. return std::string(Sym.Name);
  31. }
  32. uint32_t NativePublicSymbol::getRelativeVirtualAddress() const {
  33. return Session.getRVAFromSectOffset(Sym.Segment, Sym.Offset);
  34. }
  35. uint64_t NativePublicSymbol::getVirtualAddress() const {
  36. return Session.getVAFromSectOffset(Sym.Segment, Sym.Offset);
  37. }