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