LLVM  7.0.0svn
PDBSymbol.cpp
Go to the documentation of this file.
1 //===- PDBSymbol.cpp - base class for user-facing symbol types --*- 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 
47 #include <algorithm>
48 #include <memory>
49 
50 using namespace llvm;
51 using namespace llvm::pdb;
52 
54  std::unique_ptr<IPDBRawSymbol> Symbol)
55  : Session(PDBSession), RawSymbol(std::move(Symbol)) {}
56 
58  : Session(Symbol.Session), RawSymbol(std::move(Symbol.RawSymbol)) {}
59 
60 PDBSymbol::~PDBSymbol() = default;
61 
62 #define FACTORY_SYMTAG_CASE(Tag, Type) \
63  case PDB_SymType::Tag: \
64  return std::unique_ptr<PDBSymbol>(new Type(PDBSession, std::move(Symbol)));
65 
66 std::unique_ptr<PDBSymbol>
67 PDBSymbol::create(const IPDBSession &PDBSession,
68  std::unique_ptr<IPDBRawSymbol> Symbol) {
69  switch (Symbol->getSymTag()) {
100  default:
101  return std::unique_ptr<PDBSymbol>(
102  new PDBSymbolUnknown(PDBSession, std::move(Symbol)));
103  }
104 }
105 
106 void PDBSymbol::defaultDump(raw_ostream &OS, int Indent) const {
107  RawSymbol->dump(OS, Indent);
108 }
109 
111  outs() << "\n";
112  defaultDump(outs(), 0);
113  outs().flush();
114 }
115 
117  TagStats Stats;
118  getChildStats(Stats);
119  outs() << "\n";
120  for (auto &Stat : Stats) {
121  outs() << Stat.first << ": " << Stat.second << "\n";
122  }
123  outs().flush();
124 }
125 
126 std::unique_ptr<PDBSymbol> PDBSymbol::clone() const {
128 }
129 
130 PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); }
131 uint32_t PDBSymbol::getSymIndexId() const { return RawSymbol->getSymIndexId(); }
132 
133 std::unique_ptr<IPDBEnumSymbols> PDBSymbol::findAllChildren() const {
135 }
136 
137 std::unique_ptr<IPDBEnumSymbols>
139  return RawSymbol->findChildren(Type);
140 }
141 
142 std::unique_ptr<IPDBEnumSymbols>
144  PDB_NameSearchFlags Flags) const {
145  return RawSymbol->findChildren(Type, Name, Flags);
146 }
147 
148 std::unique_ptr<IPDBEnumSymbols>
150  PDB_NameSearchFlags Flags, uint32_t RVA) const {
151  return RawSymbol->findChildrenByRVA(Type, Name, Flags, RVA);
152 }
153 
154 std::unique_ptr<IPDBEnumSymbols>
156  return RawSymbol->findInlineFramesByRVA(RVA);
157 }
158 
159 std::unique_ptr<IPDBEnumSymbols>
161  std::unique_ptr<IPDBEnumSymbols> Result(findAllChildren());
162  if (!Result)
163  return nullptr;
164  Stats.clear();
165  while (auto Child = Result->getNext()) {
166  ++Stats[Child->getSymTag()];
167  }
168  Result->reset();
169  return Result;
170 }
171 
172 std::unique_ptr<PDBSymbol> PDBSymbol::getSymbolByIdHelper(uint32_t Id) const {
173  return Session.getSymbolById(Id);
174 }
void defaultDump(raw_ostream &OS, int Indent) const
Definition: PDBSymbol.cpp:106
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
PDBSymbolCustom represents symbols that are compiler-specific and do not fit anywhere else in the lex...
PDB_NameSearchFlags
Defines flags used for enumerating child symbols.
Definition: PDBTypes.h:97
std::unique_ptr< ConcreteSymbolEnumerator< T > > findAllChildren() const
Definition: PDBSymbol.h:100
std::unique_ptr< IPDBRawSymbol > RawSymbol
Definition: PDBSymbol.h:134
PDBSymbol(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > Symbol)
Definition: PDBSymbol.cpp:53
Definition: BitVector.h:921
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:23
static std::unique_ptr< PDBSymbol > create(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > Symbol)
Definition: PDBSymbol.cpp:67
block placement Basic Block Placement Stats
std::unique_ptr< IPDBEnumSymbols > getChildStats(TagStats &Stats) const
Definition: PDBSymbol.cpp:160
Class to represent array types.
Definition: DerivedTypes.h:369
Class to represent pointers.
Definition: DerivedTypes.h:467
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx.
Definition: PDBTypes.h:179
raw_ostream & outs()
This returns a reference to a raw_ostream for standard output.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
std::unique_ptr< IPDBEnumSymbols > findChildren(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags) const
Definition: PDBSymbol.cpp:143
std::unique_ptr< PDBSymbol > getSymbolByIdHelper(uint32_t Id) const
Definition: PDBSymbol.cpp:172
PDB_SymType getSymTag() const
Definition: PDBSymbol.cpp:130
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
#define FACTORY_SYMTAG_CASE(Tag, Type)
Definition: PDBSymbol.cpp:62
const IPDBSession & Session
Definition: PDBSymbol.h:133
std::unique_ptr< IPDBEnumSymbols > findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, uint32_t RVA) const
Definition: PDBSymbol.cpp:149
void dumpProperties() const
Definition: PDBSymbol.cpp:110
std::unique_ptr< IPDBEnumSymbols > findInlineFramesByRVA(uint32_t RVA) const
Definition: PDBSymbol.cpp:155
uint32_t getSymIndexId() const
Definition: PDBSymbol.cpp:131
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
void dumpChildStats() const
Definition: PDBSymbol.cpp:116
std::unique_ptr< PDBSymbol > clone() const
Definition: PDBSymbol.cpp:126