LLVM  16.0.0git
InputFile.cpp
Go to the documentation of this file.
1 //===- InputFile.cpp ------------------------------------------ *- C++ --*-===//
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 
10 
24 #include "llvm/DebugInfo/PDB/PDB.h"
25 #include "llvm/Object/COFF.h"
28 
29 using namespace llvm;
30 using namespace llvm::codeview;
31 using namespace llvm::object;
32 using namespace llvm::pdb;
33 
34 InputFile::InputFile() = default;
35 InputFile::~InputFile() = default;
36 
39  uint32_t Index) {
40  Expected<DbiStream &> DbiOrErr = File.getPDBDbiStream();
41  if (!DbiOrErr)
42  return DbiOrErr.takeError();
43  DbiStream &Dbi = *DbiOrErr;
44  const auto &Modules = Dbi.modules();
45  if (Index >= Modules.getModuleCount())
46  return make_error<RawError>(raw_error_code::index_out_of_bounds,
47  "Invalid module index");
48 
49  auto Modi = Modules.getModuleDescriptor(Index);
50 
51  ModuleName = Modi.getModuleName();
52 
53  uint16_t ModiStream = Modi.getModuleStreamIndex();
54  if (ModiStream == kInvalidStreamIndex)
55  return make_error<RawError>(raw_error_code::no_stream,
56  "Module stream not present");
57 
58  auto ModStreamData = File.createIndexedStream(ModiStream);
59 
60  ModuleDebugStreamRef ModS(Modi, std::move(ModStreamData));
61  if (auto EC = ModS.reload())
62  return make_error<RawError>(raw_error_code::corrupt_file,
63  "Invalid module stream");
64 
65  return std::move(ModS);
66 }
67 
69  uint32_t Index) {
70  Expected<DbiStream &> DbiOrErr = File.getPDBDbiStream();
71  if (!DbiOrErr)
72  return DbiOrErr.takeError();
73  DbiStream &Dbi = *DbiOrErr;
74  const auto &Modules = Dbi.modules();
75  auto Modi = Modules.getModuleDescriptor(Index);
76 
77  uint16_t ModiStream = Modi.getModuleStreamIndex();
78  if (ModiStream == kInvalidStreamIndex)
79  return make_error<RawError>(raw_error_code::no_stream,
80  "Module stream not present");
81 
82  auto ModStreamData = File.createIndexedStream(ModiStream);
83 
84  ModuleDebugStreamRef ModS(Modi, std::move(ModStreamData));
85  if (Error Err = ModS.reload())
86  return make_error<RawError>(raw_error_code::corrupt_file,
87  "Invalid module stream");
88 
89  return std::move(ModS);
90 }
91 
92 static inline bool isCodeViewDebugSubsection(object::SectionRef Section,
93  StringRef Name,
94  BinaryStreamReader &Reader) {
95  if (Expected<StringRef> NameOrErr = Section.getName()) {
96  if (*NameOrErr != Name)
97  return false;
98  } else {
99  consumeError(NameOrErr.takeError());
100  return false;
101  }
102 
103  Expected<StringRef> ContentsOrErr = Section.getContents();
104  if (!ContentsOrErr) {
105  consumeError(ContentsOrErr.takeError());
106  return false;
107  }
108 
109  Reader = BinaryStreamReader(*ContentsOrErr, support::little);
110  uint32_t Magic;
111  if (Reader.bytesRemaining() < sizeof(uint32_t))
112  return false;
113  cantFail(Reader.readInteger(Magic));
115  return false;
116  return true;
117 }
118 
119 static inline bool isDebugSSection(object::SectionRef Section,
120  DebugSubsectionArray &Subsections) {
121  BinaryStreamReader Reader;
122  if (!isCodeViewDebugSubsection(Section, ".debug$S", Reader))
123  return false;
124 
125  cantFail(Reader.readArray(Subsections, Reader.bytesRemaining()));
126  return true;
127 }
128 
129 static bool isDebugTSection(SectionRef Section, CVTypeArray &Types) {
130  BinaryStreamReader Reader;
131  if (!isCodeViewDebugSubsection(Section, ".debug$T", Reader) &&
132  !isCodeViewDebugSubsection(Section, ".debug$P", Reader))
133  return false;
134  cantFail(Reader.readArray(Types, Reader.bytesRemaining()));
135  return true;
136 }
137 
139  switch (Kind) {
142  RETURN_CASE(FileChecksumKind, SHA1, "SHA-1");
143  RETURN_CASE(FileChecksumKind, SHA256, "SHA-256");
144  }
145  return formatUnknownEnum(Kind);
146 }
147 
148 template <typename... Args>
149 static void formatInternal(LinePrinter &Printer, bool Append, Args &&...args) {
150  if (Append)
151  Printer.format(std::forward<Args>(args)...);
152  else
153  Printer.formatLine(std::forward<Args>(args)...);
154 }
155 
156 SymbolGroup::SymbolGroup(InputFile *File, uint32_t GroupIndex) : File(File) {
157  if (!File)
158  return;
159 
160  if (File->isPdb())
161  initializeForPdb(GroupIndex);
162  else {
163  Name = ".debug$S";
164  uint32_t I = 0;
165  for (const auto &S : File->obj().sections()) {
167  if (!isDebugSSection(S, SS))
168  continue;
169 
170  if (!SC.hasChecksums() || !SC.hasStrings())
171  SC.initialize(SS);
172 
173  if (I == GroupIndex)
174  Subsections = SS;
175 
176  if (SC.hasChecksums() && SC.hasStrings())
177  break;
178  }
179  rebuildChecksumMap();
180  }
181 }
182 
183 StringRef SymbolGroup::name() const { return Name; }
184 
185 void SymbolGroup::updateDebugS(const codeview::DebugSubsectionArray &SS) {
186  Subsections = SS;
187 }
188 
189 void SymbolGroup::updatePdbModi(uint32_t Modi) { initializeForPdb(Modi); }
190 
191 void SymbolGroup::initializeForPdb(uint32_t Modi) {
192  assert(File && File->isPdb());
193 
194  // PDB always uses the same string table, but each module has its own
195  // checksums. So we only set the strings if they're not already set.
196  if (!SC.hasStrings()) {
197  auto StringTable = File->pdb().getStringTable();
198  if (StringTable)
199  SC.setStrings(StringTable->getStringTable());
200  else
201  consumeError(StringTable.takeError());
202  }
203 
204  SC.resetChecksums();
205  auto MDS = getModuleDebugStream(File->pdb(), Name, Modi);
206  if (!MDS) {
207  consumeError(MDS.takeError());
208  return;
209  }
210 
211  DebugStream = std::make_shared<ModuleDebugStreamRef>(std::move(*MDS));
212  Subsections = DebugStream->getSubsectionsArray();
213  SC.initialize(Subsections);
214  rebuildChecksumMap();
215 }
216 
217 void SymbolGroup::rebuildChecksumMap() {
218  if (!SC.hasChecksums())
219  return;
220 
221  for (const auto &Entry : SC.checksums()) {
222  auto S = SC.strings().getString(Entry.FileNameOffset);
223  if (!S)
224  continue;
225  ChecksumsByFile[*S] = Entry;
226  }
227 }
228 
230  assert(File && File->isPdb() && DebugStream);
231  return *DebugStream;
232 }
233 
235  return SC.strings().getString(Offset);
236 }
237 
239  StringRef Name;
240  if (!SC.hasChecksums()) {
241  return std::move(Name);
242  }
243 
244  auto Iter = SC.checksums().getArray().at(Offset);
245  if (Iter == SC.checksums().getArray().end()) {
246  return std::move(Name);
247  }
248 
249  uint32_t FO = Iter->FileNameOffset;
250  auto ExpectedFile = getNameFromStringTable(FO);
251  if (!ExpectedFile) {
252  return std::move(Name);
253  }
254 
255  return *ExpectedFile;
256 }
257 
259  bool Append) const {
260  auto FC = ChecksumsByFile.find(File);
261  if (FC == ChecksumsByFile.end()) {
262  formatInternal(Printer, Append, "- (no checksum) {0}", File);
263  return;
264  }
265 
266  formatInternal(Printer, Append, "- ({0}: {1}) {2}",
267  formatChecksumKind(FC->getValue().Kind),
268  toHex(FC->getValue().Checksum), File);
269 }
270 
272  uint32_t Offset,
273  bool Append) const {
274  if (!SC.hasChecksums()) {
275  formatInternal(Printer, Append, "(unknown file name offset {0})", Offset);
276  return;
277  }
278 
279  auto Iter = SC.checksums().getArray().at(Offset);
280  if (Iter == SC.checksums().getArray().end()) {
281  formatInternal(Printer, Append, "(unknown file name offset {0})", Offset);
282  return;
283  }
284 
285  uint32_t FO = Iter->FileNameOffset;
286  auto ExpectedFile = getNameFromStringTable(FO);
287  if (!ExpectedFile) {
288  formatInternal(Printer, Append, "(unknown file name offset {0})", Offset);
289  consumeError(ExpectedFile.takeError());
290  return;
291  }
292  if (Iter->Kind == FileChecksumKind::None) {
293  formatInternal(Printer, Append, "{0} (no checksum)", *ExpectedFile);
294  } else {
295  formatInternal(Printer, Append, "{0} ({1}: {2})", *ExpectedFile,
296  formatChecksumKind(Iter->Kind), toHex(Iter->Checksum));
297  }
298 }
299 
300 Expected<InputFile> InputFile::open(StringRef Path, bool AllowUnknownFile) {
301  InputFile IF;
303  return make_error<StringError>(formatv("File {0} not found", Path),
305 
307  if (auto EC = identify_magic(Path, Magic))
308  return make_error<StringError>(
309  formatv("Unable to identify file type for file {0}", Path), EC);
310 
313  if (!BinaryOrErr)
314  return BinaryOrErr.takeError();
315 
316  IF.CoffObject = std::move(*BinaryOrErr);
317  IF.PdbOrObj = llvm::cast<COFFObjectFile>(IF.CoffObject.getBinary());
318  return std::move(IF);
319  }
320 
321  if (Magic == file_magic::pdb) {
322  std::unique_ptr<IPDBSession> Session;
323  if (auto Err = loadDataForPDB(PDB_ReaderType::Native, Path, Session))
324  return std::move(Err);
325 
326  IF.PdbSession.reset(static_cast<NativeSession *>(Session.release()));
327  IF.PdbOrObj = &IF.PdbSession->getPDBFile();
328 
329  return std::move(IF);
330  }
331 
332  if (!AllowUnknownFile)
333  return make_error<StringError>(
334  formatv("File {0} is not a supported file type", Path),
336 
337  auto Result = MemoryBuffer::getFile(Path, /*IsText=*/false,
338  /*RequiresNullTerminator=*/false);
339  if (!Result)
340  return make_error<StringError>(
341  formatv("File {0} could not be opened", Path), Result.getError());
342 
343  IF.UnknownFile = std::move(*Result);
344  IF.PdbOrObj = IF.UnknownFile.get();
345  return std::move(IF);
346 }
347 
349  assert(isPdb());
350  return *PdbOrObj.get<PDBFile *>();
351 }
352 
353 const PDBFile &InputFile::pdb() const {
354  assert(isPdb());
355  return *PdbOrObj.get<PDBFile *>();
356 }
357 
359  assert(isObj());
360  return *PdbOrObj.get<object::COFFObjectFile *>();
361 }
362 
363 const object::COFFObjectFile &InputFile::obj() const {
364  assert(isObj());
365  return *PdbOrObj.get<object::COFFObjectFile *>();
366 }
367 
369  assert(isUnknown());
370  return *PdbOrObj.get<MemoryBuffer *>();
371 }
372 
373 const MemoryBuffer &InputFile::unknown() const {
374  assert(isUnknown());
375  return *PdbOrObj.get<MemoryBuffer *>();
376 }
377 
379  if (isPdb())
380  return pdb().getFilePath();
381  if (isObj())
382  return obj().getFileName();
383  assert(isUnknown());
384  return unknown().getBufferIdentifier();
385 }
386 
387 bool InputFile::hasTypes() const {
388  if (isPdb())
389  return pdb().hasPDBTpiStream();
390 
391  for (const auto &Section : obj().sections()) {
392  CVTypeArray Types;
393  if (isDebugTSection(Section, Types))
394  return true;
395  }
396  return false;
397 }
398 
399 bool InputFile::hasIds() const {
400  if (isObj())
401  return false;
402  return pdb().hasPDBIpiStream();
403 }
404 
405 bool InputFile::isPdb() const { return PdbOrObj.is<PDBFile *>(); }
406 
407 bool InputFile::isObj() const {
408  return PdbOrObj.is<object::COFFObjectFile *>();
409 }
410 
411 bool InputFile::isUnknown() const { return PdbOrObj.is<MemoryBuffer *>(); }
412 
414 InputFile::getOrCreateTypeCollection(TypeCollectionKind Kind) {
415  if (Types && Kind == kTypes)
416  return *Types;
417  if (Ids && Kind == kIds)
418  return *Ids;
419 
420  if (Kind == kIds) {
421  assert(isPdb() && pdb().hasPDBIpiStream());
422  }
423 
424  // If the collection was already initialized, we should have just returned it
425  // in step 1.
426  if (isPdb()) {
427  TypeCollectionPtr &Collection = (Kind == kIds) ? Ids : Types;
428  auto &Stream = cantFail((Kind == kIds) ? pdb().getPDBIpiStream()
429  : pdb().getPDBTpiStream());
430 
431  auto &Array = Stream.typeArray();
432  uint32_t Count = Stream.getNumTypeRecords();
433  auto Offsets = Stream.getTypeIndexOffsets();
434  Collection =
435  std::make_unique<LazyRandomTypeCollection>(Array, Count, Offsets);
436  return *Collection;
437  }
438 
439  assert(isObj());
440  assert(Kind == kTypes);
441  assert(!Types);
442 
443  for (const auto &Section : obj().sections()) {
444  CVTypeArray Records;
445  if (!isDebugTSection(Section, Records))
446  continue;
447 
448  Types = std::make_unique<LazyRandomTypeCollection>(Records, 100);
449  return *Types;
450  }
451 
452  Types = std::make_unique<LazyRandomTypeCollection>(100);
453  return *Types;
454 }
455 
457  return getOrCreateTypeCollection(kTypes);
458 }
459 
461  // Object files have only one type stream that contains both types and ids.
462  // Similarly, some PDBs don't contain an IPI stream, and for those both types
463  // and IDs are in the same stream.
464  if (isObj() || !pdb().hasPDBIpiStream())
465  return types();
466 
467  return getOrCreateTypeCollection(kIds);
468 }
469 
471  return make_range<SymbolGroupIterator>(symbol_groups_begin(),
473 }
474 
476  return SymbolGroupIterator(*this);
477 }
478 
480  return SymbolGroupIterator();
481 }
482 
484 
486  if (File.isObj()) {
487  SectionIter = File.obj().section_begin();
488  scanToNextDebugS();
489  }
490 }
491 
493  bool E = isEnd();
494  bool RE = R.isEnd();
495  if (E || RE)
496  return E == RE;
497 
498  if (Value.File != R.Value.File)
499  return false;
500  return Index == R.Index;
501 }
502 
504  assert(!isEnd());
505  return Value;
506 }
508  assert(!isEnd());
509  return Value;
510 }
511 
513  assert(Value.File && !isEnd());
514  ++Index;
515  if (isEnd())
516  return *this;
517 
518  if (Value.File->isPdb()) {
519  Value.updatePdbModi(Index);
520  return *this;
521  }
522 
523  scanToNextDebugS();
524  return *this;
525 }
526 
527 void SymbolGroupIterator::scanToNextDebugS() {
528  assert(SectionIter);
529  auto End = Value.File->obj().section_end();
530  auto &Iter = *SectionIter;
531  assert(!isEnd());
532 
533  while (++Iter != End) {
535  SectionRef SR = *Iter;
536  if (!isDebugSSection(SR, SS))
537  continue;
538 
539  Value.updateDebugS(SS);
540  return;
541  }
542 }
543 
544 bool SymbolGroupIterator::isEnd() const {
545  if (!Value.File)
546  return true;
547  if (Value.File->isPdb()) {
548  DbiStream &Dbi = cantFail(Value.File->pdb().getPDBDbiStream());
549  uint32_t Count = Dbi.modules().getModuleCount();
550  assert(Index <= Count);
551  return Index == Count;
552  }
553 
554  assert(SectionIter);
555  return *SectionIter == Value.File->obj().section_end();
556 }
557 
558 static bool isMyCode(const SymbolGroup &Group) {
559  if (Group.getFile().isObj())
560  return true;
561 
562  StringRef Name = Group.name();
563  if (Name.startswith("Import:"))
564  return false;
565  if (Name.endswith_insensitive(".dll"))
566  return false;
567  if (Name.equals_insensitive("* linker *"))
568  return false;
569  if (Name.startswith_insensitive("f:\\binaries\\Intermediate\\vctools"))
570  return false;
571  if (Name.startswith_insensitive("f:\\dd\\vctools\\crt"))
572  return false;
573  return true;
574 }
575 
577  const FilterOptions &Filters) {
578  if (Filters.JustMyCode && !isMyCode(Group))
579  return false;
580 
581  // If the arg was not specified on the command line, always dump all modules.
582  if (!Filters.DumpModi)
583  return true;
584 
585  // Otherwise, only dump if this is the same module specified.
586  return (Filters.DumpModi == Idx);
587 }
llvm::pdb::DbiModuleList::getModuleCount
uint32_t getModuleCount() const
Definition: DbiModuleList.cpp:242
llvm::pdb::PDBFile::hasPDBIpiStream
bool hasPDBIpiStream() const
Definition: PDBFile.cpp:428
FilterOptions::DumpModi
llvm::Optional< uint32_t > DumpModi
Definition: LinePrinter.h:33
llvm::pdb::InputFile::types
codeview::LazyRandomTypeCollection & types()
Definition: InputFile.cpp:456
isCodeViewDebugSubsection
static bool isCodeViewDebugSubsection(object::SectionRef Section, StringRef Name, BinaryStreamReader &Reader)
Definition: InputFile.cpp:92
llvm::object::Kind
Kind
Definition: COFFModuleDefinition.cpp:31
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::codeview::StringsAndChecksumsRef::initialize
void initialize(T &&FragmentRange)
Definition: StringsAndChecksums.h:42
FileSystem.h
llvm::file_magic
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
Definition: Magic.h:20
llvm::pdb::InputFile::isPdb
bool isPdb() const
Definition: InputFile.cpp:405
TpiStream.h
llvm::pdb::ModuleDebugStreamRef
Definition: ModuleDebugStream.h:31
llvm::pdb::LinePrinter
Definition: LinePrinter.h:50
llvm::file_magic::pdb
@ pdb
Windows PDB debug info file.
Definition: Magic.h:53
llvm::pdb::SymbolGroupIterator::operator*
const SymbolGroup & operator*() const
Definition: InputFile.cpp:503
llvm::SHA256
Definition: SHA256.h:33
llvm::pdb::PDBFile::getFilePath
StringRef getFilePath() const
Definition: PDBFile.cpp:48
llvm::codeview::FileChecksumKind
FileChecksumKind
Definition: CodeView.h:566
llvm::AMDGPUISD::IF
@ IF
Definition: AMDGPUISelLowering.h:361
llvm::pdb::SymbolGroup::getNameFromStringTable
Expected< StringRef > getNameFromStringTable(uint32_t Offset) const
Definition: InputFile.cpp:234
llvm::pdb::SymbolGroup::formatFromFileName
void formatFromFileName(LinePrinter &Printer, StringRef File, bool Append=false) const
Definition: InputFile.cpp:258
llvm::pdb::SymbolGroupIterator::operator==
bool operator==(const SymbolGroupIterator &R) const
Definition: InputFile.cpp:492
R600_InstFlag::FC
@ FC
Definition: R600Defines.h:32
llvm::pdb::kInvalidStreamIndex
const uint16_t kInvalidStreamIndex
Definition: RawConstants.h:19
llvm::pdb::InputFile::isUnknown
bool isUnknown() const
Definition: InputFile.cpp:411
llvm::pdb::InputFile::symbol_groups_begin
SymbolGroupIterator symbol_groups_begin()
Definition: InputFile.cpp:475
llvm::BinaryStreamReader::bytesRemaining
uint64_t bytesRemaining() const
Definition: BinaryStreamReader.h:250
llvm::VarStreamArray::end
Iterator end() const
Definition: BinaryStreamArray.h:117
llvm::codeview::DebugSubsectionKind::StringTable
@ StringTable
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::pdb::DbiStream
Definition: DbiStream.h:39
RawError.h
llvm::pdb::SymbolGroup::getNameFromChecksums
Expected< StringRef > getNameFromChecksums(uint32_t Offset) const
Definition: InputFile.cpp:238
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1042
llvm::MemoryBuffer
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:51
llvm::pdb::SymbolGroupIterator::operator++
SymbolGroupIterator & operator++()
Definition: InputFile.cpp:512
llvm::X86AS::SS
@ SS
Definition: X86.h:201
llvm::codeview::StringsAndChecksumsRef::resetChecksums
void resetChecksums()
Definition: StringsAndChecksums.cpp:51
PDB.h
llvm::formatv
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Definition: FormatVariadic.h:251
FilterOptions
Definition: LinePrinter.h:24
llvm::object
Definition: DWARFDebugLoc.h:25
llvm::pdb::SymbolGroupIterator::SymbolGroupIterator
SymbolGroupIterator()
Definition: InputFile.cpp:483
Magic.h
llvm::pdb::PDBFile::hasPDBTpiStream
bool hasPDBTpiStream() const
Definition: PDBFile.cpp:455
llvm::codeview::StringsAndChecksumsRef::hasChecksums
bool hasChecksums() const
Definition: StringsAndChecksums.h:70
llvm::SHA1
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:26
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::support::little
@ little
Definition: Endian.h:27
LazyRandomTypeCollection.h
llvm::pdb::InputFile::ids
codeview::LazyRandomTypeCollection & ids()
Definition: InputFile.cpp:460
llvm::VarStreamArray< DebugSubsectionRecord >
llvm::codeview::LazyRandomTypeCollection
Provides amortized O(1) random access to a CodeView type stream.
Definition: LazyRandomTypeCollection.h:49
llvm::pdb::InputFile::isObj
bool isObj() const
Definition: InputFile.cpp:407
isMyCode
static bool isMyCode(const SymbolGroup &Group)
Definition: InputFile.cpp:558
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::BinaryStreamReader::readInteger
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
Definition: BinaryStreamReader.h:68
llvm::pdb::PDB_ColorItem::Path
@ Path
CodeView.h
FormatVariadic.h
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::BinaryStreamReader
Provides read only access to a subclass of BinaryStream.
Definition: BinaryStreamReader.h:29
llvm::MemoryBuffer::getBufferIdentifier
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
Definition: MemoryBuffer.h:76
llvm::pdb::InputFile::hasTypes
bool hasTypes() const
Definition: InputFile.cpp:387
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:80
llvm::pdb::ModuleDebugStreamRef::reload
Error reload()
Definition: ModuleDebugStream.cpp:38
llvm::pdb::getModuleDebugStream
Expected< ModuleDebugStreamRef > getModuleDebugStream(PDBFile &File, StringRef &ModuleName, uint32_t Index)
Definition: InputFile.cpp:38
llvm::pdb::InputFile::unknown
MemoryBuffer & unknown()
Definition: InputFile.cpp:368
llvm::pdb::InputFile::pdb
PDBFile & pdb()
Definition: InputFile.cpp:348
llvm::sys::fs::exists
bool exists(const basic_file_status &status)
Does file exist?
Definition: Path.cpp:1077
llvm::codeview::StringsAndChecksumsRef::checksums
const DebugChecksumsSubsectionRef & checksums() const
Definition: StringsAndChecksums.h:67
llvm::pdb::SymbolGroup::getPdbModuleStream
const ModuleDebugStreamRef & getPdbModuleStream() const
Definition: InputFile.cpp:229
llvm::symbolize::toHex
static std::string toHex(uint64_t V)
Definition: DIPrinter.cpp:278
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::MD5
Definition: MD5.h:41
llvm::file_magic::coff_object
@ coff_object
COFF object file.
Definition: Magic.h:46
llvm::pdb::loadDataForPDB
Error loadDataForPDB(PDB_ReaderType Type, StringRef Path, std::unique_ptr< IPDBSession > &Session)
Definition: PDB.cpp:22
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::pdb::SymbolGroup::formatFromChecksumsOffset
void formatFromChecksumsOffset(LinePrinter &Printer, uint32_t Offset, bool Append=false) const
Definition: InputFile.cpp:271
isDebugTSection
static bool isDebugTSection(SectionRef Section, CVTypeArray &Types)
Definition: InputFile.cpp:129
MappedBlockStream.h
llvm::pdb::PDB_ReaderType::Native
@ Native
RETURN_CASE
#define RETURN_CASE(Enum, X, Ret)
Definition: FormatUtil.h:32
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ModuleName
Definition: ItaniumDemangle.h:999
llvm::pdb::SymbolGroupIterator
Definition: InputFile.h:132
llvm::codeview::CompileSym2Flags::EC
@ EC
DbiStream.h
formatChecksumKind
static std::string formatChecksumKind(FileChecksumKind Kind)
Definition: InputFile.cpp:138
InputFile.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::msf::Magic
static const char Magic[]
Definition: MSFCommon.h:23
Printer
Memory true print Memory SSA Printer
Definition: MemorySSA.cpp:80
llvm::pdb::PDBFile::getStringTable
Expected< PDBStringTable & > getStringTable()
Definition: PDBFile.cpp:367
llvm::pdb::InputFile::getFilePath
StringRef getFilePath() const
Definition: InputFile.cpp:378
llvm::cantFail
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:744
uint32_t
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MemoryBuffer::getFile
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, Optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Definition: MemoryBuffer.cpp:248
llvm::COFF::DEBUG_SECTION_MAGIC
@ DEBUG_SECTION_MAGIC
Definition: COFF.h:771
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:79
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
uint16_t
llvm::codeview::StringsAndChecksumsRef::setStrings
void setStrings(const DebugStringTableSubsectionRef &Strings)
Definition: StringsAndChecksums.cpp:56
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
StringsAndChecksums.h
FormatUtil.h
llvm::pdb::shouldDumpSymbolGroup
bool shouldDumpSymbolGroup(uint32_t Idx, const SymbolGroup &Group, const FilterOptions &Filters)
Definition: InputFile.cpp:576
llvm::object::COFFObjectFile
Definition: COFF.h:788
LinePrinter.h
llvm::pdb::SymbolGroup::name
StringRef name() const
Definition: InputFile.cpp:183
llvm::pdb::NativeSession
Definition: NativeSession.h:32
llvm::pdb::formatUnknownEnum
std::string formatUnknownEnum(T Value)
Definition: FormatUtil.h:36
FilterOptions::JustMyCode
bool JustMyCode
Definition: LinePrinter.h:37
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
PDBStringTable.h
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:596
llvm::codeview::DebugStringTableSubsectionRef::getString
Expected< StringRef > getString(uint32_t Offset) const
Definition: DebugStringTableSubsection.cpp:35
llvm::codeview::StringsAndChecksumsRef::strings
const DebugStringTableSubsectionRef & strings() const
Definition: StringsAndChecksums.h:66
llvm::object::Binary::getFileName
StringRef getFileName() const
Definition: Binary.cpp:41
COFF.h
llvm::pdb::InputFile
Definition: InputFile.h:40
llvm::pdb::PDBFile
Definition: PDBFile.h:40
PDBFile.h
llvm::pdb::DbiModuleList::getModuleDescriptor
DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const
Definition: DbiModuleList.cpp:254
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::pdb::InputFile::obj
object::COFFObjectFile & obj()
Definition: InputFile.cpp:358
isDebugSSection
static bool isDebugSSection(object::SectionRef Section, DebugSubsectionArray &Subsections)
Definition: InputFile.cpp:119
llvm::object::createBinary
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
Definition: Binary.cpp:45
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:134
llvm::pdb::InputFile::symbol_groups
iterator_range< SymbolGroupIterator > symbol_groups()
Definition: InputFile.cpp:470
llvm::pdb::InputFile::hasIds
bool hasIds() const
Definition: InputFile.cpp:399
llvm::pdb::InputFile::symbol_groups_end
SymbolGroupIterator symbol_groups_end()
Definition: InputFile.cpp:479
formatInternal
static void formatInternal(LinePrinter &Printer, bool Append, Args &&...args)
Definition: InputFile.cpp:149
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::pdb::SymbolGroup::getFile
const InputFile & getFile() const
Definition: InputFile.h:113
llvm::SI::KernelInputOffsets::Offsets
Offsets
Offsets in bytes from the start of the input buffer.
Definition: SIInstrInfo.h:1314
llvm::codeview::StringsAndChecksumsRef::hasStrings
bool hasStrings() const
Definition: StringsAndChecksums.h:69
llvm::identify_magic
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
Definition: Magic.cpp:33
llvm::codeview::DebugChecksumsSubsectionRef::getArray
const FileChecksumArray & getArray() const
Definition: DebugChecksumsSubsection.h:71
llvm::pdb::InputFile::open
static Expected< InputFile > open(StringRef Path, bool AllowUnknownFile=false)
Definition: InputFile.cpp:300
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::pdb::SymbolGroup
Definition: InputFile.h:91
llvm::BinaryStreamReader::readArray
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
Definition: BinaryStreamReader.h:180
NativeSession.h
llvm::pdb::DbiStream::modules
const DbiModuleList & modules() const
Definition: DbiStream.cpp:215