LLVM 22.0.0git
DebugLinesSubsection.h
Go to the documentation of this file.
1//===- DebugLinesSubsection.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_DEBUGLINESSUBSECTION_H
10#define LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H
11
12#include "llvm/ADT/StringRef.h"
19#include "llvm/Support/Endian.h"
20#include "llvm/Support/Error.h"
21#include <cstdint>
22#include <vector>
23
24namespace llvm {
25class BinaryStreamReader;
26class BinaryStreamWriter;
27namespace codeview {
28
29class DebugChecksumsSubsection;
30class DebugStringTableSubsection;
31
32// Corresponds to the `CV_DebugSLinesHeader_t` structure.
34 support::ulittle32_t RelocOffset; // Code offset of line contribution.
35 support::ulittle16_t RelocSegment; // Code segment of line contribution.
36 support::ulittle16_t Flags; // See LineFlags enumeration.
37 support::ulittle32_t CodeSize; // Code size of this line contribution.
38};
39
40// Corresponds to the `CV_DebugSLinesFileBlockHeader_t` structure.
42 support::ulittle32_t NameIndex; // Offset of FileChecksum entry in File
43 // checksums buffer. The checksum entry then
44 // contains another offset into the string
45 // table of the actual name.
46 support::ulittle32_t NumLines; // Number of lines
47 support::ulittle32_t BlockSize; // Code size of block, in bytes.
48 // The following two variable length arrays appear immediately after the
49 // header. The structure definitions follow.
50 // LineNumberEntry Lines[NumLines];
51 // ColumnNumberEntry Columns[NumLines];
52};
53
54// Corresponds to `CV_Line_t` structure
56 support::ulittle32_t Offset; // Offset to start of code bytes for line number
57 support::ulittle32_t Flags; // Start:24, End:7, IsStatement:1
58};
59
60// Corresponds to `CV_Column_t` structure
64};
65
70};
71
73public:
75 LineColumnEntry &Item);
76
77 const LineFragmentHeader *Header = nullptr;
78};
79
81 friend class LineColumnExtractor;
82
85
86public:
88
89 static bool classof(const DebugSubsectionRef *S) {
90 return S->kind() == DebugSubsectionKind::Lines;
91 }
92
94
95 Iterator begin() const { return LinesAndColumns.begin(); }
96 Iterator end() const { return LinesAndColumns.end(); }
97
98 const LineFragmentHeader *header() const { return Header; }
99
100 LLVM_ABI bool hasColumnInfo() const;
101
102private:
103 const LineFragmentHeader *Header = nullptr;
104 LineInfoArray LinesAndColumns;
105};
106
108 struct Block {
109 Block(uint32_t ChecksumBufferOffset)
110 : ChecksumBufferOffset(ChecksumBufferOffset) {}
111
112 uint32_t ChecksumBufferOffset;
113 std::vector<LineNumberEntry> Lines;
114 std::vector<ColumnNumberEntry> Columns;
115 };
116
117public:
120
121 static bool classof(const DebugSubsection *S) {
122 return S->kind() == DebugSubsectionKind::Lines;
123 }
124
125 void createBlock(StringRef FileName);
126 void addLineInfo(uint32_t Offset, const LineInfo &Line);
127 void addLineAndColumnInfo(uint32_t Offset, const LineInfo &Line,
128 uint32_t ColStart, uint32_t ColEnd);
129
130 uint32_t calculateSerializedSize() const override;
131 Error commit(BinaryStreamWriter &Writer) const override;
132
133 void setRelocationAddress(uint16_t Segment, uint32_t Offset);
134 void setCodeSize(uint32_t Size);
135 void setFlags(LineFlags Flags);
136
137 bool hasColumnInfo() const;
138
139private:
140 DebugChecksumsSubsection &Checksums;
141 uint32_t RelocOffset = 0;
142 uint16_t RelocSegment = 0;
143 uint32_t CodeSize = 0;
144 LineFlags Flags = LF_None;
145 std::vector<Block> Blocks;
146};
147
148} // end namespace codeview
149} // end namespace llvm
150
151#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H
Lightweight arrays that are backed by an arbitrary BinaryStream.
#define LLVM_ABI
Definition: Compiler.h:213
uint64_t Size
DenseMap< Block *, BlockRelaxAux > Blocks
Definition: ELF_riscv.cpp:507
uint64_t Offset
Definition: ELF_riscv.cpp:478
Provides read only access to a subclass of BinaryStream.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Provides write only access to a subclass of WritableBinaryStream.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
VarStreamArray represents an array of variable length records backed by a stream.
Iterator end() const
VarStreamArrayIterator< LineColumnEntry, LineColumnExtractor > Iterator
Iterator begin(bool *HadError=nullptr) const
const LineFragmentHeader * header() const
static bool classof(const DebugSubsectionRef *S)
LLVM_ABI Error initialize(BinaryStreamReader Reader)
static bool classof(const DebugSubsection *S)
Represents a read-write view of a CodeView string table.
DebugSubsectionKind kind() const
DebugSubsectionKind kind() const
LLVM_ABI Error operator()(BinaryStreamRef Stream, uint32_t &Len, LineColumnEntry &Item)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
FixedStreamArray< ColumnNumberEntry > Columns
FixedStreamArray< LineNumberEntry > LineNumbers