LineEntry.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- LineEntry.h ----------------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H
  14. #define LLVM_DEBUGINFO_GSYM_LINEENTRY_H
  15. #include "llvm/DebugInfo/GSYM/ExtractRanges.h"
  16. namespace llvm {
  17. namespace gsym {
  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. inline 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. inline bool operator==(const LineEntry &LHS, const LineEntry &RHS) {
  36. return LHS.Addr == RHS.Addr && LHS.File == RHS.File && LHS.Line == RHS.Line;
  37. }
  38. inline bool operator!=(const LineEntry &LHS, const LineEntry &RHS) {
  39. return !(LHS == RHS);
  40. }
  41. inline bool operator<(const LineEntry &LHS, const LineEntry &RHS) {
  42. return LHS.Addr < RHS.Addr;
  43. }
  44. } // namespace gsym
  45. } // namespace llvm
  46. #endif // LLVM_DEBUGINFO_GSYM_LINEENTRY_H
  47. #ifdef __GNUC__
  48. #pragma GCC diagnostic pop
  49. #endif