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 | |
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 | |
24 | 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: "name" , Value: getName(), Indent); |
29 | dumpSymbolField(OS, Name: "offset" , Value: getAddressOffset(), Indent); |
30 | dumpSymbolField(OS, Name: "section" , Value: getAddressSection(), Indent); |
31 | } |
32 | |
33 | uint32_t NativePublicSymbol::getAddressOffset() const { return Sym.Offset; } |
34 | |
35 | uint32_t NativePublicSymbol::getAddressSection() const { return Sym.Segment; } |
36 | |
37 | std::string NativePublicSymbol::getName() const { |
38 | return std::string(Sym.Name); |
39 | } |
40 | |
41 | uint32_t NativePublicSymbol::getRelativeVirtualAddress() const { |
42 | return Session.getRVAFromSectOffset(Section: Sym.Segment, Offset: Sym.Offset); |
43 | } |
44 | |
45 | uint64_t NativePublicSymbol::getVirtualAddress() const { |
46 | return Session.getVAFromSectOffset(Section: Sym.Segment, Offset: Sym.Offset); |
47 | } |
48 | |