• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- IPDBSession.h - base interface for a PDB symbol context --*- 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_IPDBSESSION_H
11 #define LLVM_DEBUGINFO_PDB_IPDBSESSION_H
12 
13 #include "PDBTypes.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/Casting.h"
16 #include <memory>
17 
18 namespace llvm {
19 namespace pdb {
20 class PDBSymbolCompiland;
21 class PDBSymbolExe;
22 
23 /// IPDBSession defines an interface used to provide a context for querying
24 /// debug information from a debug data source (for example, a PDB).
25 class IPDBSession {
26 public:
27   virtual ~IPDBSession();
28 
29   virtual uint64_t getLoadAddress() const = 0;
30   virtual void setLoadAddress(uint64_t Address) = 0;
31   virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() const = 0;
32   virtual std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const = 0;
33 
34   template <typename T>
getConcreteSymbolById(uint32_t SymbolId)35   std::unique_ptr<T> getConcreteSymbolById(uint32_t SymbolId) const {
36     auto Symbol(getSymbolById(SymbolId));
37     if (!Symbol)
38       return nullptr;
39 
40     T *ConcreteSymbol = dyn_cast<T>(Symbol.get());
41     if (!ConcreteSymbol)
42       return nullptr;
43     Symbol.release();
44     return std::unique_ptr<T>(ConcreteSymbol);
45   }
46 
47   virtual std::unique_ptr<PDBSymbol>
48   findSymbolByAddress(uint64_t Address, PDB_SymType Type) const = 0;
49 
50   virtual std::unique_ptr<IPDBEnumLineNumbers>
51   findLineNumbers(const PDBSymbolCompiland &Compiland,
52                   const IPDBSourceFile &File) const = 0;
53   virtual std::unique_ptr<IPDBEnumLineNumbers>
54   findLineNumbersByAddress(uint64_t Address, uint32_t Length) const = 0;
55 
56   virtual std::unique_ptr<IPDBEnumSourceFiles>
57   findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern,
58                   PDB_NameSearchFlags Flags) const = 0;
59   virtual std::unique_ptr<IPDBSourceFile>
60   findOneSourceFile(const PDBSymbolCompiland *Compiland,
61                     llvm::StringRef Pattern,
62                     PDB_NameSearchFlags Flags) const = 0;
63   virtual std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
64   findCompilandsForSourceFile(llvm::StringRef Pattern,
65                               PDB_NameSearchFlags Flags) const = 0;
66   virtual std::unique_ptr<PDBSymbolCompiland>
67   findOneCompilandForSourceFile(llvm::StringRef Pattern,
68                                 PDB_NameSearchFlags Flags) const = 0;
69 
70   virtual std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const = 0;
71   virtual std::unique_ptr<IPDBEnumSourceFiles>
72   getSourceFilesForCompiland(const PDBSymbolCompiland &Compiland) const = 0;
73   virtual std::unique_ptr<IPDBSourceFile>
74   getSourceFileById(uint32_t FileId) const = 0;
75 
76   virtual std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const = 0;
77 };
78 }
79 }
80 
81 #endif
82