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
14using namespace llvm;
15using namespace llvm::codeview;
16using namespace llvm::pdb;
17
18NativePublicSymbol::NativePublicSymbol(NativeSession &Session, SymIndexId Id,
19 const codeview::PublicSym32 &Sym)
20 : NativeRawSymbol(Session, PDB_SymType::PublicSymbol, Id), Sym(Sym) {}
21
22NativePublicSymbol::~NativePublicSymbol() = default;
23
24void 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: "name", Value: getName(), Indent);
29 dumpSymbolField(OS, Name: "offset", Value: getAddressOffset(), Indent);
30 dumpSymbolField(OS, Name: "section", Value: getAddressSection(), Indent);
31}
32
33uint32_t NativePublicSymbol::getAddressOffset() const { return Sym.Offset; }
34
35uint32_t NativePublicSymbol::getAddressSection() const { return Sym.Segment; }
36
37std::string NativePublicSymbol::getName() const {
38 return std::string(Sym.Name);
39}
40
41uint32_t NativePublicSymbol::getRelativeVirtualAddress() const {
42 return Session.getRVAFromSectOffset(Section: Sym.Segment, Offset: Sym.Offset);
43}
44
45uint64_t NativePublicSymbol::getVirtualAddress() const {
46 return Session.getVAFromSectOffset(Section: Sym.Segment, Offset: Sym.Offset);
47}
48

source code of llvm/lib/DebugInfo/PDB/Native/NativePublicSymbol.cpp