LLVM  6.0.0svn
DebugInlineeLinesSubsection.cpp
Go to the documentation of this file.
1 //===- DebugInlineeLinesSubsection.cpp ------------------------------------===//
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 
11 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/Support/Endian.h"
17 #include "llvm/Support/Error.h"
18 #include <cassert>
19 #include <cstdint>
20 
21 using namespace llvm;
22 using namespace llvm::codeview;
23 
26  BinaryStreamReader Reader(Stream);
27 
28  if (auto EC = Reader.readObject(Item.Header))
29  return EC;
30 
31  if (HasExtraFiles) {
32  uint32_t ExtraFileCount;
33  if (auto EC = Reader.readInteger(ExtraFileCount))
34  return EC;
35  if (auto EC = Reader.readArray(Item.ExtraFiles, ExtraFileCount))
36  return EC;
37  }
38 
39  Len = Reader.getOffset();
40  return Error::success();
41 }
42 
45 
47  if (auto EC = Reader.readEnum(Signature))
48  return EC;
49 
50  Lines.getExtractor().HasExtraFiles = hasExtraFiles();
51  if (auto EC = Reader.readArray(Lines, Reader.bytesRemaining()))
52  return EC;
53 
54  assert(Reader.bytesRemaining() == 0);
55  return Error::success();
56 }
57 
59  return Signature == InlineeLinesSignature::ExtraFiles;
60 }
61 
63  DebugChecksumsSubsection &Checksums, bool HasExtraFiles)
64  : DebugSubsection(DebugSubsectionKind::InlineeLines), Checksums(Checksums),
65  HasExtraFiles(HasExtraFiles) {}
66 
68  // 4 bytes for the signature
70 
71  // one header for each entry.
72  Size += Entries.size() * sizeof(InlineeSourceLineHeader);
73  if (HasExtraFiles) {
74  // If extra files are enabled, one count for each entry.
75  Size += Entries.size() * sizeof(uint32_t);
76 
77  // And one file id for each file.
78  Size += ExtraFileCount * sizeof(uint32_t);
79  }
80  assert(Size % 4 == 0);
81  return Size;
82 }
83 
86  if (HasExtraFiles)
88 
89  if (auto EC = Writer.writeEnum(Sig))
90  return EC;
91 
92  for (const auto &E : Entries) {
93  if (auto EC = Writer.writeObject(E.Header))
94  return EC;
95 
96  if (!HasExtraFiles)
97  continue;
98 
99  if (auto EC = Writer.writeInteger<uint32_t>(E.ExtraFiles.size()))
100  return EC;
101  if (auto EC = Writer.writeArray(makeArrayRef(E.ExtraFiles)))
102  return EC;
103  }
104 
105  return Error::success();
106 }
107 
109  uint32_t Offset = Checksums.mapChecksumOffset(FileName);
110 
111  auto &Entry = Entries.back();
112  Entry.ExtraFiles.push_back(ulittle32_t(Offset));
113  ++ExtraFileCount;
114 }
115 
117  StringRef FileName,
118  uint32_t SourceLine) {
119  uint32_t Offset = Checksums.mapChecksumOffset(FileName);
120 
121  Entries.emplace_back();
122  auto &Entry = Entries.back();
124  Entry.Header.SourceLineNum = SourceLine;
125  Entry.Header.Inlinee = FuncId;
126 }
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
Error commit(BinaryStreamWriter &Writer) const override
DebugInlineeLinesSubsection(DebugChecksumsSubsection &Checksums, bool HasExtraFiles=false)
A 32-bit type reference.
Definition: TypeIndex.h:96
Error writeArray(ArrayRef< T > Array)
Writes an array of objects of type T to the underlying stream, as if by using memcpy.
uint32_t mapChecksumOffset(StringRef FileName) const
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
Definition: Endian.h:271
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Provides write only access to a subclass of WritableBinaryStream.
const InlineeSourceLineHeader * Header
Error writeInteger(T Value)
Write the the integer Value to the underlying stream in the specified endianness. ...
static ErrorSuccess success()
Create a success value.
Definition: Error.h:313
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Error writeEnum(T Num)
Similar to writeInteger.
uint32_t bytesRemaining() const
Error operator()(BinaryStreamRef Stream, uint32_t &Len, T &Item) const =delete
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FixedStreamArray< support::ulittle32_t > ExtraFiles
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine)
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Error readEnum(T &Dest)
Similar to readInteger.
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...