Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
//===- DebugInlineeLinesSubsection.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_DEBUGINLINEELINESSUBSECTION_H
10
#define LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H
11
 
12
#include "llvm/ADT/StringRef.h"
13
#include "llvm/DebugInfo/CodeView/CodeView.h"
14
#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
15
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
16
#include "llvm/Support/BinaryStreamArray.h"
17
#include "llvm/Support/BinaryStreamReader.h"
18
#include "llvm/Support/BinaryStreamRef.h"
19
#include "llvm/Support/Endian.h"
20
#include "llvm/Support/Error.h"
21
#include <cstdint>
22
#include <vector>
23
 
24
namespace llvm {
25
 
26
namespace codeview {
27
 
28
class DebugChecksumsSubsection;
29
 
30
enum class InlineeLinesSignature : uint32_t {
31
  Normal,    // CV_INLINEE_SOURCE_LINE_SIGNATURE
32
  ExtraFiles // CV_INLINEE_SOURCE_LINE_SIGNATURE_EX
33
};
34
 
35
struct InlineeSourceLineHeader {
36
  TypeIndex Inlinee;                  // ID of the function that was inlined.
37
  support::ulittle32_t FileID;        // Offset into FileChecksums subsection.
38
  support::ulittle32_t SourceLineNum; // First line of inlined code.
39
                                      // If extra files present:
40
                                      //   ulittle32_t ExtraFileCount;
41
                                      //   ulittle32_t Files[];
42
};
43
 
44
struct InlineeSourceLine {
45
  const InlineeSourceLineHeader *Header;
46
  FixedStreamArray<support::ulittle32_t> ExtraFiles;
47
};
48
 
49
} // end namespace codeview
50
 
51
template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> {
52
  Error operator()(BinaryStreamRef Stream, uint32_t &Len,
53
                   codeview::InlineeSourceLine &Item);
54
 
55
  bool HasExtraFiles = false;
56
};
57
 
58
namespace codeview {
59
 
60
class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef {
61
  using LinesArray = VarStreamArray<InlineeSourceLine>;
62
  using Iterator = LinesArray::Iterator;
63
 
64
public:
65
  DebugInlineeLinesSubsectionRef();
66
 
67
  static bool classof(const DebugSubsectionRef *S) {
68
    return S->kind() == DebugSubsectionKind::InlineeLines;
69
  }
70
 
71
  Error initialize(BinaryStreamReader Reader);
72
  Error initialize(BinaryStreamRef Section) {
73
    return initialize(BinaryStreamReader(Section));
74
  }
75
 
76
  bool valid() const { return Lines.valid(); }
77
  bool hasExtraFiles() const;
78
 
79
  Iterator begin() const { return Lines.begin(); }
80
  Iterator end() const { return Lines.end(); }
81
 
82
private:
83
  InlineeLinesSignature Signature;
84
  LinesArray Lines;
85
};
86
 
87
class DebugInlineeLinesSubsection final : public DebugSubsection {
88
public:
89
  struct Entry {
90
    std::vector<support::ulittle32_t> ExtraFiles;
91
    InlineeSourceLineHeader Header;
92
  };
93
 
94
  DebugInlineeLinesSubsection(DebugChecksumsSubsection &Checksums,
95
                              bool HasExtraFiles = false);
96
 
97
  static bool classof(const DebugSubsection *S) {
98
    return S->kind() == DebugSubsectionKind::InlineeLines;
99
  }
100
 
101
  Error commit(BinaryStreamWriter &Writer) const override;
102
  uint32_t calculateSerializedSize() const override;
103
 
104
  void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine);
105
  void addExtraFile(StringRef FileName);
106
 
107
  bool hasExtraFiles() const { return HasExtraFiles; }
108
  void setHasExtraFiles(bool Has) { HasExtraFiles = Has; }
109
 
110
  std::vector<Entry>::const_iterator begin() const { return Entries.begin(); }
111
  std::vector<Entry>::const_iterator end() const { return Entries.end(); }
112
 
113
private:
114
  DebugChecksumsSubsection &Checksums;
115
  bool HasExtraFiles = false;
116
  uint32_t ExtraFileCount = 0;
117
  std::vector<Entry> Entries;
118
};
119
 
120
} // end namespace codeview
121
 
122
} // end namespace llvm
123
 
124
#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H