LLVM: include/llvm/DebugInfo/DWARF/DWARFDebugLine.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLINE_H

10#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLINE_H

11

20#include

21#include

22#include

23#include

24

25namespace llvm {

26

28

30public:

41

42

43

46

47

49

51

53

55

56

58 };

59

62

63

64

66

67

68

70

71

73

75

76

77

79

80

82

84

86

88

90

95

100

102

104

106

107

109

110

111

114

116

118

122 std::string &Result,

124

130 };

131

132

134 LLVM_ABI explicit Row(bool DefaultIsStmt = false);

135

136

140

142

144 return std::tie(LHS.Address.SectionIndex, LHS.Address.Address) <

145 std::tie(RHS.Address.SectionIndex, RHS.Address.Address);

146 }

147

148

149

150

151

152

154

155

156

158

159

160

162

163

165

166

168

169

171

172

173

175

176

178

179

181

182

183

185

186

187

189

190

191

193 };

194

195

196

197

200

201

202

205

206

207

212

213

215

217

219 return std::tie(LHS.SectionIndex, LHS.HighPC) <

220 std::tie(RHS.SectionIndex, RHS.HighPC);

221 }

222

226

231 };

232

235

236

238

240

244

245

246

248 bool *IsApproximateLine = nullptr) const;

249

250

251

252

253

254

255

256

257

258

259

262 std::vector<uint32_t> &Result,

263 std::optional<uint64_t> StmtSequenceOffset = std::nullopt) const;

264

266 return Prologue.hasFileAtIndex(FileIndex);

267 }

268

270 return Prologue.getLastValidFileIndex();

271 }

272

273

274

275

276

277

280 std::string &Result) const {

281 return Prologue.getFileNameByIndex(FileIndex, CompDir, Kind, Result);

282 }

283

284

285

289

290

291

293 std::string &Directory) const;

294

297

298

303

305 using RowIter = RowVector::const_iterator;

308

312

313 private:

316 std::optional

317 getSourceByIndex(uint64_t FileIndex,

319

321 bool *IsApproximateLine = nullptr) const;

322

323

324

325

326

327

328

329

330

331

332

333 bool

335 std::vector<uint32_t> &Result,

336 std::optional<uint64_t> StmtSequenceOffset) const;

337 };

338

345

346

348 public:

350

353

354

355

356

357

358

359

360

361

362

363

364

369

370

371

372

373

374

375

376

379

380

381

382

383

384 bool done() const { return Done; }

385

386

388

389 private:

393

395

399 bool Done = false;

400 };

401

402private:

403 struct ParsingState {

404 LLVM_ABI ParsingState(struct LineTable *LT, uint64_t TableOffset,

406

408 LLVM_ABI void appendRowToMatrix();

409

414

415

416

420

426

427

428

431

437

438

439

442

443

444 struct LineTable *LineTable;

445 struct Row Row;

446 struct Sequence Sequence;

447

448 private:

450

451 bool ReportAdvanceAddrProblem = true;

452 bool ReportBadLineRange = true;

454 };

455

456 using LineTableMapTy = std::map<uint64_t, LineTable>;

457 using LineTableIter = LineTableMapTy::iterator;

458 using LineTableConstIter = LineTableMapTy::const_iterator;

459

460 LineTableMapTy LineTableMap;

461};

462

463}

464

465#endif

This file contains constants used for implementing Dwarf debug support.

static fatal_error_handler_t ErrorHandler

DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...

LLVM_ABI void skip(function_ref< void(Error)> RecoverableErrorHandler, function_ref< void(Error)> UnrecoverableErrorHandler)

Skip the current line table and go to the following line table (if present) immediately.

uint64_t getOffset() const

Get the offset the parser has reached.

Definition DWARFDebugLine.h:387

std::map< uint64_t, DWARFUnit * > LineToUnitMap

Definition DWARFDebugLine.h:349

LLVM_ABI LineTable parseNext(function_ref< void(Error)> RecoverableErrorHandler, function_ref< void(Error)> UnrecoverableErrorHandler, raw_ostream *OS=nullptr, bool Verbose=false)

Get the next line table from the section.

bool done() const

Indicates if the parser has parsed as much as possible.

Definition DWARFDebugLine.h:384

LLVM_ABI SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, DWARFUnitVector::iterator_range Units)

Definition DWARFDebugLine.h:29

LLVM_ABI void clearLineTable(uint64_t Offset)

LLVM_ABI Expected< const LineTable * > getOrParseLineTable(DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx, const DWARFUnit *U, function_ref< void(Error)> RecoverableErrorHandler)

LLVM_ABI const LineTable * getLineTable(uint64_t Offset) const

llvm::iterator_range< UnitVector::iterator > iterator_range

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

StringRef - Represent a constant reference to a string, i.e.

An efficient, type-erasing, non-owning reference to a callable.

This class implements an extremely fast bulk output stream that can only output to a stream.

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

Container for dump options that control which debug information will be dumped.

A format-neutral container for source line information.

Tracks which optional content types are present in a DWARF file name entry format.

Definition DWARFDebugLine.h:44

bool HasLength

Whether filename entries provide a file size.

Definition DWARFDebugLine.h:50

ContentTypeTracker()=default

bool HasSource

For v5, whether filename entries provide source text.

Definition DWARFDebugLine.h:54

bool HasModTime

Whether filename entries provide a modification timestamp.

Definition DWARFDebugLine.h:48

bool HasMD5

For v5, whether filename entries provide an MD5 checksum.

Definition DWARFDebugLine.h:52

LLVM_ABI void trackContentType(dwarf::LineNumberEntryFormat ContentType)

Update tracked content types with ContentType.

Definition DWARFDebugLine.h:31

uint64_t Length

Definition DWARFDebugLine.h:37

uint64_t ModTime

Definition DWARFDebugLine.h:36

MD5::MD5Result Checksum

Definition DWARFDebugLine.h:38

DWARFFormValue Name

Definition DWARFDebugLine.h:34

DWARFFormValue Source

Definition DWARFDebugLine.h:39

uint64_t DirIdx

Definition DWARFDebugLine.h:35

Definition DWARFDebugLine.h:233

LLVM_ABI uint32_t lookupAddress(object::SectionedAddress Address, bool *IsApproximateLine=nullptr) const

Returns the index of the row with file/line info for a given address, or UnknownRowIndex if there is ...

RowVector Rows

Definition DWARFDebugLine.h:310

LLVM_ABI bool getDirectoryForEntry(const FileNameEntry &Entry, std::string &Directory) const

Extracts directory name by its Entry in include directories table in prologue.

const uint32_t UnknownRowIndex

Represents an invalid row.

Definition DWARFDebugLine.h:237

LLVM_ABI bool getFileLineInfoForAddress(object::SectionedAddress Address, bool Approximate, const char *CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, DILineInfo &Result) const

Fills the Result argument with the file and line information corresponding to Address.

std::optional< uint64_t > getLastValidFileIndex() const

Definition DWARFDebugLine.h:269

bool hasFileAtIndex(uint64_t FileIndex) const

Definition DWARFDebugLine.h:265

LLVM_ABI Error parse(DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U, function_ref< void(Error)> RecoverableErrorHandler, raw_ostream *OS=nullptr, bool Verbose=false)

Parse prologue and all rows.

bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, std::string &Result) const

Extracts filename by its index in filename table in prologue.

Definition DWARFDebugLine.h:278

RowVector::const_iterator RowIter

Definition DWARFDebugLine.h:305

SequenceVector::const_iterator SequenceIter

Definition DWARFDebugLine.h:307

std::vector< Row > RowVector

Definition DWARFDebugLine.h:304

std::vector< Sequence > SequenceVector

Definition DWARFDebugLine.h:306

void appendSequence(const DWARFDebugLine::Sequence &S)

Definition DWARFDebugLine.h:241

LLVM_ABI bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size, std::vector< uint32_t > &Result, std::optional< uint64_t > StmtSequenceOffset=std::nullopt) const

Fills the Result argument with the indices of the rows that correspond to the address range specified...

SequenceVector Sequences

Definition DWARFDebugLine.h:311

void appendRow(const DWARFDebugLine::Row &R)

Definition DWARFDebugLine.h:239

LLVM_ABI void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const

struct Prologue Prologue

Definition DWARFDebugLine.h:309

Definition DWARFDebugLine.h:410

uint64_t AddrOffset

Definition DWARFDebugLine.h:411

int16_t OpIndexDelta

Definition DWARFDebugLine.h:412

Definition DWARFDebugLine.h:421

uint8_t AdjustedOpcode

Definition DWARFDebugLine.h:424

int16_t OpIndexDelta

Definition DWARFDebugLine.h:423

uint64_t AddrDelta

Definition DWARFDebugLine.h:422

Definition DWARFDebugLine.h:432

uint64_t Address

Definition DWARFDebugLine.h:433

int32_t Line

Definition DWARFDebugLine.h:434

int16_t OpIndex

Definition DWARFDebugLine.h:435

Definition DWARFDebugLine.h:60

uint8_t MaxOpsPerInst

The maximum number of individual operations that may be encoded in an instruction.

Definition DWARFDebugLine.h:81

uint8_t MinInstLength

The size in bytes of the smallest target machine instruction.

Definition DWARFDebugLine.h:78

LLVM_ABI bool hasFileAtIndex(uint64_t FileIndex) const

uint64_t PrologueLength

The number of bytes following the prologue_length field to the beginning of the first byte of the sta...

Definition DWARFDebugLine.h:72

LLVM_ABI void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const

uint32_t sizeofTotalLength() const

Definition DWARFDebugLine.h:101

bool isDWARF64() const

Definition DWARFDebugLine.h:99

uint8_t SegSelectorSize

In v5, size in bytes of a segment selector.

Definition DWARFDebugLine.h:74

uint16_t getVersion() const

Definition DWARFDebugLine.h:97

int8_t LineBase

This parameter affects the meaning of the special opcodes. See below.

Definition DWARFDebugLine.h:85

LLVM_ABI std::optional< uint64_t > getLastValidFileIndex() const

uint32_t sizeofPrologueLength() const

Definition DWARFDebugLine.h:103

LLVM_ABI Error parse(DWARFDataExtractor Data, uint64_t *OffsetPtr, function_ref< void(Error)> RecoverableErrorHandler, const DWARFContext &Ctx, const DWARFUnit *U=nullptr)

uint8_t LineRange

This parameter affects the meaning of the special opcodes. See below.

Definition DWARFDebugLine.h:87

const dwarf::FormParams getFormParams() const

Definition DWARFDebugLine.h:96

std::vector< DWARFFormValue > IncludeDirectories

Definition DWARFDebugLine.h:93

uint8_t OpcodeBase

The number assigned to the first special opcode.

Definition DWARFDebugLine.h:89

std::vector< uint8_t > StandardOpcodeLengths

Definition DWARFDebugLine.h:92

LLVM_ABI bool totalLengthIsValid() const

uint8_t getAddressSize() const

Definition DWARFDebugLine.h:98

LLVM_ABI const llvm::DWARFDebugLine::FileNameEntry & getFileNameEntry(uint64_t Index) const

Get DWARF-version aware access to the file name entry at the provided index.

LLVM_ABI bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, std::string &Result, sys::path::Style Style=sys::path::Style::native) const

uint8_t DefaultIsStmt

The initial value of theis_stmtregister.

Definition DWARFDebugLine.h:83

uint64_t TotalLength

The size in bytes of the statement information for this compilation unit (not including the total_len...

Definition DWARFDebugLine.h:65

dwarf::FormParams FormParams

Version, address size (starting in v5), and DWARF32/64 format; these parameters affect interpretation...

Definition DWARFDebugLine.h:69

LLVM_ABI uint64_t getLength() const

Length of the prologue in bytes.

ContentTypeTracker ContentTypes

This tracks which optional file format content types are present.

Definition DWARFDebugLine.h:91

std::vector< FileNameEntry > FileNames

Definition DWARFDebugLine.h:94

Standard .debug_line state machine structure.

Definition DWARFDebugLine.h:133

uint8_t BasicBlock

A boolean indicating that the current instruction is the beginning of a basic block.

Definition DWARFDebugLine.h:180

static bool orderByAddress(const Row &LHS, const Row &RHS)

Definition DWARFDebugLine.h:143

uint32_t Line

An unsigned integer indicating a source line number.

Definition DWARFDebugLine.h:157

uint16_t File

An unsigned integer indicating the identity of the source file corresponding to a machine instruction...

Definition DWARFDebugLine.h:164

uint32_t Discriminator

An unsigned integer representing the DWARF path discriminator value for this location.

Definition DWARFDebugLine.h:167

uint8_t EpilogueBegin

A boolean indicating that the current address is one (of possibly many) where execution should be sus...

Definition DWARFDebugLine.h:192

object::SectionedAddress Address

The program-counter value corresponding to a machine instruction generated by the compiler and sectio...

Definition DWARFDebugLine.h:153

LLVM_ABI void postAppend()

Called after a row is appended to the matrix.

uint8_t PrologueEnd

A boolean indicating that the current address is one (of possibly many) where execution should be sus...

Definition DWARFDebugLine.h:188

uint16_t Column

An unsigned integer indicating a column number within a source line.

Definition DWARFDebugLine.h:161

uint8_t EndSequence

A boolean indicating that the current address is that of the first byte after the end of a sequence o...

Definition DWARFDebugLine.h:184

static LLVM_ABI void dumpTableHeader(raw_ostream &OS, unsigned Indent)

uint8_t IsStmt

A boolean indicating that the current instruction is the beginning of a statement.

Definition DWARFDebugLine.h:177

LLVM_ABI void reset(bool DefaultIsStmt)

LLVM_ABI Row(bool DefaultIsStmt=false)

uint8_t Isa

An unsigned integer whose value encodes the applicable instruction set architecture for the current i...

Definition DWARFDebugLine.h:170

LLVM_ABI void dump(raw_ostream &OS) const

uint8_t OpIndex

An unsigned integer representing the index of an operation within a VLIW instruction.

Definition DWARFDebugLine.h:174

Represents a series of contiguous machine instructions.

Definition DWARFDebugLine.h:198

uint64_t LowPC

Sequence describes instructions at address range [LowPC, HighPC) and is described by line table rows ...

Definition DWARFDebugLine.h:203

unsigned LastRowIndex

Definition DWARFDebugLine.h:210

static bool orderByHighPC(const Sequence &LHS, const Sequence &RHS)

Definition DWARFDebugLine.h:218

unsigned FirstRowIndex

Definition DWARFDebugLine.h:209

bool isValid() const

Definition DWARFDebugLine.h:223

bool containsPC(object::SectionedAddress PC) const

Definition DWARFDebugLine.h:227

uint64_t StmtSeqOffset

The offset into the line table where this sequence begins.

Definition DWARFDebugLine.h:214

uint64_t HighPC

Definition DWARFDebugLine.h:204

bool Empty

Definition DWARFDebugLine.h:211

uint64_t SectionIndex

If relocation information is present then this is the index of the section which contains above addre...

Definition DWARFDebugLine.h:208

A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...