LLVM  14.0.0git
SymbolCache.cpp
Go to the documentation of this file.
2 
36 
37 using namespace llvm;
38 using namespace llvm::codeview;
39 using namespace llvm::pdb;
40 
41 // Maps codeview::SimpleTypeKind of a built-in type to the parameters necessary
42 // to instantiate a NativeBuiltinSymbol for that type.
43 static const struct BuiltinTypeEntry {
47 } BuiltinTypes[] = {
49  {codeview::SimpleTypeKind::Void, PDB_BuiltinType::Void, 0},
50  {codeview::SimpleTypeKind::HResult, PDB_BuiltinType::HResult, 4},
51  {codeview::SimpleTypeKind::Int16Short, PDB_BuiltinType::Int, 2},
52  {codeview::SimpleTypeKind::UInt16Short, PDB_BuiltinType::UInt, 2},
53  {codeview::SimpleTypeKind::Int32, PDB_BuiltinType::Int, 4},
54  {codeview::SimpleTypeKind::UInt32, PDB_BuiltinType::UInt, 4},
55  {codeview::SimpleTypeKind::Int32Long, PDB_BuiltinType::Int, 4},
56  {codeview::SimpleTypeKind::UInt32Long, PDB_BuiltinType::UInt, 4},
57  {codeview::SimpleTypeKind::Int64Quad, PDB_BuiltinType::Int, 8},
58  {codeview::SimpleTypeKind::UInt64Quad, PDB_BuiltinType::UInt, 8},
59  {codeview::SimpleTypeKind::NarrowCharacter, PDB_BuiltinType::Char, 1},
60  {codeview::SimpleTypeKind::WideCharacter, PDB_BuiltinType::WCharT, 2},
61  {codeview::SimpleTypeKind::Character16, PDB_BuiltinType::Char16, 2},
62  {codeview::SimpleTypeKind::Character32, PDB_BuiltinType::Char32, 4},
63  {codeview::SimpleTypeKind::SignedCharacter, PDB_BuiltinType::Char, 1},
64  {codeview::SimpleTypeKind::UnsignedCharacter, PDB_BuiltinType::UInt, 1},
69  // This table can be grown as necessary, but these are the only types we've
70  // needed so far.
71 };
72 
73 SymbolCache::SymbolCache(NativeSession &Session, DbiStream *Dbi)
74  : Session(Session), Dbi(Dbi) {
75  // Id 0 is reserved for the invalid symbol.
76  Cache.push_back(nullptr);
77  SourceFiles.push_back(nullptr);
78 
79  if (Dbi)
80  Compilands.resize(Dbi->modules().getModuleCount());
81 }
82 
83 std::unique_ptr<IPDBEnumSymbols>
85  return createTypeEnumerator(std::vector<TypeLeafKind>{Kind});
86 }
87 
88 std::unique_ptr<IPDBEnumSymbols>
89 SymbolCache::createTypeEnumerator(std::vector<TypeLeafKind> Kinds) {
90  auto Tpi = Session.getPDBFile().getPDBTpiStream();
91  if (!Tpi) {
92  consumeError(Tpi.takeError());
93  return nullptr;
94  }
95  auto &Types = Tpi->typeCollection();
96  return std::unique_ptr<IPDBEnumSymbols>(
97  new NativeEnumTypes(Session, Types, std::move(Kinds)));
98 }
99 
100 std::unique_ptr<IPDBEnumSymbols>
102  return std::unique_ptr<IPDBEnumSymbols>(
103  new NativeEnumGlobals(Session, {Kind}));
104 }
105 
106 SymIndexId SymbolCache::createSimpleType(TypeIndex Index,
107  ModifierOptions Mods) const {
108  if (Index.getSimpleMode() != codeview::SimpleTypeMode::Direct)
109  return createSymbol<NativeTypePointer>(Index);
110 
111  const auto Kind = Index.getSimpleKind();
112  const auto It =
113  llvm::find_if(BuiltinTypes, [Kind](const BuiltinTypeEntry &Builtin) {
114  return Builtin.Kind == Kind;
115  });
116  if (It == std::end(BuiltinTypes))
117  return 0;
118  return createSymbol<NativeTypeBuiltin>(Mods, It->Type, It->Size);
119 }
120 
122 SymbolCache::createSymbolForModifiedType(codeview::TypeIndex ModifierTI,
123  codeview::CVType CVT) const {
125  if (auto EC = TypeDeserializer::deserializeAs<ModifierRecord>(CVT, Record)) {
126  consumeError(std::move(EC));
127  return 0;
128  }
129 
130  if (Record.ModifiedType.isSimple())
131  return createSimpleType(Record.ModifiedType, Record.Modifiers);
132 
133  // Make sure we create and cache a record for the unmodified type.
134  SymIndexId UnmodifiedId = findSymbolByTypeIndex(Record.ModifiedType);
135  NativeRawSymbol &UnmodifiedNRS = *Cache[UnmodifiedId];
136 
137  switch (UnmodifiedNRS.getSymTag()) {
138  case PDB_SymType::Enum:
139  return createSymbol<NativeTypeEnum>(
140  static_cast<NativeTypeEnum &>(UnmodifiedNRS), std::move(Record));
141  case PDB_SymType::UDT:
142  return createSymbol<NativeTypeUDT>(
143  static_cast<NativeTypeUDT &>(UnmodifiedNRS), std::move(Record));
144  default:
145  // No other types can be modified. (LF_POINTER, for example, records
146  // its modifiers a different way.
147  assert(false && "Invalid LF_MODIFIER record");
148  break;
149  }
150  return 0;
151 }
152 
154  // First see if it's already in our cache.
155  const auto Entry = TypeIndexToSymbolId.find(Index);
156  if (Entry != TypeIndexToSymbolId.end())
157  return Entry->second;
158 
159  // Symbols for built-in types are created on the fly.
160  if (Index.isSimple()) {
161  SymIndexId Result = createSimpleType(Index, ModifierOptions::None);
162  assert(TypeIndexToSymbolId.count(Index) == 0);
163  TypeIndexToSymbolId[Index] = Result;
164  return Result;
165  }
166 
167  // We need to instantiate and cache the desired type symbol.
168  auto Tpi = Session.getPDBFile().getPDBTpiStream();
169  if (!Tpi) {
170  consumeError(Tpi.takeError());
171  return 0;
172  }
173  codeview::LazyRandomTypeCollection &Types = Tpi->typeCollection();
174  codeview::CVType CVT = Types.getType(Index);
175 
176  if (isUdtForwardRef(CVT)) {
177  Expected<TypeIndex> EFD = Tpi->findFullDeclForForwardRef(Index);
178 
179  if (!EFD)
180  consumeError(EFD.takeError());
181  else if (*EFD != Index) {
182  assert(!isUdtForwardRef(Types.getType(*EFD)));
183  SymIndexId Result = findSymbolByTypeIndex(*EFD);
184  // Record a mapping from ForwardRef -> SymIndex of complete type so that
185  // we'll take the fast path next time.
186  assert(TypeIndexToSymbolId.count(Index) == 0);
187  TypeIndexToSymbolId[Index] = Result;
188  return Result;
189  }
190  }
191 
192  // At this point if we still have a forward ref udt it means the full decl was
193  // not in the PDB. We just have to deal with it and use the forward ref.
194  SymIndexId Id = 0;
195  switch (CVT.kind()) {
196  case codeview::LF_ENUM:
197  Id = createSymbolForType<NativeTypeEnum, EnumRecord>(Index, std::move(CVT));
198  break;
199  case codeview::LF_ARRAY:
200  Id = createSymbolForType<NativeTypeArray, ArrayRecord>(Index,
201  std::move(CVT));
202  break;
203  case codeview::LF_CLASS:
204  case codeview::LF_STRUCTURE:
205  case codeview::LF_INTERFACE:
206  Id = createSymbolForType<NativeTypeUDT, ClassRecord>(Index, std::move(CVT));
207  break;
208  case codeview::LF_UNION:
209  Id = createSymbolForType<NativeTypeUDT, UnionRecord>(Index, std::move(CVT));
210  break;
211  case codeview::LF_POINTER:
212  Id = createSymbolForType<NativeTypePointer, PointerRecord>(Index,
213  std::move(CVT));
214  break;
215  case codeview::LF_MODIFIER:
216  Id = createSymbolForModifiedType(Index, std::move(CVT));
217  break;
218  case codeview::LF_PROCEDURE:
219  Id = createSymbolForType<NativeTypeFunctionSig, ProcedureRecord>(
220  Index, std::move(CVT));
221  break;
222  case codeview::LF_MFUNCTION:
223  Id = createSymbolForType<NativeTypeFunctionSig, MemberFunctionRecord>(
224  Index, std::move(CVT));
225  break;
226  case codeview::LF_VTSHAPE:
227  Id = createSymbolForType<NativeTypeVTShape, VFTableShapeRecord>(
228  Index, std::move(CVT));
229  break;
230  default:
231  Id = createSymbolPlaceholder();
232  break;
233  }
234  if (Id != 0) {
235  assert(TypeIndexToSymbolId.count(Index) == 0);
236  TypeIndexToSymbolId[Index] = Id;
237  }
238  return Id;
239 }
240 
241 std::unique_ptr<PDBSymbol>
243  assert(SymbolId < Cache.size());
244 
245  // Id 0 is reserved.
246  if (SymbolId == 0 || SymbolId >= Cache.size())
247  return nullptr;
248 
249  // Make sure to handle the case where we've inserted a placeholder symbol
250  // for types we don't yet support.
251  NativeRawSymbol *NRS = Cache[SymbolId].get();
252  if (!NRS)
253  return nullptr;
254 
255  return PDBSymbol::create(Session, *NRS);
256 }
257 
259  return *Cache[SymbolId];
260 }
261 
263  if (!Dbi)
264  return 0;
265 
266  return Dbi->modules().getModuleCount();
267 }
268 
270  auto Iter = GlobalOffsetToSymbolId.find(Offset);
271  if (Iter != GlobalOffsetToSymbolId.end())
272  return Iter->second;
273 
275  CVSymbol CVS = SS.readRecord(Offset);
276  SymIndexId Id = 0;
277  switch (CVS.kind()) {
278  case SymbolKind::S_UDT: {
279  UDTSym US = cantFail(SymbolDeserializer::deserializeAs<UDTSym>(CVS));
280  Id = createSymbol<NativeTypeTypedef>(std::move(US));
281  break;
282  }
283  default:
284  Id = createSymbolPlaceholder();
285  break;
286  }
287  if (Id != 0) {
288  assert(GlobalOffsetToSymbolId.count(Offset) == 0);
289  GlobalOffsetToSymbolId[Offset] = Id;
290  }
291 
292  return Id;
293 }
294 
296  uint64_t ParentAddr,
297  uint16_t Modi,
298  uint32_t RecordOffset) const {
299  auto Iter = SymTabOffsetToSymbolId.find({Modi, RecordOffset});
300  if (Iter != SymTabOffsetToSymbolId.end())
301  return Iter->second;
302 
303  SymIndexId Id = createSymbol<NativeInlineSiteSymbol>(Sym, ParentAddr);
304  SymTabOffsetToSymbolId.insert({{Modi, RecordOffset}, Id});
305  return Id;
306 }
307 
308 std::unique_ptr<PDBSymbol>
310  PDB_SymType Type) {
311  switch (Type) {
313  return findFunctionSymbolBySectOffset(Sect, Offset);
315  return findPublicSymbolBySectOffset(Sect, Offset);
316  case PDB_SymType::Compiland: {
317  uint16_t Modi;
318  if (!Session.moduleIndexForSectOffset(Sect, Offset, Modi))
319  return nullptr;
320  return getOrCreateCompiland(Modi);
321  }
322  case PDB_SymType::None: {
323  // FIXME: Implement for PDB_SymType::Data. The symbolizer calls this but
324  // only uses it to find the symbol length.
325  if (auto Sym = findFunctionSymbolBySectOffset(Sect, Offset))
326  return Sym;
327  return nullptr;
328  }
329  default:
330  return nullptr;
331  }
332 }
333 
334 std::unique_ptr<PDBSymbol>
335 SymbolCache::findFunctionSymbolBySectOffset(uint32_t Sect, uint32_t Offset) {
336  auto Iter = AddressToSymbolId.find({Sect, Offset});
337  if (Iter != AddressToSymbolId.end())
338  return getSymbolById(Iter->second);
339 
340  if (!Dbi)
341  return nullptr;
342 
343  uint16_t Modi;
344  if (!Session.moduleIndexForSectOffset(Sect, Offset, Modi))
345  return nullptr;
346 
347  Expected<ModuleDebugStreamRef> ExpectedModS =
348  Session.getModuleDebugStream(Modi);
349  if (!ExpectedModS) {
350  consumeError(ExpectedModS.takeError());
351  return nullptr;
352  }
353  CVSymbolArray Syms = ExpectedModS->getSymbolArray();
354 
355  // Search for the symbol in this module.
356  for (auto I = Syms.begin(), E = Syms.end(); I != E; ++I) {
357  if (I->kind() != S_LPROC32 && I->kind() != S_GPROC32)
358  continue;
359  auto PS = cantFail(SymbolDeserializer::deserializeAs<ProcSym>(*I));
360  if (Sect == PS.Segment && Offset >= PS.CodeOffset &&
361  Offset < PS.CodeOffset + PS.CodeSize) {
362  // Check if the symbol is already cached.
363  auto Found = AddressToSymbolId.find({PS.Segment, PS.CodeOffset});
364  if (Found != AddressToSymbolId.end())
365  return getSymbolById(Found->second);
366 
367  // Otherwise, create a new symbol.
368  SymIndexId Id = createSymbol<NativeFunctionSymbol>(PS, I.offset());
369  AddressToSymbolId.insert({{PS.Segment, PS.CodeOffset}, Id});
370  return getSymbolById(Id);
371  }
372 
373  // Jump to the end of this ProcSym.
374  I = Syms.at(PS.End);
375  }
376  return nullptr;
377 }
378 
379 std::unique_ptr<PDBSymbol>
380 SymbolCache::findPublicSymbolBySectOffset(uint32_t Sect, uint32_t Offset) {
381  auto Iter = AddressToPublicSymId.find({Sect, Offset});
382  if (Iter != AddressToPublicSymId.end())
383  return getSymbolById(Iter->second);
384 
385  auto Publics = Session.getPDBFile().getPDBPublicsStream();
386  if (!Publics)
387  return nullptr;
388 
389  auto ExpectedSyms = Session.getPDBFile().getPDBSymbolStream();
390  if (!ExpectedSyms)
391  return nullptr;
392  BinaryStreamRef SymStream =
393  ExpectedSyms->getSymbolArray().getUnderlyingStream();
394 
395  // Use binary search to find the first public symbol with an address greater
396  // than or equal to Sect, Offset.
397  auto AddrMap = Publics->getAddressMap();
398  auto First = AddrMap.begin();
399  auto It = AddrMap.begin();
400  size_t Count = AddrMap.size();
401  size_t Half;
402  while (Count > 0) {
403  It = First;
404  Half = Count / 2;
405  It += Half;
406  Expected<CVSymbol> Sym = readSymbolFromStream(SymStream, *It);
407  if (!Sym) {
408  consumeError(Sym.takeError());
409  return nullptr;
410  }
411 
412  auto PS =
413  cantFail(SymbolDeserializer::deserializeAs<PublicSym32>(Sym.get()));
414  if (PS.Segment < Sect || (PS.Segment == Sect && PS.Offset <= Offset)) {
415  First = ++It;
416  Count -= Half + 1;
417  } else
418  Count = Half;
419  }
420  if (It == AddrMap.begin())
421  return nullptr;
422  --It;
423 
424  Expected<CVSymbol> Sym = readSymbolFromStream(SymStream, *It);
425  if (!Sym) {
426  consumeError(Sym.takeError());
427  return nullptr;
428  }
429 
430  // Check if the symbol is already cached.
431  auto PS = cantFail(SymbolDeserializer::deserializeAs<PublicSym32>(Sym.get()));
432  auto Found = AddressToPublicSymId.find({PS.Segment, PS.Offset});
433  if (Found != AddressToPublicSymId.end())
434  return getSymbolById(Found->second);
435 
436  // Otherwise, create a new symbol.
437  SymIndexId Id = createSymbol<NativePublicSymbol>(PS);
438  AddressToPublicSymId.insert({{PS.Segment, PS.Offset}, Id});
439  return getSymbolById(Id);
440 }
441 
442 std::vector<SymbolCache::LineTableEntry>
443 SymbolCache::findLineTable(uint16_t Modi) const {
444  // Check if this module has already been added.
445  auto LineTableIter = LineTable.find(Modi);
446  if (LineTableIter != LineTable.end())
447  return LineTableIter->second;
448 
449  std::vector<LineTableEntry> &ModuleLineTable = LineTable[Modi];
450 
451  // If there is an error or there are no lines, just return the
452  // empty vector.
453  Expected<ModuleDebugStreamRef> ExpectedModS =
454  Session.getModuleDebugStream(Modi);
455  if (!ExpectedModS) {
456  consumeError(ExpectedModS.takeError());
457  return ModuleLineTable;
458  }
459 
460  std::vector<std::vector<LineTableEntry>> EntryList;
461  for (const auto &SS : ExpectedModS->getSubsectionsArray()) {
462  if (SS.kind() != DebugSubsectionKind::Lines)
463  continue;
464 
466  BinaryStreamReader Reader(SS.getRecordData());
467  if (auto EC = Lines.initialize(Reader)) {
468  consumeError(std::move(EC));
469  continue;
470  }
471 
472  uint32_t RelocSegment = Lines.header()->RelocSegment;
473  uint32_t RelocOffset = Lines.header()->RelocOffset;
474  for (const LineColumnEntry &Group : Lines) {
475  if (Group.LineNumbers.empty())
476  continue;
477 
478  std::vector<LineTableEntry> Entries;
479 
480  // If there are column numbers, then they should be in a parallel stream
481  // to the line numbers.
482  auto ColIt = Group.Columns.begin();
483  auto ColsEnd = Group.Columns.end();
484 
485  // Add a line to mark the beginning of this section.
486  uint64_t StartAddr =
487  Session.getVAFromSectOffset(RelocSegment, RelocOffset);
488  LineInfo FirstLine(Group.LineNumbers.front().Flags);
489  uint32_t ColNum =
490  (Lines.hasColumnInfo()) ? Group.Columns.front().StartColumn : 0;
491  Entries.push_back({StartAddr, FirstLine, ColNum, Group.NameIndex, false});
492 
493  for (const LineNumberEntry &LN : Group.LineNumbers) {
494  uint64_t VA =
495  Session.getVAFromSectOffset(RelocSegment, RelocOffset + LN.Offset);
496  LineInfo Line(LN.Flags);
497  ColNum = 0;
498 
499  if (Lines.hasColumnInfo() && ColIt != ColsEnd) {
500  ColNum = ColIt->StartColumn;
501  ++ColIt;
502  }
503  Entries.push_back({VA, Line, ColNum, Group.NameIndex, false});
504  }
505 
506  // Add a terminal entry line to mark the end of this subsection.
507  uint64_t EndAddr = StartAddr + Lines.header()->CodeSize;
508  LineInfo LastLine(Group.LineNumbers.back().Flags);
509  ColNum = (Lines.hasColumnInfo()) ? Group.Columns.back().StartColumn : 0;
510  Entries.push_back({EndAddr, LastLine, ColNum, Group.NameIndex, true});
511 
512  EntryList.push_back(Entries);
513  }
514  }
515 
516  // Sort EntryList, and add flattened contents to the line table.
517  llvm::sort(EntryList, [](const std::vector<LineTableEntry> &LHS,
518  const std::vector<LineTableEntry> &RHS) {
519  return LHS[0].Addr < RHS[0].Addr;
520  });
521  for (size_t I = 0; I < EntryList.size(); ++I)
522  llvm::append_range(ModuleLineTable, EntryList[I]);
523 
524  return ModuleLineTable;
525 }
526 
527 std::unique_ptr<IPDBEnumLineNumbers>
529  uint16_t Modi;
530  if (!Session.moduleIndexForVA(VA, Modi))
531  return nullptr;
532 
533  std::vector<LineTableEntry> Lines = findLineTable(Modi);
534  if (Lines.empty())
535  return nullptr;
536 
537  // Find the first line in the line table whose address is not greater than
538  // the one we are searching for.
539  auto LineIter = llvm::partition_point(Lines, [&](const LineTableEntry &E) {
540  return (E.Addr < VA || (E.Addr == VA && E.IsTerminalEntry));
541  });
542 
543  // Try to back up if we've gone too far.
544  if (LineIter == Lines.end() || LineIter->Addr > VA) {
545  if (LineIter == Lines.begin() || std::prev(LineIter)->IsTerminalEntry)
546  return nullptr;
547  --LineIter;
548  }
549 
550  Expected<ModuleDebugStreamRef> ExpectedModS =
551  Session.getModuleDebugStream(Modi);
552  if (!ExpectedModS) {
553  consumeError(ExpectedModS.takeError());
554  return nullptr;
555  }
556  Expected<DebugChecksumsSubsectionRef> ExpectedChecksums =
557  ExpectedModS->findChecksumsSubsection();
558  if (!ExpectedChecksums) {
559  consumeError(ExpectedChecksums.takeError());
560  return nullptr;
561  }
562 
563  // Populate a vector of NativeLineNumbers that have addresses in the given
564  // address range.
565  std::vector<NativeLineNumber> LineNumbers;
566  while (LineIter != Lines.end()) {
567  if (LineIter->IsTerminalEntry) {
568  ++LineIter;
569  continue;
570  }
571 
572  // If the line is still within the address range, create a NativeLineNumber
573  // and add to the list.
574  if (LineIter->Addr > VA + Length)
575  break;
576 
577  uint32_t LineSect, LineOff;
578  Session.addressForVA(LineIter->Addr, LineSect, LineOff);
579  uint32_t LineLength = std::next(LineIter)->Addr - LineIter->Addr;
580  auto ChecksumIter =
581  ExpectedChecksums->getArray().at(LineIter->FileNameIndex);
582  uint32_t SrcFileId = getOrCreateSourceFile(*ChecksumIter);
583  NativeLineNumber LineNum(Session, LineIter->Line, LineIter->ColumnNumber,
584  LineSect, LineOff, LineLength, SrcFileId, Modi);
585  LineNumbers.push_back(LineNum);
586  ++LineIter;
587  }
588  return std::make_unique<NativeEnumLineNumbers>(std::move(LineNumbers));
589 }
590 
591 std::unique_ptr<PDBSymbolCompiland>
593  if (!Dbi)
594  return nullptr;
595 
596  if (Index >= Compilands.size())
597  return nullptr;
598 
599  if (Compilands[Index] == 0) {
600  const DbiModuleList &Modules = Dbi->modules();
601  Compilands[Index] =
602  createSymbol<NativeCompilandSymbol>(Modules.getModuleDescriptor(Index));
603  }
604 
605  return Session.getConcreteSymbolById<PDBSymbolCompiland>(Compilands[Index]);
606 }
607 
608 std::unique_ptr<IPDBSourceFile>
610  assert(FileId < SourceFiles.size());
611 
612  // Id 0 is reserved.
613  if (FileId == 0)
614  return nullptr;
615 
616  return std::unique_ptr<NativeSourceFile>(
617  new NativeSourceFile(*SourceFiles[FileId].get()));
618 }
619 
622  auto Iter = FileNameOffsetToId.find(Checksums.FileNameOffset);
623  if (Iter != FileNameOffsetToId.end())
624  return Iter->second;
625 
626  SymIndexId Id = SourceFiles.size();
627  auto SrcFile = std::make_unique<NativeSourceFile>(Session, Id, Checksums);
628  SourceFiles.push_back(std::move(SrcFile));
629  FileNameOffsetToId[Checksums.FileNameOffset] = Id;
630  return Id;
631 }
632 
633 
llvm::pdb::DbiModuleList::getModuleCount
uint32_t getModuleCount() const
Definition: DbiModuleList.cpp:241
llvm::pdb::SymbolCache::createTypeEnumerator
std::unique_ptr< IPDBEnumSymbols > createTypeEnumerator(codeview::TypeLeafKind Kind)
Definition: SymbolCache.cpp:84
NativeTypeTypedef.h
NativePublicSymbol.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::codeview::SimpleTypeKind::Int32
@ Int32
PublicsStream.h
TpiStream.h
llvm::codeview::DebugSubsectionKind::Lines
@ Lines
llvm::codeview::ModifierOptions
ModifierOptions
Equivalent to CV_modifier_t.
Definition: CodeView.h:302
NativeTypeArray.h
llvm::pdb::NativeTypeUDT
Definition: NativeTypeUDT.h:21
llvm::codeview::SymbolKind
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:47
llvm::pdb::SymbolCache::getOrCreateInlineSymbol
SymIndexId getOrCreateInlineSymbol(codeview::InlineSiteSym Sym, uint64_t ParentAddr, uint16_t Modi, uint32_t RecordOffset) const
Definition: SymbolCache.cpp:295
llvm::pdb::SymbolCache::getSourceFileById
std::unique_ptr< IPDBSourceFile > getSourceFileById(SymIndexId FileId) const
Definition: SymbolCache.cpp:609
llvm::codeview::SimpleTypeKind::Int64Quad
@ Int64Quad
llvm::codeview::Line
Definition: Line.h:91
NativeCompilandSymbol.h
llvm::pdb::SymbolStream
Definition: SymbolStream.h:23
llvm::codeview::SimpleTypeKind::UInt64Quad
@ UInt64Quad
NativeEnumLineNumbers.h
llvm::pdb::NativeSession::getPDBFile
PDBFile & getPDBFile()
Definition: NativeSession.h:105
llvm::pdb::NativeRawSymbol::getSymTag
PDB_SymType getSymTag() const override
Definition: NativeRawSymbol.cpp:364
BuiltinTypeEntry
Definition: SymbolCache.cpp:43
llvm::codeview::LineNumberEntry::Flags
support::ulittle32_t Flags
Definition: DebugLinesSubsection.h:55
llvm::pdb::NativeSession::getVAFromSectOffset
uint64_t getVAFromSectOffset(uint32_t Section, uint32_t Offset) const
Definition: NativeSession.cpp:389
llvm::pdb::NativeEnumTypes
Definition: NativeEnumTypes.h:24
llvm::codeview::SimpleTypeKind
SimpleTypeKind
Definition: TypeIndex.h:26
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
llvm::codeview::FileChecksumEntry::FileNameOffset
uint32_t FileNameOffset
Definition: DebugChecksumsSubsection.h:32
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::codeview::isUdtForwardRef
bool isUdtForwardRef(CVType CVT)
Given an arbitrary codeview type, determine if it is an LF_STRUCTURE, LF_CLASS, LF_INTERFACE,...
Definition: TypeRecordHelpers.cpp:27
llvm::pdb::NativeLineNumber
Definition: NativeLineNumber.h:19
NativeFunctionSymbol.h
llvm::VarStreamArray::end
Iterator end() const
Definition: BinaryStreamArray.h:115
llvm::codeview::SimpleTypeKind::Float80
@ Float80
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::pdb::PDBFile::getPDBSymbolStream
Expected< SymbolStream & > getPDBSymbolStream()
Definition: PDBFile.cpp:349
llvm::codeview::SimpleTypeKind::NarrowCharacter
@ NarrowCharacter
llvm::pdb::DbiStream
Definition: DbiStream.h:37
llvm::pdb::NativeSession::getModuleDebugStream
Expected< ModuleDebugStreamRef > getModuleDebugStream(uint32_t Index) const
Definition: NativeSession.cpp:445
llvm::codeview::SimpleTypeKind::Boolean8
@ Boolean8
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1035
llvm::pdb::PDB_SymType
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:243
llvm::codeview::SimpleTypeKind::None
@ None
llvm::pdb::PDBSymbol::create
static std::unique_ptr< PDBSymbol > create(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > RawSymbol)
Definition: PDBSymbol.cpp:102
llvm::codeview::SimpleTypeMode::Direct
@ Direct
BuiltinTypeEntry::Kind
codeview::SimpleTypeKind Kind
Definition: SymbolCache.cpp:44
llvm::codeview::LineColumnEntry
Definition: DebugLinesSubsection.h:64
llvm::pdb::NativeSession::moduleIndexForVA
bool moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const
Definition: NativeSession.cpp:394
NativeTypePointer.h
llvm::pdb::DbiModuleList
Definition: DbiModuleList.h:69
GlobalsStream.h
NativeInlineSiteSymbol.h
NativeEnumSymbols.h
llvm::codeview::SimpleTypeKind::Int16Short
@ Int16Short
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::codeview::InlineSiteSym
Definition: SymbolRecord.h:333
llvm::pdb::SymIndexId
uint32_t SymIndexId
Definition: PDBTypes.h:26
PDBSymbolTypeEnum.h
SymbolDeserializer.h
llvm::VarStreamArray< CVSymbol >
llvm::codeview::LazyRandomTypeCollection
Provides amortized O(1) random access to a CodeView type stream.
Definition: LazyRandomTypeCollection.h:49
llvm::pdb::PDB_SymType::UDT
@ UDT
NativeTypeFunctionSig.h
First
into llvm powi allowing the code generator to produce balanced multiplication trees First
Definition: README.txt:54
NativeEnumGlobals.h
llvm::codeview::FileChecksumEntry
Definition: DebugChecksumsSubsection.h:31
BuiltinTypes
static const struct BuiltinTypeEntry BuiltinTypes[]
llvm::codeview::SimpleTypeKind::UInt32Long
@ UInt32Long
llvm::codeview::LineNumberEntry
Definition: DebugLinesSubsection.h:53
llvm::codeview::ModifierRecord
Definition: TypeRecord.h:129
PDBSymbol.h
llvm::pdb::IPDBSession::getConcreteSymbolById
std::unique_ptr< T > getConcreteSymbolById(SymIndexId SymbolId) const
Definition: IPDBSession.h:41
llvm::pdb::PDB_TableType::LineNumbers
@ LineNumbers
llvm::None
const NoneType None
Definition: None.h:23
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::BinaryStreamReader
Provides read only access to a subclass of BinaryStream.
Definition: BinaryStreamReader.h:31
llvm::codeview::readSymbolFromStream
Expected< CVSymbol > readSymbolFromStream(BinaryStreamRef Stream, uint32_t Offset)
Definition: RecordSerialization.cpp:151
llvm::pdb::SymbolCache::getSymbolById
std::unique_ptr< PDBSymbol > getSymbolById(SymIndexId SymbolId) const
Definition: SymbolCache.cpp:242
llvm::pdb::NativeTypeEnum
Definition: NativeTypeEnum.h:23
llvm::pdb::SymbolCache::findSymbolBySectOffset
std::unique_ptr< PDBSymbol > findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type)
Definition: SymbolCache.cpp:309
llvm::codeview::SimpleTypeKind::UInt16Short
@ UInt16Short
BuiltinTypeEntry::Type
PDB_BuiltinType Type
Definition: SymbolCache.cpp:45
llvm::codeview::LineNumberEntry::Offset
support::ulittle32_t Offset
Definition: DebugLinesSubsection.h:54
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
uint64_t
DebugLinesSubsection.h
llvm::codeview::CVRecord::kind
Kind kind() const
Definition: CVRecord.h:43
llvm::pdb::NativeEnumGlobals
Definition: NativeEnumGlobals.h:23
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::NVPTX::PTXLdStInstCode::Float
@ Float
Definition: NVPTX.h:118
PDBSymbolCompiland.h
llvm::pdb::NativeSession::addressForVA
bool addressForVA(uint64_t VA, uint32_t &Section, uint32_t &Offset) const override
Definition: NativeSession.cpp:212
llvm::codeview::SimpleTypeKind::Float64
@ Float64
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::codeview::DebugLinesSubsectionRef
Definition: DebugLinesSubsection.h:78
llvm::codeview::SimpleTypeKind::Void
@ Void
BuiltinTypeEntry::Size
uint32_t Size
Definition: SymbolCache.cpp:46
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
TypeRecordHelpers.h
llvm::pdb::SymbolCache::getNumCompilands
uint32_t getNumCompilands() const
Definition: SymbolCache.cpp:262
llvm::pdb::NativeSourceFile
Definition: NativeSourceFile.h:21
llvm::pdb::PDB_SymType::Function
@ Function
NativeEnumTypes.h
llvm::Record
Definition: Record.h:1472
llvm::pdb::PDB_SymType::None
@ None
DbiStream.h
NativeTypeVTShape.h
llvm::codeview::CVRecord< TypeLeafKind >
llvm::X86AS::SS
@ SS
Definition: X86.h:189
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition: Error.h:569
llvm::cantFail
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:737
uint32_t
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:1746
llvm::pdb::PDB_BuiltinType
PDB_BuiltinType
These values correspond to the Basictype enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:335
ISectionContribVisitor.h
llvm::codeview::SimpleTypeKind::Int32Long
@ Int32Long
llvm::pdb::PDB_SymType::Enum
@ Enum
llvm::pdb::Bool
@ Bool
Definition: PDBTypes.h:406
llvm::find_if
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1576
llvm::VarStreamArray::begin
Iterator begin(bool *HadError=nullptr) const
Definition: BinaryStreamArray.h:108
llvm::codeview::SimpleTypeKind::Float32
@ Float32
llvm::pdb::PDBFile::getPDBTpiStream
Expected< TpiStream & > getPDBTpiStream()
Definition: PDBFile.cpp:302
llvm::partition_point
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
Definition: STLExtras.h:1697
llvm::codeview::LineInfo
Definition: Line.h:21
llvm::pdb::SymbolCache::findSymbolByTypeIndex
SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI) const
Definition: SymbolCache.cpp:153
DebugInlineeLinesSubsection.h
NativeTypeUDT.h
uint16_t
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
TypeDeserializer.h
llvm::DenseMapBase::end
iterator end()
Definition: DenseMap.h:83
llvm::codeview::SimpleTypeKind::Character32
@ Character32
llvm::pdb::PDB_SymType::Compiland
@ Compiland
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1490
NativeRawSymbol.h
llvm::pdb::NativeSession
Definition: NativeSession.h:28
NativeTypeEnum.h
llvm::codeview::SimpleTypeKind::WideCharacter
@ WideCharacter
llvm::pdb::SymbolCache::getOrCreateCompiland
std::unique_ptr< PDBSymbolCompiland > getOrCreateCompiland(uint32_t Index)
Definition: SymbolCache.cpp:592
llvm::codeview::TypeLeafKind
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:33
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::codeview::SimpleTypeKind::UnsignedCharacter
@ UnsignedCharacter
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:589
NativeTypeBuiltin.h
llvm::pdb::PDBFile::getPDBPublicsStream
Expected< PublicsStream & > getPDBPublicsStream()
Definition: PDBFile.cpp:331
PDBFile.h
llvm::pdb::DbiModuleList::getModuleDescriptor
DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const
Definition: DbiModuleList.cpp:253
SymbolCache.h
llvm::codeview::SimpleTypeKind::UInt32
@ UInt32
llvm::codeview::SimpleTypeKind::HResult
@ HResult
llvm::VarStreamArray::at
Iterator at(uint32_t Offset) const
given an offset into the array's underlying stream, return an iterator to the record at that offset.
Definition: BinaryStreamArray.h:132
llvm::pdb::PDB_SymType::PublicSymbol
@ PublicSymbol
llvm::codeview::TypeIndex
A 32-bit type reference.
Definition: TypeIndex.h:95
llvm::pdb::SymbolCache::getOrCreateGlobalSymbolByOffset
SymIndexId getOrCreateGlobalSymbolByOffset(uint32_t Offset)
Definition: SymbolCache.cpp:269
SymbolStream.h
llvm::pdb::SymbolCache::getNativeSymbolById
NativeRawSymbol & getNativeSymbolById(SymIndexId SymbolId) const
Definition: SymbolCache.cpp:258
llvm::codeview::LazyRandomTypeCollection::getType
CVType getType(TypeIndex Index) override
Definition: LazyRandomTypeCollection.cpp:90
llvm::pdb::SymbolCache::getOrCreateSourceFile
SymIndexId getOrCreateSourceFile(const codeview::FileChecksumEntry &Checksum) const
Definition: SymbolCache.cpp:621
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:228
llvm::pdb::PDBSymbolCompiland
Definition: PDBSymbolCompiland.h:21
llvm::codeview::SimpleTypeKind::Character16
@ Character16
llvm::codeview::SimpleTypeKind::SignedCharacter
@ SignedCharacter
llvm::codeview::UDTSym
Definition: SymbolRecord.h:864
llvm::pdb::NativeRawSymbol
Definition: NativeRawSymbol.h:21
llvm::BinaryStreamRef
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Definition: BinaryStreamRef.h:156
llvm::pdb::SymbolCache::findLineNumbersByVA
std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersByVA(uint64_t VA, uint32_t Length) const
Definition: SymbolCache.cpp:528
llvm::pdb::SymbolCache::createGlobalsEnumerator
std::unique_ptr< IPDBEnumSymbols > createGlobalsEnumerator(codeview::SymbolKind Kind)
Definition: SymbolCache.cpp:101
llvm::pdb::NativeSession::moduleIndexForSectOffset
bool moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset, uint16_t &ModuleIndex) const
Definition: NativeSession.cpp:403
NativeSession.h
llvm::pdb::DbiStream::modules
const DbiModuleList & modules() const
Definition: DbiStream.cpp:217