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