LLVM  7.0.0
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 
21  std::unique_ptr<IPDBRawSymbol> DataSymbol)
22  : PDBSymbol(PDBSession, std::move(DataSymbol)) {
23  assert(RawSymbol->getSymTag() == PDB_SymType::Data);
24 }
25 
26 void PDBSymbolData::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); }
27 
28 std::unique_ptr<IPDBEnumLineNumbers> PDBSymbolData::getLineNumbers() const {
29  auto Len = RawSymbol->getLength();
30  Len = Len ? Len : 1;
31  if (auto RVA = RawSymbol->getRelativeVirtualAddress())
32  return Session.findLineNumbersByRVA(RVA, Len);
33 
34  if (auto Section = RawSymbol->getAddressSection())
36  Section, RawSymbol->getAddressOffset(), Len);
37 
38  return nullptr;
39 }
40 
42  if (auto Lines = getLineNumbers()) {
43  if (auto FirstLine = Lines->getNext())
44  return FirstLine->getCompilandId();
45  }
46 
47  uint32_t DataSection = RawSymbol->getAddressSection();
48  uint32_t DataOffset = RawSymbol->getAddressOffset();
49  if (DataSection == 0) {
50  if (auto RVA = RawSymbol->getRelativeVirtualAddress())
51  Session.addressForRVA(RVA, DataSection, DataOffset);
52  }
53 
54  if (DataSection) {
55  if (auto SecContribs = Session.getSectionContribs()) {
56  while (auto Section = SecContribs->getNext()) {
57  if (Section->getAddressSection() == DataSection &&
58  Section->getAddressOffset() <= DataOffset &&
59  (Section->getAddressOffset() + Section->getLength()) > DataOffset)
60  return Section->getCompilandId();
61  }
62  }
63  } else {
64  auto LexParentId = RawSymbol->getLexicalParentId();
65  while (auto LexParent = Session.getSymbolById(LexParentId)) {
66  if (LexParent->getSymTag() == PDB_SymType::Exe)
67  break;
68  if (LexParent->getSymTag() == PDB_SymType::Compiland)
69  return LexParentId;
70  LexParentId = LexParent->getRawSymbol().getLexicalParentId();
71  }
72  }
73 
74  return 0;
75 }
virtual std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const =0
IPDBSession defines an interface used to provide a context for querying debug information from a debu...
Definition: IPDBSession.h:26
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
std::unique_ptr< IPDBRawSymbol > RawSymbol
Definition: PDBSymbol.h:134
Definition: BitVector.h:921
PDBSymbolData(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > DataSymbol)
std::unique_ptr< IPDBEnumLineNumbers > getLineNumbers() const
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.
uint32_t getCompilandId() const
virtual std::unique_ptr< IPDBEnumSectionContribs > getSectionContribs() const =0
virtual std::unique_ptr< PDBSymbol > getSymbolById(uint32_t SymbolId) const =0
PDBSymbol defines the base of the inheritance hierarchy for concrete symbol types (e...
Definition: PDBSymbol.h:61
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:133
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())