blob: aac7c48e067ee3fdebe085af5ba53cc866c2f86a [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===- LineEntry.h ----------------------------------------------*- C++ -*-===//
2//
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003// 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
Andrew Walbran3d2c1972020-04-07 12:24:26 +01006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H
10#define LLVM_DEBUGINFO_GSYM_LINEENTRY_H
11
12#include "llvm/DebugInfo/GSYM/Range.h"
13
14namespace llvm {
15namespace gsym {
16
17/// Line entries are used to encode the line tables in FunctionInfo objects.
18/// They are stored as a sorted vector of these objects and store the
19/// address, file and line of the line table row for a given address. The
20/// size of a line table entry is calculated by looking at the next entry
21/// in the FunctionInfo's vector of entries.
22struct LineEntry {
23 uint64_t Addr; ///< Start address of this line entry.
24 uint32_t File; ///< 1 based index of file in FileTable
25 uint32_t Line; ///< Source line number.
26 LineEntry(uint64_t A = 0, uint32_t F = 0, uint32_t L = 0)
27 : Addr(A), File(F), Line(L) {}
28 bool isValid() { return File != 0; }
29};
30
31inline raw_ostream &operator<<(raw_ostream &OS, const LineEntry &LE) {
32 return OS << "addr=" << HEX64(LE.Addr) << ", file=" << format("%3u", LE.File)
33 << ", line=" << format("%3u", LE.Line);
34}
35
36inline bool operator==(const LineEntry &LHS, const LineEntry &RHS) {
37 return LHS.Addr == RHS.Addr && LHS.File == RHS.File && LHS.Line == RHS.Line;
38}
39inline bool operator!=(const LineEntry &LHS, const LineEntry &RHS) {
40 return !(LHS == RHS);
41}
42inline bool operator<(const LineEntry &LHS, const LineEntry &RHS) {
43 return LHS.Addr < RHS.Addr;
44}
45} // namespace gsym
46} // namespace llvm
47#endif // #ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H