TpiStream.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- TpiStream.cpp - PDB Type Info (TPI) Stream 2 Access ------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_PDB_NATIVE_TPISTREAM_H
  14. #define LLVM_DEBUGINFO_PDB_NATIVE_TPISTREAM_H
  15. #include "llvm/DebugInfo/CodeView/CVRecord.h"
  16. #include "llvm/DebugInfo/PDB/Native/HashTable.h"
  17. #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
  18. #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
  19. #include "llvm/DebugInfo/PDB/PDBTypes.h"
  20. #include "llvm/Support/BinaryStreamArray.h"
  21. #include "llvm/Support/BinaryStreamRef.h"
  22. #include "llvm/Support/raw_ostream.h"
  23. #include "llvm/Support/Error.h"
  24. namespace llvm {
  25. namespace codeview {
  26. class LazyRandomTypeCollection;
  27. }
  28. namespace msf {
  29. class MappedBlockStream;
  30. }
  31. namespace pdb {
  32. class PDBFile;
  33. class TpiStream {
  34. friend class TpiStreamBuilder;
  35. public:
  36. TpiStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream);
  37. ~TpiStream();
  38. Error reload();
  39. PdbRaw_TpiVer getTpiVersion() const;
  40. uint32_t TypeIndexBegin() const;
  41. uint32_t TypeIndexEnd() const;
  42. uint32_t getNumTypeRecords() const;
  43. uint16_t getTypeHashStreamIndex() const;
  44. uint16_t getTypeHashStreamAuxIndex() const;
  45. uint32_t getHashKeySize() const;
  46. uint32_t getNumHashBuckets() const;
  47. FixedStreamArray<support::ulittle32_t> getHashValues() const;
  48. FixedStreamArray<codeview::TypeIndexOffset> getTypeIndexOffsets() const;
  49. HashTable<support::ulittle32_t> &getHashAdjusters();
  50. codeview::CVTypeRange types(bool *HadError) const;
  51. const codeview::CVTypeArray &typeArray() const { return TypeRecords; }
  52. codeview::LazyRandomTypeCollection &typeCollection() { return *Types; }
  53. Expected<codeview::TypeIndex>
  54. findFullDeclForForwardRef(codeview::TypeIndex ForwardRefTI) const;
  55. std::vector<codeview::TypeIndex> findRecordsByName(StringRef Name) const;
  56. codeview::CVType getType(codeview::TypeIndex Index);
  57. BinarySubstreamRef getTypeRecordsSubstream() const;
  58. Error commit();
  59. void buildHashMap();
  60. bool supportsTypeLookup() const;
  61. private:
  62. PDBFile &Pdb;
  63. std::unique_ptr<msf::MappedBlockStream> Stream;
  64. std::unique_ptr<codeview::LazyRandomTypeCollection> Types;
  65. BinarySubstreamRef TypeRecordsSubstream;
  66. codeview::CVTypeArray TypeRecords;
  67. std::unique_ptr<BinaryStream> HashStream;
  68. FixedStreamArray<support::ulittle32_t> HashValues;
  69. FixedStreamArray<codeview::TypeIndexOffset> TypeIndexOffsets;
  70. HashTable<support::ulittle32_t> HashAdjusters;
  71. std::vector<std::vector<codeview::TypeIndex>> HashMap;
  72. const TpiStreamHeader *Header;
  73. };
  74. }
  75. }
  76. #endif
  77. #ifdef __GNUC__
  78. #pragma GCC diagnostic pop
  79. #endif