LLDB  mainline
SymbolFileNativePDB.cpp
Go to the documentation of this file.
1 //===-- SymbolFileNativePDB.cpp -------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "SymbolFileNativePDB.h"
10 
11 #include "clang/AST/Attr.h"
12 #include "clang/AST/CharUnits.h"
13 #include "clang/AST/Decl.h"
14 #include "clang/AST/DeclCXX.h"
15 #include "clang/AST/Type.h"
16 
21 #include "lldb/Core/Module.h"
23 #include "lldb/Core/StreamBuffer.h"
24 #include "lldb/Core/StreamFile.h"
26 #include "lldb/Symbol/LineTable.h"
27 #include "lldb/Symbol/ObjectFile.h"
30 #include "lldb/Symbol/Variable.h"
32 #include "lldb/Utility/LLDBLog.h"
33 #include "lldb/Utility/Log.h"
34 
35 #include "llvm/DebugInfo/CodeView/CVRecord.h"
36 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
37 #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
38 #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
39 #include "llvm/DebugInfo/CodeView/RecordName.h"
40 #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
41 #include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
42 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
43 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
44 #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
45 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
46 #include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
47 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
48 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
49 #include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
50 #include "llvm/DebugInfo/PDB/Native/TpiStream.h"
51 #include "llvm/DebugInfo/PDB/PDB.h"
52 #include "llvm/DebugInfo/PDB/PDBTypes.h"
53 #include "llvm/Demangle/MicrosoftDemangle.h"
54 #include "llvm/Object/COFF.h"
55 #include "llvm/Support/Allocator.h"
56 #include "llvm/Support/BinaryStreamReader.h"
57 #include "llvm/Support/Error.h"
58 #include "llvm/Support/ErrorOr.h"
59 #include "llvm/Support/MemoryBuffer.h"
60 
62 #include "PdbAstBuilder.h"
63 #include "PdbSymUid.h"
64 #include "PdbUtil.h"
65 #include "UdtRecordCompleter.h"
66 
67 using namespace lldb;
68 using namespace lldb_private;
69 using namespace npdb;
70 using namespace llvm::codeview;
71 using namespace llvm::pdb;
72 
74 
75 static lldb::LanguageType TranslateLanguage(PDB_Lang lang) {
76  switch (lang) {
77  case PDB_Lang::Cpp:
79  case PDB_Lang::C:
81  case PDB_Lang::Swift:
83  case PDB_Lang::Rust:
85  default:
87  }
88 }
89 
90 static std::unique_ptr<PDBFile>
91 loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) {
92  // Try to find a matching PDB for an EXE.
93  using namespace llvm::object;
94  auto expected_binary = createBinary(exe_path);
95 
96  // If the file isn't a PE/COFF executable, fail.
97  if (!expected_binary) {
98  llvm::consumeError(expected_binary.takeError());
99  return nullptr;
100  }
101  OwningBinary<Binary> binary = std::move(*expected_binary);
102 
103  // TODO: Avoid opening the PE/COFF binary twice by reading this information
104  // directly from the lldb_private::ObjectFile.
105  auto *obj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary.getBinary());
106  if (!obj)
107  return nullptr;
108  const llvm::codeview::DebugInfo *pdb_info = nullptr;
109 
110  // If it doesn't have a debug directory, fail.
111  llvm::StringRef pdb_file;
112  if (llvm::Error e = obj->getDebugPDBInfo(pdb_info, pdb_file)) {
113  consumeError(std::move(e));
114  return nullptr;
115  }
116 
117  // If the file doesn't exist, perhaps the path specified at build time
118  // doesn't match the PDB's current location, so check the location of the
119  // executable.
120  if (!FileSystem::Instance().Exists(pdb_file)) {
121  const auto exe_dir = FileSpec(exe_path).CopyByRemovingLastPathComponent();
122  const auto pdb_name = FileSpec(pdb_file).GetFilename().GetCString();
123  pdb_file = exe_dir.CopyByAppendingPathComponent(pdb_name).GetCString();
124  }
125 
126  // If the file is not a PDB or if it doesn't have a matching GUID, fail.
127  auto pdb = ObjectFilePDB::loadPDBFile(std::string(pdb_file), allocator);
128  if (!pdb)
129  return nullptr;
130 
131  auto expected_info = pdb->getPDBInfoStream();
132  if (!expected_info) {
133  llvm::consumeError(expected_info.takeError());
134  return nullptr;
135  }
136  llvm::codeview::GUID guid;
137  memcpy(&guid, pdb_info->PDB70.Signature, 16);
138 
139  if (expected_info->getGuid() != guid)
140  return nullptr;
141  return pdb;
142 }
143 
144 static bool IsFunctionPrologue(const CompilandIndexItem &cci,
145  lldb::addr_t addr) {
146  // FIXME: Implement this.
147  return false;
148 }
149 
150 static bool IsFunctionEpilogue(const CompilandIndexItem &cci,
151  lldb::addr_t addr) {
152  // FIXME: Implement this.
153  return false;
154 }
155 
156 static llvm::StringRef GetSimpleTypeName(SimpleTypeKind kind) {
157  switch (kind) {
158  case SimpleTypeKind::Boolean128:
159  case SimpleTypeKind::Boolean16:
160  case SimpleTypeKind::Boolean32:
161  case SimpleTypeKind::Boolean64:
162  case SimpleTypeKind::Boolean8:
163  return "bool";
164  case SimpleTypeKind::Byte:
165  case SimpleTypeKind::UnsignedCharacter:
166  return "unsigned char";
167  case SimpleTypeKind::NarrowCharacter:
168  return "char";
169  case SimpleTypeKind::SignedCharacter:
170  case SimpleTypeKind::SByte:
171  return "signed char";
172  case SimpleTypeKind::Character16:
173  return "char16_t";
174  case SimpleTypeKind::Character32:
175  return "char32_t";
176  case SimpleTypeKind::Character8:
177  return "char8_t";
178  case SimpleTypeKind::Complex80:
179  case SimpleTypeKind::Complex64:
180  case SimpleTypeKind::Complex32:
181  return "complex";
182  case SimpleTypeKind::Float128:
183  case SimpleTypeKind::Float80:
184  return "long double";
185  case SimpleTypeKind::Float64:
186  return "double";
187  case SimpleTypeKind::Float32:
188  return "float";
189  case SimpleTypeKind::Float16:
190  return "single";
191  case SimpleTypeKind::Int128:
192  return "__int128";
193  case SimpleTypeKind::Int64:
194  case SimpleTypeKind::Int64Quad:
195  return "int64_t";
196  case SimpleTypeKind::Int32:
197  return "int";
198  case SimpleTypeKind::Int16:
199  return "short";
200  case SimpleTypeKind::UInt128:
201  return "unsigned __int128";
202  case SimpleTypeKind::UInt64:
203  case SimpleTypeKind::UInt64Quad:
204  return "uint64_t";
205  case SimpleTypeKind::HResult:
206  return "HRESULT";
207  case SimpleTypeKind::UInt32:
208  return "unsigned";
209  case SimpleTypeKind::UInt16:
210  case SimpleTypeKind::UInt16Short:
211  return "unsigned short";
212  case SimpleTypeKind::Int32Long:
213  return "long";
214  case SimpleTypeKind::UInt32Long:
215  return "unsigned long";
216  case SimpleTypeKind::Void:
217  return "void";
218  case SimpleTypeKind::WideCharacter:
219  return "wchar_t";
220  default:
221  return "";
222  }
223 }
224 
225 static bool IsClassRecord(TypeLeafKind kind) {
226  switch (kind) {
227  case LF_STRUCTURE:
228  case LF_CLASS:
229  case LF_INTERFACE:
230  return true;
231  default:
232  return false;
233  }
234 }
235 
236 void SymbolFileNativePDB::Initialize() {
237  PluginManager::RegisterPlugin(GetPluginNameStatic(),
238  GetPluginDescriptionStatic(), CreateInstance,
239  DebuggerInitialize);
240 }
241 
242 void SymbolFileNativePDB::Terminate() {
243  PluginManager::UnregisterPlugin(CreateInstance);
244 }
245 
246 void SymbolFileNativePDB::DebuggerInitialize(Debugger &debugger) {}
247 
248 llvm::StringRef SymbolFileNativePDB::GetPluginDescriptionStatic() {
249  return "Microsoft PDB debug symbol cross-platform file reader.";
250 }
251 
252 SymbolFile *SymbolFileNativePDB::CreateInstance(ObjectFileSP objfile_sp) {
253  return new SymbolFileNativePDB(std::move(objfile_sp));
254 }
255 
256 SymbolFileNativePDB::SymbolFileNativePDB(ObjectFileSP objfile_sp)
257  : SymbolFileCommon(std::move(objfile_sp)) {}
258 
260 
262  uint32_t abilities = 0;
263  if (!m_objfile_sp)
264  return 0;
265 
266  if (!m_index) {
267  // Lazily load and match the PDB file, but only do this once.
268  PDBFile *pdb_file;
269  if (auto *pdb = llvm::dyn_cast<ObjectFilePDB>(m_objfile_sp.get())) {
270  pdb_file = &pdb->GetPDBFile();
271  } else {
272  m_file_up = loadMatchingPDBFile(m_objfile_sp->GetFileSpec().GetPath(),
273  m_allocator);
274  pdb_file = m_file_up.get();
275  }
276 
277  if (!pdb_file)
278  return 0;
279 
280  auto expected_index = PdbIndex::create(pdb_file);
281  if (!expected_index) {
282  llvm::consumeError(expected_index.takeError());
283  return 0;
284  }
285  m_index = std::move(*expected_index);
286  }
287  if (!m_index)
288  return 0;
289 
290  // We don't especially have to be precise here. We only distinguish between
291  // stripped and not stripped.
292  abilities = kAllAbilities;
293 
294  if (m_index->dbi().isStripped())
295  abilities &= ~(Blocks | LocalVariables);
296  return abilities;
297 }
298 
300  m_obj_load_address = m_objfile_sp->GetModule()
301  ->GetObjectFile()
302  ->GetBaseAddress()
303  .GetFileAddress();
304  m_index->SetLoadAddress(m_obj_load_address);
305  m_index->ParseSectionContribs();
306 
307  auto ts_or_err = m_objfile_sp->GetModule()->GetTypeSystemForLanguage(
309  if (auto err = ts_or_err.takeError()) {
310  LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
311  "Failed to initialize");
312  } else {
313  ts_or_err->SetSymbolFile(this);
314  auto *clang = llvm::cast_or_null<TypeSystemClang>(&ts_or_err.get());
315  lldbassert(clang);
316  m_ast = std::make_unique<PdbAstBuilder>(*m_objfile_sp, *m_index, *clang);
317  }
318 }
319 
321  const DbiModuleList &modules = m_index->dbi().modules();
322  uint32_t count = modules.getModuleCount();
323  if (count == 0)
324  return count;
325 
326  // The linker can inject an additional "dummy" compilation unit into the
327  // PDB. Ignore this special compile unit for our purposes, if it is there.
328  // It is always the last one.
329  DbiModuleDescriptor last = modules.getModuleDescriptor(count - 1);
330  if (last.getModuleName() == "* Linker *")
331  --count;
332  return count;
333 }
334 
336  CompilandIndexItem *cii = m_index->compilands().GetCompiland(block_id.modi);
337  CVSymbol sym = cii->m_debug_stream.readSymbolAtOffset(block_id.offset);
338  CompUnitSP comp_unit = GetOrCreateCompileUnit(*cii);
339  lldb::user_id_t opaque_block_uid = toOpaqueUid(block_id);
340  BlockSP child_block = std::make_shared<Block>(opaque_block_uid);
341 
342  switch (sym.kind()) {
343  case S_GPROC32:
344  case S_LPROC32: {
345  // This is a function. It must be global. Creating the Function entry
346  // for it automatically creates a block for it.
347  FunctionSP func = GetOrCreateFunction(block_id, *comp_unit);
348  Block &block = func->GetBlock(false);
349  if (block.GetNumRanges() == 0)
350  block.AddRange(Block::Range(0, func->GetAddressRange().GetByteSize()));
351  return block;
352  }
353  case S_BLOCK32: {
354  // This is a block. Its parent is either a function or another block. In
355  // either case, its parent can be viewed as a block (e.g. a function
356  // contains 1 big block. So just get the parent block and add this block
357  // to it.
358  BlockSym block(static_cast<SymbolRecordKind>(sym.kind()));
359  cantFail(SymbolDeserializer::deserializeAs<BlockSym>(sym, block));
360  lldbassert(block.Parent != 0);
361  PdbCompilandSymId parent_id(block_id.modi, block.Parent);
362  Block &parent_block = GetOrCreateBlock(parent_id);
363  parent_block.AddChild(child_block);
364  m_ast->GetOrCreateBlockDecl(block_id);
365  m_blocks.insert({opaque_block_uid, child_block});
366  break;
367  }
368  case S_INLINESITE: {
369  // This ensures line table is parsed first so we have inline sites info.
370  comp_unit->GetLineTable();
371 
372  std::shared_ptr<InlineSite> inline_site = m_inline_sites[opaque_block_uid];
373  Block &parent_block = GetOrCreateBlock(inline_site->parent_id);
374  parent_block.AddChild(child_block);
375  m_ast->GetOrCreateInlinedFunctionDecl(block_id);
376  // Copy ranges from InlineSite to Block.
377  for (size_t i = 0; i < inline_site->ranges.GetSize(); ++i) {
378  auto *entry = inline_site->ranges.GetEntryAtIndex(i);
379  child_block->AddRange(
380  Block::Range(entry->GetRangeBase(), entry->GetByteSize()));
381  }
382  child_block->FinalizeRanges();
383 
384  // Get the inlined function callsite info.
385  Declaration &decl = inline_site->inline_function_info->GetDeclaration();
386  Declaration &callsite = inline_site->inline_function_info->GetCallSite();
387  child_block->SetInlinedFunctionInfo(
388  inline_site->inline_function_info->GetName().GetCString(), nullptr,
389  &decl, &callsite);
390  m_blocks.insert({opaque_block_uid, child_block});
391  break;
392  }
393  default:
394  lldbassert(false && "Symbol is not a block!");
395  }
396 
397  return *child_block;
398 }
399 
401  CompileUnit &comp_unit) {
402  const CompilandIndexItem *cci =
403  m_index->compilands().GetCompiland(func_id.modi);
404  lldbassert(cci);
405  CVSymbol sym_record = cci->m_debug_stream.readSymbolAtOffset(func_id.offset);
406 
407  lldbassert(sym_record.kind() == S_LPROC32 || sym_record.kind() == S_GPROC32);
409 
410  auto file_vm_addr = m_index->MakeVirtualAddress(sol.so);
411  if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0)
412  return nullptr;
413 
414  AddressRange func_range(file_vm_addr, sol.length,
415  comp_unit.GetModule()->GetSectionList());
416  if (!func_range.GetBaseAddress().IsValid())
417  return nullptr;
418 
419  ProcSym proc(static_cast<SymbolRecordKind>(sym_record.kind()));
420  cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym_record, proc));
421  if (proc.FunctionType == TypeIndex::None())
422  return nullptr;
423  TypeSP func_type = GetOrCreateType(proc.FunctionType);
424  if (!func_type)
425  return nullptr;
426 
427  PdbTypeSymId sig_id(proc.FunctionType, false);
428  Mangled mangled(proc.Name);
429  FunctionSP func_sp = std::make_shared<Function>(
430  &comp_unit, toOpaqueUid(func_id), toOpaqueUid(sig_id), mangled,
431  func_type.get(), func_range);
432 
433  comp_unit.AddFunction(func_sp);
434 
435  m_ast->GetOrCreateFunctionDecl(func_id);
436 
437  return func_sp;
438 }
439 
440 CompUnitSP
442  lldb::LanguageType lang =
443  cci.m_compile_opts ? TranslateLanguage(cci.m_compile_opts->getLanguage())
445 
446  LazyBool optimized = eLazyBoolNo;
447  if (cci.m_compile_opts && cci.m_compile_opts->hasOptimizations())
448  optimized = eLazyBoolYes;
449 
450  llvm::SmallString<64> source_file_name =
451  m_index->compilands().GetMainSourceFile(cci);
452  FileSpec fs(source_file_name);
453 
454  CompUnitSP cu_sp =
455  std::make_shared<CompileUnit>(m_objfile_sp->GetModule(), nullptr, fs,
456  toOpaqueUid(cci.m_id), lang, optimized);
457 
458  SetCompileUnitAtIndex(cci.m_id.modi, cu_sp);
459  return cu_sp;
460 }
461 
463  const ModifierRecord &mr,
464  CompilerType ct) {
465  TpiStream &stream = m_index->tpi();
466 
467  std::string name;
468  if (mr.ModifiedType.isSimple())
469  name = std::string(GetSimpleTypeName(mr.ModifiedType.getSimpleKind()));
470  else
471  name = computeTypeName(stream.typeCollection(), mr.ModifiedType);
472  Declaration decl;
473  lldb::TypeSP modified_type = GetOrCreateType(mr.ModifiedType);
474 
475  return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(name),
476  modified_type->GetByteSize(nullptr), nullptr,
479 }
480 
481 lldb::TypeSP
483  const llvm::codeview::PointerRecord &pr,
484  CompilerType ct) {
485  TypeSP pointee = GetOrCreateType(pr.ReferentType);
486  if (!pointee)
487  return nullptr;
488 
489  if (pr.isPointerToMember()) {
490  MemberPointerInfo mpi = pr.getMemberInfo();
491  GetOrCreateType(mpi.ContainingType);
492  }
493 
494  Declaration decl;
495  return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(),
496  pr.getSize(), nullptr, LLDB_INVALID_UID,
497  Type::eEncodingIsUID, decl, ct,
499 }
500 
501 lldb::TypeSP SymbolFileNativePDB::CreateSimpleType(TypeIndex ti,
502  CompilerType ct) {
503  uint64_t uid = toOpaqueUid(PdbTypeSymId(ti, false));
504  if (ti == TypeIndex::NullptrT()) {
505  Declaration decl;
506  return std::make_shared<Type>(
507  uid, this, ConstString("std::nullptr_t"), 0, nullptr, LLDB_INVALID_UID,
509  }
510 
511  if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
512  TypeSP direct_sp = GetOrCreateType(ti.makeDirect());
513  uint32_t pointer_size = 0;
514  switch (ti.getSimpleMode()) {
515  case SimpleTypeMode::FarPointer32:
516  case SimpleTypeMode::NearPointer32:
517  pointer_size = 4;
518  break;
519  case SimpleTypeMode::NearPointer64:
520  pointer_size = 8;
521  break;
522  default:
523  // 128-bit and 16-bit pointers unsupported.
524  return nullptr;
525  }
526  Declaration decl;
527  return std::make_shared<Type>(
528  uid, this, ConstString(), pointer_size, nullptr, LLDB_INVALID_UID,
530  }
531 
532  if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
533  return nullptr;
534 
535  size_t size = GetTypeSizeForSimpleKind(ti.getSimpleKind());
536  llvm::StringRef type_name = GetSimpleTypeName(ti.getSimpleKind());
537 
538  Declaration decl;
539  return std::make_shared<Type>(uid, this, ConstString(type_name), size,
541  decl, ct, Type::ResolveState::Full);
542 }
543 
544 static std::string GetUnqualifiedTypeName(const TagRecord &record) {
545  if (!record.hasUniqueName()) {
546  MSVCUndecoratedNameParser parser(record.Name);
547  llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.GetSpecifiers();
548 
549  return std::string(specs.back().GetBaseName());
550  }
551 
552  llvm::ms_demangle::Demangler demangler;
553  StringView sv(record.UniqueName.begin(), record.UniqueName.size());
554  llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
555  if (demangler.Error)
556  return std::string(record.Name);
557 
558  llvm::ms_demangle::IdentifierNode *idn =
559  ttn->QualifiedName->getUnqualifiedIdentifier();
560  return idn->toString();
561 }
562 
563 lldb::TypeSP
565  const TagRecord &record,
566  size_t size, CompilerType ct) {
567 
568  std::string uname = GetUnqualifiedTypeName(record);
569 
570  // FIXME: Search IPI stream for LF_UDT_MOD_SRC_LINE.
571  Declaration decl;
572  return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(uname),
573  size, nullptr, LLDB_INVALID_UID,
574  Type::eEncodingIsUID, decl, ct,
576 }
577 
579  const ClassRecord &cr,
580  CompilerType ct) {
581  return CreateClassStructUnion(type_id, cr, cr.getSize(), ct);
582 }
583 
585  const UnionRecord &ur,
586  CompilerType ct) {
587  return CreateClassStructUnion(type_id, ur, ur.getSize(), ct);
588 }
589 
591  const EnumRecord &er,
592  CompilerType ct) {
594 
595  Declaration decl;
596  TypeSP underlying_type = GetOrCreateType(er.UnderlyingType);
597 
598  return std::make_shared<lldb_private::Type>(
599  toOpaqueUid(type_id), this, ConstString(uname),
600  underlying_type->GetByteSize(nullptr), nullptr, LLDB_INVALID_UID,
603 }
604 
606  const ArrayRecord &ar,
607  CompilerType ct) {
608  TypeSP element_type = GetOrCreateType(ar.ElementType);
609 
610  Declaration decl;
611  TypeSP array_sp = std::make_shared<lldb_private::Type>(
612  toOpaqueUid(type_id), this, ConstString(), ar.Size, nullptr,
615  array_sp->SetEncodingType(element_type.get());
616  return array_sp;
617 }
618 
619 
621  const MemberFunctionRecord &mfr,
622  CompilerType ct) {
623  Declaration decl;
624  return std::make_shared<lldb_private::Type>(
625  toOpaqueUid(type_id), this, ConstString(), 0, nullptr, LLDB_INVALID_UID,
628 }
629 
631  const ProcedureRecord &pr,
632  CompilerType ct) {
633  Declaration decl;
634  return std::make_shared<lldb_private::Type>(
635  toOpaqueUid(type_id), this, ConstString(), 0, nullptr, LLDB_INVALID_UID,
638 }
639 
641  if (type_id.index.isSimple())
642  return CreateSimpleType(type_id.index, ct);
643 
644  TpiStream &stream = type_id.is_ipi ? m_index->ipi() : m_index->tpi();
645  CVType cvt = stream.getType(type_id.index);
646 
647  if (cvt.kind() == LF_MODIFIER) {
648  ModifierRecord modifier;
649  llvm::cantFail(
650  TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier));
651  return CreateModifierType(type_id, modifier, ct);
652  }
653 
654  if (cvt.kind() == LF_POINTER) {
655  PointerRecord pointer;
656  llvm::cantFail(
657  TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer));
658  return CreatePointerType(type_id, pointer, ct);
659  }
660 
661  if (IsClassRecord(cvt.kind())) {
662  ClassRecord cr;
663  llvm::cantFail(TypeDeserializer::deserializeAs<ClassRecord>(cvt, cr));
664  return CreateTagType(type_id, cr, ct);
665  }
666 
667  if (cvt.kind() == LF_ENUM) {
668  EnumRecord er;
669  llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, er));
670  return CreateTagType(type_id, er, ct);
671  }
672 
673  if (cvt.kind() == LF_UNION) {
674  UnionRecord ur;
675  llvm::cantFail(TypeDeserializer::deserializeAs<UnionRecord>(cvt, ur));
676  return CreateTagType(type_id, ur, ct);
677  }
678 
679  if (cvt.kind() == LF_ARRAY) {
680  ArrayRecord ar;
681  llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar));
682  return CreateArrayType(type_id, ar, ct);
683  }
684 
685  if (cvt.kind() == LF_PROCEDURE) {
686  ProcedureRecord pr;
687  llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
688  return CreateProcedureType(type_id, pr, ct);
689  }
690  if (cvt.kind() == LF_MFUNCTION) {
691  MemberFunctionRecord mfr;
692  llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
693  return CreateFunctionType(type_id, mfr, ct);
694  }
695 
696  return nullptr;
697 }
698 
700  // If they search for a UDT which is a forward ref, try and resolve the full
701  // decl and just map the forward ref uid to the full decl record.
702  llvm::Optional<PdbTypeSymId> full_decl_uid;
703  if (IsForwardRefUdt(type_id, m_index->tpi())) {
704  auto expected_full_ti =
705  m_index->tpi().findFullDeclForForwardRef(type_id.index);
706  if (!expected_full_ti)
707  llvm::consumeError(expected_full_ti.takeError());
708  else if (*expected_full_ti != type_id.index) {
709  full_decl_uid = PdbTypeSymId(*expected_full_ti, false);
710 
711  // It's possible that a lookup would occur for the full decl causing it
712  // to be cached, then a second lookup would occur for the forward decl.
713  // We don't want to create a second full decl, so make sure the full
714  // decl hasn't already been cached.
715  auto full_iter = m_types.find(toOpaqueUid(*full_decl_uid));
716  if (full_iter != m_types.end()) {
717  TypeSP result = full_iter->second;
718  // Map the forward decl to the TypeSP for the full decl so we can take
719  // the fast path next time.
720  m_types[toOpaqueUid(type_id)] = result;
721  return result;
722  }
723  }
724  }
725 
726  PdbTypeSymId best_decl_id = full_decl_uid ? *full_decl_uid : type_id;
727 
728  clang::QualType qt = m_ast->GetOrCreateType(best_decl_id);
729 
730  TypeSP result = CreateType(best_decl_id, m_ast->ToCompilerType(qt));
731  if (!result)
732  return nullptr;
733 
734  uint64_t best_uid = toOpaqueUid(best_decl_id);
735  m_types[best_uid] = result;
736  // If we had both a forward decl and a full decl, make both point to the new
737  // type.
738  if (full_decl_uid)
739  m_types[toOpaqueUid(type_id)] = result;
740 
741  return result;
742 }
743 
745  // We can't use try_emplace / overwrite here because the process of creating
746  // a type could create nested types, which could invalidate iterators. So
747  // we have to do a 2-phase lookup / insert.
748  auto iter = m_types.find(toOpaqueUid(type_id));
749  if (iter != m_types.end())
750  return iter->second;
751 
752  TypeSP type = CreateAndCacheType(type_id);
753  if (type)
754  GetTypeList().Insert(type);
755  return type;
756 }
757 
759  CVSymbol sym = m_index->symrecords().readRecord(var_id.offset);
760  if (sym.kind() == S_CONSTANT)
761  return CreateConstantSymbol(var_id, sym);
762 
764  TypeIndex ti;
765  llvm::StringRef name;
766  lldb::addr_t addr = 0;
767  uint16_t section = 0;
768  uint32_t offset = 0;
769  bool is_external = false;
770  switch (sym.kind()) {
771  case S_GDATA32:
772  is_external = true;
773  LLVM_FALLTHROUGH;
774  case S_LDATA32: {
775  DataSym ds(sym.kind());
776  llvm::cantFail(SymbolDeserializer::deserializeAs<DataSym>(sym, ds));
777  ti = ds.Type;
778  scope = (sym.kind() == S_GDATA32) ? eValueTypeVariableGlobal
780  name = ds.Name;
781  section = ds.Segment;
782  offset = ds.DataOffset;
783  addr = m_index->MakeVirtualAddress(ds.Segment, ds.DataOffset);
784  break;
785  }
786  case S_GTHREAD32:
787  is_external = true;
788  LLVM_FALLTHROUGH;
789  case S_LTHREAD32: {
790  ThreadLocalDataSym tlds(sym.kind());
791  llvm::cantFail(
792  SymbolDeserializer::deserializeAs<ThreadLocalDataSym>(sym, tlds));
793  ti = tlds.Type;
794  name = tlds.Name;
795  section = tlds.Segment;
796  offset = tlds.DataOffset;
797  addr = m_index->MakeVirtualAddress(tlds.Segment, tlds.DataOffset);
799  break;
800  }
801  default:
802  llvm_unreachable("unreachable!");
803  }
804 
805  CompUnitSP comp_unit;
806  llvm::Optional<uint16_t> modi = m_index->GetModuleIndexForVa(addr);
807  if (modi) {
808  CompilandIndexItem &cci = m_index->compilands().GetOrCreateCompiland(*modi);
809  comp_unit = GetOrCreateCompileUnit(cci);
810  }
811 
812  Declaration decl;
813  PdbTypeSymId tid(ti, false);
814  SymbolFileTypeSP type_sp =
815  std::make_shared<SymbolFileType>(*this, toOpaqueUid(tid));
816  Variable::RangeList ranges;
817 
818  m_ast->GetOrCreateVariableDecl(var_id);
819 
821  section, offset, GetObjectFile()->GetModule());
822 
823  std::string global_name("::");
824  global_name += name;
825  bool artificial = false;
826  bool location_is_constant_data = false;
827  bool static_member = false;
828  VariableSP var_sp = std::make_shared<Variable>(
829  toOpaqueUid(var_id), name.str().c_str(), global_name.c_str(), type_sp,
830  scope, comp_unit.get(), ranges, &decl, location, is_external, artificial,
831  location_is_constant_data, static_member);
832 
833  return var_sp;
834 }
835 
836 lldb::VariableSP
838  const CVSymbol &cvs) {
839  TpiStream &tpi = m_index->tpi();
840  ConstantSym constant(cvs.kind());
841 
842  llvm::cantFail(SymbolDeserializer::deserializeAs<ConstantSym>(cvs, constant));
843  std::string global_name("::");
844  global_name += constant.Name;
845  PdbTypeSymId tid(constant.Type, false);
846  SymbolFileTypeSP type_sp =
847  std::make_shared<SymbolFileType>(*this, toOpaqueUid(tid));
848 
849  Declaration decl;
850  Variable::RangeList ranges;
851  ModuleSP module = GetObjectFile()->GetModule();
853  constant.Type, tpi, constant.Value, module);
854 
855  bool external = false;
856  bool artificial = false;
857  bool location_is_constant_data = true;
858  bool static_member = false;
859  VariableSP var_sp = std::make_shared<Variable>(
860  toOpaqueUid(var_id), constant.Name.str().c_str(), global_name.c_str(),
861  type_sp, eValueTypeVariableGlobal, module.get(), ranges, &decl, location,
862  external, artificial, location_is_constant_data, static_member);
863  return var_sp;
864 }
865 
866 VariableSP
868  auto emplace_result = m_global_vars.try_emplace(toOpaqueUid(var_id), nullptr);
869  if (emplace_result.second)
870  emplace_result.first->second = CreateGlobalVariable(var_id);
871 
872  return emplace_result.first->second;
873 }
874 
875 lldb::TypeSP SymbolFileNativePDB::GetOrCreateType(TypeIndex ti) {
876  return GetOrCreateType(PdbTypeSymId(ti, false));
877 }
878 
880  CompileUnit &comp_unit) {
881  auto emplace_result = m_functions.try_emplace(toOpaqueUid(func_id), nullptr);
882  if (emplace_result.second)
883  emplace_result.first->second = CreateFunction(func_id, comp_unit);
884 
885  return emplace_result.first->second;
886 }
887 
888 CompUnitSP
890 
891  auto emplace_result =
892  m_compilands.try_emplace(toOpaqueUid(cci.m_id), nullptr);
893  if (emplace_result.second)
894  emplace_result.first->second = CreateCompileUnit(cci);
895 
896  lldbassert(emplace_result.first->second);
897  return emplace_result.first->second;
898 }
899 
901  auto iter = m_blocks.find(toOpaqueUid(block_id));
902  if (iter != m_blocks.end())
903  return *iter->second;
904 
905  return CreateBlock(block_id);
906 }
907 
910  clang::DeclContext *context = m_ast->FromCompilerDeclContext(decl_ctx);
911  if (!context)
912  return;
913  m_ast->ParseDeclsForContext(*context);
914 }
915 
917  if (index >= GetNumCompileUnits())
918  return CompUnitSP();
919  lldbassert(index < UINT16_MAX);
920  if (index >= UINT16_MAX)
921  return nullptr;
922 
923  CompilandIndexItem &item = m_index->compilands().GetOrCreateCompiland(index);
924 
925  return GetOrCreateCompileUnit(item);
926 }
927 
929  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
930  PdbSymUid uid(comp_unit.GetID());
932 
933  CompilandIndexItem *item =
934  m_index->compilands().GetCompiland(uid.asCompiland().modi);
935  lldbassert(item);
936  if (!item->m_compile_opts)
938 
939  return TranslateLanguage(item->m_compile_opts->getLanguage());
940 }
941 
943 
945  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
946  PdbSymUid uid{comp_unit.GetID()};
947  lldbassert(uid.kind() == PdbSymUidKind::Compiland);
948  uint16_t modi = uid.asCompiland().modi;
949  CompilandIndexItem &cii = m_index->compilands().GetOrCreateCompiland(modi);
950 
951  size_t count = comp_unit.GetNumFunctions();
952  const CVSymbolArray &syms = cii.m_debug_stream.getSymbolArray();
953  for (auto iter = syms.begin(); iter != syms.end(); ++iter) {
954  if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32)
955  continue;
956 
957  PdbCompilandSymId sym_id{modi, iter.offset()};
958 
959  FunctionSP func = GetOrCreateFunction(sym_id, comp_unit);
960  }
961 
962  size_t new_count = comp_unit.GetNumFunctions();
963  lldbassert(new_count >= count);
964  return new_count - count;
965 }
966 
967 static bool NeedsResolvedCompileUnit(uint32_t resolve_scope) {
968  // If any of these flags are set, we need to resolve the compile unit.
969  uint32_t flags = eSymbolContextCompUnit;
970  flags |= eSymbolContextVariable;
971  flags |= eSymbolContextFunction;
972  flags |= eSymbolContextBlock;
973  flags |= eSymbolContextLineEntry;
974  return (resolve_scope & flags) != 0;
975 }
976 
978  const Address &addr, SymbolContextItem resolve_scope, SymbolContext &sc) {
979  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
980  uint32_t resolved_flags = 0;
981  lldb::addr_t file_addr = addr.GetFileAddress();
982 
983  if (NeedsResolvedCompileUnit(resolve_scope)) {
984  llvm::Optional<uint16_t> modi = m_index->GetModuleIndexForVa(file_addr);
985  if (!modi)
986  return 0;
987  CompUnitSP cu_sp = GetCompileUnitAtIndex(modi.getValue());
988  if (!cu_sp)
989  return 0;
990 
991  sc.comp_unit = cu_sp.get();
992  resolved_flags |= eSymbolContextCompUnit;
993  }
994 
995  if (resolve_scope & eSymbolContextFunction ||
996  resolve_scope & eSymbolContextBlock) {
997  lldbassert(sc.comp_unit);
998  std::vector<SymbolAndUid> matches = m_index->FindSymbolsByVa(file_addr);
999  // Search the matches in reverse. This way if there are multiple matches
1000  // (for example we are 3 levels deep in a nested scope) it will find the
1001  // innermost one first.
1002  for (const auto &match : llvm::reverse(matches)) {
1003  if (match.uid.kind() != PdbSymUidKind::CompilandSym)
1004  continue;
1005 
1006  PdbCompilandSymId csid = match.uid.asCompilandSym();
1007  CVSymbol cvs = m_index->ReadSymbolRecord(csid);
1008  PDB_SymType type = CVSymToPDBSym(cvs.kind());
1009  if (type != PDB_SymType::Function && type != PDB_SymType::Block)
1010  continue;
1011  if (type == PDB_SymType::Function) {
1012  sc.function = GetOrCreateFunction(csid, *sc.comp_unit).get();
1013  Block &block = sc.function->GetBlock(true);
1014  addr_t func_base =
1016  addr_t offset = file_addr - func_base;
1017  sc.block = block.FindInnermostBlockByOffset(offset);
1018  }
1019 
1020  if (type == PDB_SymType::Block) {
1021  sc.block = &GetOrCreateBlock(csid);
1023  }
1024  if (sc.function)
1025  resolved_flags |= eSymbolContextFunction;
1026  if (sc.block)
1027  resolved_flags |= eSymbolContextBlock;
1028  break;
1029  }
1030  }
1031 
1032  if (resolve_scope & eSymbolContextLineEntry) {
1033  lldbassert(sc.comp_unit);
1034  if (auto *line_table = sc.comp_unit->GetLineTable()) {
1035  if (line_table->FindLineEntryByAddress(addr, sc.line_entry))
1036  resolved_flags |= eSymbolContextLineEntry;
1037  }
1038  }
1039 
1040  return resolved_flags;
1041 }
1042 
1044  const SourceLocationSpec &src_location_spec,
1045  lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
1046  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1047  const uint32_t prev_size = sc_list.GetSize();
1048  if (resolve_scope & eSymbolContextCompUnit) {
1049  for (uint32_t cu_idx = 0, num_cus = GetNumCompileUnits(); cu_idx < num_cus;
1050  ++cu_idx) {
1051  CompileUnit *cu = ParseCompileUnitAtIndex(cu_idx).get();
1052  if (!cu)
1053  continue;
1054 
1055  bool file_spec_matches_cu_file_spec = FileSpec::Match(
1056  src_location_spec.GetFileSpec(), cu->GetPrimaryFile());
1057  if (file_spec_matches_cu_file_spec) {
1058  cu->ResolveSymbolContext(src_location_spec, resolve_scope, sc_list);
1059  break;
1060  }
1061  }
1062  }
1063  return sc_list.GetSize() - prev_size;
1064 }
1065 
1067  // Unfortunately LLDB is set up to parse the entire compile unit line table
1068  // all at once, even if all it really needs is line info for a specific
1069  // function. In the future it would be nice if it could set the sc.m_function
1070  // member, and we could only get the line info for the function in question.
1071  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1072  PdbSymUid cu_id(comp_unit.GetID());
1074  uint16_t modi = cu_id.asCompiland().modi;
1075  CompilandIndexItem *cii = m_index->compilands().GetCompiland(modi);
1076  lldbassert(cii);
1077 
1078  // Parse DEBUG_S_LINES subsections first, then parse all S_INLINESITE records
1079  // in this CU. Add line entries into the set first so that if there are line
1080  // entries with same addres, the later is always more accurate than the
1081  // former.
1082  std::set<LineTable::Entry, LineTableEntryComparator> line_set;
1083 
1084  // This is basically a copy of the .debug$S subsections from all original COFF
1085  // object files merged together with address relocations applied. We are
1086  // looking for all DEBUG_S_LINES subsections.
1087  for (const DebugSubsectionRecord &dssr :
1088  cii->m_debug_stream.getSubsectionsArray()) {
1089  if (dssr.kind() != DebugSubsectionKind::Lines)
1090  continue;
1091 
1092  DebugLinesSubsectionRef lines;
1093  llvm::BinaryStreamReader reader(dssr.getRecordData());
1094  if (auto EC = lines.initialize(reader)) {
1095  llvm::consumeError(std::move(EC));
1096  return false;
1097  }
1098 
1099  const LineFragmentHeader *lfh = lines.header();
1100  uint64_t virtual_addr =
1101  m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset);
1102 
1103  for (const LineColumnEntry &group : lines) {
1104  llvm::Expected<uint32_t> file_index_or_err =
1105  GetFileIndex(*cii, group.NameIndex);
1106  if (!file_index_or_err)
1107  continue;
1108  uint32_t file_index = file_index_or_err.get();
1109  lldbassert(!group.LineNumbers.empty());
1112  for (const LineNumberEntry &entry : group.LineNumbers) {
1113  LineInfo cur_info(entry.Flags);
1114 
1115  if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto())
1116  continue;
1117 
1118  uint64_t addr = virtual_addr + entry.Offset;
1119 
1120  bool is_statement = cur_info.isStatement();
1121  bool is_prologue = IsFunctionPrologue(*cii, addr);
1122  bool is_epilogue = IsFunctionEpilogue(*cii, addr);
1123 
1124  uint32_t lno = cur_info.getStartLine();
1125 
1126  LineTable::Entry new_entry(addr, lno, 0, file_index, is_statement, false,
1127  is_prologue, is_epilogue, false);
1128  // Terminal entry has lower precedence than new entry.
1129  auto iter = line_set.find(new_entry);
1130  if (iter != line_set.end() && iter->is_terminal_entry)
1131  line_set.erase(iter);
1132  line_set.insert(new_entry);
1133 
1134  if (line_entry.GetRangeBase() != LLDB_INVALID_ADDRESS) {
1135  line_entry.SetRangeEnd(addr);
1136  cii->m_global_line_table.Append(line_entry);
1137  }
1138  line_entry.SetRangeBase(addr);
1139  line_entry.data = {file_index, lno};
1140  }
1141  LineInfo last_line(group.LineNumbers.back().Flags);
1142  line_set.emplace(virtual_addr + lfh->CodeSize, last_line.getEndLine(), 0,
1143  file_index, false, false, false, false, true);
1144 
1145  if (line_entry.GetRangeBase() != LLDB_INVALID_ADDRESS) {
1146  line_entry.SetRangeEnd(virtual_addr + lfh->CodeSize);
1147  cii->m_global_line_table.Append(line_entry);
1148  }
1149  }
1150  }
1151 
1152  cii->m_global_line_table.Sort();
1153 
1154  // Parse all S_INLINESITE in this CU.
1155  const CVSymbolArray &syms = cii->m_debug_stream.getSymbolArray();
1156  for (auto iter = syms.begin(); iter != syms.end();) {
1157  if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) {
1158  ++iter;
1159  continue;
1160  }
1161 
1162  uint32_t record_offset = iter.offset();
1163  CVSymbol func_record =
1164  cii->m_debug_stream.readSymbolAtOffset(record_offset);
1166  addr_t file_vm_addr = m_index->MakeVirtualAddress(sol.so);
1167  AddressRange func_range(file_vm_addr, sol.length,
1168  comp_unit.GetModule()->GetSectionList());
1169  Address func_base = func_range.GetBaseAddress();
1170  PdbCompilandSymId func_id{modi, record_offset};
1171 
1172  // Iterate all S_INLINESITEs in the function.
1173  auto parse_inline_sites = [&](SymbolKind kind, PdbCompilandSymId id) {
1174  if (kind != S_INLINESITE)
1175  return false;
1176 
1177  ParseInlineSite(id, func_base);
1178 
1179  for (const auto &line_entry :
1180  m_inline_sites[toOpaqueUid(id)]->line_entries) {
1181  // If line_entry is not terminal entry, remove previous line entry at
1182  // the same address and insert new one. Terminal entry inside an inline
1183  // site might not be terminal entry for its parent.
1184  if (!line_entry.is_terminal_entry)
1185  line_set.erase(line_entry);
1186  line_set.insert(line_entry);
1187  }
1188  // No longer useful after adding to line_set.
1189  m_inline_sites[toOpaqueUid(id)]->line_entries.clear();
1190  return true;
1191  };
1192  ParseSymbolArrayInScope(func_id, parse_inline_sites);
1193  // Jump to the end of the function record.
1194  iter = syms.at(getScopeEndOffset(func_record));
1195  }
1196 
1197  cii->m_global_line_table.Clear();
1198 
1199  // Add line entries in line_set to line_table.
1200  auto line_table = std::make_unique<LineTable>(&comp_unit);
1201  std::unique_ptr<LineSequence> sequence(
1202  line_table->CreateLineSequenceContainer());
1203  for (const auto &line_entry : line_set) {
1204  line_table->AppendLineEntryToSequence(
1205  sequence.get(), line_entry.file_addr, line_entry.line,
1206  line_entry.column, line_entry.file_idx,
1207  line_entry.is_start_of_statement, line_entry.is_start_of_basic_block,
1208  line_entry.is_prologue_end, line_entry.is_epilogue_begin,
1209  line_entry.is_terminal_entry);
1210  }
1211  line_table->InsertSequence(sequence.get());
1212 
1213  if (line_table->GetSize() == 0)
1214  return false;
1215 
1216  comp_unit.SetLineTable(line_table.release());
1217  return true;
1218 }
1219 
1221  // PDB doesn't contain information about macros
1222  return false;
1223 }
1224 
1225 llvm::Expected<uint32_t>
1227  uint32_t file_id) {
1228  const auto &checksums = cii.m_strings.checksums().getArray();
1229  const auto &strings = cii.m_strings.strings();
1230  // Indices in this structure are actually offsets of records in the
1231  // DEBUG_S_FILECHECKSUMS subsection. Those entries then have an index
1232  // into the global PDB string table.
1233  auto iter = checksums.at(file_id);
1234  if (iter == checksums.end())
1235  return llvm::make_error<RawError>(raw_error_code::no_entry);
1236 
1237  llvm::Expected<llvm::StringRef> efn = strings.getString(iter->FileNameOffset);
1238  if (!efn) {
1239  return efn.takeError();
1240  }
1241 
1242  // LLDB wants the index of the file in the list of support files.
1243  auto fn_iter = llvm::find(cii.m_file_list, *efn);
1244  if (fn_iter != cii.m_file_list.end())
1245  return std::distance(cii.m_file_list.begin(), fn_iter);
1246  return llvm::make_error<RawError>(raw_error_code::no_entry);
1247 }
1248 
1250  FileSpecList &support_files) {
1251  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1252  PdbSymUid cu_id(comp_unit.GetID());
1254  CompilandIndexItem *cci =
1255  m_index->compilands().GetCompiland(cu_id.asCompiland().modi);
1256  lldbassert(cci);
1257 
1258  for (llvm::StringRef f : cci->m_file_list) {
1259  FileSpec::Style style =
1260  f.startswith("/") ? FileSpec::Style::posix : FileSpec::Style::windows;
1261  FileSpec spec(f, style);
1262  support_files.Append(spec);
1263  }
1264  return true;
1265 }
1266 
1268  const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
1269  // PDB does not yet support module debug info
1270  return false;
1271 }
1272 
1274  Address func_addr) {
1275  lldb::user_id_t opaque_uid = toOpaqueUid(id);
1276  if (m_inline_sites.find(opaque_uid) != m_inline_sites.end())
1277  return;
1278 
1279  addr_t func_base = func_addr.GetFileAddress();
1280  CompilandIndexItem *cii = m_index->compilands().GetCompiland(id.modi);
1281  CVSymbol sym = cii->m_debug_stream.readSymbolAtOffset(id.offset);
1282  CompUnitSP comp_unit = GetOrCreateCompileUnit(*cii);
1283 
1284  InlineSiteSym inline_site(static_cast<SymbolRecordKind>(sym.kind()));
1285  cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
1286  PdbCompilandSymId parent_id(id.modi, inline_site.Parent);
1287 
1288  std::shared_ptr<InlineSite> inline_site_sp =
1289  std::make_shared<InlineSite>(parent_id);
1290 
1291  // Get the inlined function declaration info.
1292  auto iter = cii->m_inline_map.find(inline_site.Inlinee);
1293  if (iter == cii->m_inline_map.end())
1294  return;
1295  InlineeSourceLine inlinee_line = iter->second;
1296 
1297  const FileSpecList &files = comp_unit->GetSupportFiles();
1298  FileSpec decl_file;
1299  llvm::Expected<uint32_t> file_index_or_err =
1300  GetFileIndex(*cii, inlinee_line.Header->FileID);
1301  if (!file_index_or_err)
1302  return;
1303  uint32_t file_offset = file_index_or_err.get();
1304  decl_file = files.GetFileSpecAtIndex(file_offset);
1305  uint32_t decl_line = inlinee_line.Header->SourceLineNum;
1306  std::unique_ptr<Declaration> decl_up =
1307  std::make_unique<Declaration>(decl_file, decl_line);
1308 
1309  // Parse range and line info.
1310  uint32_t code_offset = 0;
1311  int32_t line_offset = 0;
1312  llvm::Optional<uint32_t> code_offset_base;
1313  llvm::Optional<uint32_t> code_offset_end;
1314  llvm::Optional<int32_t> cur_line_offset;
1315  llvm::Optional<int32_t> next_line_offset;
1316  llvm::Optional<uint32_t> next_file_offset;
1317 
1318  bool is_terminal_entry = false;
1319  bool is_start_of_statement = true;
1320  // The first instruction is the prologue end.
1321  bool is_prologue_end = true;
1322 
1323  auto update_code_offset = [&](uint32_t code_delta) {
1324  if (!code_offset_base)
1325  code_offset_base = code_offset;
1326  else if (!code_offset_end)
1327  code_offset_end = *code_offset_base + code_delta;
1328  };
1329  auto update_line_offset = [&](int32_t line_delta) {
1330  line_offset += line_delta;
1331  if (!code_offset_base || !cur_line_offset)
1332  cur_line_offset = line_offset;
1333  else
1334  next_line_offset = line_offset;
1335  ;
1336  };
1337  auto update_file_offset = [&](uint32_t offset) {
1338  if (!code_offset_base)
1339  file_offset = offset;
1340  else
1341  next_file_offset = offset;
1342  };
1343 
1344  for (auto &annot : inline_site.annotations()) {
1345  switch (annot.OpCode) {
1346  case BinaryAnnotationsOpCode::CodeOffset:
1347  case BinaryAnnotationsOpCode::ChangeCodeOffset:
1348  case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
1349  code_offset += annot.U1;
1350  update_code_offset(annot.U1);
1351  break;
1352  case BinaryAnnotationsOpCode::ChangeLineOffset:
1353  update_line_offset(annot.S1);
1354  break;
1355  case BinaryAnnotationsOpCode::ChangeCodeLength:
1356  update_code_offset(annot.U1);
1357  code_offset += annot.U1;
1358  is_terminal_entry = true;
1359  break;
1360  case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset:
1361  code_offset += annot.U1;
1362  update_code_offset(annot.U1);
1363  update_line_offset(annot.S1);
1364  break;
1365  case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset:
1366  code_offset += annot.U2;
1367  update_code_offset(annot.U2);
1368  update_code_offset(annot.U1);
1369  code_offset += annot.U1;
1370  is_terminal_entry = true;
1371  break;
1372  case BinaryAnnotationsOpCode::ChangeFile:
1373  update_file_offset(annot.U1);
1374  break;
1375  default:
1376  break;
1377  }
1378 
1379  // Add range if current range is finished.
1380  if (code_offset_base && code_offset_end && cur_line_offset) {
1381  inline_site_sp->ranges.Append(RangeSourceLineVector::Entry(
1382  *code_offset_base, *code_offset_end - *code_offset_base,
1383  decl_line + *cur_line_offset));
1384  // Set base, end, file offset and line offset for next range.
1385  if (next_file_offset)
1386  file_offset = *next_file_offset;
1387  if (next_line_offset) {
1388  cur_line_offset = next_line_offset;
1389  next_line_offset = llvm::None;
1390  }
1391  code_offset_base = is_terminal_entry ? llvm::None : code_offset_end;
1392  code_offset_end = next_file_offset = llvm::None;
1393  }
1394  if (code_offset_base && cur_line_offset) {
1395  if (is_terminal_entry) {
1396  LineTable::Entry line_entry(
1397  func_base + *code_offset_base, decl_line + *cur_line_offset, 0,
1398  file_offset, false, false, false, false, true);
1399  inline_site_sp->line_entries.push_back(line_entry);
1400  } else {
1401  LineTable::Entry line_entry(func_base + *code_offset_base,
1402  decl_line + *cur_line_offset, 0,
1403  file_offset, is_start_of_statement, false,
1404  is_prologue_end, false, false);
1405  inline_site_sp->line_entries.push_back(line_entry);
1406  is_prologue_end = false;
1407  is_start_of_statement = false;
1408  }
1409  }
1410  if (is_terminal_entry)
1411  is_start_of_statement = true;
1412  is_terminal_entry = false;
1413  }
1414 
1415  inline_site_sp->ranges.Sort();
1416 
1417  // Get the inlined function callsite info.
1418  std::unique_ptr<Declaration> callsite_up;
1419  if (!inline_site_sp->ranges.IsEmpty()) {
1420  auto *entry = inline_site_sp->ranges.GetEntryAtIndex(0);
1421  addr_t base_offset = entry->GetRangeBase();
1422  if (cii->m_debug_stream.readSymbolAtOffset(parent_id.offset).kind() ==
1423  S_INLINESITE) {
1424  // Its parent is another inline site, lookup parent site's range vector
1425  // for callsite line.
1426  ParseInlineSite(parent_id, func_base);
1427  std::shared_ptr<InlineSite> parent_site =
1428  m_inline_sites[toOpaqueUid(parent_id)];
1429  FileSpec &parent_decl_file =
1430  parent_site->inline_function_info->GetDeclaration().GetFile();
1431  if (auto *parent_entry =
1432  parent_site->ranges.FindEntryThatContains(base_offset)) {
1433  callsite_up =
1434  std::make_unique<Declaration>(parent_decl_file, parent_entry->data);
1435  }
1436  } else {
1437  // Its parent is a function, lookup global line table for callsite.
1438  if (auto *entry = cii->m_global_line_table.FindEntryThatContains(
1439  func_base + base_offset)) {
1440  const FileSpec &callsite_file =
1441  files.GetFileSpecAtIndex(entry->data.first);
1442  callsite_up =
1443  std::make_unique<Declaration>(callsite_file, entry->data.second);
1444  }
1445  }
1446  }
1447 
1448  // Get the inlined function name.
1449  CVType inlinee_cvt = m_index->ipi().getType(inline_site.Inlinee);
1450  std::string inlinee_name;
1451  if (inlinee_cvt.kind() == LF_MFUNC_ID) {
1452  MemberFuncIdRecord mfr;
1453  cantFail(
1454  TypeDeserializer::deserializeAs<MemberFuncIdRecord>(inlinee_cvt, mfr));
1455  LazyRandomTypeCollection &types = m_index->tpi().typeCollection();
1456  inlinee_name.append(std::string(types.getTypeName(mfr.ClassType)));
1457  inlinee_name.append("::");
1458  inlinee_name.append(mfr.getName().str());
1459  } else if (inlinee_cvt.kind() == LF_FUNC_ID) {
1460  FuncIdRecord fir;
1461  cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(inlinee_cvt, fir));
1462  TypeIndex parent_idx = fir.getParentScope();
1463  if (!parent_idx.isNoneType()) {
1464  LazyRandomTypeCollection &ids = m_index->ipi().typeCollection();
1465  inlinee_name.append(std::string(ids.getTypeName(parent_idx)));
1466  inlinee_name.append("::");
1467  }
1468  inlinee_name.append(fir.getName().str());
1469  }
1470  inline_site_sp->inline_function_info = std::make_shared<InlineFunctionInfo>(
1471  inlinee_name.c_str(), llvm::StringRef(), decl_up.get(),
1472  callsite_up.get());
1473 
1474  m_inline_sites[opaque_uid] = inline_site_sp;
1475 }
1476 
1478  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1479  PdbCompilandSymId func_id = PdbSymUid(func.GetID()).asCompilandSym();
1480  // After we iterate through inline sites inside the function, we already get
1481  // all the info needed, removing from the map to save memory.
1482  std::set<uint64_t> remove_uids;
1483  auto parse_blocks = [&](SymbolKind kind, PdbCompilandSymId id) {
1484  if (kind == S_GPROC32 || kind == S_LPROC32 || kind == S_BLOCK32 ||
1485  kind == S_INLINESITE) {
1486  GetOrCreateBlock(id);
1487  if (kind == S_INLINESITE)
1488  remove_uids.insert(toOpaqueUid(id));
1489  return true;
1490  }
1491  return false;
1492  };
1493  size_t count = ParseSymbolArrayInScope(func_id, parse_blocks);
1494  for (uint64_t uid : remove_uids) {
1495  m_inline_sites.erase(uid);
1496  }
1497  return count;
1498 }
1499 
1501  PdbCompilandSymId parent_id,
1502  llvm::function_ref<bool(SymbolKind, PdbCompilandSymId)> fn) {
1503  CompilandIndexItem *cii = m_index->compilands().GetCompiland(parent_id.modi);
1504  CVSymbolArray syms =
1505  cii->m_debug_stream.getSymbolArrayForScope(parent_id.offset);
1506 
1507  size_t count = 1;
1508  for (auto iter = syms.begin(); iter != syms.end(); ++iter) {
1509  PdbCompilandSymId child_id(parent_id.modi, iter.offset());
1510  if (fn(iter->kind(), child_id))
1511  ++count;
1512  }
1513 
1514  return count;
1515 }
1516 
1518 
1520  ConstString name, const CompilerDeclContext &parent_decl_ctx,
1521  uint32_t max_matches, VariableList &variables) {
1522  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1523  using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1524 
1525  std::vector<SymbolAndOffset> results = m_index->globals().findRecordsByName(
1526  name.GetStringRef(), m_index->symrecords());
1527  for (const SymbolAndOffset &result : results) {
1528  VariableSP var;
1529  switch (result.second.kind()) {
1530  case SymbolKind::S_GDATA32:
1531  case SymbolKind::S_LDATA32:
1532  case SymbolKind::S_GTHREAD32:
1533  case SymbolKind::S_LTHREAD32:
1534  case SymbolKind::S_CONSTANT: {
1535  PdbGlobalSymId global(result.first, false);
1536  var = GetOrCreateGlobalVariable(global);
1537  variables.AddVariable(var);
1538  break;
1539  }
1540  default:
1541  continue;
1542  }
1543  }
1544 }
1545 
1547  ConstString name, const CompilerDeclContext &parent_decl_ctx,
1548  FunctionNameType name_type_mask, bool include_inlines,
1549  SymbolContextList &sc_list) {
1550  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1551  // For now we only support lookup by method name or full name.
1552  if (!(name_type_mask & eFunctionNameTypeFull ||
1553  name_type_mask & eFunctionNameTypeMethod))
1554  return;
1555 
1556  using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1557 
1558  std::vector<SymbolAndOffset> matches = m_index->globals().findRecordsByName(
1559  name.GetStringRef(), m_index->symrecords());
1560  for (const SymbolAndOffset &match : matches) {
1561  if (match.second.kind() != S_PROCREF && match.second.kind() != S_LPROCREF)
1562  continue;
1563  ProcRefSym proc(match.second.kind());
1564  cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(match.second, proc));
1565 
1566  if (!IsValidRecord(proc))
1567  continue;
1568 
1569  CompilandIndexItem &cci =
1570  m_index->compilands().GetOrCreateCompiland(proc.modi());
1571  SymbolContext sc;
1572 
1573  sc.comp_unit = GetOrCreateCompileUnit(cci).get();
1574  PdbCompilandSymId func_id(proc.modi(), proc.SymOffset);
1575  sc.function = GetOrCreateFunction(func_id, *sc.comp_unit).get();
1576 
1577  sc_list.Append(sc);
1578  }
1579 }
1580 
1582  bool include_inlines,
1583  SymbolContextList &sc_list) {}
1584 
1586  ConstString name, const CompilerDeclContext &parent_decl_ctx,
1587  uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
1588  TypeMap &types) {
1589  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1590  if (!name)
1591  return;
1592 
1593  searched_symbol_files.clear();
1594  searched_symbol_files.insert(this);
1595 
1596  // There is an assumption 'name' is not a regex
1597  FindTypesByName(name.GetStringRef(), max_matches, types);
1598 }
1599 
1601  llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
1602  llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) {}
1603 
1604 void SymbolFileNativePDB::FindTypesByName(llvm::StringRef name,
1605  uint32_t max_matches,
1606  TypeMap &types) {
1607 
1608  std::vector<TypeIndex> matches = m_index->tpi().findRecordsByName(name);
1609  if (max_matches > 0 && max_matches < matches.size())
1610  matches.resize(max_matches);
1611 
1612  for (TypeIndex ti : matches) {
1613  TypeSP type = GetOrCreateType(ti);
1614  if (!type)
1615  continue;
1616 
1617  types.Insert(type);
1618  }
1619 }
1620 
1622  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1623  // Only do the full type scan the first time.
1625  return 0;
1626 
1627  const size_t old_count = GetTypeList().GetSize();
1628  LazyRandomTypeCollection &types = m_index->tpi().typeCollection();
1629 
1630  // First process the entire TPI stream.
1631  for (auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
1632  TypeSP type = GetOrCreateType(*ti);
1633  if (type)
1634  (void)type->GetFullCompilerType();
1635  }
1636 
1637  // Next look for S_UDT records in the globals stream.
1638  for (const uint32_t gid : m_index->globals().getGlobalsTable()) {
1639  PdbGlobalSymId global{gid, false};
1640  CVSymbol sym = m_index->ReadSymbolRecord(global);
1641  if (sym.kind() != S_UDT)
1642  continue;
1643 
1644  UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1645  bool is_typedef = true;
1646  if (IsTagRecord(PdbTypeSymId{udt.Type, false}, m_index->tpi())) {
1647  CVType cvt = m_index->tpi().getType(udt.Type);
1648  llvm::StringRef name = CVTagRecord::create(cvt).name();
1649  if (name == udt.Name)
1650  is_typedef = false;
1651  }
1652 
1653  if (is_typedef)
1654  GetOrCreateTypedef(global);
1655  }
1656 
1657  const size_t new_count = GetTypeList().GetSize();
1658 
1659  m_done_full_type_scan = true;
1660 
1661  return new_count - old_count;
1662 }
1663 
1664 size_t
1666  VariableList &variables) {
1667  PdbSymUid sym_uid(comp_unit.GetID());
1669  return 0;
1670 }
1671 
1673  PdbCompilandSymId var_id,
1674  bool is_param) {
1675  ModuleSP module = GetObjectFile()->GetModule();
1676  Block &block = GetOrCreateBlock(scope_id);
1677  VariableInfo var_info =
1678  GetVariableLocationInfo(*m_index, var_id, block, module);
1679  if (!var_info.location || !var_info.ranges)
1680  return nullptr;
1681 
1682  CompilandIndexItem *cii = m_index->compilands().GetCompiland(var_id.modi);
1683  CompUnitSP comp_unit_sp = GetOrCreateCompileUnit(*cii);
1684  TypeSP type_sp = GetOrCreateType(var_info.type);
1685  std::string name = var_info.name.str();
1686  Declaration decl;
1687  SymbolFileTypeSP sftype =
1688  std::make_shared<SymbolFileType>(*this, type_sp->GetID());
1689 
1690  is_param |= var_info.is_param;
1691  ValueType var_scope =
1693  bool external = false;
1694  bool artificial = false;
1695  bool location_is_constant_data = false;
1696  bool static_member = false;
1697  VariableSP var_sp = std::make_shared<Variable>(
1698  toOpaqueUid(var_id), name.c_str(), name.c_str(), sftype, var_scope,
1699  &block, *var_info.ranges, &decl, *var_info.location, external,
1700  artificial, location_is_constant_data, static_member);
1701 
1702  if (!is_param)
1703  m_ast->GetOrCreateVariableDecl(scope_id, var_id);
1704 
1705  m_local_variables[toOpaqueUid(var_id)] = var_sp;
1706  return var_sp;
1707 }
1708 
1710  PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param) {
1711  auto iter = m_local_variables.find(toOpaqueUid(var_id));
1712  if (iter != m_local_variables.end())
1713  return iter->second;
1714 
1715  return CreateLocalVariable(scope_id, var_id, is_param);
1716 }
1717 
1719  CVSymbol sym = m_index->ReadSymbolRecord(id);
1720  lldbassert(sym.kind() == SymbolKind::S_UDT);
1721 
1722  UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1723 
1724  TypeSP target_type = GetOrCreateType(udt.Type);
1725 
1726  (void)m_ast->GetOrCreateTypedefDecl(id);
1727 
1728  Declaration decl;
1729  return std::make_shared<lldb_private::Type>(
1730  toOpaqueUid(id), this, ConstString(udt.Name),
1731  target_type->GetByteSize(nullptr), nullptr, target_type->GetID(),
1733  target_type->GetForwardCompilerType(),
1735 }
1736 
1738  auto iter = m_types.find(toOpaqueUid(id));
1739  if (iter != m_types.end())
1740  return iter->second;
1741 
1742  return CreateTypedef(id);
1743 }
1744 
1746  Block &block = GetOrCreateBlock(block_id);
1747 
1748  size_t count = 0;
1749 
1750  CompilandIndexItem *cii = m_index->compilands().GetCompiland(block_id.modi);
1751  CVSymbol sym = cii->m_debug_stream.readSymbolAtOffset(block_id.offset);
1752  uint32_t params_remaining = 0;
1753  switch (sym.kind()) {
1754  case S_GPROC32:
1755  case S_LPROC32: {
1756  ProcSym proc(static_cast<SymbolRecordKind>(sym.kind()));
1757  cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym, proc));
1758  CVType signature = m_index->tpi().getType(proc.FunctionType);
1759  ProcedureRecord sig;
1760  cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(signature, sig));
1761  params_remaining = sig.getParameterCount();
1762  break;
1763  }
1764  case S_BLOCK32:
1765  break;
1766  case S_INLINESITE:
1767  break;
1768  default:
1769  lldbassert(false && "Symbol is not a block!");
1770  return 0;
1771  }
1772 
1773  VariableListSP variables = block.GetBlockVariableList(false);
1774  if (!variables) {
1775  variables = std::make_shared<VariableList>();
1776  block.SetVariableList(variables);
1777  }
1778 
1779  CVSymbolArray syms = limitSymbolArrayToScope(
1780  cii->m_debug_stream.getSymbolArray(), block_id.offset);
1781 
1782  // Skip the first record since it's a PROC32 or BLOCK32, and there's
1783  // no point examining it since we know it's not a local variable.
1784  syms.drop_front();
1785  auto iter = syms.begin();
1786  auto end = syms.end();
1787 
1788  while (iter != end) {
1789  uint32_t record_offset = iter.offset();
1790  CVSymbol variable_cvs = *iter;
1791  PdbCompilandSymId child_sym_id(block_id.modi, record_offset);
1792  ++iter;
1793 
1794  // If this is a block or inline site, recurse into its children and then
1795  // skip it.
1796  if (variable_cvs.kind() == S_BLOCK32 ||
1797  variable_cvs.kind() == S_INLINESITE) {
1798  uint32_t block_end = getScopeEndOffset(variable_cvs);
1799  count += ParseVariablesForBlock(child_sym_id);
1800  iter = syms.at(block_end);
1801  continue;
1802  }
1803 
1804  bool is_param = params_remaining > 0;
1805  VariableSP variable;
1806  switch (variable_cvs.kind()) {
1807  case S_REGREL32:
1808  case S_REGISTER:
1809  case S_LOCAL:
1810  variable = GetOrCreateLocalVariable(block_id, child_sym_id, is_param);
1811  if (is_param)
1812  --params_remaining;
1813  if (variable)
1814  variables->AddVariableIfUnique(variable);
1815  break;
1816  default:
1817  break;
1818  }
1819  }
1820 
1821  // Pass false for set_children, since we call this recursively so that the
1822  // children will call this for themselves.
1823  block.SetDidParseVariables(true, false);
1824 
1825  return count;
1826 }
1827 
1829  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1830  lldbassert(sc.function || sc.comp_unit);
1831 
1832  VariableListSP variables;
1833  if (sc.block) {
1834  PdbSymUid block_id(sc.block->GetID());
1835 
1836  size_t count = ParseVariablesForBlock(block_id.asCompilandSym());
1837  return count;
1838  }
1839 
1840  if (sc.function) {
1841  PdbSymUid block_id(sc.function->GetID());
1842 
1843  size_t count = ParseVariablesForBlock(block_id.asCompilandSym());
1844  return count;
1845  }
1846 
1847  if (sc.comp_unit) {
1848  variables = sc.comp_unit->GetVariableList(false);
1849  if (!variables) {
1850  variables = std::make_shared<VariableList>();
1851  sc.comp_unit->SetVariableList(variables);
1852  }
1853  return ParseVariablesForCompileUnit(*sc.comp_unit, *variables);
1854  }
1855 
1856  llvm_unreachable("Unreachable!");
1857 }
1858 
1860  if (auto decl = m_ast->GetOrCreateDeclForUid(uid))
1861  return decl.getValue();
1862  else
1863  return CompilerDecl();
1864 }
1865 
1868  clang::DeclContext *context =
1869  m_ast->GetOrCreateDeclContextForUid(PdbSymUid(uid));
1870  if (!context)
1871  return {};
1872 
1873  return m_ast->ToCompilerDeclContext(*context);
1874 }
1875 
1878  clang::DeclContext *context = m_ast->GetParentDeclContext(PdbSymUid(uid));
1879  return m_ast->ToCompilerDeclContext(*context);
1880 }
1881 
1883  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1884  auto iter = m_types.find(type_uid);
1885  // lldb should not be passing us non-sensical type uids. the only way it
1886  // could have a type uid in the first place is if we handed it out, in which
1887  // case we should know about the type. However, that doesn't mean we've
1888  // instantiated it yet. We can vend out a UID for a future type. So if the
1889  // type doesn't exist, let's instantiate it now.
1890  if (iter != m_types.end())
1891  return &*iter->second;
1892 
1893  PdbSymUid uid(type_uid);
1895  PdbTypeSymId type_id = uid.asTypeSym();
1896  if (type_id.index.isNoneType())
1897  return nullptr;
1898 
1899  TypeSP type_sp = CreateAndCacheType(type_id);
1900  return &*type_sp;
1901 }
1902 
1903 llvm::Optional<SymbolFile::ArrayInfo>
1905  lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) {
1906  return llvm::None;
1907 }
1908 
1909 
1911  clang::QualType qt =
1912  clang::QualType::getFromOpaquePtr(compiler_type.GetOpaqueQualType());
1913 
1914  return m_ast->CompleteType(qt);
1915 }
1916 
1918  TypeClass type_mask,
1919  lldb_private::TypeList &type_list) {}
1920 
1923  const CompilerDeclContext &parent_decl_ctx) {
1924  return {};
1925 }
1926 
1927 llvm::Expected<TypeSystem &>
1929  auto type_system_or_err =
1930  m_objfile_sp->GetModule()->GetTypeSystemForLanguage(language);
1931  if (type_system_or_err) {
1932  type_system_or_err->SetSymbolFile(this);
1933  }
1934  return type_system_or_err;
1935 }
1936 
1938  // PDB files are a separate file that contains all debug info.
1939  return m_index->pdb().getFileSize();
1940 }
lldb_private::SourceLocationSpec::GetFileSpec
FileSpec GetFileSpec() const
Definition: SourceLocationSpec.h:166
lldb_private::Block::FindInnermostBlockByOffset
Block * FindInnermostBlockByOffset(const lldb::addr_t offset)
Definition: Block.cpp:126
lldb_private::npdb::PdbSymUidKind::Type
@ Type
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
lldb_private::npdb::CompilandIndexItem::m_debug_stream
llvm::pdb::ModuleDebugStreamRef m_debug_stream
Definition: CompileUnitIndex.h:48
lldb_private::SymbolFile
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:45
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
lldb_private::Range::GetRangeBase
BaseType GetRangeBase() const
Definition: RangeMap.h:46
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
lldb_private::npdb::SymbolFileNativePDB::GetOrCreateLocalVariable
lldb::VariableSP GetOrCreateLocalVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param)
Definition: SymbolFileNativePDB.cpp:1709
lldb_private::CompileUnit::GetVariableList
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
Definition: CompileUnit.cpp:208
lldb_private::npdb::SymbolFileNativePDB::GetFileIndex
llvm::Expected< uint32_t > GetFileIndex(const CompilandIndexItem &cii, uint32_t file_id)
Definition: SymbolFileNativePDB.cpp:1226
lldb::eValueTypeVariableGlobal
@ eValueTypeVariableGlobal
globals variable
Definition: lldb-enumerations.h:317
lldb_private::Block::GetBlockVariableList
lldb::VariableListSP GetBlockVariableList(bool can_create)
Get the variable list for this block only.
Definition: Block.cpp:399
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::npdb::PdbSymUid::asTypeSym
PdbTypeSymId asTypeSym() const
Definition: PdbSymUid.cpp:144
lldb_private::npdb::SymbolFileNativePDB::GetOrCreateTypedef
lldb::TypeSP GetOrCreateTypedef(PdbGlobalSymId id)
Definition: SymbolFileNativePDB.cpp:1737
lldb_private::npdb::SymbolFileNativePDB::GetDebugInfoSize
uint64_t GetDebugInfoSize() override
Metrics gathering functions.
Definition: SymbolFileNativePDB.cpp:1937
lldb_private::npdb::SymbolFileNativePDB::m_ast
std::unique_ptr< PdbAstBuilder > m_ast
Definition: SymbolFileNativePDB.h:266
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
lldb_private::npdb::SymbolFileNativePDB::CreateGlobalVariable
lldb::VariableSP CreateGlobalVariable(PdbGlobalSymId var_id)
Definition: SymbolFileNativePDB.cpp:758
lldb_private::LLDBLog::Symbols
@ Symbols
CompileUnit.h
lldb_private::npdb::SymbolFileNativePDB::CreateFunctionType
lldb::TypeSP CreateFunctionType(PdbTypeSymId type_id, const llvm::codeview::MemberFunctionRecord &pr, CompilerType ct)
Definition: SymbolFileNativePDB.cpp:620
lldb_private::Function::GetAddressRange
const AddressRange & GetAddressRange()
Definition: Function.h:457
lldb_private::npdb::SymbolFileNativePDB::CreateSimpleType
lldb::TypeSP CreateSimpleType(llvm::codeview::TypeIndex ti, CompilerType ct)
Definition: SymbolFileNativePDB.cpp:501
lldb_private::npdb::SymbolFileNativePDB::ParseLineTable
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileNativePDB.cpp:1066
lldb_private::npdb::SegmentOffsetLength
Definition: PdbUtil.h:95
lldb_private::SourceLocationSpec
Definition: SourceLocationSpec.h:27
lldb_private::Type::eEncodingIsTypedefUID
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
Definition: Type.h:83
lldb_private::npdb::PdbSymUid::asCompilandSym
PdbCompilandSymId asCompilandSym() const
Definition: PdbSymUid.cpp:125
lldb_private::VariableList::AddVariable
void AddVariable(const lldb::VariableSP &var_sp)
Definition: VariableList.cpp:25
lldb_private::npdb::CVSymToPDBSym
llvm::pdb::PDB_SymType CVSymToPDBSym(llvm::codeview::SymbolKind kind)
lldb_private::npdb::SymbolFileNativePDB
Definition: SymbolFileNativePDB.h:42
MSVCUndecoratedNameParser
Definition: MSVCUndecoratedNameParser.h:31
lldb_private::SymbolContextList::Append
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
Definition: SymbolContext.cpp:1189
lldb_private::npdb::SymbolFileNativePDB::ParseTypes
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileNativePDB.cpp:1621
lldb_private::npdb::SymbolFileNativePDB::FindTypes
void FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet< SymbolFile * > &searched_symbol_files, TypeMap &types) override
Definition: SymbolFileNativePDB.cpp:1585
MSVCUndecoratedNameParser::GetSpecifiers
llvm::ArrayRef< MSVCUndecoratedNameSpecifier > GetSpecifiers() const
Definition: MSVCUndecoratedNameParser.h:35
TranslateLanguage
static lldb::LanguageType TranslateLanguage(PDB_Lang lang)
Definition: SymbolFileNativePDB.cpp:75
lldb_private::npdb::PdbCompilandSymId
Definition: PdbSymUid.h:44
lldb_private::npdb::VariableInfo::type
llvm::codeview::TypeIndex type
Definition: PdbUtil.h:105
lldb_private::npdb::PdbTypeSymId::index
llvm::codeview::TypeIndex index
Definition: PdbSymUid.h:76
LLDB_INVALID_UID
#define LLDB_INVALID_UID
Definition: lldb-defines.h:80
lldb_private::npdb::SymbolFileNativePDB::m_index
std::unique_ptr< PdbIndex > m_index
Definition: SymbolFileNativePDB.h:264
lldb_private::npdb::GetSegmentOffsetAndLength
SegmentOffsetLength GetSegmentOffsetAndLength(const llvm::codeview::CVSymbol &sym)
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
GetSimpleTypeName
static llvm::StringRef GetSimpleTypeName(SimpleTypeKind kind)
Definition: SymbolFileNativePDB.cpp:156
lldb_private::SymbolFile::GetModuleMutex
virtual std::recursive_mutex & GetModuleMutex() const
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
Definition: SymbolFile.cpp:35
IsFunctionEpilogue
static bool IsFunctionEpilogue(const CompilandIndexItem &cci, lldb::addr_t addr)
Definition: SymbolFileNativePDB.cpp:150
lldb_private::npdb::SymbolFileNativePDB::ParseBlocksRecursive
size_t ParseBlocksRecursive(Function &func) override
Definition: SymbolFileNativePDB.cpp:1477
Module.h
lldb_private::npdb::SymbolFileNativePDB::GetTypes
void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list) override
Definition: SymbolFileNativePDB.cpp:1917
lldb_private::npdb::SymbolFileNativePDB::GetOrCreateGlobalVariable
lldb::VariableSP GetOrCreateGlobalVariable(PdbGlobalSymId var_id)
Definition: SymbolFileNativePDB.cpp:867
lldb_private::npdb::SymbolFileNativePDB::CreateFunction
lldb::FunctionSP CreateFunction(PdbCompilandSymId func_id, CompileUnit &comp_unit)
Definition: SymbolFileNativePDB.cpp:400
GetUnqualifiedTypeName
static std::string GetUnqualifiedTypeName(const TagRecord &record)
Definition: SymbolFileNativePDB.cpp:544
lldb_private::npdb::PdbCompilandSymId::modi
uint16_t modi
Definition: PdbSymUid.h:49
lldb_private::RangeDataVector::Sort
void Sort()
Definition: RangeMap.h:448
lldb_private::CompileUnit::SetVariableList
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
Definition: CompileUnit.cpp:365
lldb_private::npdb::SymbolFileNativePDB::CreateConstantSymbol
lldb::VariableSP CreateConstantSymbol(PdbGlobalSymId var_id, const llvm::codeview::CVSymbol &cvs)
Definition: SymbolFileNativePDB.cpp:837
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::CompilerDecl
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
lldb_private::npdb::SymbolFileNativePDB::ResolveSymbolContext
uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) override
lldb_private::CompilerType::GetOpaqueQualType
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:173
lldb_private::npdb::SymbolFileNativePDB::GetOrCreateType
lldb::TypeSP GetOrCreateType(PdbTypeSymId type_id)
Definition: SymbolFileNativePDB.cpp:744
lldb_private::npdb::VariableInfo::location
llvm::Optional< DWARFExpression > location
Definition: PdbUtil.h:106
lldb_private::RangeDataVector::Clear
void Clear()
Definition: RangeMap.h:510
lldb_private::npdb::PdbGlobalSymId::offset
uint32_t offset
Definition: PdbSymUid.h:63
lldb_private::npdb::SymbolFileNativePDB::m_obj_load_address
lldb::addr_t m_obj_load_address
Definition: SymbolFileNativePDB.h:260
lldb_private::npdb::GetTypeSizeForSimpleKind
size_t GetTypeSizeForSimpleKind(llvm::codeview::SimpleTypeKind kind)
lldb_private::Stream
Definition: Stream.h:28
lldb_private::RangeData
Definition: RangeMap.h:410
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::npdb::SymbolFileNativePDB::GetDeclContextForUID
CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
Definition: SymbolFileNativePDB.cpp:1867
lldb::eLanguageTypeRust
@ eLanguageTypeRust
Rust.
Definition: lldb-enumerations.h:467
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
lldb_private::npdb::SymbolFileNativePDB::CreateTagType
lldb::TypeSP CreateTagType(PdbTypeSymId type_id, const llvm::codeview::ClassRecord &cr, CompilerType ct)
lldb_private::npdb::VariableInfo::name
llvm::StringRef name
Definition: PdbUtil.h:104
lldb_private::npdb::SymbolFileNativePDB::CreateCompileUnit
lldb::CompUnitSP CreateCompileUnit(const CompilandIndexItem &cci)
Definition: SymbolFileNativePDB.cpp:441
lldb_private::FileSpec::CopyByRemovingLastPathComponent
FileSpec CopyByRemovingLastPathComponent() const
Definition: FileSpec.cpp:405
lldb_private::SymbolFileCommon
Containing protected virtual methods for child classes to override.
Definition: SymbolFile.h:374
lldb_private::npdb::SymbolFileNativePDB::GetTypeSystemForLanguage
llvm::Expected< TypeSystem & > GetTypeSystemForLanguage(lldb::LanguageType language) override
Definition: SymbolFileNativePDB.cpp:1928
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::npdb::SymbolFileNativePDB::ResolveTypeUID
Type * ResolveTypeUID(lldb::user_id_t type_uid) override
Definition: SymbolFileNativePDB.cpp:1882
lldb_private::npdb::SymbolFileNativePDB::CompleteType
bool CompleteType(CompilerType &compiler_type) override
Definition: SymbolFileNativePDB.cpp:1910
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::npdb::SymbolFileNativePDB::ParseImportedModules
bool ParseImportedModules(const SymbolContext &sc, std::vector< lldb_private::SourceModule > &imported_modules) override
Definition: SymbolFileNativePDB.cpp:1267
lldb_private::npdb::SymbolFileNativePDB::GetDeclContextContainingUID
CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
Definition: SymbolFileNativePDB.cpp:1877
ClangUtil.h
lldb_private::npdb::PdbSymUidKind::Compiland
@ Compiland
lldb_private::CompileUnit
Definition: CompileUnit.h:38
lldb_private::npdb::CVTagRecord::create
static CVTagRecord create(llvm::codeview::CVType type)
Definition: PdbUtil.cpp:72
lldb_private::npdb::CompilandIndexItem::m_compile_opts
llvm::Optional< llvm::codeview::Compile3Sym > m_compile_opts
Definition: CompileUnitIndex.h:65
lldb_private::Block::AddRange
void AddRange(const Range &range)
Add a new offset range to this block.
Definition: Block.cpp:335
StreamBuffer.h
lldb_private::RangeDataVector::FindEntryThatContains
Entry * FindEntryThatContains(B addr)
Definition: RangeMap.h:551
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::npdb::SymbolFileNativePDB::CreateLocalVariable
lldb::VariableSP CreateLocalVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param)
Definition: SymbolFileNativePDB.cpp:1672
lldb_private::Range::SetRangeEnd
void SetRangeEnd(BaseType end)
Definition: RangeMap.h:75
lldb_private::SymbolFileCommon::m_objfile_sp
lldb::ObjectFileSP m_objfile_sp
Definition: SymbolFile.h:444
lldb_private::Function
Definition: Function.h:409
lldb_private::RangeDataVector::Append
void Append(const Entry &entry)
Definition: RangeMap.h:446
lldb_private::npdb::SymbolFileNativePDB::GetDynamicArrayInfoForUID
llvm::Optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) override
If type_uid points to an array type, return its characteristics.
Definition: SymbolFileNativePDB.cpp:1904
lldb_private::npdb::SymbolFileNativePDB::ParseSymbolArrayInScope
size_t ParseSymbolArrayInScope(PdbCompilandSymId parent, llvm::function_ref< bool(llvm::codeview::SymbolKind, PdbCompilandSymId)> fn)
Definition: SymbolFileNativePDB.cpp:1500
lldb_private::npdb::PdbSymUidKind::CompilandSym
@ CompilandSym
ID
static char ID
Definition: IRDynamicChecks.cpp:33
lldb_private::npdb::toOpaqueUid
uint64_t toOpaqueUid(const T &cid)
Definition: PdbSymUid.h:114
lldb_private::npdb::CompilandIndexItem::m_global_line_table
GlobalLineTable m_global_line_table
Definition: CompileUnitIndex.h:84
lldb_private::npdb::PdbGlobalSymId
Definition: PdbSymUid.h:57
lldb_private::npdb::GetVariableLocationInfo
VariableInfo GetVariableLocationInfo(PdbIndex &index, PdbCompilandSymId var_id, Block &block, lldb::ModuleSP module)
Definition: PdbUtil.cpp:603
lldb_private::npdb::SymbolFileNativePDB::m_inline_sites
llvm::DenseMap< lldb::user_id_t, std::shared_ptr< InlineSite > > m_inline_sites
Definition: SymbolFileNativePDB.h:274
lldb_private::SymbolFileCommon::GetTypeList
virtual TypeList & GetTypeList()
Definition: SymbolFile.h:441
lldb_private::npdb::CompilandIndexItem::m_file_list
std::vector< llvm::StringRef > m_file_list
Definition: CompileUnitIndex.h:56
lldb_private::npdb::SymbolFileNativePDB::CreateTypedef
lldb::TypeSP CreateTypedef(PdbGlobalSymId id)
Definition: SymbolFileNativePDB.cpp:1718
lldb_private::npdb::SymbolFileNativePDB::m_global_vars
llvm::DenseMap< lldb::user_id_t, lldb::VariableSP > m_global_vars
Definition: SymbolFileNativePDB.h:268
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:202
Log.h
lldb_private::SymbolFile::LocalVariables
@ LocalVariables
Definition: SymbolFile.h:68
TypeSystemClang.h
lldb_private::TypeList::Insert
void Insert(const lldb::TypeSP &type)
Definition: TypeList.cpp:27
lldb_private::npdb::SymbolFileNativePDB::ParseVariablesForContext
size_t ParseVariablesForContext(const SymbolContext &sc) override
Definition: SymbolFileNativePDB.cpp:1828
lldb_private::Function::GetBlock
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:345
lldb_private::FileSpec::Match
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition: FileSpec.cpp:300
lldb_private::npdb::SymbolFileNativePDB::CreateClassStructUnion
lldb::TypeSP CreateClassStructUnion(PdbTypeSymId type_id, const llvm::codeview::TagRecord &record, size_t size, CompilerType ct)
Definition: SymbolFileNativePDB.cpp:564
lldb_private::npdb::SymbolFileNativePDB::ParseLanguage
lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileNativePDB.cpp:928
lldb_private::npdb::SymbolFileNativePDB::m_functions
llvm::DenseMap< lldb::user_id_t, lldb::FunctionSP > m_functions
Definition: SymbolFileNativePDB.h:271
lldb_private::npdb::SymbolFileNativePDB::m_local_variables
llvm::DenseMap< lldb::user_id_t, lldb::VariableSP > m_local_variables
Definition: SymbolFileNativePDB.h:269
lldb_private::Block::AddChild
void AddChild(const lldb::BlockSP &child_block_sp)
Add a child to this object.
Definition: Block.cpp:385
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb_private::npdb::SymbolFileNativePDB::FindNamespace
CompilerDeclContext FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx) override
Definition: SymbolFileNativePDB.cpp:1922
lldb_private::CompileUnit::AddFunction
void AddFunction(lldb::FunctionSP &function_sp)
Add a function to this compile unit.
Definition: CompileUnit.cpp:139
IsClassRecord
static bool IsClassRecord(TypeLeafKind kind)
Definition: SymbolFileNativePDB.cpp:225
lldb_private::Block::CalculateSymbolContextFunction
Function * CalculateSymbolContextFunction() override
Definition: Block.cpp:154
lldb_private::DWARFExpression
Definition: DWARFExpression.h:36
llvm::pdb
Definition: DWARFLocationExpression.h:23
lldb_private::TypeList::GetSize
uint32_t GetSize() const
Definition: TypeList.cpp:60
lldb_private::npdb::SymbolFileNativePDB::m_types
llvm::DenseMap< lldb::user_id_t, lldb::TypeSP > m_types
Definition: SymbolFileNativePDB.h:273
lldb_private::SymbolContextList::GetSize
uint32_t GetSize() const
Get accessor for a symbol context list size.
Definition: SymbolContext.cpp:1279
lldb_private::npdb::SymbolFileNativePDB::ParseCompileUnitAtIndex
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
Definition: SymbolFileNativePDB.cpp:916
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::npdb::SymbolFileNativePDB::CreatePointerType
lldb::TypeSP CreatePointerType(PdbTypeSymId type_id, const llvm::codeview::PointerRecord &pr, CompilerType ct)
Definition: SymbolFileNativePDB.cpp:482
MSVCUndecoratedNameParser.h
lldb_private::npdb::PdbTypeSymId
Definition: PdbSymUid.h:70
lldb_private::npdb::SymbolFileNativePDB::ParseVariablesForBlock
size_t ParseVariablesForBlock(PdbCompilandSymId block_id)
Definition: SymbolFileNativePDB.cpp:1745
lldb_private::npdb::SymbolFileNativePDB::CreateBlock
Block & CreateBlock(PdbCompilandSymId block_id)
Definition: SymbolFileNativePDB.cpp:335
lldb_private::npdb::IsTagRecord
bool IsTagRecord(llvm::codeview::CVType cvt)
Definition: PdbUtil.cpp:391
lldb_private::npdb::PdbCompilandSymId::offset
uint32_t offset
Definition: PdbSymUid.h:54
lldb_private::AddressRange
Definition: AddressRange.h:25
lldb_private::npdb::PdbIndex::create
static llvm::Expected< std::unique_ptr< PdbIndex > > create(llvm::pdb::PDBFile *)
Definition: PdbIndex.cpp:42
lldb_private::CompileUnit::SetLineTable
void SetLineTable(LineTable *line_table)
Set the line table for the compile unit.
Definition: CompileUnit.cpp:172
lldb_private::Range
Definition: Process.h:61
lldb_private::SymbolFile::kAllAbilities
@ kAllAbilities
Definition: SymbolFile.h:70
lldb_private::npdb::MakeGlobalLocationExpression
DWARFExpression MakeGlobalLocationExpression(uint16_t section, uint32_t offset, lldb::ModuleSP module)
lldb_private::npdb::SymbolFileNativePDB::FindTypesByName
void FindTypesByName(llvm::StringRef name, uint32_t max_matches, TypeMap &types)
Definition: SymbolFileNativePDB.cpp:1604
lldb_private::npdb::SymbolFileNativePDB::CreateModifierType
lldb::TypeSP CreateModifierType(PdbTypeSymId type_id, const llvm::codeview::ModifierRecord &mr, CompilerType ct)
Definition: SymbolFileNativePDB.cpp:462
lldb_private::Debugger
Definition: Debugger.h:72
lldb_private::CompileUnit::GetPrimaryFile
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
Definition: CompileUnit.h:227
PdbAstBuilder.h
lldb::eValueTypeVariableArgument
@ eValueTypeVariableArgument
function argument variables
Definition: lldb-enumerations.h:319
lldb_private::SymbolFileCommon::GetNumCompileUnits
uint32_t GetNumCompileUnits() override
Definition: SymbolFile.cpp:194
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::CompileUnit::GetLineTable
LineTable * GetLineTable()
Get the line table for the compile unit.
Definition: CompileUnit.cpp:161
loadMatchingPDBFile
static std::unique_ptr< PDBFile > loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator)
Definition: SymbolFileNativePDB.cpp:91
lldb_private::RangeVector< lldb::addr_t, lldb::addr_t >
lldb_private::Type::ResolveState::Full
@ Full
lldb_private::npdb::SymbolFileNativePDB::GetOrCreateCompileUnit
lldb::CompUnitSP GetOrCreateCompileUnit(const CompilandIndexItem &cci)
Definition: SymbolFileNativePDB.cpp:889
lldb_private::npdb::PdbTypeSymId::is_ipi
bool is_ipi
Definition: PdbSymUid.h:80
VariableList.h
lldb_private::TypeMap
Definition: TypeMap.h:20
lldb_private::npdb::SymbolFileNativePDB::ParseDeclsForContext
void ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override
Definition: SymbolFileNativePDB.cpp:908
lldb_private::npdb::SegmentOffsetLength::so
SegmentOffset so
Definition: PdbUtil.h:99
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
PdbUtil.h
lldb_private::SymbolContextScope
Definition: SymbolContextScope.h:64
ObjectFile.h
lldb_private::npdb::SymbolFileNativePDB::DumpClangAST
void DumpClangAST(Stream &s) override
Definition: SymbolFileNativePDB.cpp:1517
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb_private::FileSpec::Style
llvm::sys::path::Style Style
Definition: FileSpec.h:58
StreamFile.h
lldbassert
#define lldbassert(x)
Definition: LLDBAssert.h:15
lldb_private::npdb::CompilandIndexItem::m_strings
llvm::codeview::StringsAndChecksumsRef m_strings
Definition: CompileUnitIndex.h:53
lldb_private::Block::SetVariableList
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
Definition: Block.h:331
lldb_private::npdb::IsValidRecord
bool IsValidRecord(const RecordT &sym)
Definition: PdbUtil.h:121
lldb_private::npdb::SymbolFileNativePDB::ParseFunctions
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileNativePDB.cpp:944
lldb_private::npdb::VariableInfo
Definition: PdbUtil.h:103
lldb::eValueTypeVariableLocal
@ eValueTypeVariableLocal
function local variables
Definition: lldb-enumerations.h:320
NeedsResolvedCompileUnit
static bool NeedsResolvedCompileUnit(uint32_t resolve_scope)
Definition: SymbolFileNativePDB.cpp:967
lldb_private::npdb::CompilandIndexItem
Represents a single compile unit.
Definition: CompileUnitIndex.h:39
lldb_private::npdb::SymbolFileNativePDB::AddSymbols
void AddSymbols(Symtab &symtab) override
Definition: SymbolFileNativePDB.cpp:942
lldb::ValueType
ValueType
Definition: lldb-enumerations.h:315
lldb_private::npdb::VariableInfo::ranges
llvm::Optional< Variable::RangeList > ranges
Definition: PdbUtil.h:107
lldb_private::Block
Definition: Block.h:41
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
lldb_private::npdb::SymbolFileNativePDB::m_allocator
llvm::BumpPtrAllocator m_allocator
Definition: SymbolFileNativePDB.h:258
lldb_private::Symtab
Definition: Symtab.h:22
uint32_t
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
lldb_private::npdb::SymbolFileNativePDB::CalculateAbilities
uint32_t CalculateAbilities() override
Definition: SymbolFileNativePDB.cpp:261
UdtRecordCompleter.h
PdbSymUid.h
lldb_private::Address
Definition: Address.h:59
lldb_private::npdb::SymbolFileNativePDB::ParseSupportFiles
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, FileSpecList &support_files) override
Definition: SymbolFileNativePDB.cpp:1249
id
void * id
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:20
DWARFLocationExpression.h
lldb_private::npdb::SymbolFileNativePDB::ParseDebugMacros
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileNativePDB.cpp:1220
lldb_private::npdb::SymbolFileNativePDB::m_file_up
std::unique_ptr< llvm::pdb::PDBFile > m_file_up
Definition: SymbolFileNativePDB.h:263
lldb_private::npdb::CompilandIndexItem::m_id
PdbCompilandId m_id
Definition: CompileUnitIndex.h:45
lldb_private::npdb::SymbolFileNativePDB::InitializeObject
void InitializeObject() override
Initialize the SymbolFile object.
Definition: SymbolFileNativePDB.cpp:299
lldb_private::npdb::PdbCompilandId::modi
uint16_t modi
Definition: PdbSymUid.h:41
lldb_private::Type
Definition: Type.h:66
LineTable.h
lldb_private::npdb::SymbolFileNativePDB::CalculateNumCompileUnits
uint32_t CalculateNumCompileUnits() override
Definition: SymbolFileNativePDB.cpp:320
lldb_private::Range::SetRangeBase
void SetRangeBase(BaseType b)
Definition: RangeMap.h:48
lldb_private::CompileUnit::GetNumFunctions
size_t GetNumFunctions() const
Returns the number of functions in this compile unit.
Definition: CompileUnit.h:398
lldb_private::ModuleChild::GetModule
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
lldb_private::TypeMap::Insert
void Insert(const lldb::TypeSP &type)
Definition: TypeMap.cpp:27
lldb_private::CompileUnit::ResolveSymbolContext
void ResolveSymbolContext(const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
Resolve symbol contexts by file and line.
Definition: CompileUnit.cpp:248
ObjectFilePDB.h
uint16_t
lldb_private::npdb::MakeConstantLocationExpression
DWARFExpression MakeConstantLocationExpression(llvm::codeview::TypeIndex underlying_ti, llvm::pdb::TpiStream &tpi, const llvm::APSInt &constant, lldb::ModuleSP module)
lldb_private::npdb::SymbolFileNativePDB::FindGlobalVariables
void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, VariableList &variables) override
Definition: SymbolFileNativePDB.cpp:1519
lldb_private::npdb::PdbSymUid::kind
PdbSymUidKind kind() const
Definition: PdbSymUid.cpp:112
PluginManager.h
lldb_private::Block::SetDidParseVariables
void SetDidParseVariables(bool b, bool set_children)
Definition: Block.cpp:496
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
lldb_private::npdb::SymbolFileNativePDB::CreateAndCacheType
lldb::TypeSP CreateAndCacheType(PdbTypeSymId type_id)
Definition: SymbolFileNativePDB.cpp:699
SymbolFileNativePDB.h
clang
Definition: ASTResultSynthesizer.h:15
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
lldb_private::SymbolFileCommon::GetCompileUnitAtIndex
lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx) override
Definition: SymbolFile.cpp:204
lldb_private::npdb::SymbolFileNativePDB::GetOrCreateFunction
lldb::FunctionSP GetOrCreateFunction(PdbCompilandSymId func_id, CompileUnit &comp_unit)
Definition: SymbolFileNativePDB.cpp:879
lldb_private::SymbolFileCommon::GetObjectFile
ObjectFile * GetObjectFile() override
Definition: SymbolFile.h:403
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
SymbolContext.h
lldb::eValueTypeVariableThreadLocal
@ eValueTypeVariableThreadLocal
thread local storage variable
Definition: lldb-enumerations.h:324
lldb::eLanguageTypeC
@ eLanguageTypeC
Non-standardized C, such as K&R.
Definition: lldb-enumerations.h:439
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Type::ResolveState::Forward
@ Forward
lldb_private::npdb::SymbolFileNativePDB::~SymbolFileNativePDB
~SymbolFileNativePDB() override
lldb::eValueTypeInvalid
@ eValueTypeInvalid
Definition: lldb-enumerations.h:316
llvm::codeview
Definition: DWARFLocationExpression.h:20
lldb_private::npdb::SegmentOffsetLength::length
uint32_t length
Definition: PdbUtil.h:100
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:30
lldb_private::TypeList
Definition: TypeList.h:20
lldb_private::npdb::SymbolFileNativePDB::ParseVariablesForCompileUnit
size_t ParseVariablesForCompileUnit(CompileUnit &comp_unit, VariableList &variables)
Definition: SymbolFileNativePDB.cpp:1665
lldb_private::LanguageSet
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:40
lldb_private::SymbolFile::Blocks
@ Blocks
Definition: SymbolFile.h:66
lldb_private::npdb::SymbolFileNativePDB::ParseInlineSite
void ParseInlineSite(PdbCompilandSymId inline_site_id, Address func_addr)
Definition: SymbolFileNativePDB.cpp:1273
lldb_private::npdb::SymbolFileNativePDB::CreateProcedureType
lldb::TypeSP CreateProcedureType(PdbTypeSymId type_id, const llvm::codeview::ProcedureRecord &pr, CompilerType ct)
Definition: SymbolFileNativePDB.cpp:630
lldb::eValueTypeVariableStatic
@ eValueTypeVariableStatic
static variable
Definition: lldb-enumerations.h:318
lldb_private::npdb::PdbSymUid
Definition: PdbSymUid.h:91
lldb_private::SymbolContext::line_entry
LineEntry line_entry
The LineEntry for a given query.
Definition: SymbolContext.h:322
lldb_private::RangeData::data
DataType data
Definition: RangeMap.h:413
lldb_private::npdb::SymbolFileNativePDB::CreateArrayType
lldb::TypeSP CreateArrayType(PdbTypeSymId type_id, const llvm::codeview::ArrayRecord &ar, CompilerType ct)
Definition: SymbolFileNativePDB.cpp:605
lldb_private::npdb::SymbolFileNativePDB::GetDeclForUID
CompilerDecl GetDeclForUID(lldb::user_id_t uid) override
Definition: SymbolFileNativePDB.cpp:1859
SymbolVendor.h
Variable.h
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:235
lldb_private::Block::GetNumRanges
size_t GetNumRanges() const
Definition: Block.h:343
lldb_private::Declaration
Definition: Declaration.h:24
lldb_private::npdb::SymbolFileNativePDB::m_compilands
llvm::DenseMap< lldb::user_id_t, lldb::CompUnitSP > m_compilands
Definition: SymbolFileNativePDB.h:272
lldb_private::npdb::VariableInfo::is_param
bool is_param
Definition: PdbUtil.h:108
lldb_private::LineTable::Entry
Definition: LineTable.h:209
lldb
Definition: SBAddress.h:15
lldb_private::npdb::SymbolFileNativePDB::GetOrCreateBlock
Block & GetOrCreateBlock(PdbCompilandSymId block_id)
Definition: SymbolFileNativePDB.cpp:900
lldb_private::npdb::SymbolFileNativePDB::CreateType
lldb::TypeSP CreateType(PdbTypeSymId type_id, CompilerType ct)
Definition: SymbolFileNativePDB.cpp:640
lldb_private::npdb::CompilandIndexItem::m_inline_map
std::map< llvm::codeview::TypeIndex, llvm::codeview::InlineeSourceLine > m_inline_map
Definition: CompileUnitIndex.h:77
lldb_private::npdb::SymbolFileNativePDB::m_blocks
llvm::DenseMap< lldb::user_id_t, lldb::BlockSP > m_blocks
Definition: SymbolFileNativePDB.h:270
LLDB_LOG_ERROR
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:286
lldb_private::FileSpec::GetFilename
ConstString & GetFilename()
Filename string get accessor.
Definition: FileSpec.cpp:340
lldb_private::npdb::SymbolFileNativePDB::m_done_full_type_scan
bool m_done_full_type_scan
Definition: SymbolFileNativePDB.h:261
LLDBLog.h
lldb_private::SymbolFileCommon::SetCompileUnitAtIndex
void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp)
Definition: SymbolFile.cpp:215
IsFunctionPrologue
static bool IsFunctionPrologue(const CompilandIndexItem &cci, lldb::addr_t addr)
Definition: SymbolFileNativePDB.cpp:144
lldb_private::npdb::CVTagRecord::name
llvm::StringRef name() const
Definition: PdbUtil.h:68
lldb_private::Type::eEncodingIsUID
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
Definition: Type.h:72
lldb_private::npdb::IsForwardRefUdt
bool IsForwardRefUdt(llvm::codeview::CVType cvt)
lldb_private::npdb::PdbSymUid::asCompiland
PdbCompilandId asCompiland() const
Definition: PdbSymUid.cpp:117
lldb_private::npdb::SymbolFileNativePDB::FindFunctions
void FindFunctions(ConstString name, const CompilerDeclContext &parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool include_inlines, SymbolContextList &sc_list) override
lldb::eLanguageTypeSwift
@ eLanguageTypeSwift
Swift.
Definition: lldb-enumerations.h:469
lldb::eLanguageTypeC_plus_plus
@ eLanguageTypeC_plus_plus
ISO C++:1998.
Definition: lldb-enumerations.h:441