NativePublicSymbol.cpp 1.8 KB

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