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