blob: 1cd197b60d1dab73c0623af7a2d9340815e6ff24 [file] [log] [blame]
Zachary Turner307f5ae2018-10-12 19:47:13 +00001//===-- SymbolFileNativePDB.h -----------------------------------*- 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 lldb_Plugins_SymbolFile_PDB_SymbolFileNativePDB_h_
11#define lldb_Plugins_SymbolFile_PDB_SymbolFileNativePDB_h_
12
13#include "lldb/Core/UniqueCStringMap.h"
14#include "lldb/Symbol/SymbolFile.h"
15#include "lldb/Symbol/VariableList.h"
16#include "lldb/Utility/UserID.h"
17
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/Optional.h"
20#include "llvm/DebugInfo/CodeView/CVRecord.h"
21#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
22#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
23#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
24#include "llvm/DebugInfo/PDB/PDBTypes.h"
25
26#include "CompileUnitIndex.h"
27#include "PdbIndex.h"
28
29#include <unordered_map>
30
31namespace llvm {
32namespace pdb {
33class PDBFile;
34class PDBSymbol;
35class PDBSymbolCompiland;
36class PDBSymbolData;
37class PDBSymbolFunc;
38
39class DbiStream;
40class TpiStream;
41class TpiStream;
42class InfoStream;
43class PublicsStream;
44class GlobalsStream;
45class SymbolStream;
46class ModuleDebugStreamRef;
47} // namespace pdb
48} // namespace llvm
49
50namespace lldb_private {
51namespace npdb {
52
53class SymbolFileNativePDB : public lldb_private::SymbolFile {
54public:
55 //------------------------------------------------------------------
56 // Static Functions
57 //------------------------------------------------------------------
58 static void Initialize();
59
60 static void Terminate();
61
62 static void DebuggerInitialize(lldb_private::Debugger &debugger);
63
64 static lldb_private::ConstString GetPluginNameStatic();
65
66 static const char *GetPluginDescriptionStatic();
67
68 static lldb_private::SymbolFile *
69 CreateInstance(lldb_private::ObjectFile *obj_file);
70
71 //------------------------------------------------------------------
72 // Constructors and Destructors
73 //------------------------------------------------------------------
74 SymbolFileNativePDB(lldb_private::ObjectFile *ofile);
75
76 ~SymbolFileNativePDB() override;
77
78 uint32_t CalculateAbilities() override;
79
80 void InitializeObject() override;
81
82 //------------------------------------------------------------------
83 // Compile Unit function calls
84 //------------------------------------------------------------------
85
86 uint32_t GetNumCompileUnits() override;
87
88 lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
89
90 lldb::LanguageType
91 ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) override;
92
93 size_t
94 ParseCompileUnitFunctions(const lldb_private::SymbolContext &sc) override;
95
96 bool
97 ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc) override;
98
99 bool
100 ParseCompileUnitDebugMacros(const lldb_private::SymbolContext &sc) override;
101
102 bool ParseCompileUnitSupportFiles(
103 const lldb_private::SymbolContext &sc,
104 lldb_private::FileSpecList &support_files) override;
105
106 bool ParseImportedModules(
107 const lldb_private::SymbolContext &sc,
108 std::vector<lldb_private::ConstString> &imported_modules) override;
109
110 size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override;
111
112 size_t ParseTypes(const lldb_private::SymbolContext &sc) override {
113 return 0;
114 }
115 size_t
116 ParseVariablesForContext(const lldb_private::SymbolContext &sc) override {
117 return 0;
118 }
119 lldb_private::Type *ResolveTypeUID(lldb::user_id_t type_uid) override {
120 return nullptr;
121 }
122 bool CompleteType(lldb_private::CompilerType &compiler_type) override {
123 return false;
124 }
125 uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr,
126 uint32_t resolve_scope,
127 lldb_private::SymbolContext &sc) override;
128
129 virtual size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
130 uint32_t type_mask,
131 lldb_private::TypeList &type_list) override {
132 return 0;
133 }
134
135 uint32_t
136 FindFunctions(const lldb_private::ConstString &name,
137 const lldb_private::CompilerDeclContext *parent_decl_ctx,
138 uint32_t name_type_mask, bool include_inlines, bool append,
139 lldb_private::SymbolContextList &sc_list) override;
140
141 uint32_t FindFunctions(const lldb_private::RegularExpression &regex,
142 bool include_inlines, bool append,
143 lldb_private::SymbolContextList &sc_list) override;
144
145 lldb_private::TypeSystem *
146 GetTypeSystemForLanguage(lldb::LanguageType language) override;
147
148 lldb_private::CompilerDeclContext FindNamespace(
149 const lldb_private::SymbolContext &sc,
150 const lldb_private::ConstString &name,
151 const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
152
153 lldb_private::ConstString GetPluginName() override;
154
155 uint32_t GetPluginVersion() override;
156
157 llvm::pdb::PDBFile &GetPDBFile() { return m_index->pdb(); }
158 const llvm::pdb::PDBFile &GetPDBFile() const { return m_index->pdb(); }
159
160private:
161 lldb::FunctionSP GetOrCreateFunction(PdbSymUid func_uid,
162 const SymbolContext &sc);
163 lldb::CompUnitSP GetOrCreateCompileUnit(const CompilandIndexItem &cci);
164
165 lldb::FunctionSP CreateFunction(PdbSymUid func_uid, const SymbolContext &sc);
166 lldb::CompUnitSP CreateCompileUnit(const CompilandIndexItem &cci);
167
168 llvm::BumpPtrAllocator m_allocator;
169
170 lldb::addr_t m_obj_load_address = 0;
171
172 std::unique_ptr<PdbIndex> m_index;
173
174 llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions;
175 llvm::DenseMap<lldb::user_id_t, lldb::CompUnitSP> m_compilands;
176};
177
178} // namespace npdb
179} // namespace lldb_private
180
181#endif // lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_