1 //===- NativeSession.h - Native implementation of IPDBSession ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H
11 #define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H
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"
29 class NativeSession : public IPDBSession {
31 NativeSession(std::unique_ptr<PDBFile> PdbFile,
32 std::unique_ptr<BumpPtrAllocator> Allocator);
33 ~NativeSession() override;
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);
40 std::unique_ptr<PDBSymbolCompiland>
41 createCompilandSymbol(DbiModuleDescriptor MI);
43 std::unique_ptr<PDBSymbolTypeEnum>
44 createEnumSymbol(codeview::TypeIndex Index);
46 std::unique_ptr<IPDBEnumSymbols>
47 createTypeEnumerator(codeview::TypeLeafKind Kind);
49 SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI);
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;
56 std::unique_ptr<PDBSymbol>
57 findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override;
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;
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;
84 std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
86 std::unique_ptr<IPDBEnumTables> getEnumTables() const override;
88 PDBFile &getPDBFile() { return *Pdb; }
89 const PDBFile &getPDBFile() const { return *Pdb; }
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;