LLVM  8.0.1
PDBSymbolData.cpp
Go to the documentation of this file.
1 //===- PDBSymbolData.cpp - PDB data (e.g. variable) accessors ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
14 
15 #include <utility>
16 
17 using namespace llvm;
18 using namespace llvm::pdb;
19 
20 void PDBSymbolData::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); }
21 
22 std::unique_ptr<IPDBEnumLineNumbers> PDBSymbolData::getLineNumbers() const {
23  auto Len = RawSymbol->getLength();
24  Len = Len ? Len : 1;
25  if (auto RVA = RawSymbol->getRelativeVirtualAddress())
26  return Session.findLineNumbersByRVA(RVA, Len);
27 
28  if (auto Section = RawSymbol->getAddressSection())
31 
32  return nullptr;
33 }
34 
36  if (auto Lines = getLineNumbers()) {
37  if (auto FirstLine = Lines->getNext())
38  return FirstLine->getCompilandId();
39  }
40 
41  uint32_t DataSection = RawSymbol->getAddressSection();
42  uint32_t DataOffset = RawSymbol->getAddressOffset();
43  if (DataSection == 0) {
44  if (auto RVA = RawSymbol->getRelativeVirtualAddress())
45  Session.addressForRVA(RVA, DataSection, DataOffset);
46  }
47 
48  if (DataSection) {
49  if (auto SecContribs = Session.getSectionContribs()) {
50  while (auto Section = SecContribs->getNext()) {
51  if (Section->getAddressSection() == DataSection &&
52  Section->getAddressOffset() <= DataOffset &&
53  (Section->getAddressOffset() + Section->getLength()) > DataOffset)
54  return Section->getCompilandId();
55  }
56  }
57  } else {
58  auto LexParentId = RawSymbol->getLexicalParentId();
59  while (auto LexParent = Session.getSymbolById(LexParentId)) {
60  if (LexParent->getSymTag() == PDB_SymType::Exe)
61  break;
62  if (LexParent->getSymTag() == PDB_SymType::Compiland)
63  return LexParentId;
64  LexParentId = LexParent->getRawSymbol().getLexicalParentId();
65  }
66  }
67 
68  return 0;
69 }
virtual std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const =0
IPDBRawSymbol * RawSymbol
Definition: PDBSymbol.h:166
This class represents lattice values for constants.
Definition: AllocatorList.h:24
std::unique_ptr< IPDBEnumLineNumbers > getLineNumbers() const
virtual std::unique_ptr< PDBSymbol > getSymbolById(SymIndexId SymbolId) const =0
virtual std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, uint32_t Length) const =0
void dump(PDBSymDumper &Dumper) const override
Dumps the contents of a symbol a raw_ostream.
virtual uint32_t getAddressOffset() const =0
uint32_t getCompilandId() const
virtual uint32_t getRelativeVirtualAddress() const =0
virtual SymIndexId getLexicalParentId() const =0
virtual std::unique_ptr< IPDBEnumSectionContribs > getSectionContribs() const =0
virtual bool addressForRVA(uint32_t RVA, uint32_t &Section, uint32_t &Offset) const =0
virtual void dump(const PDBSymbolAnnotation &Symbol)
const IPDBSession & Session
Definition: PDBSymbol.h:164
virtual uint32_t getAddressSection() const =0
virtual uint64_t getLength() const =0