Line data Source code
1 : //===- ModuleDebugFragment.h ------------------------------------*- C++ -*-===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 :
10 : #ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H
11 : #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H
12 :
13 : #include "llvm/DebugInfo/CodeView/CodeView.h"
14 : #include "llvm/Support/BinaryStreamArray.h"
15 : #include "llvm/Support/BinaryStreamRef.h"
16 : #include "llvm/Support/BinaryStreamWriter.h"
17 : #include "llvm/Support/Endian.h"
18 : #include "llvm/Support/Error.h"
19 :
20 : namespace llvm {
21 : namespace codeview {
22 :
23 : class ModuleDebugFragment;
24 :
25 : // Corresponds to the `CV_DebugSSubsectionHeader_t` structure.
26 3 : struct ModuleDebugFragmentHeader {
27 : support::ulittle32_t Kind; // codeview::ModuleDebugFragmentKind enum
28 : support::ulittle32_t Length; // number of bytes occupied by this record.
29 : };
30 :
31 132 : class ModuleDebugFragmentRecord {
32 : public:
33 : ModuleDebugFragmentRecord();
34 : ModuleDebugFragmentRecord(ModuleDebugFragmentKind Kind, BinaryStreamRef Data);
35 :
36 : static Error initialize(BinaryStreamRef Stream,
37 : ModuleDebugFragmentRecord &Info);
38 :
39 : uint32_t getRecordLength() const;
40 : ModuleDebugFragmentKind kind() const;
41 : BinaryStreamRef getRecordData() const;
42 :
43 : private:
44 : ModuleDebugFragmentKind Kind;
45 : BinaryStreamRef Data;
46 : };
47 :
48 : class ModuleDebugFragmentRecordBuilder {
49 : public:
50 : ModuleDebugFragmentRecordBuilder(ModuleDebugFragmentKind Kind,
51 : ModuleDebugFragment &Frag);
52 : uint32_t calculateSerializedLength();
53 : Error commit(BinaryStreamWriter &Writer);
54 :
55 : private:
56 : ModuleDebugFragmentKind Kind;
57 : ModuleDebugFragment &Frag;
58 : };
59 :
60 : } // namespace codeview
61 :
62 : template <>
63 : struct VarStreamArrayExtractor<codeview::ModuleDebugFragmentRecord> {
64 : typedef void ContextType;
65 :
66 9 : static Error extract(BinaryStreamRef Stream, uint32_t &Length,
67 : codeview::ModuleDebugFragmentRecord &Info) {
68 36 : if (auto EC = codeview::ModuleDebugFragmentRecord::initialize(Stream, Info))
69 0 : return EC;
70 9 : Length = Info.getRecordLength();
71 27 : return Error::success();
72 : }
73 : };
74 :
75 : namespace codeview {
76 : typedef VarStreamArray<ModuleDebugFragmentRecord> ModuleDebugFragmentArray;
77 : }
78 : } // namespace llvm
79 :
80 : #endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H
|