LLVM  3.7.0
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 
11 
46 #include <memory>
47 #include <utility>
48 
49 #include <memory>
50 #include <utility>
51 
52 using namespace llvm;
53 
55  std::unique_ptr<IPDBRawSymbol> Symbol)
56  : Session(PDBSession), RawSymbol(std::move(Symbol)) {}
57 
59 
60 #define FACTORY_SYMTAG_CASE(Tag, Type) \
61  case PDB_SymType::Tag: \
62  return std::unique_ptr<PDBSymbol>(new Type(PDBSession, std::move(Symbol)));
63 
64 std::unique_ptr<PDBSymbol>
65 PDBSymbol::create(const IPDBSession &PDBSession,
66  std::unique_ptr<IPDBRawSymbol> Symbol) {
67  switch (Symbol->getSymTag()) {
98  default:
99  return std::unique_ptr<PDBSymbol>(
100  new PDBSymbolUnknown(PDBSession, std::move(Symbol)));
101  }
102 }
103 
104 #define TRY_DUMP_TYPE(Type) \
105  if (const Type *DerivedThis = dyn_cast<Type>(this)) \
106  Dumper.dump(OS, Indent, *DerivedThis);
107 
108 #define ELSE_TRY_DUMP_TYPE(Type, Dumper) else TRY_DUMP_TYPE(Type, Dumper)
109 
110 void PDBSymbol::defaultDump(raw_ostream &OS, int Indent) const {
111  RawSymbol->dump(OS, Indent);
112 }
113 
114 PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); }
115 
116 std::unique_ptr<IPDBEnumSymbols> PDBSymbol::findAllChildren() const {
118 }
119 
120 std::unique_ptr<IPDBEnumSymbols>
122  return RawSymbol->findChildren(Type);
123 }
124 
125 std::unique_ptr<IPDBEnumSymbols>
127  PDB_NameSearchFlags Flags) const {
128  return RawSymbol->findChildren(Type, Name, Flags);
129 }
130 
131 std::unique_ptr<IPDBEnumSymbols>
133  PDB_NameSearchFlags Flags, uint32_t RVA) const {
134  return RawSymbol->findChildrenByRVA(Type, Name, Flags, RVA);
135 }
136 
137 std::unique_ptr<IPDBEnumSymbols>
138 PDBSymbol::findInlineFramesByRVA(uint32_t RVA) const {
139  return RawSymbol->findInlineFramesByRVA(RVA);
140 }
141 
142 std::unique_ptr<IPDBEnumSymbols>
144  std::unique_ptr<IPDBEnumSymbols> Result(findAllChildren());
145  Stats.clear();
146  while (auto Child = Result->getNext()) {
147  ++Stats[Child->getSymTag()];
148  }
149  Result->reset();
150  return Result;
151 }
std::unique_ptr< IPDBEnumSymbols > findInlineFramesByRVA(uint32_t RVA) const
Definition: PDBSymbol.cpp:138
std::unique_ptr< IPDBEnumSymbols > getChildStats(TagStats &Stats) const
Definition: PDBSymbol.cpp:143
PDB_SymType getSymTag() const
Definition: PDBSymbol.cpp:114
block placement Basic Block Placement Stats
static std::unique_ptr< PDBSymbol > create(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > Symbol)
Definition: PDBSymbol.cpp:65
ArrayType - Class to represent array types.
Definition: DerivedTypes.h:336
PointerType - Class to represent pointers.
Definition: DerivedTypes.h:449
PDB_NameSearchFlags
Defines flags used for enumerating child symbols.
Definition: PDBTypes.h:94
PDBSymbolCustom represents symbols that are compiler-specific and do not fit anywhere else in the lex...
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
virtual ~PDBSymbol()
Definition: PDBSymbol.cpp:58
std::unique_ptr< IPDBEnumSymbols > findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, uint32_t RVA) const
Definition: PDBSymbol.cpp:132
const std::unique_ptr< IPDBRawSymbol > RawSymbol
Definition: PDBSymbol.h:92
std::unique_ptr< IPDBEnumSymbols > findChildren(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags) const
Definition: PDBSymbol.cpp:126
std::unique_ptr< ConcreteSymbolEnumerator< T > > findAllChildren() const
Definition: PDBSymbol.h:67
IPDBSession defines an interface used to provide a context for querying debug information from a debu...
Definition: IPDBSession.h:24
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:270
#define FACTORY_SYMTAG_CASE(Tag, Type)
Definition: PDBSymbol.cpp:60
PDBSymbol(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > Symbol)
Definition: PDBSymbol.cpp:54
void defaultDump(raw_ostream &OS, int Indent) const
Definition: PDBSymbol.cpp:110
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:18