InfoStreamBuilder.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- InfoStreamBuilder.h - PDB Info Stream Creation -----------*- 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_INFOSTREAMBUILDER_H
  14. #define LLVM_DEBUGINFO_PDB_NATIVE_INFOSTREAMBUILDER_H
  15. #include "llvm/Support/Error.h"
  16. #include "llvm/DebugInfo/CodeView/GUID.h"
  17. #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
  18. namespace llvm {
  19. class WritableBinaryStreamRef;
  20. namespace msf {
  21. class MSFBuilder;
  22. struct MSFLayout;
  23. }
  24. namespace pdb {
  25. class NamedStreamMap;
  26. class InfoStreamBuilder {
  27. public:
  28. InfoStreamBuilder(msf::MSFBuilder &Msf, NamedStreamMap &NamedStreams);
  29. InfoStreamBuilder(const InfoStreamBuilder &) = delete;
  30. InfoStreamBuilder &operator=(const InfoStreamBuilder &) = delete;
  31. void setVersion(PdbRaw_ImplVer V);
  32. void addFeature(PdbRaw_FeatureSig Sig);
  33. // If this is true, the PDB contents are hashed and this hash is used as
  34. // PDB GUID and as Signature. The age is always 1.
  35. void setHashPDBContentsToGUID(bool B);
  36. // These only have an effect if hashPDBContentsToGUID() is false.
  37. void setSignature(uint32_t S);
  38. void setAge(uint32_t A);
  39. void setGuid(codeview::GUID G);
  40. bool hashPDBContentsToGUID() const { return HashPDBContentsToGUID; }
  41. uint32_t getAge() const { return Age; }
  42. codeview::GUID getGuid() const { return Guid; }
  43. std::optional<uint32_t> getSignature() const { return Signature; }
  44. uint32_t finalize();
  45. Error finalizeMsfLayout();
  46. Error commit(const msf::MSFLayout &Layout,
  47. WritableBinaryStreamRef Buffer) const;
  48. private:
  49. msf::MSFBuilder &Msf;
  50. std::vector<PdbRaw_FeatureSig> Features;
  51. PdbRaw_ImplVer Ver;
  52. uint32_t Age;
  53. std::optional<uint32_t> Signature;
  54. codeview::GUID Guid;
  55. bool HashPDBContentsToGUID = false;
  56. NamedStreamMap &NamedStreams;
  57. };
  58. } // namespace pdb
  59. }
  60. #endif
  61. #ifdef __GNUC__
  62. #pragma GCC diagnostic pop
  63. #endif