]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/PDB/Native/NativeSession.h
Merge ^/head r327341 through r327623.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / PDB / Native / NativeSession.h
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"
15 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
16 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
17 #include "llvm/DebugInfo/PDB/IPDBSession.h"
18 #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
19 #include "llvm/DebugInfo/PDB/Native/NativeBuiltinSymbol.h"
20 #include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.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>
41   createCompilandSymbol(DbiModuleDescriptor MI);
42
43   std::unique_ptr<PDBSymbolTypeEnum>
44   createEnumSymbol(codeview::TypeIndex Index);
45
46   std::unique_ptr<IPDBEnumSymbols>
47   createTypeEnumerator(codeview::TypeLeafKind Kind);
48
49   SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI);
50
51   uint64_t getLoadAddress() const override;
52   void 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   std::unique_ptr<PDBSymbol>
57   findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override;
58
59   std::unique_ptr<IPDBEnumLineNumbers>
60   findLineNumbers(const PDBSymbolCompiland &Compiland,
61                   const IPDBSourceFile &File) const override;
62   std::unique_ptr<IPDBEnumLineNumbers>
63   findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override;
64
65   std::unique_ptr<IPDBEnumSourceFiles>
66   findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern,
67                   PDB_NameSearchFlags Flags) const override;
68   std::unique_ptr<IPDBSourceFile>
69   findOneSourceFile(const PDBSymbolCompiland *Compiland,
70                     llvm::StringRef Pattern,
71                     PDB_NameSearchFlags Flags) const override;
72   std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
73   findCompilandsForSourceFile(llvm::StringRef Pattern,
74                               PDB_NameSearchFlags Flags) const override;
75   std::unique_ptr<PDBSymbolCompiland>
76   findOneCompilandForSourceFile(llvm::StringRef Pattern,
77                                 PDB_NameSearchFlags Flags) const override;
78   std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const override;
79   std::unique_ptr<IPDBEnumSourceFiles> getSourceFilesForCompiland(
80       const PDBSymbolCompiland &Compiland) const override;
81   std::unique_ptr<IPDBSourceFile>
82   getSourceFileById(uint32_t FileId) const override;
83
84   std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
85
86   std::unique_ptr<IPDBEnumTables> getEnumTables() const override;
87
88   PDBFile &getPDBFile() { return *Pdb; }
89   const PDBFile &getPDBFile() const { return *Pdb; }
90
91 private:
92   std::unique_ptr<PDBFile> Pdb;
93   std::unique_ptr<BumpPtrAllocator> Allocator;
94   std::vector<std::unique_ptr<NativeRawSymbol>> SymbolCache;
95   DenseMap<codeview::TypeIndex, SymIndexId> TypeIndexToSymbolId;
96 };
97 }
98 }
99
100 #endif