LLVM  14.0.0git
NativeExeSymbol.cpp
Go to the documentation of this file.
1 //===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "llvm/ADT/STLExtras.h"
19 
20 using namespace llvm;
21 using namespace llvm::pdb;
22 
25  if (DbiS)
26  return &DbiS.get();
27 
28  consumeError(DbiS.takeError());
29  return nullptr;
30 }
31 
33  : NativeRawSymbol(Session, PDB_SymType::Exe, SymbolId),
34  Dbi(getDbiStreamPtr(Session)) {}
35 
36 std::unique_ptr<IPDBEnumSymbols>
38  switch (Type) {
40  return std::unique_ptr<IPDBEnumSymbols>(new NativeEnumModules(Session));
41  break;
42  }
44  return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ARRAY);
45  case PDB_SymType::Enum:
46  return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);
48  return Session.getSymbolCache().createTypeEnumerator(codeview::LF_POINTER);
49  case PDB_SymType::UDT:
51  {codeview::LF_STRUCTURE, codeview::LF_CLASS, codeview::LF_UNION,
52  codeview::LF_INTERFACE});
54  return Session.getSymbolCache().createTypeEnumerator(codeview::LF_VTSHAPE);
57  {codeview::LF_PROCEDURE, codeview::LF_MFUNCTION});
59  return Session.getSymbolCache().createGlobalsEnumerator(codeview::S_UDT);
60 
61  default:
62  break;
63  }
64  return nullptr;
65 }
66 
68  auto IS = Session.getPDBFile().getPDBInfoStream();
69  if (IS)
70  return IS->getAge();
71  consumeError(IS.takeError());
72  return 0;
73 }
74 
76  return std::string(Session.getPDBFile().getFilePath());
77 }
78 
80  auto IS = Session.getPDBFile().getPDBInfoStream();
81  if (IS)
82  return IS->getGuid();
83  consumeError(IS.takeError());
84  return codeview::GUID{{0}};
85 }
86 
88  auto Dbi = Session.getPDBFile().getPDBDbiStream();
89  if (Dbi)
90  return Dbi->hasCTypes();
91  consumeError(Dbi.takeError());
92  return false;
93 }
94 
96  auto Dbi = Session.getPDBFile().getPDBDbiStream();
97  if (Dbi)
98  return !Dbi->isStripped();
99  consumeError(Dbi.takeError());
100  return false;
101 }
llvm::pdb::NativeEnumModules
Definition: NativeEnumModules.h:19
llvm::pdb::DbiStream::isStripped
bool isStripped() const
Definition: DbiStream.cpp:172
llvm::pdb::SymbolCache::createTypeEnumerator
std::unique_ptr< IPDBEnumSymbols > createTypeEnumerator(codeview::TypeLeafKind Kind)
Definition: SymbolCache.cpp:84
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::pdb::PDB_SymType::FunctionSig
@ FunctionSig
llvm::pdb::NativeExeSymbol::findChildren
std::unique_ptr< IPDBEnumSymbols > findChildren(PDB_SymType Type) const override
Definition: NativeExeSymbol.cpp:37
NativeCompilandSymbol.h
llvm::pdb::PDBFile::getFilePath
StringRef getFilePath() const
Definition: PDBFile.cpp:49
llvm::pdb::NativeSession::getPDBFile
PDBFile & getPDBFile()
Definition: NativeSession.h:105
llvm::codeview::GUID
This represents the 'GUID' type from windows.h.
Definition: GUID.h:21
llvm::pdb::PDB_SymType::PointerType
@ PointerType
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
STLExtras.h
llvm::pdb::DbiStream
Definition: DbiStream.h:37
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1045
llvm::pdb::PDB_SymType
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:243
llvm::pdb::NativeExeSymbol::hasCTypes
bool hasCTypes() const override
Definition: NativeExeSymbol.cpp:87
NativeEnumModules.h
getDbiStreamPtr
static DbiStream * getDbiStreamPtr(NativeSession &Session)
Definition: NativeExeSymbol.cpp:23
llvm::pdb::PDB_SymType::UDT
@ UDT
llvm::pdb::PDBFile::getPDBDbiStream
Expected< DbiStream & > getPDBDbiStream()
Definition: PDBFile.cpp:289
llvm::pdb::PDB_SymType::ArrayType
@ ArrayType
llvm::pdb::NativeExeSymbol::getSymbolsFileName
std::string getSymbolsFileName() const override
Definition: NativeExeSymbol.cpp:75
llvm::pdb::NativeExeSymbol::getAge
uint32_t getAge() const override
Definition: NativeExeSymbol.cpp:67
llvm::pdb::PDB_SymType::VTableShape
@ VTableShape
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::pdb::NativeExeSymbol::hasPrivateSymbols
bool hasPrivateSymbols() const override
Definition: NativeExeSymbol.cpp:95
PDBSymbolCompiland.h
llvm::pdb::NativeSession::getSymbolCache
SymbolCache & getSymbolCache()
Definition: NativeSession.h:109
llvm::pdb::DbiStream::hasCTypes
bool hasCTypes() const
Definition: DbiStream.cpp:168
llvm::pdb::PDBFile::getPDBInfoStream
Expected< InfoStream & > getPDBInfoStream()
Definition: PDBFile.cpp:276
DbiStream.h
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition: Error.h:569
uint32_t
llvm::pdb::PDB_SymType::Enum
@ Enum
llvm::pdb::NativeExeSymbol::NativeExeSymbol
NativeExeSymbol(NativeSession &Session, SymIndexId Id)
Definition: NativeExeSymbol.cpp:32
llvm::pdb::PDB_SymType::Compiland
@ Compiland
llvm::pdb::NativeSession
Definition: NativeSession.h:28
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:599
InfoStream.h
llvm::pdb::PDB_SymType::Typedef
@ Typedef
PDBFile.h
llvm::pdb::PDB_SymType::Exe
@ Exe
SymbolCache.h
llvm::pdb::NativeRawSymbol::Session
NativeSession & Session
Definition: NativeRawSymbol.h:232
llvm::pdb::NativeExeSymbol::getGuid
codeview::GUID getGuid() const override
Definition: NativeExeSymbol.cpp:79
NativeExeSymbol.h
llvm::pdb::NativeRawSymbol
Definition: NativeRawSymbol.h:21
llvm::pdb::SymbolCache::createGlobalsEnumerator
std::unique_ptr< IPDBEnumSymbols > createGlobalsEnumerator(codeview::SymbolKind Kind)
Definition: SymbolCache.cpp:101