TpiStream.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/Support/BinaryStreamArray.h"
  19. #include "llvm/Support/BinaryStreamRef.h"
  20. #include "llvm/Support/Error.h"
  21. namespace llvm {
  22. class BinaryStream;
  23. namespace codeview {
  24. class TypeIndex;
  25. struct TypeIndexOffset;
  26. class LazyRandomTypeCollection;
  27. }
  28. namespace msf {
  29. class MappedBlockStream;
  30. }
  31. namespace pdb {
  32. struct TpiStreamHeader;
  33. class PDBFile;
  34. class TpiStream {
  35. friend class TpiStreamBuilder;
  36. public:
  37. TpiStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream);
  38. ~TpiStream();
  39. Error reload();
  40. PdbRaw_TpiVer getTpiVersion() const;
  41. uint32_t TypeIndexBegin() const;
  42. uint32_t TypeIndexEnd() const;
  43. uint32_t getNumTypeRecords() const;
  44. uint16_t getTypeHashStreamIndex() const;
  45. uint16_t getTypeHashStreamAuxIndex() const;
  46. uint32_t getHashKeySize() const;
  47. uint32_t getNumHashBuckets() const;
  48. FixedStreamArray<support::ulittle32_t> getHashValues() const;
  49. FixedStreamArray<codeview::TypeIndexOffset> getTypeIndexOffsets() const;
  50. HashTable<support::ulittle32_t> &getHashAdjusters();
  51. codeview::CVTypeRange types(bool *HadError) const;
  52. const codeview::CVTypeArray &typeArray() const { return TypeRecords; }
  53. codeview::LazyRandomTypeCollection &typeCollection() { return *Types; }
  54. Expected<codeview::TypeIndex>
  55. findFullDeclForForwardRef(codeview::TypeIndex ForwardRefTI) const;
  56. std::vector<codeview::TypeIndex> findRecordsByName(StringRef Name) const;
  57. codeview::CVType getType(codeview::TypeIndex Index);
  58. BinarySubstreamRef getTypeRecordsSubstream() const;
  59. Error commit();
  60. void buildHashMap();
  61. bool supportsTypeLookup() const;
  62. private:
  63. PDBFile &Pdb;
  64. std::unique_ptr<msf::MappedBlockStream> Stream;
  65. std::unique_ptr<codeview::LazyRandomTypeCollection> Types;
  66. BinarySubstreamRef TypeRecordsSubstream;
  67. codeview::CVTypeArray TypeRecords;
  68. std::unique_ptr<BinaryStream> HashStream;
  69. FixedStreamArray<support::ulittle32_t> HashValues;
  70. FixedStreamArray<codeview::TypeIndexOffset> TypeIndexOffsets;
  71. HashTable<support::ulittle32_t> HashAdjusters;
  72. std::vector<std::vector<codeview::TypeIndex>> HashMap;
  73. const TpiStreamHeader *Header;
  74. };
  75. }
  76. }
  77. #endif
  78. #ifdef __GNUC__
  79. #pragma GCC diagnostic pop
  80. #endif