LLVM  7.0.0
NativeSession.h
Go to the documentation of this file.
1 //===- NativeSession.h - Native implementation of IPDBSession ---*- 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 
10 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H
11 #define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H
12 
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/Allocator.h"
22 #include "llvm/Support/Error.h"
23 
24 namespace llvm {
25 class MemoryBuffer;
26 namespace pdb {
27 class PDBFile;
28 
29 class NativeSession : public IPDBSession {
30 public:
31  NativeSession(std::unique_ptr<PDBFile> PdbFile,
32  std::unique_ptr<BumpPtrAllocator> Allocator);
33  ~NativeSession() override;
34 
35  static Error createFromPdb(std::unique_ptr<MemoryBuffer> MB,
36  std::unique_ptr<IPDBSession> &Session);
37  static Error createFromExe(StringRef Path,
38  std::unique_ptr<IPDBSession> &Session);
39 
40  std::unique_ptr<PDBSymbolCompiland>
42 
43  std::unique_ptr<PDBSymbolTypeEnum>
45 
46  std::unique_ptr<IPDBEnumSymbols>
48 
50 
51  uint64_t getLoadAddress() const override;
52  bool setLoadAddress(uint64_t Address) override;
53  std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
54  std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
55 
56  bool addressForVA(uint64_t VA, uint32_t &Section,
57  uint32_t &Offset) const override;
58  bool addressForRVA(uint32_t RVA, uint32_t &Section,
59  uint32_t &Offset) const override;
60 
61  std::unique_ptr<PDBSymbol>
62  findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override;
63  std::unique_ptr<PDBSymbol> findSymbolByRVA(uint32_t RVA,
64  PDB_SymType Type) const override;
65  std::unique_ptr<PDBSymbol>
67  PDB_SymType Type) const override;
68 
69  std::unique_ptr<IPDBEnumLineNumbers>
71  const IPDBSourceFile &File) const override;
72  std::unique_ptr<IPDBEnumLineNumbers>
73  findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override;
74  std::unique_ptr<IPDBEnumLineNumbers>
75  findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const override;
76  std::unique_ptr<IPDBEnumLineNumbers>
78  uint32_t Length) const override;
79 
80  std::unique_ptr<IPDBEnumSourceFiles>
81  findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern,
82  PDB_NameSearchFlags Flags) const override;
83  std::unique_ptr<IPDBSourceFile>
84  findOneSourceFile(const PDBSymbolCompiland *Compiland,
85  llvm::StringRef Pattern,
86  PDB_NameSearchFlags Flags) const override;
87  std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
89  PDB_NameSearchFlags Flags) const override;
90  std::unique_ptr<PDBSymbolCompiland>
92  PDB_NameSearchFlags Flags) const override;
93  std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const override;
94  std::unique_ptr<IPDBEnumSourceFiles> getSourceFilesForCompiland(
95  const PDBSymbolCompiland &Compiland) const override;
96  std::unique_ptr<IPDBSourceFile>
97  getSourceFileById(uint32_t FileId) const override;
98 
99  std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
100 
101  std::unique_ptr<IPDBEnumTables> getEnumTables() const override;
102 
103  std::unique_ptr<IPDBEnumInjectedSources> getInjectedSources() const override;
104 
105  std::unique_ptr<IPDBEnumSectionContribs> getSectionContribs() const override;
106 
107  PDBFile &getPDBFile() { return *Pdb; }
108  const PDBFile &getPDBFile() const { return *Pdb; }
109 
110 private:
111  std::unique_ptr<PDBFile> Pdb;
112  std::unique_ptr<BumpPtrAllocator> Allocator;
113  std::vector<std::unique_ptr<NativeRawSymbol>> SymbolCache;
114  DenseMap<codeview::TypeIndex, SymIndexId> TypeIndexToSymbolId;
115 };
116 } // namespace pdb
117 } // namespace llvm
118 
119 #endif
std::unique_ptr< IPDBEnumSourceFiles > getAllSourceFiles() const override
static Error createFromExe(StringRef Path, std::unique_ptr< IPDBSession > &Session)
std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, uint32_t Length) const override
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
std::unique_ptr< IPDBEnumSectionContribs > getSectionContribs() const override
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:34
PDB_NameSearchFlags
Defines flags used for enumerating child symbols.
Definition: PDBTypes.h:97
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
std::unique_ptr< PDBSymbol > findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override
IPDBSourceFile defines an interface used to represent source files whose information are stored in th...
std::unique_ptr< IPDBEnumSourceFiles > findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override
std::unique_ptr< IPDBEnumTables > getEnumTables() const override
std::unique_ptr< PDBSymbolTypeEnum > createEnumSymbol(codeview::TypeIndex Index)
A 32-bit type reference.
Definition: TypeIndex.h:96
std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersByRVA(uint32_t RVA, uint32_t Length) 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:179
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
std::unique_ptr< PDBSymbol > findSymbolByRVA(uint32_t RVA, PDB_SymType Type) const override
uint64_t getLoadAddress() const override
std::unique_ptr< IPDBEnumLineNumbers > findLineNumbers(const PDBSymbolCompiland &Compiland, const IPDBSourceFile &File) const override
std::unique_ptr< PDBSymbol > findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type) const override
std::unique_ptr< IPDBEnumSourceFiles > getSourceFilesForCompiland(const PDBSymbolCompiland &Compiland) const override
std::unique_ptr< IPDBEnumSymbols > createTypeEnumerator(codeview::TypeLeafKind Kind)
std::unique_ptr< PDBSymbolExe > getGlobalScope() override
bool setLoadAddress(uint64_t Address) override
std::unique_ptr< PDBSymbolCompiland > createCompilandSymbol(DbiModuleDescriptor MI)
std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override
std::unique_ptr< PDBSymbolCompiland > findOneCompilandForSourceFile(llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override
std::unique_ptr< IPDBSourceFile > getSourceFileById(uint32_t FileId) const override
NativeSession(std::unique_ptr< PDBFile > PdbFile, std::unique_ptr< BumpPtrAllocator > Allocator)
std::unique_ptr< IPDBEnumChildren< PDBSymbolCompiland > > findCompilandsForSourceFile(llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override
std::unique_ptr< IPDBSourceFile > findOneSourceFile(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override
const unsigned Kind
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI)
static Error createFromPdb(std::unique_ptr< MemoryBuffer > MB, std::unique_ptr< IPDBSession > &Session)
bool addressForRVA(uint32_t RVA, uint32_t &Section, uint32_t &Offset) const override
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
std::unique_ptr< IPDBEnumDataStreams > getDebugStreams() const override
bool addressForVA(uint64_t VA, uint32_t &Section, uint32_t &Offset) const override
std::unique_ptr< IPDBEnumInjectedSources > getInjectedSources() const override
std::unique_ptr< PDBSymbol > getSymbolById(uint32_t SymbolId) const override
const PDBFile & getPDBFile() const