File indexing completed on 2026-05-10 08:43:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H
0011
0012 #include "llvm/DebugInfo/CodeView/CodeView.h"
0013 #include "llvm/Support/BinaryStreamArray.h"
0014 #include "llvm/Support/BinaryStreamRef.h"
0015 #include "llvm/Support/Endian.h"
0016 #include "llvm/Support/Error.h"
0017 #include "llvm/Support/MathExtras.h"
0018 #include <cstdint>
0019 #include <memory>
0020
0021 namespace llvm {
0022
0023 class BinaryStreamWriter;
0024
0025 namespace codeview {
0026
0027 class DebugSubsection;
0028
0029
0030 struct DebugSubsectionHeader {
0031 support::ulittle32_t Kind;
0032 support::ulittle32_t Length;
0033 };
0034
0035 class DebugSubsectionRecord {
0036 public:
0037 DebugSubsectionRecord();
0038 DebugSubsectionRecord(DebugSubsectionKind Kind, BinaryStreamRef Data);
0039
0040 static Error initialize(BinaryStreamRef Stream, DebugSubsectionRecord &Info);
0041
0042 uint32_t getRecordLength() const;
0043 DebugSubsectionKind kind() const;
0044 BinaryStreamRef getRecordData() const;
0045
0046 private:
0047 DebugSubsectionKind Kind = DebugSubsectionKind::None;
0048 BinaryStreamRef Data;
0049 };
0050
0051 class DebugSubsectionRecordBuilder {
0052 public:
0053 DebugSubsectionRecordBuilder(std::shared_ptr<DebugSubsection> Subsection);
0054
0055
0056
0057
0058 DebugSubsectionRecordBuilder(const DebugSubsectionRecord &Contents);
0059
0060 uint32_t calculateSerializedLength() const;
0061 Error commit(BinaryStreamWriter &Writer, CodeViewContainer Container) const;
0062
0063 private:
0064
0065 std::shared_ptr<DebugSubsection> Subsection;
0066
0067
0068
0069 DebugSubsectionRecord Contents;
0070 };
0071
0072 }
0073
0074 template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> {
0075 Error operator()(BinaryStreamRef Stream, uint32_t &Length,
0076 codeview::DebugSubsectionRecord &Info) {
0077
0078
0079
0080 if (auto EC = codeview::DebugSubsectionRecord::initialize(Stream, Info))
0081 return EC;
0082 Length = alignTo(Info.getRecordLength(), 4);
0083 return Error::success();
0084 }
0085 };
0086
0087 namespace codeview {
0088
0089 using DebugSubsectionArray = VarStreamArray<DebugSubsectionRecord>;
0090
0091 }
0092
0093 }
0094
0095 #endif