Home | History | Annotate | Download | only in Native
      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 namespace pdb {
     26 class PDBFile;
     27 
     28 class NativeSession : public IPDBSession {
     29 public:
     30   NativeSession(std::unique_ptr<PDBFile> PdbFile,
     31                 std::unique_ptr<BumpPtrAllocator> Allocator);
     32   ~NativeSession() override;
     33 
     34   static Error createFromPdb(StringRef Path,
     35                              std::unique_ptr<IPDBSession> &Session);
     36   static Error createFromExe(StringRef Path,
     37                              std::unique_ptr<IPDBSession> &Session);
     38 
     39   std::unique_ptr<PDBSymbolCompiland>
     40   createCompilandSymbol(DbiModuleDescriptor MI);
     41 
     42   std::unique_ptr<PDBSymbolTypeEnum>
     43   createEnumSymbol(codeview::TypeIndex Index);
     44 
     45   std::unique_ptr<IPDBEnumSymbols>
     46   createTypeEnumerator(codeview::TypeLeafKind Kind);
     47 
     48   SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI);
     49 
     50   uint64_t getLoadAddress() const override;
     51   void setLoadAddress(uint64_t Address) override;
     52   std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
     53   std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
     54 
     55   std::unique_ptr<PDBSymbol>
     56   findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override;
     57 
     58   std::unique_ptr<IPDBEnumLineNumbers>
     59   findLineNumbers(const PDBSymbolCompiland &Compiland,
     60                   const IPDBSourceFile &File) const override;
     61   std::unique_ptr<IPDBEnumLineNumbers>
     62   findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override;
     63 
     64   std::unique_ptr<IPDBEnumSourceFiles>
     65   findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern,
     66                   PDB_NameSearchFlags Flags) const override;
     67   std::unique_ptr<IPDBSourceFile>
     68   findOneSourceFile(const PDBSymbolCompiland *Compiland,
     69                     llvm::StringRef Pattern,
     70                     PDB_NameSearchFlags Flags) const override;
     71   std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
     72   findCompilandsForSourceFile(llvm::StringRef Pattern,
     73                               PDB_NameSearchFlags Flags) const override;
     74   std::unique_ptr<PDBSymbolCompiland>
     75   findOneCompilandForSourceFile(llvm::StringRef Pattern,
     76                                 PDB_NameSearchFlags Flags) const override;
     77   std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const override;
     78   std::unique_ptr<IPDBEnumSourceFiles> getSourceFilesForCompiland(
     79       const PDBSymbolCompiland &Compiland) const override;
     80   std::unique_ptr<IPDBSourceFile>
     81   getSourceFileById(uint32_t FileId) const override;
     82 
     83   std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
     84 
     85   PDBFile &getPDBFile() { return *Pdb; }
     86   const PDBFile &getPDBFile() const { return *Pdb; }
     87 
     88 private:
     89   std::unique_ptr<PDBFile> Pdb;
     90   std::unique_ptr<BumpPtrAllocator> Allocator;
     91   std::vector<std::unique_ptr<NativeRawSymbol>> SymbolCache;
     92   DenseMap<codeview::TypeIndex, SymIndexId> TypeIndexToSymbolId;
     93 };
     94 }
     95 }
     96 
     97 #endif
     98