LLVM  14.0.0git
DebugChecksumsSubsection.h
Go to the documentation of this file.
1 //===- DebugChecksumsSubsection.h -------------------------------*- 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 
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H
10 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H
11 
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/StringRef.h"
17 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/Error.h"
22 #include <cstdint>
23 #include <vector>
24 
25 namespace llvm {
26 
27 namespace codeview {
28 
29 class DebugStringTableSubsection;
30 
32  uint32_t FileNameOffset; // Byte offset of filename in global stringtable.
33  FileChecksumKind Kind; // The type of checksum.
34  ArrayRef<uint8_t> Checksum; // The bytes of the checksum.
35 };
36 
37 } // end namespace codeview
38 
39 template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> {
40 public:
41  using ContextType = void;
42 
45 };
46 
47 namespace codeview {
48 
52 
53 public:
56 
57  static bool classof(const DebugSubsectionRef *S) {
58  return S->kind() == DebugSubsectionKind::FileChecksums;
59  }
60 
61  bool valid() const { return Checksums.valid(); }
62 
65 
66  Iterator begin() const { return Checksums.begin(); }
67  Iterator end() const { return Checksums.end(); }
68 
69  const FileChecksumArray &getArray() const { return Checksums; }
70 
71 private:
72  FileChecksumArray Checksums;
73 };
74 
76 public:
78 
79  static bool classof(const DebugSubsection *S) {
80  return S->kind() == DebugSubsectionKind::FileChecksums;
81  }
82 
84  ArrayRef<uint8_t> Bytes);
85 
86  uint32_t calculateSerializedSize() const override;
87  Error commit(BinaryStreamWriter &Writer) const override;
88  uint32_t mapChecksumOffset(StringRef FileName) const;
89 
90 private:
92 
94  uint32_t SerializedSize = 0;
95  BumpPtrAllocator Storage;
96  std::vector<FileChecksumEntry> Checksums;
97 };
98 
99 } // end namespace codeview
100 
101 } // end namespace llvm
102 
103 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H
BinaryStreamReader.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::codeview::DebugChecksumsSubsection
Definition: DebugChecksumsSubsection.h:75
StringRef.h
llvm::BinaryStreamWriter
Provides write only access to a subclass of WritableBinaryStream.
Definition: BinaryStreamWriter.h:31
llvm::codeview::FileChecksumKind
FileChecksumKind
Definition: CodeView.h:564
Allocator.h
Error.h
DenseMap.h
llvm::codeview::DebugStringTableSubsection
Represents a read-write view of a CodeView string table.
Definition: DebugStringTableSubsection.h:56
llvm::codeview::FileChecksumEntry::FileNameOffset
uint32_t FileNameOffset
Definition: DebugChecksumsSubsection.h:32
llvm::codeview::DebugChecksumsSubsection::DebugChecksumsSubsection
DebugChecksumsSubsection(DebugStringTableSubsection &Strings)
Definition: DebugChecksumsSubsection.cpp:63
llvm::VarStreamArray::end
Iterator end() const
Definition: BinaryStreamArray.h:115
llvm::VarStreamArrayExtractor
VarStreamArrayExtractor is intended to be specialized to provide customized extraction logic.
Definition: BinaryStreamArray.h:47
llvm::codeview::DebugChecksumsSubsectionRef::DebugChecksumsSubsectionRef
DebugChecksumsSubsectionRef()
Definition: DebugChecksumsSubsection.h:54
llvm::codeview::DebugSubsection::Kind
DebugSubsectionKind Kind
Definition: DebugSubsection.h:45
llvm::codeview::DebugChecksumsSubsectionRef::classof
static bool classof(const DebugSubsectionRef *S)
Definition: DebugChecksumsSubsection.h:57
llvm::codeview::DebugChecksumsSubsectionRef::valid
bool valid() const
Definition: DebugChecksumsSubsection.h:61
llvm::VarStreamArray< codeview::FileChecksumEntry >
llvm::codeview::DebugSubsectionRef
Definition: DebugSubsection.h:19
llvm::VarStreamArray< codeview::FileChecksumEntry >::Iterator
VarStreamArrayIterator< codeview::FileChecksumEntry, VarStreamArrayExtractor< codeview::FileChecksumEntry > > Iterator
Definition: BinaryStreamArray.h:96
llvm::codeview::DebugSubsectionKind::FileChecksums
@ FileChecksums
llvm::codeview::FileChecksumEntry
Definition: DebugChecksumsSubsection.h:31
llvm::VarStreamArrayExtractor::operator()
Error operator()(BinaryStreamRef Stream, uint32_t &Len, T &Item) const =delete
Definition: DebugChecksumsSubsection.cpp:35
CodeView.h
llvm::BinaryStreamReader
Provides read only access to a subclass of BinaryStream.
Definition: BinaryStreamReader.h:31
DebugSubsection.h
llvm::codeview::DebugChecksumsSubsection::mapChecksumOffset
uint32_t mapChecksumOffset(StringRef FileName) const
Definition: DebugChecksumsSubsection.cpp:110
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
llvm::DenseMap< uint32_t, uint32_t >
llvm::codeview::DebugChecksumsSubsectionRef::begin
Iterator begin() const
Definition: DebugChecksumsSubsection.h:66
ArrayRef.h
BinaryStreamArray.h
llvm::codeview::FileChecksumEntry::Kind
FileChecksumKind Kind
Definition: DebugChecksumsSubsection.h:33
llvm::VarStreamArrayIterator
VarStreamArray represents an array of variable length records backed by a stream.
Definition: BinaryStreamArray.h:88
llvm::codeview::DebugChecksumsSubsectionRef::end
Iterator end() const
Definition: DebugChecksumsSubsection.h:67
llvm::ArrayRef< uint8_t >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
BinaryStreamRef.h
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::VarStreamArray::valid
bool valid() const
Definition: BinaryStreamArray.h:112
llvm::VarStreamArray::begin
Iterator begin(bool *HadError=nullptr) const
Definition: BinaryStreamArray.h:108
llvm::codeview::DebugSubsection
Definition: DebugSubsection.h:32
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::VarStreamArrayExtractor< codeview::FileChecksumEntry >::ContextType
void ContextType
Definition: DebugChecksumsSubsection.h:41
llvm::codeview::DebugSubsectionKind
DebugSubsectionKind
Definition: CodeView.h:313
llvm::codeview::FileChecksumEntry::Checksum
ArrayRef< uint8_t > Checksum
Definition: DebugChecksumsSubsection.h:34
llvm::codeview::DebugChecksumsSubsection::addChecksum
void addChecksum(StringRef FileName, FileChecksumKind Kind, ArrayRef< uint8_t > Bytes)
Definition: DebugChecksumsSubsection.cpp:67
llvm::codeview::DebugChecksumsSubsection::commit
Error commit(BinaryStreamWriter &Writer) const override
Definition: DebugChecksumsSubsection.cpp:94
llvm::codeview::DebugChecksumsSubsection::calculateSerializedSize
uint32_t calculateSerializedSize() const override
Definition: DebugChecksumsSubsection.cpp:90
llvm::codeview::DebugChecksumsSubsection::classof
static bool classof(const DebugSubsection *S)
Definition: DebugChecksumsSubsection.h:79
llvm::codeview::DebugChecksumsSubsectionRef::getArray
const FileChecksumArray & getArray() const
Definition: DebugChecksumsSubsection.h:69
llvm::codeview::DebugChecksumsSubsectionRef
Definition: DebugChecksumsSubsection.h:49
llvm::codeview::DebugChecksumsSubsectionRef::initialize
Error initialize(BinaryStreamReader Reader)
Definition: DebugChecksumsSubsection.cpp:51
llvm::BinaryStreamRef
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Definition: BinaryStreamRef.h:156