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