• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 #include "llvm/DebugInfo/PDB/Native/NativePublicSymbol.h"
10 
11 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
12 #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
13 #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
14 
15 using namespace llvm;
16 using namespace llvm::codeview;
17 using namespace llvm::pdb;
18 
NativePublicSymbol(NativeSession & Session,SymIndexId Id,const codeview::PublicSym32 & Sym)19 NativePublicSymbol::NativePublicSymbol(NativeSession &Session, SymIndexId Id,
20                                        const codeview::PublicSym32 &Sym)
21     : NativeRawSymbol(Session, PDB_SymType::PublicSymbol, Id), Sym(Sym) {}
22 
~NativePublicSymbol()23 NativePublicSymbol::~NativePublicSymbol() {}
24 
dump(raw_ostream & OS,int Indent,PdbSymbolIdField ShowIdFields,PdbSymbolIdField RecurseIdFields) const25 void NativePublicSymbol::dump(raw_ostream &OS, int Indent,
26                               PdbSymbolIdField ShowIdFields,
27                               PdbSymbolIdField RecurseIdFields) const {
28   NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
29   dumpSymbolField(OS, "name", getName(), Indent);
30   dumpSymbolField(OS, "offset", getAddressOffset(), Indent);
31   dumpSymbolField(OS, "section", getAddressSection(), Indent);
32 }
33 
getAddressOffset() const34 uint32_t NativePublicSymbol::getAddressOffset() const { return Sym.Offset; }
35 
getAddressSection() const36 uint32_t NativePublicSymbol::getAddressSection() const { return Sym.Segment; }
37 
getName() const38 std::string NativePublicSymbol::getName() const {
39   return std::string(Sym.Name);
40 }
41 
getRelativeVirtualAddress() const42 uint32_t NativePublicSymbol::getRelativeVirtualAddress() const {
43   return Session.getRVAFromSectOffset(Sym.Segment, Sym.Offset);
44 }
45 
getVirtualAddress() const46 uint64_t NativePublicSymbol::getVirtualAddress() const {
47   return Session.getVAFromSectOffset(Sym.Segment, Sym.Offset);
48 }
49