1 //===-- SymbolFileNativePDB.cpp ---------------------------------*- 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 #include "SymbolFileNativePDB.h"
11 
12 #include "clang/Lex/Lexer.h"
13 
14 #include "lldb/Core/Module.h"
15 #include "lldb/Core/PluginManager.h"
16 #include "lldb/Symbol/CompileUnit.h"
17 #include "lldb/Symbol/LineTable.h"
18 #include "lldb/Symbol/ObjectFile.h"
19 #include "lldb/Symbol/SymbolContext.h"
20 #include "lldb/Symbol/SymbolVendor.h"
21 
22 #include "llvm/DebugInfo/CodeView/CVRecord.h"
23 #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
24 #include "llvm/DebugInfo/CodeView/RecordName.h"
25 #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
26 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
27 #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
28 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
29 #include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
30 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
31 #include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
32 #include "llvm/DebugInfo/PDB/PDBTypes.h"
33 #include "llvm/Object/COFF.h"
34 #include "llvm/Support/Allocator.h"
35 #include "llvm/Support/BinaryStreamReader.h"
36 #include "llvm/Support/ErrorOr.h"
37 #include "llvm/Support/MemoryBuffer.h"
38 
39 #include "PdbSymUid.h"
40 #include "PdbUtil.h"
41 
42 using namespace lldb;
43 using namespace lldb_private;
44 using namespace lldb_private::npdb;
45 using namespace llvm::codeview;
46 using namespace llvm::pdb;
47 
48 static lldb::LanguageType TranslateLanguage(PDB_Lang lang) {
49   switch (lang) {
50   case PDB_Lang::Cpp:
51     return lldb::LanguageType::eLanguageTypeC_plus_plus;
52   case PDB_Lang::C:
53     return lldb::LanguageType::eLanguageTypeC;
54   default:
55     return lldb::LanguageType::eLanguageTypeUnknown;
56   }
57 }
58 
59 static std::unique_ptr<PDBFile> loadPDBFile(std::string PdbPath,
60                                             llvm::BumpPtrAllocator &Allocator) {
61   llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ErrorOrBuffer =
62       llvm::MemoryBuffer::getFile(PdbPath, /*FileSize=*/-1,
63                                   /*RequiresNullTerminator=*/false);
64   if (!ErrorOrBuffer)
65     return nullptr;
66   std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
67 
68   llvm::StringRef Path = Buffer->getBufferIdentifier();
69   auto Stream = llvm::make_unique<llvm::MemoryBufferByteStream>(
70       std::move(Buffer), llvm::support::little);
71 
72   auto File = llvm::make_unique<PDBFile>(Path, std::move(Stream), Allocator);
73   if (auto EC = File->parseFileHeaders())
74     return nullptr;
75   if (auto EC = File->parseStreamData())
76     return nullptr;
77 
78   return File;
79 }
80 
81 static std::unique_ptr<PDBFile>
82 loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) {
83   // Try to find a matching PDB for an EXE.
84   using namespace llvm::object;
85   auto expected_binary = createBinary(exe_path);
86 
87   // If the file isn't a PE/COFF executable, fail.
88   if (!expected_binary) {
89     llvm::consumeError(expected_binary.takeError());
90     return nullptr;
91   }
92   OwningBinary<Binary> binary = std::move(*expected_binary);
93 
94   auto *obj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary.getBinary());
95   if (!obj)
96     return nullptr;
97   const llvm::codeview::DebugInfo *pdb_info = nullptr;
98 
99   // If it doesn't have a debug directory, fail.
100   llvm::StringRef pdb_file;
101   auto ec = obj->getDebugPDBInfo(pdb_info, pdb_file);
102   if (ec)
103     return nullptr;
104 
105   // if the file doesn't exist, is not a pdb, or doesn't have a matching guid,
106   // fail.
107   llvm::file_magic magic;
108   ec = llvm::identify_magic(pdb_file, magic);
109   if (ec || magic != llvm::file_magic::pdb)
110     return nullptr;
111   std::unique_ptr<PDBFile> pdb = loadPDBFile(pdb_file, allocator);
112   auto expected_info = pdb->getPDBInfoStream();
113   if (!expected_info) {
114     llvm::consumeError(expected_info.takeError());
115     return nullptr;
116   }
117   llvm::codeview::GUID guid;
118   memcpy(&guid, pdb_info->PDB70.Signature, 16);
119 
120   if (expected_info->getGuid() != guid)
121     return nullptr;
122   return pdb;
123 }
124 
125 static bool IsFunctionPrologue(const CompilandIndexItem &cci,
126                                lldb::addr_t addr) {
127   // FIXME: Implement this.
128   return false;
129 }
130 
131 static bool IsFunctionEpilogue(const CompilandIndexItem &cci,
132                                lldb::addr_t addr) {
133   // FIXME: Implement this.
134   return false;
135 }
136 
137 void SymbolFileNativePDB::Initialize() {
138   PluginManager::RegisterPlugin(GetPluginNameStatic(),
139                                 GetPluginDescriptionStatic(), CreateInstance,
140                                 DebuggerInitialize);
141 }
142 
143 void SymbolFileNativePDB::Terminate() {
144   PluginManager::UnregisterPlugin(CreateInstance);
145 }
146 
147 void SymbolFileNativePDB::DebuggerInitialize(lldb_private::Debugger &debugger) {
148 }
149 
150 lldb_private::ConstString SymbolFileNativePDB::GetPluginNameStatic() {
151   static ConstString g_name("native-pdb");
152   return g_name;
153 }
154 
155 const char *SymbolFileNativePDB::GetPluginDescriptionStatic() {
156   return "Microsoft PDB debug symbol cross-platform file reader.";
157 }
158 
159 lldb_private::SymbolFile *
160 SymbolFileNativePDB::CreateInstance(lldb_private::ObjectFile *obj_file) {
161   return new SymbolFileNativePDB(obj_file);
162 }
163 
164 SymbolFileNativePDB::SymbolFileNativePDB(lldb_private::ObjectFile *object_file)
165     : SymbolFile(object_file) {}
166 
167 SymbolFileNativePDB::~SymbolFileNativePDB() {}
168 
169 uint32_t SymbolFileNativePDB::CalculateAbilities() {
170   uint32_t abilities = 0;
171   if (!m_obj_file)
172     return 0;
173 
174   if (!m_index) {
175     // Lazily load and match the PDB file, but only do this once.
176     std::unique_ptr<PDBFile> file_up =
177         loadMatchingPDBFile(m_obj_file->GetFileSpec().GetPath(), m_allocator);
178 
179     if (!file_up) {
180       auto module_sp = m_obj_file->GetModule();
181       if (!module_sp)
182         return 0;
183       // See if any symbol file is specified through `--symfile` option.
184       FileSpec symfile = module_sp->GetSymbolFileFileSpec();
185       if (!symfile)
186         return 0;
187       file_up = loadPDBFile(symfile.GetPath(), m_allocator);
188     }
189 
190     if (!file_up)
191       return 0;
192 
193     auto expected_index = PdbIndex::create(std::move(file_up));
194     if (!expected_index) {
195       llvm::consumeError(expected_index.takeError());
196       return 0;
197     }
198     m_index = std::move(*expected_index);
199   }
200   if (!m_index)
201     return 0;
202 
203   // We don't especially have to be precise here.  We only distinguish between
204   // stripped and not stripped.
205   abilities = kAllAbilities;
206 
207   if (m_index->dbi().isStripped())
208     abilities &= ~(Blocks | LocalVariables);
209   return abilities;
210 }
211 
212 void SymbolFileNativePDB::InitializeObject() {
213   m_obj_load_address = m_obj_file->GetFileOffset();
214   m_index->SetLoadAddress(m_obj_load_address);
215   m_index->ParseSectionContribs();
216 }
217 
218 uint32_t SymbolFileNativePDB::GetNumCompileUnits() {
219   const DbiModuleList &modules = m_index->dbi().modules();
220   uint32_t count = modules.getModuleCount();
221   if (count == 0)
222     return count;
223 
224   // The linker can inject an additional "dummy" compilation unit into the
225   // PDB. Ignore this special compile unit for our purposes, if it is there.
226   // It is always the last one.
227   DbiModuleDescriptor last = modules.getModuleDescriptor(count - 1);
228   if (last.getModuleName() == "* Linker *")
229     --count;
230   return count;
231 }
232 
233 lldb::FunctionSP SymbolFileNativePDB::CreateFunction(PdbSymUid func_uid,
234                                                      const SymbolContext &sc) {
235   lldbassert(func_uid.tag() == PDB_SymType::Function);
236 
237   PdbSymUid cuid = PdbSymUid::makeCompilandId(func_uid.asCuSym().modi);
238 
239   const CompilandIndexItem *cci = m_index->compilands().GetCompiland(cuid);
240   lldbassert(cci);
241   CVSymbol sym_record =
242       cci->m_debug_stream.readSymbolAtOffset(func_uid.asCuSym().offset);
243 
244   lldbassert(sym_record.kind() == S_LPROC32 || sym_record.kind() == S_GPROC32);
245   SegmentOffsetLength sol = GetSegmentOffsetAndLength(sym_record);
246 
247   auto file_vm_addr = m_index->MakeVirtualAddress(sol.so);
248   if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0)
249     return nullptr;
250 
251   AddressRange func_range(file_vm_addr, sol.length,
252                           sc.module_sp->GetSectionList());
253   if (!func_range.GetBaseAddress().IsValid())
254     return nullptr;
255 
256   lldb_private::Type *func_type = nullptr;
257 
258   // FIXME: Resolve types and mangled names.
259   PdbSymUid sig_uid =
260       PdbSymUid::makeTypeSymId(PDB_SymType::FunctionSig, TypeIndex{0}, false);
261   Mangled mangled(getSymbolName(sym_record));
262 
263   FunctionSP func_sp = std::make_shared<Function>(
264       sc.comp_unit, func_uid.toOpaqueId(), sig_uid.toOpaqueId(), mangled,
265       func_type, func_range);
266 
267   sc.comp_unit->AddFunction(func_sp);
268   return func_sp;
269 }
270 
271 CompUnitSP
272 SymbolFileNativePDB::CreateCompileUnit(const CompilandIndexItem &cci) {
273   lldb::LanguageType lang =
274       cci.m_compile_opts ? TranslateLanguage(cci.m_compile_opts->getLanguage())
275                          : lldb::eLanguageTypeUnknown;
276 
277   LazyBool optimized = eLazyBoolNo;
278   if (cci.m_compile_opts && cci.m_compile_opts->hasOptimizations())
279     optimized = eLazyBoolYes;
280 
281   llvm::StringRef source_file_name =
282       m_index->compilands().GetMainSourceFile(cci);
283   lldb_private::FileSpec fs(source_file_name, false);
284 
285   CompUnitSP cu_sp =
286       std::make_shared<CompileUnit>(m_obj_file->GetModule(), nullptr, fs,
287                                     cci.m_uid.toOpaqueId(), lang, optimized);
288 
289   const PdbCompilandId &cuid = cci.m_uid.asCompiland();
290   m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(cuid.modi,
291                                                                     cu_sp);
292   return cu_sp;
293 }
294 
295 FunctionSP SymbolFileNativePDB::GetOrCreateFunction(PdbSymUid func_uid,
296                                                     const SymbolContext &sc) {
297   lldbassert(func_uid.tag() == PDB_SymType::Function);
298   auto emplace_result = m_functions.try_emplace(func_uid.toOpaqueId(), nullptr);
299   if (emplace_result.second)
300     emplace_result.first->second = CreateFunction(func_uid, sc);
301 
302   lldbassert(emplace_result.first->second);
303   return emplace_result.first->second;
304 }
305 
306 CompUnitSP
307 SymbolFileNativePDB::GetOrCreateCompileUnit(const CompilandIndexItem &cci) {
308   auto emplace_result =
309       m_compilands.try_emplace(cci.m_uid.toOpaqueId(), nullptr);
310   if (emplace_result.second)
311     emplace_result.first->second = CreateCompileUnit(cci);
312 
313   lldbassert(emplace_result.first->second);
314   return emplace_result.first->second;
315 }
316 
317 lldb::CompUnitSP SymbolFileNativePDB::ParseCompileUnitAtIndex(uint32_t index) {
318   if (index >= GetNumCompileUnits())
319     return CompUnitSP();
320   lldbassert(index < UINT16_MAX);
321   if (index >= UINT16_MAX)
322     return nullptr;
323 
324   CompilandIndexItem &item = m_index->compilands().GetOrCreateCompiland(index);
325 
326   return GetOrCreateCompileUnit(item);
327 }
328 
329 lldb::LanguageType SymbolFileNativePDB::ParseCompileUnitLanguage(
330     const lldb_private::SymbolContext &sc) {
331   // What fields should I expect to be filled out on the SymbolContext?  Is it
332   // safe to assume that `sc.comp_unit` is valid?
333   if (!sc.comp_unit)
334     return lldb::eLanguageTypeUnknown;
335   PdbSymUid uid = PdbSymUid::fromOpaqueId(sc.comp_unit->GetID());
336   lldbassert(uid.tag() == PDB_SymType::Compiland);
337 
338   CompilandIndexItem *item = m_index->compilands().GetCompiland(uid);
339   lldbassert(item);
340   if (!item->m_compile_opts)
341     return lldb::eLanguageTypeUnknown;
342 
343   return TranslateLanguage(item->m_compile_opts->getLanguage());
344 }
345 
346 size_t SymbolFileNativePDB::ParseCompileUnitFunctions(
347     const lldb_private::SymbolContext &sc) {
348   lldbassert(sc.comp_unit);
349   return false;
350 }
351 
352 static bool NeedsResolvedCompileUnit(uint32_t resolve_scope) {
353   // If any of these flags are set, we need to resolve the compile unit.
354   uint32_t flags = eSymbolContextCompUnit;
355   flags |= eSymbolContextVariable;
356   flags |= eSymbolContextFunction;
357   flags |= eSymbolContextBlock;
358   flags |= eSymbolContextLineEntry;
359   return (resolve_scope & flags) != 0;
360 }
361 
362 uint32_t
363 SymbolFileNativePDB::ResolveSymbolContext(const lldb_private::Address &addr,
364                                           uint32_t resolve_scope,
365                                           lldb_private::SymbolContext &sc) {
366   uint32_t resolved_flags = 0;
367   lldb::addr_t file_addr = addr.GetFileAddress();
368 
369   if (NeedsResolvedCompileUnit(resolve_scope)) {
370     llvm::Optional<uint16_t> modi = m_index->GetModuleIndexForVa(file_addr);
371     if (!modi)
372       return 0;
373     PdbSymUid cuid = PdbSymUid::makeCompilandId(*modi);
374     CompilandIndexItem *cci = m_index->compilands().GetCompiland(cuid);
375     if (!cci)
376       return 0;
377 
378     sc.comp_unit = GetOrCreateCompileUnit(*cci).get();
379     resolved_flags |= eSymbolContextCompUnit;
380   }
381 
382   if (resolve_scope & eSymbolContextFunction) {
383     lldbassert(sc.comp_unit);
384     std::vector<SymbolAndUid> matches = m_index->FindSymbolsByVa(file_addr);
385     for (const auto &match : matches) {
386       if (match.uid.tag() != PDB_SymType::Function)
387         continue;
388       sc.function = GetOrCreateFunction(match.uid, sc).get();
389     }
390     resolved_flags |= eSymbolContextFunction;
391   }
392 
393   if (resolve_scope & eSymbolContextLineEntry) {
394     lldbassert(sc.comp_unit);
395     if (auto *line_table = sc.comp_unit->GetLineTable()) {
396       if (line_table->FindLineEntryByAddress(addr, sc.line_entry))
397         resolved_flags |= eSymbolContextLineEntry;
398     }
399   }
400 
401   return resolved_flags;
402 }
403 
404 static void AppendLineEntryToSequence(LineTable &table, LineSequence &sequence,
405                                       const CompilandIndexItem &cci,
406                                       lldb::addr_t base_addr,
407                                       uint32_t file_number,
408                                       const LineFragmentHeader &block,
409                                       const LineNumberEntry &cur) {
410   LineInfo cur_info(cur.Flags);
411 
412   if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto())
413     return;
414 
415   uint64_t addr = base_addr + cur.Offset;
416 
417   bool is_statement = cur_info.isStatement();
418   bool is_prologue = IsFunctionPrologue(cci, addr);
419   bool is_epilogue = IsFunctionEpilogue(cci, addr);
420 
421   uint32_t lno = cur_info.getStartLine();
422 
423   table.AppendLineEntryToSequence(&sequence, addr, lno, 0, file_number,
424                                   is_statement, false, is_prologue, is_epilogue,
425                                   false);
426 }
427 
428 static void TerminateLineSequence(LineTable &table,
429                                   const LineFragmentHeader &block,
430                                   lldb::addr_t base_addr, uint32_t file_number,
431                                   uint32_t last_line,
432                                   std::unique_ptr<LineSequence> seq) {
433   // The end is always a terminal entry, so insert it regardless.
434   table.AppendLineEntryToSequence(seq.get(), base_addr + block.CodeSize,
435                                   last_line, 0, file_number, false, false,
436                                   false, false, true);
437   table.InsertSequence(seq.release());
438 }
439 
440 bool SymbolFileNativePDB::ParseCompileUnitLineTable(
441     const lldb_private::SymbolContext &sc) {
442   // Unfortunately LLDB is set up to parse the entire compile unit line table
443   // all at once, even if all it really needs is line info for a specific
444   // function.  In the future it would be nice if it could set the sc.m_function
445   // member, and we could only get the line info for the function in question.
446   lldbassert(sc.comp_unit);
447   PdbSymUid cu_id = PdbSymUid::fromOpaqueId(sc.comp_unit->GetID());
448   lldbassert(cu_id.isCompiland());
449   CompilandIndexItem *cci = m_index->compilands().GetCompiland(cu_id);
450   lldbassert(cci);
451   auto line_table = llvm::make_unique<LineTable>(sc.comp_unit);
452 
453   // This is basically a copy of the .debug$S subsections from all original COFF
454   // object files merged together with address relocations applied.  We are
455   // looking for all DEBUG_S_LINES subsections.
456   for (const DebugSubsectionRecord &dssr :
457        cci->m_debug_stream.getSubsectionsArray()) {
458     if (dssr.kind() != DebugSubsectionKind::Lines)
459       continue;
460 
461     DebugLinesSubsectionRef lines;
462     llvm::BinaryStreamReader reader(dssr.getRecordData());
463     if (auto EC = lines.initialize(reader)) {
464       llvm::consumeError(std::move(EC));
465       return false;
466     }
467 
468     const LineFragmentHeader *lfh = lines.header();
469     uint64_t virtual_addr =
470         m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset);
471 
472     const auto &checksums = cci->m_strings.checksums().getArray();
473     const auto &strings = cci->m_strings.strings();
474     for (const LineColumnEntry &group : lines) {
475       // Indices in this structure are actually offsets of records in the
476       // DEBUG_S_FILECHECKSUMS subsection.  Those entries then have an index
477       // into the global PDB string table.
478       auto iter = checksums.at(group.NameIndex);
479       if (iter == checksums.end())
480         continue;
481 
482       llvm::Expected<llvm::StringRef> efn =
483           strings.getString(iter->FileNameOffset);
484       if (!efn) {
485         llvm::consumeError(efn.takeError());
486         continue;
487       }
488 
489       // LLDB wants the index of the file in the list of support files.
490       auto fn_iter = llvm::find(cci->m_file_list, *efn);
491       lldbassert(fn_iter != cci->m_file_list.end());
492       uint32_t file_index = std::distance(cci->m_file_list.begin(), fn_iter);
493 
494       std::unique_ptr<LineSequence> sequence(
495           line_table->CreateLineSequenceContainer());
496       lldbassert(!group.LineNumbers.empty());
497 
498       for (const LineNumberEntry &entry : group.LineNumbers) {
499         AppendLineEntryToSequence(*line_table, *sequence, *cci, virtual_addr,
500                                   file_index, *lfh, entry);
501       }
502       LineInfo last_line(group.LineNumbers.back().Flags);
503       TerminateLineSequence(*line_table, *lfh, virtual_addr, file_index,
504                             last_line.getEndLine(), std::move(sequence));
505     }
506   }
507 
508   if (line_table->GetSize() == 0)
509     return false;
510 
511   sc.comp_unit->SetLineTable(line_table.release());
512   return true;
513 }
514 
515 bool SymbolFileNativePDB::ParseCompileUnitDebugMacros(
516     const lldb_private::SymbolContext &sc) {
517   // PDB doesn't contain information about macros
518   return false;
519 }
520 
521 bool SymbolFileNativePDB::ParseCompileUnitSupportFiles(
522     const lldb_private::SymbolContext &sc,
523     lldb_private::FileSpecList &support_files) {
524   lldbassert(sc.comp_unit);
525 
526   PdbSymUid comp_uid = PdbSymUid::fromOpaqueId(sc.comp_unit->GetID());
527   lldbassert(comp_uid.tag() == PDB_SymType::Compiland);
528 
529   const CompilandIndexItem *cci = m_index->compilands().GetCompiland(comp_uid);
530   lldbassert(cci);
531 
532   for (llvm::StringRef f : cci->m_file_list) {
533     FileSpec::Style style =
534         f.startswith("/") ? FileSpec::Style::posix : FileSpec::Style::windows;
535     FileSpec spec(f, false, style);
536     support_files.Append(spec);
537   }
538 
539   return true;
540 }
541 
542 bool SymbolFileNativePDB::ParseImportedModules(
543     const lldb_private::SymbolContext &sc,
544     std::vector<lldb_private::ConstString> &imported_modules) {
545   // PDB does not yet support module debug info
546   return false;
547 }
548 
549 size_t SymbolFileNativePDB::ParseFunctionBlocks(
550     const lldb_private::SymbolContext &sc) {
551   lldbassert(sc.comp_unit && sc.function);
552   return 0;
553 }
554 
555 uint32_t SymbolFileNativePDB::FindFunctions(
556     const lldb_private::ConstString &name,
557     const lldb_private::CompilerDeclContext *parent_decl_ctx,
558     uint32_t name_type_mask, bool include_inlines, bool append,
559     lldb_private::SymbolContextList &sc_list) {
560   // For now we only support lookup by method name.
561   if (!(name_type_mask & eFunctionNameTypeMethod))
562     return 0;
563 
564   using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
565 
566   std::vector<SymbolAndOffset> matches = m_index->globals().findRecordsByName(
567       name.GetStringRef(), m_index->symrecords());
568   for (const SymbolAndOffset &match : matches) {
569     if (match.second.kind() != S_PROCREF && match.second.kind() != S_LPROCREF)
570       continue;
571     ProcRefSym proc(match.second.kind());
572     cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(match.second, proc));
573 
574     if (!IsValidRecord(proc))
575       continue;
576 
577     PdbSymUid cuid = PdbSymUid::makeCompilandId(proc);
578     CompilandIndexItem &cci = m_index->compilands().GetOrCreateCompiland(cuid);
579     lldb_private::SymbolContext sc;
580 
581     sc.comp_unit = GetOrCreateCompileUnit(cci).get();
582     sc.module_sp = sc.comp_unit->GetModule();
583     PdbSymUid func_uid = PdbSymUid::makeCuSymId(proc);
584     sc.function = GetOrCreateFunction(func_uid, sc).get();
585 
586     sc_list.Append(sc);
587   }
588 
589   return sc_list.GetSize();
590 }
591 
592 uint32_t
593 SymbolFileNativePDB::FindFunctions(const lldb_private::RegularExpression &regex,
594                                    bool include_inlines, bool append,
595                                    lldb_private::SymbolContextList &sc_list) {
596   return 0;
597 }
598 
599 lldb_private::CompilerDeclContext SymbolFileNativePDB::FindNamespace(
600     const lldb_private::SymbolContext &sc,
601     const lldb_private::ConstString &name,
602     const lldb_private::CompilerDeclContext *parent_decl_ctx) {
603   return {};
604 }
605 
606 lldb_private::TypeSystem *
607 SymbolFileNativePDB::GetTypeSystemForLanguage(lldb::LanguageType language) {
608   auto type_system =
609       m_obj_file->GetModule()->GetTypeSystemForLanguage(language);
610   if (type_system)
611     type_system->SetSymbolFile(this);
612   return type_system;
613 }
614 
615 lldb_private::ConstString SymbolFileNativePDB::GetPluginName() {
616   static ConstString g_name("pdb");
617   return g_name;
618 }
619 
620 uint32_t SymbolFileNativePDB::GetPluginVersion() { return 1; }
621