LLVM  8.0.1
NativeExeSymbol.cpp
Go to the documentation of this file.
1 //===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- 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 
12 #include "llvm/ADT/STLExtras.h"
20 
21 using namespace llvm;
22 using namespace llvm::pdb;
23 
26  if (DbiS)
27  return &DbiS.get();
28 
29  consumeError(DbiS.takeError());
30  return nullptr;
31 }
32 
34  : NativeRawSymbol(Session, PDB_SymType::Exe, SymbolId),
35  Dbi(getDbiStreamPtr(Session)) {}
36 
37 std::unique_ptr<IPDBEnumSymbols>
39  switch (Type) {
41  return std::unique_ptr<IPDBEnumSymbols>(new NativeEnumModules(Session));
42  break;
43  }
45  return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ARRAY);
46  case PDB_SymType::Enum:
47  return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);
49  return Session.getSymbolCache().createTypeEnumerator(codeview::LF_POINTER);
50  case PDB_SymType::UDT:
52  {codeview::LF_STRUCTURE, codeview::LF_CLASS, codeview::LF_UNION,
53  codeview::LF_INTERFACE});
55  return Session.getSymbolCache().createTypeEnumerator(codeview::LF_VTSHAPE);
58  {codeview::LF_PROCEDURE, codeview::LF_MFUNCTION});
60  return Session.getSymbolCache().createGlobalsEnumerator(codeview::S_UDT);
61 
62  default:
63  break;
64  }
65  return nullptr;
66 }
67 
69  auto IS = Session.getPDBFile().getPDBInfoStream();
70  if (IS)
71  return IS->getAge();
72  consumeError(IS.takeError());
73  return 0;
74 }
75 
77  return Session.getPDBFile().getFilePath();
78 }
79 
81  auto IS = Session.getPDBFile().getPDBInfoStream();
82  if (IS)
83  return IS->getGuid();
84  consumeError(IS.takeError());
85  return codeview::GUID{{0}};
86 }
87 
89  auto Dbi = Session.getPDBFile().getPDBDbiStream();
90  if (Dbi)
91  return Dbi->hasCTypes();
92  consumeError(Dbi.takeError());
93  return false;
94 }
95 
97  auto Dbi = Session.getPDBFile().getPDBDbiStream();
98  if (Dbi)
99  return !Dbi->isStripped();
100  consumeError(Dbi.takeError());
101  return false;
102 }
std::unique_ptr< IPDBEnumSymbols > createGlobalsEnumerator(codeview::SymbolKind Kind)
Definition: SymbolCache.cpp:91
std::string getSymbolsFileName() const override
This class represents lattice values for constants.
Definition: AllocatorList.h:24
std::unique_ptr< IPDBEnumSymbols > createTypeEnumerator(codeview::TypeLeafKind Kind)
Definition: SymbolCache.cpp:74
codeview::GUID getGuid() const override
Error takeError()
Take ownership of the stored error.
Definition: Error.h:553
static DbiStream * getDbiStreamPtr(NativeSession &Session)
bool isStripped() const
Definition: DbiStream.cpp:171
This represents the &#39;GUID&#39; type from windows.h.
Definition: GUID.h:22
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
uint32_t getAge() const override
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:183
bool hasCTypes() const override
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) const override
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:982
Expected< DbiStream & > getPDBDbiStream()
Definition: PDBFile.cpp:287
NativeExeSymbol(NativeSession &Session, SymIndexId Id)
reference get()
Returns a reference to the stored T value.
Definition: Error.h:533
StringRef getFilePath() const
Definition: PDBFile.cpp:48
bool hasPrivateSymbols() const override
SymbolCache & getSymbolCache()
Expected< InfoStream & > getPDBInfoStream()
Definition: PDBFile.cpp:274
bool hasCTypes() const
Definition: DbiStream.cpp:167