File indexing completed on 2026-05-10 08:43:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H
0011
0012 #include "llvm/ADT/ArrayRef.h"
0013 #include "llvm/ADT/DenseMap.h"
0014 #include "llvm/ADT/StringRef.h"
0015 #include "llvm/DebugInfo/CodeView/CodeView.h"
0016 #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
0017 #include "llvm/Support/Allocator.h"
0018 #include "llvm/Support/BinaryStreamArray.h"
0019 #include "llvm/Support/BinaryStreamRef.h"
0020 #include "llvm/Support/Error.h"
0021 #include <cstdint>
0022 #include <vector>
0023
0024 namespace llvm {
0025
0026 class BinaryStreamReader;
0027 class BinaryStreamWriter;
0028
0029 namespace codeview {
0030
0031 class DebugStringTableSubsection;
0032
0033 struct FileChecksumEntry {
0034 uint32_t FileNameOffset;
0035 FileChecksumKind Kind;
0036 ArrayRef<uint8_t> Checksum;
0037 };
0038
0039 }
0040
0041 template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> {
0042 public:
0043 using ContextType = void;
0044
0045 Error operator()(BinaryStreamRef Stream, uint32_t &Len,
0046 codeview::FileChecksumEntry &Item);
0047 };
0048
0049 namespace codeview {
0050
0051 class DebugChecksumsSubsectionRef final : public DebugSubsectionRef {
0052 using FileChecksumArray = VarStreamArray<codeview::FileChecksumEntry>;
0053 using Iterator = FileChecksumArray::Iterator;
0054
0055 public:
0056 DebugChecksumsSubsectionRef()
0057 : DebugSubsectionRef(DebugSubsectionKind::FileChecksums) {}
0058
0059 static bool classof(const DebugSubsectionRef *S) {
0060 return S->kind() == DebugSubsectionKind::FileChecksums;
0061 }
0062
0063 bool valid() const { return Checksums.valid(); }
0064
0065 Error initialize(BinaryStreamReader Reader);
0066 Error initialize(BinaryStreamRef Stream);
0067
0068 Iterator begin() const { return Checksums.begin(); }
0069 Iterator end() const { return Checksums.end(); }
0070
0071 const FileChecksumArray &getArray() const { return Checksums; }
0072
0073 private:
0074 FileChecksumArray Checksums;
0075 };
0076
0077 class DebugChecksumsSubsection final : public DebugSubsection {
0078 public:
0079 explicit DebugChecksumsSubsection(DebugStringTableSubsection &Strings);
0080
0081 static bool classof(const DebugSubsection *S) {
0082 return S->kind() == DebugSubsectionKind::FileChecksums;
0083 }
0084
0085 void addChecksum(StringRef FileName, FileChecksumKind Kind,
0086 ArrayRef<uint8_t> Bytes);
0087
0088 uint32_t calculateSerializedSize() const override;
0089 Error commit(BinaryStreamWriter &Writer) const override;
0090 uint32_t mapChecksumOffset(StringRef FileName) const;
0091
0092 private:
0093 DebugStringTableSubsection &Strings;
0094
0095 DenseMap<uint32_t, uint32_t> OffsetMap;
0096 uint32_t SerializedSize = 0;
0097 BumpPtrAllocator Storage;
0098 std::vector<FileChecksumEntry> Checksums;
0099 };
0100
0101 }
0102
0103 }
0104
0105 #endif